1 | <?php |
---|
2 | /** |
---|
3 | * Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
4 | * @file proyectos_operativos.module |
---|
5 | * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
6 | * Copyright 2013 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or modify |
---|
9 | * it under the terms of the GNU General Public License as published by |
---|
10 | * the Free Software Foundation; either version 2 of the License, or |
---|
11 | * (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
21 | * |
---|
22 | * @author Cenditel Merida - Msc. Juan Vizcarrondo |
---|
23 | * @date 2013-02-04 // (año-mes-dia) |
---|
24 | * @date 2015-02-06 // (año-mes-dia) |
---|
25 | * Modificado por: Ing. Jose Puentes @date 2015-11-17. |
---|
26 | * @version 0.2 // (0.1) |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | /* |
---|
31 | * Implementation of hook_node_info() |
---|
32 | */ |
---|
33 | function proyectos_operativos_node_info() { |
---|
34 | return array( |
---|
35 | 'proyectos_operativos' => array( |
---|
36 | 'name' => t('Proyectos Operativos'), |
---|
37 | 'description' => '', |
---|
38 | 'has_title' => TRUE, |
---|
39 | 'title_label' => 'Nombre del proyecto', |
---|
40 | 'has_body' => FALSE, |
---|
41 | 'body_label' => 'Cuerpo', |
---|
42 | 'module' => 'proyectos_operativos', |
---|
43 | ), |
---|
44 | ); |
---|
45 | } |
---|
46 | |
---|
47 | /* |
---|
48 | * Implementation of hook_form() |
---|
49 | */ |
---|
50 | function proyectos_operativos_form(&$node, $form_state) { |
---|
51 | return node_content_form($node, $form_state); |
---|
52 | } |
---|
53 | |
---|
54 | /* |
---|
55 | * Implementation of hook_access() |
---|
56 | */ |
---|
57 | function proyectos_operativos_access($op, $node, $account) { |
---|
58 | if ($op == 'view') { |
---|
59 | return user_access('ver planificador'); |
---|
60 | } |
---|
61 | if ($op == 'create') { |
---|
62 | return user_access('admin planificador'); |
---|
63 | } |
---|
64 | if ($op == 'update') { |
---|
65 | return user_access('admin planificador'); |
---|
66 | } |
---|
67 | if ($op == 'delete') { |
---|
68 | return user_access('admin planificador'); |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | * Implementation of hook_ente_procesos_alter() |
---|
74 | */ |
---|
75 | function proyectos_operativos_ente_procesos_alter(&$procesos, $type) { |
---|
76 | if ($type == 'status') { |
---|
77 | $procesos['proyectos_operativos'] = array( |
---|
78 | 'title' => t('Proyectos Operativos'), |
---|
79 | 'description' => t('Definición de Proyectos Direccionales'), |
---|
80 | 'weight' => -9, |
---|
81 | ); |
---|
82 | } |
---|
83 | else { |
---|
84 | $procesos['proyectos_operativos_formular'] = array( |
---|
85 | 'title' => t('Formular Proyectos Operativos'), |
---|
86 | 'description' => t('Permite agregar, modificar y eliminar los Proyectos Operativos'), |
---|
87 | 'message' => 'Se podrá registrar y/o modificar las Proyectos Operativos desde %fecha hasta la fecha %fecha1', |
---|
88 | 'message_expire' => 'Registrar y/o modificar las Proyectos Operativos no se encuentra disponible, se podra realizar desde %fecha hasta la fecha %fecha1)', |
---|
89 | 'weight' => 3, |
---|
90 | 'proceso' => 'proyectos_operativos', |
---|
91 | ); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | /* |
---|
96 | * Implementation of proyectos_operativos_status_planificacion_proyectos_operativos() |
---|
97 | */ |
---|
98 | function proyectos_operativos_status_planificacion_proyectos_operativos($ente_planificador, $tipo = 2) { |
---|
99 | $datos_proyectos_operativos_status = array(); |
---|
100 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
101 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
102 | $year = variable_get('proyectos_operativos_anho_creacion', 0); |
---|
103 | $estado_aprobado = variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
104 | $estado_naprobado = variable_get('proyectos_operativos_state_naprobado', NULL); |
---|
105 | //se obtienen todos los proyectos agregados que sean diferentes a Cancelados |
---|
106 | $cantidad_proyectos = db_fetch_object(db_query("SELECT count(ac.nid) AS cantidad FROM {proyectos_operativos} AS ac INNER JOIN {workflow_node} AS w ON w.nid = ac.nid WHERE ac.ente = %d AND year = %d AND w.sid <> %d", $ente_planificador, $year, $estado_naprobado))->cantidad; |
---|
107 | $cantidad_proyectos_aprobados = db_fetch_object(db_query("SELECT count(ac.nid) AS cantidad FROM {proyectos_operativos} AS ac INNER JOIN {workflow_node} AS w ON w.nid = ac.nid WHERE ac.ente = %d AND year = %d AND w.sid = %d", $ente_planificador, $year, $estado_aprobado))->cantidad; |
---|
108 | $porc = $cantidad_proyectos != 0 ? ($cantidad_proyectos_aprobados) / $cantidad_proyectos : 0; |
---|
109 | //se verifica que exista la planificacion, si existe al menos los datos de familiarizacion fueron ingresados |
---|
110 | $datos_proyectos_operativos_status['proyectos_operativos_formular']['value'] = $porc; |
---|
111 | $datos_proyectos_operativos_status['proyectos_operativos_formular']['title'] = t('Registrar Proyectos Operativos para el año @year', array('@year' => $year)); |
---|
112 | $datos_proyectos_operativos_status['proyectos_operativos_formular']['link'] = 'proyectos_operativos'; |
---|
113 | $datos_proyectos_operativos_status['proyectos_operativos_formular']['mylink'] = 'proyectos_operativos'; |
---|
114 | $datos_proyectos_operativos_status['proyectos_operativos_formular']['weight'] = -10; |
---|
115 | return $datos_proyectos_operativos_status; |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * Menu access control callback. Determine access to Workflow tab. |
---|
120 | */ |
---|
121 | function _proyectos_operativos_edita_datos_generales_access($node = NULL) { |
---|
122 | $acceso = _proyectos_operativos_access_editar($node); |
---|
123 | if (!$acceso) { |
---|
124 | return FALSE; |
---|
125 | } |
---|
126 | return TRUE; |
---|
127 | } |
---|
128 | |
---|
129 | /* |
---|
130 | * Implementation of hook_nodeapi() |
---|
131 | */ |
---|
132 | function proyectos_operativos_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
---|
133 | switch ($op) { |
---|
134 | case 'insert': |
---|
135 | if ($node->type == 'proyectos_operativos') { |
---|
136 | $year = variable_get('proyectos_operativos_anho_creacion', 0) ? variable_get('proyectos_operativos_anho_creacion', 0) : date("Y"); |
---|
137 | db_query('INSERT INTO {proyectos_operativos} (nid, year, ente) VALUES (%d, %d, %d)', $node->nid, $year, $node->field_proyecto_ente[0]['nid']); |
---|
138 | } |
---|
139 | break; |
---|
140 | case 'update': |
---|
141 | if ($node->type == 'proyectos_operativos') { |
---|
142 | $result = db_query("SELECT ente FROM {proyectos_operativos} WHERE nid = %d", $node->nid); |
---|
143 | $proyectos_operativos = db_fetch_array($result); |
---|
144 | //print_r($proyectos_operativos); |
---|
145 | if ($proyectos_operativos && $proyectos_operativos['ente'] != $node->field_proyecto_ente[0]['nid']){ |
---|
146 | db_query('update {proyectos_operativos} set ente = %d WHERE nid = %d', $node->field_proyecto_ente[0]['nid'], $node->nid); |
---|
147 | } |
---|
148 | } |
---|
149 | break; |
---|
150 | case 'load': |
---|
151 | if ($node->type == 'proyectos_operativos') { |
---|
152 | $titulo = isset($node->field_proyecto_titulo[0]['value']) && trim($node->field_proyecto_titulo[0]['value']) != '' ? $node->field_proyecto_titulo[0]['value'] : $node->title; |
---|
153 | $node->titulo_asignado = $titulo; |
---|
154 | $result = db_query("SELECT year FROM {proyectos_operativos} WHERE nid = %d", $node->nid); |
---|
155 | if (!($proyectos_operativos = db_fetch_array($result))){ |
---|
156 | $year = variable_get('proyectos_operativos_anho_creacion', 0) ? variable_get('proyectos_operativos_anho_creacion', 0) : date("Y"); |
---|
157 | db_query('INSERT INTO {proyectos_operativos} (nid, year, ente) VALUES (%d, %d, %d)', $node->nid, $year, $node->field_proyecto_ente[0]['nid']); |
---|
158 | $result = db_query("SELECT year FROM {proyectos_operativos} WHERE nid = %d", $node->nid); |
---|
159 | $proyectos_operativos = db_fetch_array($result); |
---|
160 | } |
---|
161 | $node->anhoproyectos_operativos = $proyectos_operativos['year']; |
---|
162 | } |
---|
163 | elseif ($node->type == 'accion_especifica') { |
---|
164 | $titulo = isset($node->field_accion_titulo[0]['value']) && trim($node->field_accion_titulo[0]['value']) != '' ? $node->field_accion_titulo[0]['value'] : $node->title; |
---|
165 | $node->titulo_asignado = $titulo; |
---|
166 | } |
---|
167 | break; |
---|
168 | case 'delete': |
---|
169 | //eliminar todas las ae del proyecto |
---|
170 | if ($node->type == 'proyectos_operativos') { |
---|
171 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
172 | if ($accion['nid']) { |
---|
173 | node_delete($accion['nid']); |
---|
174 | } |
---|
175 | } |
---|
176 | db_query('DELETE FROM {proyectos_operativos} WHERE nid = %d', $node->nid); |
---|
177 | } |
---|
178 | break; |
---|
179 | case 'view': |
---|
180 | if ($node->type == 'proyectos_operativos') { |
---|
181 | module_load_include('inc', 'workflow', 'workflow.pages'); |
---|
182 | $output = '<div class="field-label"><b>' . t('Flujo de Trabajo') . ':</b> </div>'; |
---|
183 | $wid = workflow_get_workflow_for_type($node->type); |
---|
184 | $states_per_page = variable_get('workflow_states_per_page', 20); |
---|
185 | $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid"); |
---|
186 | while ($data = db_fetch_object($result)) { |
---|
187 | $states[$data->sid] = check_plain(t($data->state)); |
---|
188 | } |
---|
189 | $deleted_states = array(); |
---|
190 | $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 0 ORDER BY sid"); |
---|
191 | while ($data = db_fetch_object($result)) { |
---|
192 | $deleted_states[$data->sid] = check_plain(t($data->state)); |
---|
193 | } |
---|
194 | $current = workflow_node_current_state($node); |
---|
195 | // theme_workflow_current_state() must run state through check_plain(). |
---|
196 | $output .= '<p>'. t('Current state: !state', array('!state' => theme('workflow_current_state', $states[$current]))) . "</p>\n"; |
---|
197 | $result = db_query("SELECT h.*, u.name FROM {workflow_node_history} h LEFT JOIN {users} u ON h.uid = u.uid WHERE nid = %d ORDER BY hid DESC", $node->nid); |
---|
198 | $rows = array(); |
---|
199 | while ($history = db_fetch_object($result)) { |
---|
200 | if ($history->sid == $current && !isset($deleted_states[$history->sid]) && !isset($current_themed)) { |
---|
201 | // Theme the current state differently so it stands out. |
---|
202 | $state_name = theme('workflow_current_state', $states[$history->sid]); |
---|
203 | // Make a note that we have themed the current state; other times in the history |
---|
204 | // of this node where the node was in this state do not need to be specially themed. |
---|
205 | $current_themed = TRUE; |
---|
206 | } |
---|
207 | elseif (isset($deleted_states[$history->sid])) { |
---|
208 | // The state has been deleted, but we include it in the history. |
---|
209 | $state_name = theme('workflow_deleted_state', $deleted_states[$history->sid]); |
---|
210 | $footer_needed = TRUE; |
---|
211 | } |
---|
212 | else { |
---|
213 | // Regular state. |
---|
214 | $state_name = check_plain(t($states[$history->sid])); |
---|
215 | } |
---|
216 | if (isset($deleted_states[$history->old_sid])) { |
---|
217 | $old_state_name = theme('workflow_deleted_state', $deleted_states[$history->old_sid]); |
---|
218 | $footer_needed = TRUE; |
---|
219 | } |
---|
220 | else { |
---|
221 | $old_state_name = check_plain(t($states[$history->old_sid])); |
---|
222 | } |
---|
223 | $rows[] = theme('workflow_history_table_row', $history, $old_state_name, $state_name); |
---|
224 | } |
---|
225 | $output .= theme('workflow_history_table', $rows, !empty($footer_needed)); |
---|
226 | $node->content['proyectos_operativos_flujo'] = array( |
---|
227 | '#value' => $output, |
---|
228 | '#weight' => 100, |
---|
229 | ); |
---|
230 | } |
---|
231 | elseif ($node->type == 'accion_especifica') { |
---|
232 | $node->title = $node->titulo_asignado; |
---|
233 | } |
---|
234 | break; |
---|
235 | } |
---|
236 | } |
---|
237 | |
---|
238 | /** |
---|
239 | * Implementation of _proyectos_operativos_edita_datos_indicadores_access() |
---|
240 | * Menu access control callback. Determina si un proyecto tiene acceso a indicadores. |
---|
241 | */ |
---|
242 | function _proyectos_operativos_edita_datos_indicadores_access($node = NULL) { |
---|
243 | global $user; |
---|
244 | $acceso = _proyectos_operativos_access_editar($node); |
---|
245 | if (!$acceso) { |
---|
246 | return FALSE; |
---|
247 | } |
---|
248 | return $node->field_proyecto_og[0]['value']; |
---|
249 | } |
---|
250 | |
---|
251 | /** |
---|
252 | * Implementation of _proyectos_operativos_edita_datos_ae_access() |
---|
253 | * Menu access control callback. Determina si un proyecto tiene acceso a acciones especificas. |
---|
254 | */ |
---|
255 | function _proyectos_operativos_edita_datos_ae_access($node = NULL) { |
---|
256 | global $user; |
---|
257 | $acceso = _proyectos_operativos_access_editar($node); |
---|
258 | if (!$acceso) { |
---|
259 | return FALSE; |
---|
260 | } |
---|
261 | return $node->field_proyecto_unidadm[0]['value']; |
---|
262 | } |
---|
263 | |
---|
264 | /** |
---|
265 | * Implementation of _proyectos_operativos_edita_datos_financieros_access() |
---|
266 | * Menu access control callback. Determina si un proyecto tiene acceso a los datos financieros. |
---|
267 | */ |
---|
268 | function _proyectos_operativos_edita_datos_financieros_access($node = NULL) { |
---|
269 | if (!_proyectos_operativos_edita_datos_ae_access($node)) { |
---|
270 | return FALSE; |
---|
271 | } |
---|
272 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
273 | if ($accion['nid'] && $nid != $accion['nid']) { |
---|
274 | $accion_load = node_load($accion['nid']); |
---|
275 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
276 | if ($accion_load->field_accion_esp_programacion[0]['tid']) { |
---|
277 | foreach($accion_load->field_accion_esp_programacion as $programacion) { |
---|
278 | foreach($programacion as $id_value => $mesp){ |
---|
279 | if ($id_value != 'tid') { |
---|
280 | $montos +=$mesp; |
---|
281 | } |
---|
282 | } |
---|
283 | } |
---|
284 | } |
---|
285 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
286 | $porcentajes[$accion_load->field_accion_esp_ponderacion[0]['value']] = 1; |
---|
287 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
288 | } |
---|
289 | } |
---|
290 | elseif($nid = $accion['nid']) { |
---|
291 | $acciones_especificas[$ae->nid] = $ae; |
---|
292 | } |
---|
293 | } |
---|
294 | $monto_restante = $node->field_proyecto_monto_anual[0]['value'] - $montos; |
---|
295 | $et = 100 - $ejecucion; |
---|
296 | return (($monto_restante == 0) && ($et == 0)); |
---|
297 | } |
---|
298 | |
---|
299 | |
---|
300 | /** |
---|
301 | * Implementation of _proyectos_operativos_ver_datos_wk_access() |
---|
302 | * Menu access control callback. Determina si un usuario tiene acceso al flujo de trabajo |
---|
303 | */ |
---|
304 | function _proyectos_operativos_ver_datos_wk_access($node = NULL) { |
---|
305 | return (user_access('ver planificador') && $node->type == 'proyectos_operativos'); |
---|
306 | } |
---|
307 | |
---|
308 | /** |
---|
309 | * Implementation of _proyectos_operativos_ver_datos_wk_access() |
---|
310 | * Menu access control callback. Determina si un usuario tiene acceso a editar el flujo de trabajo |
---|
311 | */ |
---|
312 | function _proyectos_operativos_edita_datos_wk_access($node = NULL) { |
---|
313 | global $user; |
---|
314 | $fecha = FALSE; |
---|
315 | $ente = usuario_tiene_ente($user->uid); |
---|
316 | if ($ente->nid == $ente_planificador->nid) { |
---|
317 | $fecha = TRUE; |
---|
318 | } |
---|
319 | elseif (!user_access('admin planificador')) { |
---|
320 | $fecha = FALSE; |
---|
321 | } |
---|
322 | $accesso = workflow_node_tab_access($node); |
---|
323 | return $fecha && $accesso && _proyectos_operativos_edita_datos_financieros_access($node); |
---|
324 | } |
---|
325 | |
---|
326 | /** |
---|
327 | * Implementation of _proyectos_operativos_edita_datos_agregar() |
---|
328 | * Menu access control callback. Determina si un usuario tiene acceso a crear un nuevo proyecto |
---|
329 | */ |
---|
330 | function _proyectos_operativos_edita_datos_agregar($enteagregar = 0) { |
---|
331 | global $user; |
---|
332 | $current_time = time(); |
---|
333 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
334 | $ente = usuario_tiene_ente($user->uid); |
---|
335 | $ente_planificador = 0; |
---|
336 | if ($ente && $ente->nid) { |
---|
337 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
338 | } |
---|
339 | elseif (user_access('admin planificador') && $enteagregar) { |
---|
340 | $ente_planificador = ente_planificador_leer_ente_planificadores($enteagregar); |
---|
341 | } |
---|
342 | if (!$ente_planificador) { |
---|
343 | return FALSE; |
---|
344 | } |
---|
345 | $first_state = 0; |
---|
346 | if (!user_access('admin planificador') && module_exists('workflow')) { |
---|
347 | $states = _proyectos_operativos_reformula_obtiene_estados(); |
---|
348 | if ($states['wid']) { |
---|
349 | $first_state = _workflow_creation_state($states['wid']); |
---|
350 | } |
---|
351 | if ($first_state) { |
---|
352 | $roles_perm = FALSE; |
---|
353 | $roles_allow = variable_get('proyectos_operativos_state_m_' . $first_state, array()); |
---|
354 | $roles = array_keys($user->roles); |
---|
355 | if (count($roles)) { |
---|
356 | foreach($roles as $rol) { |
---|
357 | if($roles_allow[$rol]) { |
---|
358 | $roles_perm = TRUE; |
---|
359 | } |
---|
360 | elseif ($rol == -1 && $node->uid == $user->uid) { |
---|
361 | $roles_perm = TRUE; |
---|
362 | } |
---|
363 | } |
---|
364 | } |
---|
365 | if (!$roles_perm) { |
---|
366 | return FALSE; |
---|
367 | } |
---|
368 | } |
---|
369 | } |
---|
370 | |
---|
371 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
372 | |
---|
373 | return $mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time; |
---|
374 | } |
---|
375 | |
---|
376 | /** |
---|
377 | * Implementation of _proyectos_operativos_access_editar() |
---|
378 | * Menu access control callback. Determina si un usuario tiene acceso a editar un proyecto |
---|
379 | */ |
---|
380 | function _proyectos_operativos_access_editar($node) { |
---|
381 | global $user; |
---|
382 | if (module_exists('workflow')) { |
---|
383 | $estado_aprobado = variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
384 | $estado_naprobado = variable_get('proyectos_operativos_state_naprobado', NULL); |
---|
385 | if ($node->_workflow == $estado_aprobado || $node->_workflow == $estado_naprobado) { |
---|
386 | return FALSE; |
---|
387 | } |
---|
388 | } |
---|
389 | if ($node->anhoproyectos_operativos != variable_get('proyectos_operativos_anho_creacion', 0)) { |
---|
390 | return FALSE; |
---|
391 | } |
---|
392 | $ente_planificador = ente_planificador_leer_ente_planificadores($node->field_proyecto_ente[0]['nid']); |
---|
393 | if (!$ente_planificador || !$ente_planificador->nid) { |
---|
394 | return FALSE; |
---|
395 | } |
---|
396 | $current_time = time(); |
---|
397 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
398 | $fecha = FALSE; |
---|
399 | $ente = usuario_tiene_ente($user->uid); |
---|
400 | if ($ente_planificador->nid != $ente->nid && !user_access('admin planificador')) { |
---|
401 | return FALSE; |
---|
402 | } |
---|
403 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
404 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
405 | $fecha = TRUE; |
---|
406 | } |
---|
407 | if ($fecha) { |
---|
408 | if ($ente->nid == $ente_planificador->nid) { |
---|
409 | $fecha = TRUE; |
---|
410 | } |
---|
411 | elseif (!user_access('admin planificador')) { |
---|
412 | $fecha = FALSE; |
---|
413 | } |
---|
414 | } |
---|
415 | $roles_perm = TRUE; |
---|
416 | if (module_exists('workflow') && $fecha && !user_access('admin planificador')) { |
---|
417 | $roles_perm = FALSE; |
---|
418 | $roles_allow = variable_get('proyectos_operativos_state_m_' . $node->_workflow, array()); |
---|
419 | $roles = array_keys($user->roles); |
---|
420 | if (count($roles)) { |
---|
421 | foreach($roles as $rol) { |
---|
422 | if($roles_allow[$rol]) { |
---|
423 | $roles_perm = TRUE; |
---|
424 | } |
---|
425 | elseif ($rol == -1 && $node->uid == $user->uid) { |
---|
426 | $roles_perm = TRUE; |
---|
427 | } |
---|
428 | } |
---|
429 | } |
---|
430 | } |
---|
431 | return $fecha && $roles_perm; |
---|
432 | } |
---|
433 | |
---|
434 | /* |
---|
435 | * Implementation of hook_menu() |
---|
436 | */ |
---|
437 | function proyectos_operativos_menu() { |
---|
438 | $items = array(); |
---|
439 | //consultar proyectos operativos |
---|
440 | $items['proyectos_operativos'] = array( |
---|
441 | 'title' => t('Consultar Proyectos Operativos'), |
---|
442 | 'page callback' => 'proyectos_operativos_search_ac_display', |
---|
443 | 'access arguments' => array('ver planificador'), |
---|
444 | 'type' => MENU_NORMAL_ITEM, |
---|
445 | ); |
---|
446 | //editar proyectos operativos (basicos) |
---|
447 | $items['proyectosopedit/%proyectosop'] = array( |
---|
448 | 'title callback' => 'node_page_title', |
---|
449 | 'title arguments' => array(1), |
---|
450 | 'page callback' => 'drupal_get_form', |
---|
451 | 'page arguments' => array('proyectos_operativos_proyecto_basico_form', 1), |
---|
452 | 'access callback' => '_proyectos_operativos_access_editar', |
---|
453 | 'access arguments' => array(1), |
---|
454 | 'type' => MENU_CALLBACK, |
---|
455 | ); |
---|
456 | $items['proyectosopedit/%proyectosop/basicos'] = array( |
---|
457 | 'title' => t('Datos Básicos'), |
---|
458 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
459 | 'weight' => -10 |
---|
460 | ); |
---|
461 | //editar proyectos operativos (generales) |
---|
462 | $items['proyectosopedit/%proyectosop/generales'] = array( |
---|
463 | 'title' => t('Datos Generales'), |
---|
464 | 'page callback' => 'drupal_get_form', |
---|
465 | 'page arguments' => array('proyectos_operativos_proyecto_generales_form', 1), |
---|
466 | 'access callback' => '_proyectos_operativos_edita_datos_generales_access', |
---|
467 | 'access arguments' => array(1), |
---|
468 | 'weight' => -7, |
---|
469 | 'type' => MENU_LOCAL_TASK, |
---|
470 | ); |
---|
471 | //editar proyectos operativos (indicadores) |
---|
472 | $items['proyectosopedit/%proyectosop/indicadores'] = array( |
---|
473 | 'title' => t('Indicadores del Proyecto'), |
---|
474 | 'page callback' => 'drupal_get_form', |
---|
475 | 'page arguments' => array('proyectos_operativos_proyecto_indicadores_form', 1), |
---|
476 | 'access callback' => '_proyectos_operativos_edita_datos_indicadores_access', |
---|
477 | 'access arguments' => array(1), |
---|
478 | 'weight' => -6, |
---|
479 | 'type' => MENU_LOCAL_TASK, |
---|
480 | ); |
---|
481 | //editar proyectos operativos (acciones especificas) |
---|
482 | $items['proyectosopedit/%proyectosop/ae'] = array( |
---|
483 | 'title' => t('Acciones EspecÃficas'), |
---|
484 | 'page callback' => '_proyectos_operativos_proyecto_ae', |
---|
485 | 'page arguments' => array(1), |
---|
486 | 'access callback' => '_proyectos_operativos_edita_datos_ae_access', |
---|
487 | 'access arguments' => array(1), |
---|
488 | 'weight' => -5, |
---|
489 | 'type' => MENU_LOCAL_TASK, |
---|
490 | ); |
---|
491 | $items['proyectosopedit/%proyectosop/ae/ver'] = array( |
---|
492 | 'title' => t('Acciones Especificas'), |
---|
493 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
494 | 'weight' => -10 |
---|
495 | ); |
---|
496 | //editar proyectos operativos (editar acciones especificas) |
---|
497 | $items['proyectosopedit/%proyectosop/ae/%accion_especifical/edit'] = array( |
---|
498 | 'title' => t('Editar'), |
---|
499 | 'page callback' => '_proyectos_operativos_proyecto_ae', |
---|
500 | 'page arguments' => array(1, 3), |
---|
501 | 'access callback' => '_proyectos_operativos_edita_datos_ae_access', |
---|
502 | 'access arguments' => array(1), |
---|
503 | 'weight' => -4, |
---|
504 | 'type' => MENU_LOCAL_TASK, |
---|
505 | ); |
---|
506 | //editar proyectos operativos (borrar acciones especificas) |
---|
507 | $items['proyectosopedit/%proyectosop/ae/%accion_especifical/remove'] = array( |
---|
508 | 'title' => t('Eliminar'), |
---|
509 | 'page callback' => 'drupal_get_form', |
---|
510 | 'page arguments' => array('proyectos_operativos_remove_ac_form', 1, 3), |
---|
511 | 'access callback' => '_proyectos_operativos_edita_datos_ae_access', |
---|
512 | 'access arguments' => array(1), |
---|
513 | 'weight' => -4, |
---|
514 | 'type' => MENU_LOCAL_TASK, |
---|
515 | ); |
---|
516 | //editar proyectos operativos (datos financieros) |
---|
517 | $items['proyectosopedit/%proyectosop/finacieros'] = array( |
---|
518 | 'title' => t('Datos Financieros'), |
---|
519 | 'page callback' => '_proyectos_operativos_proyecto_financieros', |
---|
520 | 'page arguments' => array(1), |
---|
521 | 'access callback' => '_proyectos_operativos_edita_datos_financieros_access', |
---|
522 | 'access arguments' => array(1), |
---|
523 | 'weight' => -4, |
---|
524 | 'type' => MENU_LOCAL_TASK, |
---|
525 | ); |
---|
526 | //ver ficha del proyecto |
---|
527 | $items['proyectosopedit/%proyectosop/ficha'] = array( |
---|
528 | 'title' => t('Ficha'), |
---|
529 | 'page callback' => '_proyectos_operativos_proyecto_ficha_proyecto', |
---|
530 | 'page arguments' => array(1), |
---|
531 | 'access callback' => '_proyectos_operativos_edita_datos_financieros_access', |
---|
532 | 'access arguments' => array(1), |
---|
533 | 'weight' => -3, |
---|
534 | 'type' => MENU_LOCAL_TASK, |
---|
535 | ); |
---|
536 | //consulta proyecto operativo |
---|
537 | $items['proyectosopedit/%proyectosop/ver'] = array( |
---|
538 | 'title' => 'Consultar', |
---|
539 | 'page callback' => '_proyectos_operativos_proyecto_regresa_ver', |
---|
540 | 'page arguments' => array(1), |
---|
541 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
542 | 'access arguments' => array(1), |
---|
543 | 'type' => MENU_LOCAL_TASK |
---|
544 | ); |
---|
545 | //agregar proyecto operativo |
---|
546 | $items['agregarproyectosop'] = array( |
---|
547 | 'title' => t('Agregar Proyecto'), |
---|
548 | 'page callback' => '_proyectos_operativos_proyecto_agregar_proyecto', |
---|
549 | 'access callback' => '_proyectos_operativos_edita_datos_agregar', |
---|
550 | 'weight' => -7, |
---|
551 | 'type' => MENU_NORMAL_ITEM, |
---|
552 | ); |
---|
553 | $items['agregarproyectosop/%'] = array( |
---|
554 | 'title' => t('Agregar Proyecto'), |
---|
555 | 'page callback' => '_proyectos_operativos_proyecto_agregar_proyecto', |
---|
556 | 'page arguments' => array(1), |
---|
557 | 'access callback' => '_proyectos_operativos_edita_datos_agregar', |
---|
558 | 'access arguments' => array(1), |
---|
559 | 'weight' => -7, |
---|
560 | 'type' => MENU_NORMAL_ITEM, |
---|
561 | ); |
---|
562 | //configuracion proyectos operativos |
---|
563 | $items['agregar_proyectoopente'] = array( |
---|
564 | 'title' => t('Agregar Proyectos Operativos por ente'), |
---|
565 | 'page callback' => 'proyectos_operativos_agregar_proyectoente', |
---|
566 | 'access arguments' => array('admin planificador'), |
---|
567 | 'weight' => -6, |
---|
568 | 'type' => MENU_NORMAL_ITEM, |
---|
569 | ); |
---|
570 | |
---|
571 | //consulta proyecto operativo |
---|
572 | $items['proyectosop/%proyectosop'] = array( |
---|
573 | 'title' => t('Ver'), |
---|
574 | 'page callback' => '_proyectos_operativos_proyecto_campos', |
---|
575 | 'page arguments' => array(1), |
---|
576 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
577 | 'access arguments' => array(1), |
---|
578 | 'weight' => -7, |
---|
579 | 'type' => MENU_CALLBACK, |
---|
580 | ); |
---|
581 | $items['proyectosop/%proyectosop/ver'] = array( |
---|
582 | 'title' => t('Ver'), |
---|
583 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
584 | 'weight' => -10 |
---|
585 | ); |
---|
586 | $items['proyectosop/%proyectosop/ficha'] = array( |
---|
587 | 'title' => t('Ficha'), |
---|
588 | 'page callback' => '_proyectos_operativos_proyecto_ficha_proyecto', |
---|
589 | 'page arguments' => array(1), |
---|
590 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
591 | 'access arguments' => array(1), |
---|
592 | 'weight' => -6, |
---|
593 | 'type' => MENU_LOCAL_TASK, |
---|
594 | ); |
---|
595 | //consulta proyecto operativo (accion especificas) |
---|
596 | $items['proyectosop/%proyectosop/ae'] = array( |
---|
597 | 'title' => t('Acciones Especificas'), |
---|
598 | 'page callback' => '_list_proyectos_operativos_proyecto_ae', |
---|
599 | 'page arguments' => array(1), |
---|
600 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
601 | 'access arguments' => array(1), |
---|
602 | 'weight' => -5, |
---|
603 | 'type' => MENU_LOCAL_TASK, |
---|
604 | ); |
---|
605 | $items['proyectosop/%proyectosop/ae/%accion_especifical/ver'] = array( |
---|
606 | 'title' => t('Consultar Acción EspecÃfica'), |
---|
607 | 'page callback' => 'node_view', |
---|
608 | 'page arguments' => array(3), |
---|
609 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
610 | 'access arguments' => array(1), |
---|
611 | 'weight' => -4, |
---|
612 | 'type' => MENU_LOCAL_TASK, |
---|
613 | ); |
---|
614 | //editar proyectos operativos (borrar acciones especificas) |
---|
615 | $items['proyectosop/%proyectosop/ae/%accion_especifical/remove'] = array( |
---|
616 | 'title' => t('Eliminar'), |
---|
617 | 'page callback' => 'drupal_get_form', |
---|
618 | 'page arguments' => array('proyectos_operativos_remove_ac_form', 1, 3), |
---|
619 | 'access callback' => '_proyectos_operativos_edita_datos_ae_access', |
---|
620 | 'access arguments' => array(1), |
---|
621 | 'weight' => -4, |
---|
622 | 'type' => MENU_CALLBACK, |
---|
623 | ); |
---|
624 | //consulta proyecto operativo (datos financieros) |
---|
625 | $items['proyectosop/%proyectosop/finacieros'] = array( |
---|
626 | 'title' => t('Datos Financieros'), |
---|
627 | 'page callback' => '_proyectos_operativos_proyecto_financieros', |
---|
628 | 'page arguments' => array(1), |
---|
629 | 'access callback' => '_proyectos_operativos_ver_datos_wk_access', |
---|
630 | 'access arguments' => array(1), |
---|
631 | 'weight' => -4, |
---|
632 | 'type' => MENU_LOCAL_TASK, |
---|
633 | ); |
---|
634 | //consulta proyecto operativo (flujo de trabajo) |
---|
635 | $items['proyectosop/%proyectosop/workflow'] = array( |
---|
636 | 'title' => t('Workflow'), |
---|
637 | 'page callback' => '_proyectos_operativos_proyecto_ver_workflow', |
---|
638 | 'page arguments' => array(1), |
---|
639 | 'access callback' => '_proyectos_operativos_edita_datos_wk_access', |
---|
640 | 'access arguments' => array(1), |
---|
641 | 'weight' => -4, |
---|
642 | 'type' => MENU_LOCAL_TASK, |
---|
643 | ); |
---|
644 | //editar proyecto operativo |
---|
645 | $items['proyectosop/%proyectosop/edit'] = array( |
---|
646 | 'title' => t('Edit'), |
---|
647 | 'page callback' => '_proyectos_operativos_proyecto_editar', |
---|
648 | 'page arguments' => array(1), |
---|
649 | 'access callback' => '_proyectos_operativos_access_editar', |
---|
650 | 'access arguments' => array(1), |
---|
651 | 'weight' => -3, |
---|
652 | 'type' => MENU_LOCAL_TASK, |
---|
653 | ); |
---|
654 | //editar proyecto operativo |
---|
655 | $items['proyectosop/%proyectosop/remove'] = array( |
---|
656 | 'title' => t('Eliminar'), |
---|
657 | 'page callback' => 'drupal_get_form', |
---|
658 | 'page arguments' => array('proyectos_operativos_remove_proyectosop_form', 1), |
---|
659 | 'access callback' => '_proyectos_operativos_access_editar', |
---|
660 | 'access arguments' => array(1), |
---|
661 | 'weight' => -3, |
---|
662 | 'type' => MENU_LOCAL_TASK, |
---|
663 | ); |
---|
664 | |
---|
665 | |
---|
666 | //configuracion proyectos operativos |
---|
667 | $items['admin/settings/ente_planificador/proyectos_operativos'] = array( |
---|
668 | 'title' => t('Proyectos Operativos'), |
---|
669 | 'page callback' => 'drupal_get_form', |
---|
670 | 'page arguments' => array('proyectos_operativos_admin_settings'), |
---|
671 | 'access arguments' => array('admin planificador'), |
---|
672 | 'weight' => -6, |
---|
673 | 'type' => MENU_LOCAL_TASK, |
---|
674 | 'file' => 'proyectos_operativos.admin.inc', |
---|
675 | ); |
---|
676 | $items['admin/settings/ente_planificador/proyectos_operativos/configurar'] = array( |
---|
677 | 'title' => t('Configurar'), |
---|
678 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
679 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
680 | 'weight' => -10 |
---|
681 | ); |
---|
682 | if (module_exists('workflow')) { |
---|
683 | //configuracion proyectos operativos |
---|
684 | $items['admin/settings/ente_planificador/proyectos_operativos/worflow'] = array( |
---|
685 | 'title' => t('Workflow'), |
---|
686 | 'page callback' => 'drupal_get_form', |
---|
687 | 'page arguments' => array('proyectos_operativos_admin_workflow_settings'), |
---|
688 | 'access arguments' => array('admin planificador'), |
---|
689 | 'weight' => -6, |
---|
690 | 'type' => MENU_LOCAL_TASK, |
---|
691 | 'file' => 'proyectos_operativos.admin.inc', |
---|
692 | ); |
---|
693 | } |
---|
694 | |
---|
695 | $items['proyectos_operativos_proyecto_generales_agrega_talento_js_util'] = array( |
---|
696 | 'title' => 'JS utilities', |
---|
697 | 'page callback' => 'proyectos_operativos_proyecto_generales_agrega_talento_js_util', |
---|
698 | 'access arguments' => array('ver planificador'), |
---|
699 | 'type' => MENU_CALLBACK, |
---|
700 | ); |
---|
701 | return $items; |
---|
702 | } |
---|
703 | |
---|
704 | /** |
---|
705 | * Implementation of _proyectos_operativos_proyecto_financieros(). |
---|
706 | * Ver datos financieros (proyectos operativos). |
---|
707 | */ |
---|
708 | function _proyectos_operativos_proyecto_ficha_proyecto($proyecto = 0) { |
---|
709 | drupal_set_title(t('Ficha del Proyecto')); |
---|
710 | //add breadcrumb |
---|
711 | $breadcrumb = array(); |
---|
712 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
713 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
714 | if ($node->nid) { |
---|
715 | $breadcrumb[] = l(check_plain($node->title), 'proyectosop/' . $node->nid); |
---|
716 | } |
---|
717 | $breadcrumb[] = t('Ficha del Proyecto'); |
---|
718 | drupal_set_breadcrumb($breadcrumb); |
---|
719 | return theme('proyectos_operativos_ficha_proyecto', $proyecto); |
---|
720 | |
---|
721 | } |
---|
722 | |
---|
723 | /* |
---|
724 | * proyectos_operativos_proyecto_generales_agrega_talento_js_util |
---|
725 | * Generates AJAX responses of talento humano |
---|
726 | */ |
---|
727 | |
---|
728 | |
---|
729 | function proyectos_operativos_proyecto_generales_agrega_talento_js_util($tipo) { |
---|
730 | $arreglov['talento'] = array( |
---|
731 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
732 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
733 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
734 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
735 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
736 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
737 | ); |
---|
738 | $arreglov['capacidades'] = array( |
---|
739 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
740 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
741 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
742 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
743 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
744 | ); |
---|
745 | $arreglov['beneficiario'] = array( |
---|
746 | 'field_proyecto_beneficiario' => 'field_proyecto_beneficiario', |
---|
747 | 'field_proyectos_masculino_d' => 'field_proyectos_masculino_d', |
---|
748 | 'field_proyectos_femenino_d' => 'field_proyectos_femenino_d', |
---|
749 | ); |
---|
750 | if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { |
---|
751 | $arreglov['beneficiario']['field_proyectos_masculino_i'] = 'field_proyectos_masculino_i'; |
---|
752 | $arreglov['beneficiario']['field_proyectos_femenino_i'] = 'field_proyectos_femenino_i'; |
---|
753 | } |
---|
754 | |
---|
755 | if (array_key_exists($tipo, $arreglov)) { |
---|
756 | $arreglo = $arreglov[$tipo]; |
---|
757 | } |
---|
758 | else { |
---|
759 | drupal_not_found(); |
---|
760 | } |
---|
761 | $cantidad = intval($_POST['cantidad_' . $tipo]) > 0 ? intval($_POST['cantidad_' . $tipo]) : 0; |
---|
762 | $form_state = array('submitted' => FALSE); |
---|
763 | $form_build_id = $_POST['form_build_id']; |
---|
764 | // Add the new element to the stored form. Without adding the element to the |
---|
765 | // form, Drupal is not aware of this new elements existence and will not |
---|
766 | // process it. We retreive the cached form, add the element, and resave. |
---|
767 | $form = form_get_cache($form_build_id, $form_state); |
---|
768 | $node_type = content_types('proyectos_operativos'); |
---|
769 | $fields = $node_type['fields']; |
---|
770 | foreach($arreglo as $field_id => $field) { |
---|
771 | $fields_extra_form1[] = $field_id; |
---|
772 | $prefixC .= '<th>' . $fields[$field_id]['widget']['label'] . '</th>'; |
---|
773 | } |
---|
774 | $format_number = array( |
---|
775 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
776 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
777 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
778 | ); |
---|
779 | $cantidad++; |
---|
780 | $texto_1_aux = $tipo == 'talento' ? 'talento-humano' : $tipo; |
---|
781 | if ($tipo == 'talento' || $tipo == 'capacidades') { |
---|
782 | for ($i = 0; $i < $cantidad; $i++) { |
---|
783 | $prefix = ''; |
---|
784 | if ($i == 0) { |
---|
785 | $prefix = '<div id="' . $texto_1_aux . '-modificar"><table align="center"><tr>' . $prefixC . '</tr><tr><td>'; |
---|
786 | } |
---|
787 | else { |
---|
788 | $prefix .= '<tr><td>'; |
---|
789 | } |
---|
790 | $aux = ''; |
---|
791 | $aui = ''; |
---|
792 | foreach($arreglo as $field_id => $field) { |
---|
793 | $new_form[$field_id . '_' . $i] = array( |
---|
794 | '#type' => 'textfield', |
---|
795 | '#size' => 18, |
---|
796 | '#maxlength' => 255, |
---|
797 | '#prefix' => $prefix, |
---|
798 | '#suffix' => '</td>', |
---|
799 | ); |
---|
800 | if ($field_id == 'field_proyecto_esfuerzo') { |
---|
801 | $new_form[$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); |
---|
802 | } |
---|
803 | $aux = $field_id; |
---|
804 | $aui = $i; |
---|
805 | $prefix = '<td>'; |
---|
806 | $form[$tipo][$field_id . '_' . $i] = $new_form[$field_id . '_' . $i]; |
---|
807 | } |
---|
808 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
809 | $form[$tipo][$aux . '_' . $aui] = $new_form[$aux . '_' . $aui]; |
---|
810 | } |
---|
811 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</table>'; |
---|
812 | $form[$tipo][$aux . '_' . $aui] = $new_form[$aux . '_' . $aui]; |
---|
813 | $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad, '#suffix' => '</div>'); |
---|
814 | unset($form[$tipo]['cantidad_' . $tipo]); |
---|
815 | $form[$tipo]['cantidad_' . $tipo] = $new_form['cantidad_' . $tipo]; |
---|
816 | } |
---|
817 | elseif($tipo == 'beneficiario') { |
---|
818 | $prefixC .= '<th>' . t('Total') . '</th>'; |
---|
819 | $vid = variable_get('proyectos_operativos_extra_bene', 0); |
---|
820 | //$terms = taxonomy_get_tree($vid); |
---|
821 | $tree = taxonomy_get_tree($vid); |
---|
822 | $options = array(); |
---|
823 | $options[''] = t('Seleccionar'); |
---|
824 | if ($tree) { |
---|
825 | foreach ($tree as $term) { |
---|
826 | $options[$term->name] = $term->name; |
---|
827 | } |
---|
828 | } |
---|
829 | for ($i = 0; $i < $cantidad; $i++) { |
---|
830 | $subtotal = 0; |
---|
831 | $prefix = ''; |
---|
832 | if ($i == 0) { |
---|
833 | $prefix = '<div id="' . $texto_1_aux . '-modificar"><table align="center"><tr>' . $prefixC . '</tr><tr><td>'; |
---|
834 | } |
---|
835 | else { |
---|
836 | $prefix .= '<tr><td>'; |
---|
837 | } |
---|
838 | $aux = ''; |
---|
839 | $aui = ''; |
---|
840 | foreach($arreglo as $field_id => $field) { |
---|
841 | //$field_id1 = 'edit-' . str_replace('_', '-', $field_id . '_' . $i); |
---|
842 | $_POST[$field_id . '_' . $i] = str_replace('.', '', $_POST[$field_id . '_' . $i]); |
---|
843 | $valor = intval($_POST[$field_id . '_' . $i]) > 0 ? intval($_POST[$field_id . '_' . $i]) : 0; |
---|
844 | if ($field_id == 'field_proyecto_beneficiario') { |
---|
845 | $new_form[$field_id . '_' . $i] = array( |
---|
846 | '#type' => 'select', |
---|
847 | '#default_value' => $valor, |
---|
848 | '#options' => $options, |
---|
849 | '#prefix' => $prefix, |
---|
850 | '#suffix' => '</td>', |
---|
851 | ); |
---|
852 | } |
---|
853 | else { |
---|
854 | $new_form[$field_id . '_' . $i] = array( |
---|
855 | '#type' => 'textfield', |
---|
856 | '#default_value' => $valor, |
---|
857 | '#size' => 10, |
---|
858 | '#maxlength' => 255, |
---|
859 | '#prefix' => $prefix, |
---|
860 | '#suffix' => '</td>', |
---|
861 | ); |
---|
862 | } |
---|
863 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
864 | if (!isset($total_arreglo[$field_id])) { |
---|
865 | $total_arreglo[$field_id] = 0; |
---|
866 | } |
---|
867 | $subtotal += (int) $valor; |
---|
868 | $totales += (int) $valor; |
---|
869 | $total_arreglo[$field_id] += (int) $valor; |
---|
870 | $sumas['beneficiarios']['beneficiario_' . $i] = 'beneficiario_' . $i; |
---|
871 | $new_form[$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); |
---|
872 | $new_form[$field_id . '_' . $i]['#attributes'] = array('class' => 'number beneficiario_' . $i . ' todosbeneficiarios beneficiarios_' . $field_id, 'onchange' => "sumabeneficiario('beneficiario_$i');sumabeneficiario('todosbeneficiarios');sumabeneficiario('beneficiarios_$field_id');"); |
---|
873 | $form[$tipo][$field_id . '_' . $i] = $new_form[$field_id . '_' . $i]; |
---|
874 | } |
---|
875 | $aux = $field_id; |
---|
876 | $aui = $i; |
---|
877 | $prefix = '<td align="center">'; |
---|
878 | $form[$tipo][$field_id . '_' . $i] = $new_form[$field_id . '_' . $i]; |
---|
879 | } |
---|
880 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="beneficiario_' . $i . '_total">' . number_format($subtotal, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div></td>'; |
---|
881 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
882 | $form[$tipo][$aux . '_' . $aui] = $new_form[$aux . '_' . $aui]; |
---|
883 | |
---|
884 | } |
---|
885 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<tr align="right"><td><b>' . t('TOTAL') . '</b></td>'; |
---|
886 | foreach($arreglo as $field_id => $field) { |
---|
887 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
888 | $sumas['beneficiarios']['beneficiarios_' . $field_id] = 'beneficiarios_' . $field_id; |
---|
889 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="beneficiarios_' . $field_id . '_total">' . $total_arreglo[$field_id] . '</div></td>'; |
---|
890 | $form[$tipo][$aux . '_' . $aui] = $new_form[$aux . '_' . $aui]; |
---|
891 | } |
---|
892 | } |
---|
893 | $sumas['beneficiarios']['todosbeneficiarios'] = 'todosbeneficiarios'; |
---|
894 | $sumas['beneficiarios']['empleos_generados'] = 'empleos_generados'; |
---|
895 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="todosbeneficiarios_total">' . $totales . '</div></td></tr>'; |
---|
896 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</table>'; |
---|
897 | $form[$tipo][$aux . '_' . $aui] = $new_form[$aux . '_' . $aui]; |
---|
898 | unset($form[$tipo]['cantidad_' . $tipo]); |
---|
899 | $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad, '#suffix' => '</div>'); |
---|
900 | $form[$tipo]['cantidad_' . $tipo] = $new_form['cantidad_' . $tipo]; |
---|
901 | } |
---|
902 | //$form[$tipo] = $new_form; |
---|
903 | form_set_cache($form_build_id, $form, $form_state); |
---|
904 | $form += array( |
---|
905 | '#post' => $_POST, |
---|
906 | '#programmed' => FALSE, |
---|
907 | ); |
---|
908 | // Rebuild the form. |
---|
909 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
910 | // Render the new output. |
---|
911 | $new_form = array(); |
---|
912 | $prefix = ''; |
---|
913 | for ($i = 0; $i < $cantidad; $i++) { |
---|
914 | if ($i == 0) { |
---|
915 | $prefix = '<table align="center"><tr>' . $prefixC . '</tr><tr><td>'; |
---|
916 | } |
---|
917 | foreach($arreglo as $field_id => $field) { |
---|
918 | $new_form[$field_id . '_' . $i] = $form[$tipo][$field_id . '_' . $i]; |
---|
919 | if ($prefix != '') { |
---|
920 | $new_form[$field_id . '_' . $i]['#prefix'] = $prefix; |
---|
921 | } |
---|
922 | $prefix = ''; |
---|
923 | $aux = $field_id; |
---|
924 | $aui = $i; |
---|
925 | $new_form[$aux . '_' . $aui] = $form[$tipo][$aux . '_' . $aui]; |
---|
926 | } |
---|
927 | $new_form[$aux . '_' . $aui] = $form[$tipo][$aux . '_' . $aui]; |
---|
928 | } |
---|
929 | $new_form[$aux . '_' . $aui] = $form[$tipo][$aux . '_' . $aui]; |
---|
930 | foreach($arreglo as $field_id => $field) { |
---|
931 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
932 | $new_form[$aux . '_' . $aui] = $form[$tipo][$aux . '_' . $aui]; |
---|
933 | } |
---|
934 | } |
---|
935 | |
---|
936 | $new_form['cantidad_' . $tipo] = $form[$tipo]['cantidad_' . $tipo]; |
---|
937 | unset($new_form['cantidad_' . $tipo]['#suffix']); |
---|
938 | unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers. |
---|
939 | //unset($new_form['agrega_' . $tipo]); |
---|
940 | $output = drupal_render($new_form); |
---|
941 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
942 | exit(); |
---|
943 | } |
---|
944 | |
---|
945 | |
---|
946 | /* |
---|
947 | |
---|
948 | function proyectos_operativos_proyecto_generales_agrega_talento_js_util($tipo) { |
---|
949 | $arreglov['talento'] = array( |
---|
950 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
951 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
952 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
953 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
954 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
955 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
956 | ); |
---|
957 | $arreglov['capacidades'] = array( |
---|
958 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
959 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
960 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
961 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
962 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
963 | ); |
---|
964 | $arreglov['beneficiario'] = array( |
---|
965 | 'field_proyecto_beneficiario' => 'field_proyecto_beneficiario', |
---|
966 | 'field_proyectos_masculino_d' => 'field_proyectos_masculino_d', |
---|
967 | 'field_proyectos_femenino_d' => 'field_proyectos_femenino_d', |
---|
968 | 'field_proyectos_masculino_i' => 'field_proyectos_masculino_i', |
---|
969 | 'field_proyectos_femenino_i' => 'field_proyectos_femenino_i', |
---|
970 | ); |
---|
971 | if (array_key_exists($tipo, $arreglov)) { |
---|
972 | $arreglo = $arreglov[$tipo]; |
---|
973 | } |
---|
974 | else { |
---|
975 | drupal_not_found(); |
---|
976 | } |
---|
977 | $cantidad = intval($_POST['cantidad_' . $tipo]) > 0 ? intval($_POST['cantidad_' . $tipo]) : 0; |
---|
978 | $form_state = array('submitted' => FALSE); |
---|
979 | $form_build_id = $_POST['form_build_id']; |
---|
980 | // Add the new element to the stored form. Without adding the element to the |
---|
981 | // form, Drupal is not aware of this new elements existence and will not |
---|
982 | // process it. We retreive the cached form, add the element, and resave. |
---|
983 | $form = form_get_cache($form_build_id, $form_state); |
---|
984 | $node_type = content_types('proyectos_operativos'); |
---|
985 | $fields = $node_type['fields']; |
---|
986 | foreach($arreglo as $field_id => $field) { |
---|
987 | $fields_extra_form1[] = $field_id; |
---|
988 | $prefixC .= '<th>' . $fields[$field_id]['widget']['label'] . '</th>'; |
---|
989 | } |
---|
990 | $cantidad++; |
---|
991 | if ($tipo == 'talento' || $tipo == 'capacidades') { |
---|
992 | for ($i = 0; $i < $cantidad; $i++) { |
---|
993 | $prefix = ''; |
---|
994 | if ($i == 0) { |
---|
995 | $prefix = '<table align="center"><tr>' . $prefixC . '</tr><tr><td>'; |
---|
996 | } |
---|
997 | else { |
---|
998 | $prefix .= '<tr><td>'; |
---|
999 | } |
---|
1000 | $aux = ''; |
---|
1001 | $aui = ''; |
---|
1002 | foreach($arreglo as $field_id => $field) { |
---|
1003 | $new_form[$field_id . '_' . $i] = array( |
---|
1004 | '#type' => 'textfield', |
---|
1005 | '#size' => 10, |
---|
1006 | '#maxlength' => 255, |
---|
1007 | '#prefix' => $prefix, |
---|
1008 | '#suffix' => '</td>', |
---|
1009 | ); |
---|
1010 | if ($field_id == 'field_proyecto_esfuerzo') { |
---|
1011 | $form[$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); |
---|
1012 | } |
---|
1013 | $aux = $field_id; |
---|
1014 | $aui = $i; |
---|
1015 | $prefix = '<td>'; |
---|
1016 | } |
---|
1017 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
1018 | } |
---|
1019 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</table>'; |
---|
1020 | $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad); |
---|
1021 | } |
---|
1022 | elseif($tipo == 'beneficiario') { |
---|
1023 | $prefixC .= '<th>' . t('Total') . '</th>'; |
---|
1024 | $vid = variable_get('proyectos_operativos_extra_bene', 0); |
---|
1025 | //$terms = taxonomy_get_tree($vid); |
---|
1026 | $tree = taxonomy_get_tree($vid); |
---|
1027 | $options = array(); |
---|
1028 | $options[''] = t('Seleccionar'); |
---|
1029 | if ($tree) { |
---|
1030 | foreach ($tree as $term) { |
---|
1031 | $options[$term->name] = $term->name; |
---|
1032 | } |
---|
1033 | } |
---|
1034 | for ($i = 0; $i < $cantidad; $i++) { |
---|
1035 | $subtotal = 0; |
---|
1036 | $prefix = ''; |
---|
1037 | if ($i == 0) { |
---|
1038 | $prefix = '<table align="center"><tr>' . $prefixC . '</tr><tr><td>'; |
---|
1039 | } |
---|
1040 | else { |
---|
1041 | $prefix .= '<tr><td>'; |
---|
1042 | } |
---|
1043 | $aux = ''; |
---|
1044 | $aui = ''; |
---|
1045 | foreach($arreglo as $field_id => $field) { |
---|
1046 | $_POST[$field_id . '_' . $i] = str_replace('.', '', $_POST[$field_id . '_' . $i]); |
---|
1047 | $valor = intval($_POST[$field_id . '_' . $i]) > 0 ? intval($field_id . '_' . $i) : 0; |
---|
1048 | if ($field_id == 'field_proyecto_beneficiario') { |
---|
1049 | $new_form[$field_id . '_' . $i] = array( |
---|
1050 | '#type' => 'select', |
---|
1051 | '#default_value' => $valor, |
---|
1052 | '#options' => $options, |
---|
1053 | '#prefix' => $prefix, |
---|
1054 | '#suffix' => '</td>', |
---|
1055 | ); |
---|
1056 | } |
---|
1057 | else { |
---|
1058 | $new_form[$field_id . '_' . $i] = array( |
---|
1059 | '#type' => 'textfield', |
---|
1060 | '#default_value' => $valor, |
---|
1061 | '#size' => 10, |
---|
1062 | '#maxlength' => 255, |
---|
1063 | '#prefix' => $prefix, |
---|
1064 | '#suffix' => '</td>', |
---|
1065 | ); |
---|
1066 | } |
---|
1067 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
1068 | if (!isset($total_arreglo[$field_id])) { |
---|
1069 | $total_arreglo[$field_id] = 0; |
---|
1070 | } |
---|
1071 | $subtotal += (int) $valor; |
---|
1072 | $totales += (int) $valor; |
---|
1073 | $total_arreglo[$field_id] += (int) $valor; |
---|
1074 | $sumas['beneficiarios']['beneficiario_' . $i] = 'beneficiario_' . $i; |
---|
1075 | $new_form[$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); |
---|
1076 | $new_form[$field_id . '_' . $i]['#attributes'] = array('class' => 'number beneficiario_' . $i . ' todosbeneficiarios beneficiarios_' . $field_id, 'onchange' => "sumabeneficiario('beneficiario_$i');sumabeneficiario('todosbeneficiarios');sumabeneficiario('beneficiarios_$field_id');"); |
---|
1077 | } |
---|
1078 | $aux = $field_id; |
---|
1079 | $aui = $i; |
---|
1080 | $prefix = '<td align="center">'; |
---|
1081 | } |
---|
1082 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="beneficiario_' . $i . '_total">' . $subtotal . '</div></td>'; |
---|
1083 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
1084 | } |
---|
1085 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<tr align="right"><td><b>' . t('TOTAL') . '</b></td>'; |
---|
1086 | foreach($arreglo as $field_id => $field) { |
---|
1087 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
1088 | $sumas['beneficiarios']['beneficiarios_' . $field_id] = 'beneficiarios_' . $field_id; |
---|
1089 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="beneficiarios_' . $field_id . '_total">' . $total_arreglo[$field_id] . '</div></td>'; |
---|
1090 | } |
---|
1091 | } |
---|
1092 | $sumas['beneficiarios']['todosbeneficiarios'] = 'todosbeneficiarios'; |
---|
1093 | $sumas['beneficiarios']['empleos_generados'] = 'empleos_generados'; |
---|
1094 | $new_form[$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="todosbeneficiarios_total">' . $totales . '</div></td></tr>'; |
---|
1095 | $new_form[$aux . '_' . $aui]['#suffix'] .= '</table>'; |
---|
1096 | $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad); |
---|
1097 | } |
---|
1098 | $form[$tipo] = $new_form; |
---|
1099 | form_set_cache($form_build_id, $form, $form_state); |
---|
1100 | $form += array( |
---|
1101 | '#post' => $_POST, |
---|
1102 | '#programmed' => FALSE, |
---|
1103 | ); |
---|
1104 | // Rebuild the form. |
---|
1105 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
1106 | // Render the new output. |
---|
1107 | $new_form = $form[$tipo]; |
---|
1108 | unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers. |
---|
1109 | $output = drupal_render($new_form); |
---|
1110 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
1111 | exit(); |
---|
1112 | } |
---|
1113 | */ |
---|
1114 | /** |
---|
1115 | * Implementation of proyectos_operativos_remove_ac_form() |
---|
1116 | * Eliminar accion especifica |
---|
1117 | */ |
---|
1118 | function proyectos_operativos_remove_ac_form($form_state, $node = 0, $ac = 0) { |
---|
1119 | //add breadcrumb |
---|
1120 | $breadcrumb = array(); |
---|
1121 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
1122 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
1123 | if ($proyecto->nid) { |
---|
1124 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
1125 | } |
---|
1126 | if ($ac->nid) { |
---|
1127 | $breadcrumb[] = check_plain($ac->titulo_asignado); |
---|
1128 | } |
---|
1129 | drupal_set_breadcrumb($breadcrumb); |
---|
1130 | $form = array(); |
---|
1131 | $form['#node'] = $node; |
---|
1132 | $form['#ac'] = $ac; |
---|
1133 | $message = t('Esta seguro de eliminar la acción especifica @nombre?', array('@nombre' => $ac->titulo_asignado)); |
---|
1134 | $caption = '<p>'. t('This action cannot be undone.') .'</p>'; |
---|
1135 | $return_path = $_REQUEST['destination'] ? $_REQUEST['destination'] : 'proyectosopedit/' . $node->nid . '/ae'; |
---|
1136 | return confirm_form($form, $message, $return_path, $caption, t('Eliminar')); |
---|
1137 | } |
---|
1138 | |
---|
1139 | /** |
---|
1140 | * Implementation of proyectos_operativos_remove_ac_form_submit(). |
---|
1141 | * Process funcion delete accion especifica. |
---|
1142 | */ |
---|
1143 | function proyectos_operativos_remove_ac_form_submit($form, &$form_state) { |
---|
1144 | global $user; |
---|
1145 | $titulo = $form['#$ac']->titulo_asignado; |
---|
1146 | $nid = $form['#ac']->nid; |
---|
1147 | node_delete($form['#ac']->nid); |
---|
1148 | $accion_esp = array(); |
---|
1149 | $proyecto = $form['#node']; |
---|
1150 | foreach($proyecto->field_proyecto_accion_esp as $ac) { |
---|
1151 | if ($ac['nid'] != $nid) { |
---|
1152 | $accion_esp[] = $ac['nid']; |
---|
1153 | } |
---|
1154 | } |
---|
1155 | $proyecto->field_proyecto_accion_esp = $accion_esp; |
---|
1156 | $proyecto->revision = 1; |
---|
1157 | $texto = t('Se elimino la acción especifica @nombre', array('@nombre' => $ac->titulo_asignado)); |
---|
1158 | $proyecto->log = $texto; |
---|
1159 | drupal_set_message($texto); |
---|
1160 | if (!$_REQUEST['destination']) { |
---|
1161 | // add redirect |
---|
1162 | $form_state['redirect'] = 'proyectosopedit/' . $form['#node']->nid . '/ae'; |
---|
1163 | } |
---|
1164 | } |
---|
1165 | |
---|
1166 | /* |
---|
1167 | * hook_form_alter() |
---|
1168 | */ |
---|
1169 | function proyectos_operativos_form_alter(&$form, $form_state, $form_id) { |
---|
1170 | if ($form_id == 'proyectos_operativos_proyecto_basico_form' && !user_access('admin planificador')) { |
---|
1171 | //$form['field_proyecto_ente']['#pre_render'][] = 'proyectos_operativos_nodereference_field_pre_render'; |
---|
1172 | } |
---|
1173 | if ($form_id == 'proyectos_operativos_proyecto_generales_form') { |
---|
1174 | //$form['field_proyecto_relacion']['#pre_render'][] = 'proyectos_operativos_nodereference2_field_pre_render'; |
---|
1175 | $arreglo = array( |
---|
1176 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
1177 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
1178 | 'field_proyecto_emindirecto' => 'field_proyecto_emindirecto', |
---|
1179 | 'field_proyecto_efindirecto' => 'field_proyecto_efindirecto', |
---|
1180 | ); |
---|
1181 | foreach($arreglo as $id) { |
---|
1182 | $form[$id]['#pre_render'][] = 'proyectos_operativos_agregaclase_field_pre_render'; |
---|
1183 | } |
---|
1184 | } |
---|
1185 | if ($form_id == 'workflow_tab_form') { |
---|
1186 | if ($form['node']['#value']->type == 'proyectos_operativos') { |
---|
1187 | /* |
---|
1188 | print "<pre>"; |
---|
1189 | print_r($form); |
---|
1190 | print "</pre>"; |
---|
1191 | */ |
---|
1192 | $current = $form['node']['#value']->_workflow; |
---|
1193 | $form['#proyectos_operativos_states_d'] = array(); |
---|
1194 | $options_worflow = $form['workflow']['Proyectos_Operativos']['#options']; |
---|
1195 | if ($options_worflow) { |
---|
1196 | foreach($options_worflow as $sid => $state) { |
---|
1197 | if (variable_get('proyectos_operativos_state_d_' . $current . '_' . $sid, FALSE)) { |
---|
1198 | $form['#proyectos_operativos_states_d'][$sid] = $sid; |
---|
1199 | $form['workflow']['Proyectos_Operativos']['#options'][$sid] = t(variable_get('proyectos_operativos_state_tdevueltos', 'Devuelto a @state'), array('@state' => $form['workflow']['Proyectos_Operativos']['#options'][$sid])); |
---|
1200 | } |
---|
1201 | else { |
---|
1202 | $form['workflow']['Proyectos_Operativos']['#options'][$sid] = t(variable_get('proyectos_operativos_state_tndevueltos', 'Enviado a @state'), array('@state' => $form['workflow']['Proyectos_Operativos']['#options'][$sid])); |
---|
1203 | } |
---|
1204 | } |
---|
1205 | } |
---|
1206 | $form['#validate'][] = 'proyectos_operativos_cambia_workflow_description_validate'; |
---|
1207 | |
---|
1208 | $form['#submit'][] = 'proyectos_operativos_cambia_redirect_submit'; |
---|
1209 | } |
---|
1210 | } |
---|
1211 | if ($form_id == 'proyectos_operativos_proyecto_indicadores_form') { |
---|
1212 | $form['field_proyecto_meta_m']['#pre_render'][] = 'proyectos_operativos_agregaclase_indicadores_field_pre_render'; |
---|
1213 | $form['field_proyecto_meta_f']['#pre_render'][] = 'proyectos_operativos_agregaclase_indicadores_field_pre_render'; |
---|
1214 | } |
---|
1215 | } |
---|
1216 | |
---|
1217 | function proyectos_operativos_cambia_workflow_description_validate($form, &$form_state) { |
---|
1218 | $new_state = $form_state['values']['workflow']; |
---|
1219 | if (isset($form['#proyectos_operativos_states_d'][$new_state]) && trim($form_state['values']['workflow_comment'] == '')) { |
---|
1220 | form_set_error('workflow_comment', t('Debe ingresar el motivo por el que se regresa el proyecto')); |
---|
1221 | } |
---|
1222 | } |
---|
1223 | |
---|
1224 | /* |
---|
1225 | * Implementation of proyectos_operativos_agregaclase_field_pre_render() |
---|
1226 | * agregar clases y funciones javascript en el formulario |
---|
1227 | */ |
---|
1228 | function proyectos_operativos_agregaclase_field_pre_render($element) { |
---|
1229 | $element[0]['value']['#attributes']['class'] .= ' empleos_generados'; |
---|
1230 | $element[0]['value']['#attributes']['onchange'] .= ";sumabeneficiario('empleos_generados');"; |
---|
1231 | return $element; |
---|
1232 | } |
---|
1233 | /* |
---|
1234 | * Implementation of proyectos_operativos_agregaclase_indicadores_field_pre_render() |
---|
1235 | * agregar clases y funciones javascript en el formulario |
---|
1236 | */ |
---|
1237 | function proyectos_operativos_agregaclase_indicadores_field_pre_render($element) { |
---|
1238 | $element[0]['value']['#attributes']['class'] .= ' unidad_personas'; |
---|
1239 | $element[0]['value']['#attributes']['onchange'] .= ";sumunidpersonas('unidad_personas');"; |
---|
1240 | return $element; |
---|
1241 | } |
---|
1242 | |
---|
1243 | |
---|
1244 | /* |
---|
1245 | * Implementation of proyectos_operativos_nodereference_field_pre_render() |
---|
1246 | * Limitar al formulario a los entes que le es posible a los usuarios |
---|
1247 | */ |
---|
1248 | function proyectos_operativos_nodereference_field_pre_render($element) { |
---|
1249 | global $user; |
---|
1250 | $ente = usuario_tiene_ente($user->uid); |
---|
1251 | if ($ente) { |
---|
1252 | if (count($element['nid']['nid']['#options'])) { |
---|
1253 | foreach($element['nid']['nid']['#options'] as $id => $entes){ |
---|
1254 | if ($ente->nid != $id) { |
---|
1255 | unset($element['nid']['nid']['#options'][$id]); |
---|
1256 | } |
---|
1257 | } |
---|
1258 | } |
---|
1259 | } |
---|
1260 | return $element; |
---|
1261 | } |
---|
1262 | |
---|
1263 | /* |
---|
1264 | * Implementation of proyectos_operativos_nodereference2_field_pre_render() |
---|
1265 | * Limitar al formulario a los entes que le es posible a los usuarios |
---|
1266 | */ |
---|
1267 | function proyectos_operativos_nodereference2_field_pre_render($element) { |
---|
1268 | global $user; |
---|
1269 | if (!((user_access('edit all planificador'))||(user_access('admin planificador')))) { |
---|
1270 | $entes = obtener_mis_ente_planificador($user->uid); |
---|
1271 | $options = array(); |
---|
1272 | if (count($entes)) { |
---|
1273 | foreach($entes as $ente){ |
---|
1274 | unset($element['nid']['nid']['#options'][$ente['nid']]); |
---|
1275 | } |
---|
1276 | } |
---|
1277 | } |
---|
1278 | return $element; |
---|
1279 | } |
---|
1280 | |
---|
1281 | /** |
---|
1282 | * proyectos_operativos_cambia_redirect_submit. |
---|
1283 | * retorna a consultar proyecto cuando se actualiza el estado del proyecto. |
---|
1284 | */ |
---|
1285 | function proyectos_operativos_cambia_redirect_submit($form, &$form_state) { |
---|
1286 | // The entire node object was stashed in the form. |
---|
1287 | $node = $form_state['values']['node']; |
---|
1288 | $form_state['redirect'] = 'proyectosop/' . $node->nid; |
---|
1289 | drupal_set_message(t('Se modifico el estado del proyecto.')); |
---|
1290 | } |
---|
1291 | |
---|
1292 | /** |
---|
1293 | * Implementation of _proyectos_operativos_proyecto_regresa_ver(). |
---|
1294 | * retorna a consultar proyecto. |
---|
1295 | */ |
---|
1296 | function _proyectos_operativos_proyecto_regresa_ver($node) { |
---|
1297 | drupal_goto('proyectosop/' . $node->nid); |
---|
1298 | } |
---|
1299 | |
---|
1300 | /** |
---|
1301 | * Implementation of _proyectos_operativos_proyecto_editar(). |
---|
1302 | * retorna a editar proyecto. |
---|
1303 | */ |
---|
1304 | function _proyectos_operativos_proyecto_editar($node) { |
---|
1305 | drupal_goto('proyectosopedit/' . $node->nid); |
---|
1306 | } |
---|
1307 | |
---|
1308 | /** |
---|
1309 | * Implementation of _list_proyectos_operativos_proyecto_ae(). |
---|
1310 | * listar acciones especificas de un proyecto. |
---|
1311 | */ |
---|
1312 | function _list_proyectos_operativos_proyecto_ae($node) { |
---|
1313 | global $user; |
---|
1314 | drupal_set_title('Consultar Acciones EspecÃficas'); |
---|
1315 | //add breadcrumb |
---|
1316 | $breadcrumb = array(); |
---|
1317 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
1318 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
1319 | if ($node->nid) { |
---|
1320 | $breadcrumb[] = l(check_plain($node->title), 'proyectosop/' . $node->nid); |
---|
1321 | } |
---|
1322 | $breadcrumb[] = t('Acciones EspecÃficas'); |
---|
1323 | drupal_set_breadcrumb($breadcrumb); |
---|
1324 | $current_time = time(); |
---|
1325 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
1326 | $fecha = FALSE; |
---|
1327 | $ente = usuario_tiene_ente($user->uid); |
---|
1328 | $ente_planificador = 0; |
---|
1329 | if ($ente && $ente->nid) { |
---|
1330 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
1331 | } |
---|
1332 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
1333 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1334 | $fecha = TRUE; |
---|
1335 | } |
---|
1336 | if (!fecha) { |
---|
1337 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
1338 | } |
---|
1339 | if ($fecha && $ente->nid) { |
---|
1340 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
1341 | } |
---|
1342 | foreach($node->field_proyecto_accion_esp as $accion) { |
---|
1343 | if ($accion['nid'] && $nid != $accion['nid']) { |
---|
1344 | $accion_load = node_load($accion['nid']); |
---|
1345 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
1346 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
1347 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
1348 | } |
---|
1349 | } |
---|
1350 | elseif($nid = $accion['nid']) { |
---|
1351 | $acciones_especificas[$ae->nid] = $ae; |
---|
1352 | } |
---|
1353 | } |
---|
1354 | $output = ''; |
---|
1355 | $header = array(); |
---|
1356 | $cab = 6; |
---|
1357 | $header[] = array('data' => t('Nro')); |
---|
1358 | $header[] = array('data' => t('Nombre')); |
---|
1359 | $header[] = array('data' => t('Fecha de inicio')); |
---|
1360 | $header[] = array('data' => t('Fecha de Fin')); |
---|
1361 | $header[] = array('data' => t('%')); |
---|
1362 | $header[] = array('data' => t('Acción')); |
---|
1363 | $rows = array(); |
---|
1364 | $i = 1; |
---|
1365 | if (count($acciones_especificas)) { |
---|
1366 | $suma = 0; |
---|
1367 | foreach($acciones_especificas as $accion) { |
---|
1368 | $row = array(); |
---|
1369 | $row[] = array('data' => $i,); |
---|
1370 | $row[] = array('data' => $accion->titulo_asignado,); |
---|
1371 | //Se cambia el formato de la fecha |
---|
1372 | $fecha = explode(' ', $accion->field_accion_esp_fechai[0]['value']); |
---|
1373 | $formato = explode('-', $fecha[0]); |
---|
1374 | $row[] = array('data' => $formato[2] . '/' . $formato[1] . '/' . $formato[0],); |
---|
1375 | //Se cambia el formato de la fecha |
---|
1376 | $fecha = explode(' ', $accion->field_accion_esp_fechaf[0]['value']); |
---|
1377 | $formato = explode('-', $fecha[0]); |
---|
1378 | $row[] = array('data' => $formato[2] . '/' . $formato[1] . '/' . $formato[0],); |
---|
1379 | $suma += $accion->field_accion_esp_ponderacion[0]['value']; |
---|
1380 | $row[] = array('data' => $accion->field_accion_esp_ponderacion[0]['value'],); |
---|
1381 | $links = array(); |
---|
1382 | $links[] = array( |
---|
1383 | 'data' => l(t('Consultar Acción especÃfica'), 'proyectosop/' . $node->nid . '/ae/' . $accion->nid . '/ver'), |
---|
1384 | 'class' => 'proyectos-operativos-acciones_especificas-pdf', |
---|
1385 | ); |
---|
1386 | if (_proyectos_operativos_edita_datos_ae_access($node)){ |
---|
1387 | $links[] = array( |
---|
1388 | 'data' => l(t('Eliminar Acción especÃfica'), 'proyectosop/' . $node->nid . '/ae/' . $accion->nid . '/remove', array('query' => array('destination' => 'proyectosop/' . $node->nid . '/ae'))), |
---|
1389 | 'class' => 'proyectos-operativos-acciones_especificas-pdf', |
---|
1390 | ); |
---|
1391 | } |
---|
1392 | drupal_alter('proyecto_accion_obtiene_links', $links, $node, $accion, $fecha); |
---|
1393 | $row[] = array('data' => theme('item_list', $links),); |
---|
1394 | $rows[] = $row; |
---|
1395 | $i++; |
---|
1396 | } |
---|
1397 | } |
---|
1398 | if (count($rows)) { |
---|
1399 | $output .= theme('table', $header, $rows); |
---|
1400 | } |
---|
1401 | else { |
---|
1402 | $output .= t('No existen acciones especifÃcas para este proyecto'); |
---|
1403 | } |
---|
1404 | return $output; |
---|
1405 | } |
---|
1406 | |
---|
1407 | /** |
---|
1408 | * Implementation of _proyectos_operativos_proyecto_ver_workflow(). |
---|
1409 | * cambiar estado del flujo de trabajo. |
---|
1410 | */ |
---|
1411 | function _proyectos_operativos_proyecto_ver_workflow($node){ |
---|
1412 | global $user; |
---|
1413 | //add breadcrumb |
---|
1414 | $breadcrumb = array(); |
---|
1415 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
1416 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
1417 | if ($node->nid) { |
---|
1418 | $breadcrumb[] = l(check_plain($node->title), 'proyectosop/' . $node->nid); |
---|
1419 | } |
---|
1420 | $breadcrumb[] = t('Flujo de Trabajo'); |
---|
1421 | drupal_set_breadcrumb($breadcrumb); |
---|
1422 | $current_time = time(); |
---|
1423 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
1424 | $fecha = FALSE; |
---|
1425 | $ente = usuario_tiene_ente($user->uid); |
---|
1426 | $ente_planificador = 0; |
---|
1427 | if ($ente && $ente->nid) { |
---|
1428 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
1429 | } |
---|
1430 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
1431 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
1432 | $fecha = TRUE; |
---|
1433 | } |
---|
1434 | if (!$fecha) { |
---|
1435 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
1436 | } |
---|
1437 | if ($fecha && $ente->nid) { |
---|
1438 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
1439 | } |
---|
1440 | module_load_include('inc', 'workflow', 'workflow.pages'); |
---|
1441 | $wid = workflow_get_workflow_for_type($node->type); |
---|
1442 | $states_per_page = variable_get('workflow_states_per_page', 20); |
---|
1443 | $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid"); |
---|
1444 | while ($data = db_fetch_object($result)) { |
---|
1445 | $states[$data->sid] = check_plain(t($data->state)); |
---|
1446 | } |
---|
1447 | $deleted_states = array(); |
---|
1448 | $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 0 ORDER BY sid"); |
---|
1449 | while ($data = db_fetch_object($result)) { |
---|
1450 | $deleted_states[$data->sid] = check_plain(t($data->state)); |
---|
1451 | } |
---|
1452 | $current = workflow_node_current_state($node); |
---|
1453 | // theme_workflow_current_state() must run state through check_plain(). |
---|
1454 | drupal_set_title(t('Cambiar el proyecto !proyecto del estado !estado', array('!proyecto' => $node->title, '!estado' =>$states[$current]))); |
---|
1455 | $output = '<p>'. t('Current state: !state', array('!state' => theme('workflow_current_state', $states[$current]))) . "</p>\n"; |
---|
1456 | unset($states[$current]); |
---|
1457 | $output .= drupal_get_form('workflow_tab_form', $node, $wid, $states, $current); |
---|
1458 | return $output; |
---|
1459 | } |
---|
1460 | |
---|
1461 | /** |
---|
1462 | * Implementation of proyectos_operativos_proyecto_genera_campos_form(). |
---|
1463 | * Formulario con todos los campos disponibles en el proyecto. |
---|
1464 | */ |
---|
1465 | function proyectos_operativos_proyecto_genera_campos_form(&$form_state, $node = 0) { |
---|
1466 | $form = array(); |
---|
1467 | $form['#node'] = $node; |
---|
1468 | $node_type = content_types('proyectos_operativos'); |
---|
1469 | $fields = $node_type['fields']; |
---|
1470 | //$campos = array(); |
---|
1471 | //DATOS BASICOS |
---|
1472 | //Datos Básicos de Identificación del Proyecto |
---|
1473 | $title_combos = array(); |
---|
1474 | $title_combos['db']['title'] = t('Datos Básicos'); |
---|
1475 | $arreglo['db']['identificacion'] = array(); |
---|
1476 | $arreglo['db']['identificacion'] = array( |
---|
1477 | 'title' => t('Nombre del Proyecto'), |
---|
1478 | 'field_proyecto_codigo' => 'field_proyecto_codigo', |
---|
1479 | 'field_proyecto_fecha_i' => 'field_proyecto_fecha_i', |
---|
1480 | 'field_proyecto_fecha_f' => 'field_proyecto_fecha_f', |
---|
1481 | 'field_proyecto_status' => 'field_proyecto_status', |
---|
1482 | 'field_proyecto_situacion_p' => 'field_proyecto_situacion_p', |
---|
1483 | 'field_proyecto_plurianual' => 'field_proyecto_plurianual', |
---|
1484 | 'field_proyecto_monto_anual' => 'field_proyecto_monto_anual', |
---|
1485 | 'field_proyecto_total' => 'field_proyecto_total', |
---|
1486 | 'field_proyecto_poan' => 'field_proyecto_poan', |
---|
1487 | ); |
---|
1488 | $title_combos['db']['identificacion']['title'] = t('Datos Básicos de Identificación del Proyecto'); |
---|
1489 | //Gerente del Proyecto |
---|
1490 | $gerentes = variable_get('proyectos_operativos_muestra_gerentes', TRUE); |
---|
1491 | $arreglo['db']['gerentep'] = array(); |
---|
1492 | $arreglo['db']['gerentep'] = array( |
---|
1493 | 'field_proyecto_ente' => 'field_proyecto_ente', |
---|
1494 | ); |
---|
1495 | if ($gerentes) { |
---|
1496 | $arreglo['db']['gerentep'] = array( |
---|
1497 | 'field_proyecto_autoridad' => 'field_proyecto_autoridad', |
---|
1498 | 'field_proyecto_lider' => 'field_proyecto_lider', |
---|
1499 | 'field_proyecto_unidad_a' => 'field_proyecto_unidad_a', |
---|
1500 | 'field_proyecto_cargo' => 'field_proyecto_cargo', |
---|
1501 | 'field_proyecto_telefono' => 'field_proyecto_telefono', |
---|
1502 | 'field_proyecto_correo' => 'field_proyecto_correo', |
---|
1503 | ); |
---|
1504 | $title_combos['db']['gerentep']['title'] = t('Gerente del Proyecto'); |
---|
1505 | } |
---|
1506 | //Ãrea Estrategica |
---|
1507 | $pndes = variable_get('proyectos_operativos_muestra_pndes', TRUE); |
---|
1508 | $mcti = variable_get('proyectos_operativos_muestra_mcti', TRUE); |
---|
1509 | $arreglo['db']['areae'] = array(); |
---|
1510 | if ($pndes) { |
---|
1511 | $arreglo['db']['areae']['field_proyecto_pndes'] = 'field_proyecto_pndes'; |
---|
1512 | } |
---|
1513 | if ($mcti) { |
---|
1514 | $arreglo['db']['areae']['field_proyecto_mcti'] = 'field_proyecto_mcti'; |
---|
1515 | } |
---|
1516 | $title_combos['db']['areae']['title'] = t('Ãrea Estratégica'); |
---|
1517 | //DATOS GENERALES |
---|
1518 | $title_combos['dg']['title'] = t('Datos Generales'); |
---|
1519 | //Clasificación Sectorial |
---|
1520 | $arreglo['dg']['sector'] = array(); |
---|
1521 | $arreglo['dg']['sector'] = array( |
---|
1522 | 'field_proyecto_sector' => 'field_proyecto_sector', |
---|
1523 | ); |
---|
1524 | $title_combos['dg']['sector']['title'] = t('Clasificación Sectorial'); |
---|
1525 | //Talento Humano |
---|
1526 | $arreglo['dg']['talentoh'] = array(); |
---|
1527 | if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { |
---|
1528 | $arreglo['dg']['talentoh'] = array( |
---|
1529 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
1530 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
1531 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
1532 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
1533 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
1534 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
1535 | ); |
---|
1536 | } |
---|
1537 | $title_combos['dg']['talentoh']['title'] = t('Talento Humano'); |
---|
1538 | //Capacidades |
---|
1539 | $arreglo['dg']['capacidades'] = array(); |
---|
1540 | if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { |
---|
1541 | $arreglo['dg']['capacidades'] = array( |
---|
1542 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
1543 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
1544 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
1545 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
1546 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
1547 | ); |
---|
1548 | } |
---|
1549 | $title_combos['dg']['capacidades']['title'] = t('Capacidades'); |
---|
1550 | //Instituciones |
---|
1551 | $arreglo['dg']['relacion'] = array(); |
---|
1552 | $arreglo['dg']['relacion'] = array( |
---|
1553 | 'field_proyecto_relacion' => 'field_proyecto_relacion', |
---|
1554 | ); |
---|
1555 | $title_combos['dg']['relacion']['title'] = t('Instituciones'); |
---|
1556 | //Empleos Generados |
---|
1557 | $arreglo['dg']['empleosg'] = array(); |
---|
1558 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { |
---|
1559 | $arreglo['dg']['empleosg'] = array( |
---|
1560 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
1561 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
1562 | ); |
---|
1563 | if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { |
---|
1564 | $arreglo['dg']['empleosg']['field_proyecto_emindirecto'] = 'field_proyecto_emindirecto'; |
---|
1565 | $arreglo['dg']['empleosg']['field_proyecto_efindirecto'] = 'field_proyecto_efindirecto'; |
---|
1566 | } |
---|
1567 | } |
---|
1568 | $title_combos['dg']['empleosg']['title'] = t('Empleos Generados'); |
---|
1569 | //Objetivos del Proyecto |
---|
1570 | $arreglo['dg']['objetivosp'] = array(); |
---|
1571 | $arreglo['dg']['objetivosp'] = array( |
---|
1572 | 'field_proyecto_og' => 'field_proyecto_og', |
---|
1573 | 'field_proyecto_oe' => 'field_proyecto_oe', |
---|
1574 | ); |
---|
1575 | //INDICADORES DEL PROYECTO |
---|
1576 | //Enunciado del Problema |
---|
1577 | $title_combos['ip']['title'] = t('Indicadores del Proyecto'); |
---|
1578 | $arreglo['ip']['enunciadop'] = array(); |
---|
1579 | if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { |
---|
1580 | $arreglo['ip']['enunciadop'] = array( |
---|
1581 | 'field_proyecto_causas' => 'field_proyecto_causas', |
---|
1582 | 'field_proyecto_problemas' => 'field_proyecto_problemas', |
---|
1583 | 'field_proyecto_consecuencias' => 'field_proyecto_consecuencias', |
---|
1584 | ); |
---|
1585 | } |
---|
1586 | $title_combos['ip']['enunciadop']['title'] = t('Enunciado del Problema'); |
---|
1587 | //Justificación del Proyecto |
---|
1588 | $arreglo['ip']['justificacion'] = array(); |
---|
1589 | if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { |
---|
1590 | $arreglo['ip']['justificacion'] = array( |
---|
1591 | 'field_proyecto_justificacion' => 'field_proyecto_justificacion', |
---|
1592 | ); |
---|
1593 | } |
---|
1594 | $title_combos['ip']['justificacion']['title'] = t('Justificación del Proyecto'); |
---|
1595 | //Alcance del Proyecto |
---|
1596 | $arreglo['ip']['alcance'] = array(); |
---|
1597 | if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { |
---|
1598 | $arreglo['ip']['alcance'] = array( |
---|
1599 | 'field_proyecto_alcance' => 'field_proyecto_alcance', |
---|
1600 | ); |
---|
1601 | } |
---|
1602 | $title_combos['ip']['alcance']['title'] = t('Alcance del Proyecto'); |
---|
1603 | //Situación Actual del Proyecto |
---|
1604 | $arreglo['ip']['situaciona'] = array(); |
---|
1605 | if (variable_get('proyectos_operativos_muestra_sa', TRUE)) { |
---|
1606 | $arreglo['ip']['situaciona'] = array( |
---|
1607 | 'field_proyecto_sa_descripcion' => 'field_proyecto_sa_descripcion', |
---|
1608 | ); |
---|
1609 | if (variable_get('proyectos_operativos_muestra_sa_cuantificacion', TRUE)) { |
---|
1610 | $arreglo['ip']['situaciona']['field_proyecto_sa_cuantificacion'] = 'field_proyecto_sa_cuantificacion'; |
---|
1611 | } |
---|
1612 | $arreglo['ip']['situaciona']['field_proyecto_sa_formulai'] = 'field_proyecto_sa_formulai'; |
---|
1613 | $arreglo['ip']['situaciona']['field_proyecto_sa_fuentei'] = 'field_proyecto_sa_fuentei'; |
---|
1614 | $arreglo['ip']['situaciona']['field_proyecto_sa_fecha'] = 'field_proyecto_sa_fecha'; |
---|
1615 | } |
---|
1616 | $title_combos['ip']['situaciona']['title'] = t('Situación Actual'); |
---|
1617 | //Situación Objetivo |
---|
1618 | $arreglo['ip']['situaciono'] = array(); |
---|
1619 | if (variable_get('proyectos_operativos_muestra_so', TRUE)) { |
---|
1620 | $arreglo['ip']['situaciono'] = array( |
---|
1621 | 'field_proyecto_so_descripcion' => 'field_proyecto_so_descripcion', |
---|
1622 | 'field_proyecto_so_cuantificacion' => 'field_proyecto_so_cuantificacion', |
---|
1623 | 'field_proyecto_tiempoi' => 'field_proyecto_tiempoi', |
---|
1624 | ); |
---|
1625 | } |
---|
1626 | $title_combos['ip']['situaciono']['title'] = t('Situación Objetivo'); |
---|
1627 | //Indicador del resultado del Proyecto |
---|
1628 | $arreglo['ip']['resultadop'] = array(); |
---|
1629 | $arreglo['ip']['resultadop'] = array( |
---|
1630 | 'field_proyecto_descripcion_bien' => 'field_proyecto_descripcion_bien', |
---|
1631 | 'field_proyecto_unidadm' => 'field_proyecto_unidadm', |
---|
1632 | 'field_proyecto_meta_m' => 'field_proyecto_meta_m', |
---|
1633 | 'field_proyecto_meta_f' => 'field_proyecto_meta_f', |
---|
1634 | 'field_proyecto_meta_fisica' => 'field_proyecto_meta_fisica', |
---|
1635 | ); |
---|
1636 | $title_combos['ip']['resultadop']['title'] = t('Indicador del resultado del Proyecto'); |
---|
1637 | if (!isset($_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid]) || !count($_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid])) { |
---|
1638 | $campos['todos-los-campos'] = t('Mostrar todos los campos'); |
---|
1639 | //$campos['title'] = t('Nombre del Proyecto'); |
---|
1640 | if (count($fields)) { |
---|
1641 | foreach($fields as $id => $field) { |
---|
1642 | if (!$field['display_settings']['full']['exclude']) { |
---|
1643 | //DATOS BASICOS DEL PROYECTO |
---|
1644 | //Datos Básicos de Identificación del Proyecto |
---|
1645 | if (array_key_exists($id, $arreglo['db']['identificacion'])) { |
---|
1646 | $arreglo['db']['identificacion'][$id] = $field['widget']['label']; |
---|
1647 | } |
---|
1648 | //Gerente del Proyecto |
---|
1649 | elseif(array_key_exists($id, $arreglo['db']['gerentep'])) { |
---|
1650 | $arreglo['db']['gerentep'][$id] = $field['widget']['label']; |
---|
1651 | } |
---|
1652 | //Ãrea Estrategica |
---|
1653 | elseif(array_key_exists($id, $arreglo['db']['areae'])) { |
---|
1654 | $arreglo['db']['areae'][$id] = $field['widget']['label']; |
---|
1655 | } |
---|
1656 | //DATOS GENERALES |
---|
1657 | //Clasificación Sectorial |
---|
1658 | elseif(array_key_exists($id, $arreglo['dg']['sector'])) { |
---|
1659 | $arreglo['dg']['sector'][$id] = $field['widget']['label']; |
---|
1660 | } |
---|
1661 | //Talento Humano |
---|
1662 | elseif(array_key_exists($id, $arreglo['dg']['talentoh'])) { |
---|
1663 | $arreglo['dg']['talentoh'][$id] = $field['widget']['label']; |
---|
1664 | } |
---|
1665 | //Capacidades |
---|
1666 | elseif(array_key_exists($id, $arreglo['dg']['capacidades'])) { |
---|
1667 | $arreglo['dg']['capacidades'][$id] = $field['widget']['label']; |
---|
1668 | } |
---|
1669 | //Instituciones |
---|
1670 | elseif(array_key_exists($id, $arreglo['dg']['relacion'])) { |
---|
1671 | $arreglo['dg']['relacion'][$id] = $field['widget']['label']; |
---|
1672 | } |
---|
1673 | //Empleos Generados |
---|
1674 | elseif(array_key_exists($id, $arreglo['dg']['empleosg'])) { |
---|
1675 | $arreglo['dg']['empleosg'][$id] = $field['widget']['label']; |
---|
1676 | } |
---|
1677 | //Objetivos del Proyecto |
---|
1678 | elseif(array_key_exists($id, $arreglo['dg']['objetivosp'])) { |
---|
1679 | $arreglo['dg']['objetivosp'][$id] = $field['widget']['label']; |
---|
1680 | } |
---|
1681 | //INDICADORES DEL PROYECTO |
---|
1682 | //Enunciado del Problema |
---|
1683 | elseif(array_key_exists($id, $arreglo['ip']['enunciadop'])) { |
---|
1684 | $arreglo['ip']['enunciadop'][$id] = $field['widget']['label']; |
---|
1685 | } |
---|
1686 | //Justificación del Proyecto |
---|
1687 | elseif(array_key_exists($id, $arreglo['ip']['justificacion'])) { |
---|
1688 | $arreglo['ip']['justificacion'][$id] = $field['widget']['label']; |
---|
1689 | } |
---|
1690 | //Alcance del Proyecto |
---|
1691 | elseif(array_key_exists($id, $arreglo['ip']['alcance'])) { |
---|
1692 | $arreglo['ip']['alcance'][$id] = $field['widget']['label']; |
---|
1693 | } |
---|
1694 | //Situación Actual del Proyecto |
---|
1695 | elseif(array_key_exists($id, $arreglo['ip']['situaciona'])) { |
---|
1696 | $arreglo['ip']['situaciona'][$id] = $field['widget']['label']; |
---|
1697 | } |
---|
1698 | //Situación Objetivo |
---|
1699 | elseif(array_key_exists($id, $arreglo['ip']['situaciono'])) { |
---|
1700 | $arreglo['ip']['situaciono'][$id] = $field['widget']['label']; |
---|
1701 | } |
---|
1702 | //Indicador del resultado del Proyecto |
---|
1703 | elseif(array_key_exists($id, $arreglo['ip']['resultadop'])) { |
---|
1704 | $arreglo['ip']['resultadop'][$id] = $field['widget']['label']; |
---|
1705 | } |
---|
1706 | //DATOS BASICOS DEL PROYECTO |
---|
1707 | //Datos Básicos de Identificación del Proyecto |
---|
1708 | elseif (variable_get('proyectos_operativos_ac_d_' . $id, FALSE)) { |
---|
1709 | $arreglo['db']['identificacion'][$id] = $field['widget']['label']; |
---|
1710 | } |
---|
1711 | //Gerente del Proyecto |
---|
1712 | elseif (variable_get('proyectos_operativos_ac_di_' . $id, FALSE)) { |
---|
1713 | $arreglo['db']['gerentep'][$id] = $field['widget']['label']; |
---|
1714 | } |
---|
1715 | //Ãrea Estrategica |
---|
1716 | elseif (variable_get('proyectos_operativos_ac_p_' . $id, FALSE)) { |
---|
1717 | $arreglo['db']['areae'][$id] = $field['widget']['label']; |
---|
1718 | } |
---|
1719 | //DATOS GENERALES |
---|
1720 | //Clasificación Sectorial |
---|
1721 | elseif (variable_get('proyectos_operativos_dg_s_' . $id, FALSE)) { |
---|
1722 | $arreglo['dg']['sector'][$id] = $field['widget']['label']; |
---|
1723 | } |
---|
1724 | //Instituciones |
---|
1725 | elseif (variable_get('proyectos_operativos_dg_r_' . $id, FALSE)) { |
---|
1726 | $arreglo['dg']['relacion'][$id] = $field['widget']['label']; |
---|
1727 | } |
---|
1728 | //Objetivos del Proyecto |
---|
1729 | elseif (variable_get('proyectos_operativos_dg_o_' . $id, FALSE)) { |
---|
1730 | $arreglo['dg']['objetivosp'][$id] = $field['widget']['label']; |
---|
1731 | } |
---|
1732 | //Enunciado del Problema |
---|
1733 | elseif (variable_get('proyectos_operativos_ip_in_' . $id, FALSE)) { |
---|
1734 | $arreglo['ip']['enunciadop'][$id] = $field['widget']['label']; |
---|
1735 | } |
---|
1736 | //Alcance del Proyecto |
---|
1737 | elseif (variable_get('proyectos_operativos_ip_al_' . $id, FALSE)) { |
---|
1738 | $arreglo['ip']['alcance'][$id] = $field['widget']['label']; |
---|
1739 | } |
---|
1740 | //Justificación del Proyecto |
---|
1741 | elseif (variable_get('proyectos_operativos_ip_ju_' . $id, FALSE)) { |
---|
1742 | $arreglo['ip']['justificacion'][$id] = $field['widget']['label']; |
---|
1743 | } |
---|
1744 | //Situación Actual del Proyecto |
---|
1745 | elseif (variable_get('proyectos_operativos_ip_sa_' . $id, FALSE)) { |
---|
1746 | $arreglo['ip']['situaciona'][$id] = $field['widget']['label']; |
---|
1747 | } |
---|
1748 | //Situación Objetivo |
---|
1749 | elseif (variable_get('proyectos_operativos_ip_so_' . $id, FALSE)) { |
---|
1750 | $arreglo['ip']['situaciono'][$id] = $field['widget']['label']; |
---|
1751 | } |
---|
1752 | //Indicador del resultado del Proyecto |
---|
1753 | elseif (variable_get('proyectos_operativos_ip_re_' . $id, FALSE)) { |
---|
1754 | $arreglo['ip']['resultadop'][$id] = $field['widget']['label']; |
---|
1755 | } |
---|
1756 | //$campos[$id] = $field['widget']['label']; |
---|
1757 | } |
---|
1758 | //DATOS BASICOS DEL PROYECTO |
---|
1759 | //Datos Básicos de Identificación del Proyecto |
---|
1760 | elseif (array_key_exists($id, $arreglo['db']['identificacion'])) { |
---|
1761 | unset($arreglo['db']['identificacion'][$id]); |
---|
1762 | } |
---|
1763 | //Gerente del Proyecto |
---|
1764 | elseif (array_key_exists($id, $arreglo['db']['gerentep'])) { |
---|
1765 | unset($arreglo['db']['gerentep'][$id]); |
---|
1766 | } |
---|
1767 | //Ãrea Estrategica |
---|
1768 | elseif (array_key_exists($id, $arreglo['db']['areae'])) { |
---|
1769 | unset($arreglo['db']['areae'][$id]); |
---|
1770 | } |
---|
1771 | //DATOS GENERALES |
---|
1772 | //Clasificación Sectorial |
---|
1773 | elseif (array_key_exists($id, $arreglo['dg']['sector'])) { |
---|
1774 | unset($arreglo['dg']['sector'][$id]); |
---|
1775 | } |
---|
1776 | //Talento Humano |
---|
1777 | elseif (array_key_exists($id, $arreglo['dg']['talentoh'])) { |
---|
1778 | unset($arreglo['dg']['talentoh'][$id]); |
---|
1779 | } |
---|
1780 | //Capacidades |
---|
1781 | elseif (array_key_exists($id, $arreglo['dg']['capacidades'])) { |
---|
1782 | unset($arreglo['dg']['capacidades'][$id]); |
---|
1783 | } |
---|
1784 | //Instituciones |
---|
1785 | elseif (array_key_exists($id, $arreglo['dg']['relacion'])) { |
---|
1786 | unset($arreglo['dg']['relacion'][$id]); |
---|
1787 | } |
---|
1788 | //Empleos Generados |
---|
1789 | elseif (array_key_exists($id, $arreglo['dg']['empleosg'])) { |
---|
1790 | unset($arreglo['dg']['empleosg'][$id]); |
---|
1791 | } |
---|
1792 | //Objetivos del Proyecto |
---|
1793 | elseif (array_key_exists($id, $arreglo['dg']['objetivosp'])) { |
---|
1794 | unset($arreglo['dg']['objetivosp'][$id]); |
---|
1795 | } |
---|
1796 | //INDICADORES DEL PROYECTO |
---|
1797 | //Enunciado del Problema |
---|
1798 | elseif (array_key_exists($id, $arreglo['ip']['enunciadop'])) { |
---|
1799 | unset($arreglo['ip']['enunciadop'][$id]); |
---|
1800 | } |
---|
1801 | //Justificación del Proyecto |
---|
1802 | elseif (array_key_exists($id, $arreglo['ip']['justificacion'])) { |
---|
1803 | unset($arreglo['ip']['justificacion'][$id]); |
---|
1804 | } |
---|
1805 | //Alcance del Proyecto |
---|
1806 | elseif (array_key_exists($id, $arreglo['ip']['alcance'])) { |
---|
1807 | unset($arreglo['ip']['alcance'][$id]); |
---|
1808 | } |
---|
1809 | //Situación Actual del Proyecto |
---|
1810 | elseif (array_key_exists($id, $arreglo['ip']['situaciona'])) { |
---|
1811 | unset($arreglo['ip']['situaciona'][$id]); |
---|
1812 | } |
---|
1813 | //Situación Objetivo |
---|
1814 | elseif (array_key_exists($id, $arreglo['ip']['situaciono'])) { |
---|
1815 | unset($arreglo['ip']['situaciono'][$id]); |
---|
1816 | } |
---|
1817 | //Indicador del resultado del Proyecto |
---|
1818 | elseif (array_key_exists($id, $arreglo['ip']['resultadop'])) { |
---|
1819 | unset($arreglo['ip']['resultadop'][$id]); |
---|
1820 | } |
---|
1821 | } |
---|
1822 | } |
---|
1823 | |
---|
1824 | //$campos['proyectos_operativos_flujo'] = t('Flujo de Trabajo'); |
---|
1825 | //DATOS BASICOS DEL PROYECTO |
---|
1826 | |
---|
1827 | |
---|
1828 | $identificacion = count($arreglo['db']['identificacion']); |
---|
1829 | $gerentep = count($arreglo['db']['gerentep']); |
---|
1830 | $areae = count($arreglo['db']['areae']); |
---|
1831 | if ($identificacion || $gerentep || $areae) { |
---|
1832 | $form['db'] = array( |
---|
1833 | '#type' => 'fieldset', |
---|
1834 | '#title' => t('Datos Básicos'), |
---|
1835 | ); |
---|
1836 | } |
---|
1837 | if ($identificacion) { |
---|
1838 | $form['db']['identificacion'] = array( |
---|
1839 | '#type' => 'checkboxes', |
---|
1840 | '#options' => $arreglo['db']['identificacion'], |
---|
1841 | '#default_value' => array(), |
---|
1842 | '#title' => t('Datos Básicos de Identificación del Proyecto'), |
---|
1843 | '#multiple' => TRUE, |
---|
1844 | ); |
---|
1845 | } |
---|
1846 | if ($gerentep) { |
---|
1847 | $form['db']['gerentep'] = array( |
---|
1848 | '#type' => 'checkboxes', |
---|
1849 | '#options' => $arreglo['db']['gerentep'], |
---|
1850 | '#default_value' => array(), |
---|
1851 | '#title' => t('Gerente del Proyecto'), |
---|
1852 | '#multiple' => TRUE, |
---|
1853 | ); |
---|
1854 | } |
---|
1855 | if ($areae) { |
---|
1856 | $form['db']['areae'] = array( |
---|
1857 | '#type' => 'checkboxes', |
---|
1858 | '#options' => $arreglo['db']['areae'], |
---|
1859 | '#default_value' => array(), |
---|
1860 | '#title' => t('Ãrea Estratégica'), |
---|
1861 | '#multiple' => TRUE, |
---|
1862 | ); |
---|
1863 | } |
---|
1864 | |
---|
1865 | //DATOS GENERALES DEL PROYECTO |
---|
1866 | $sector = count($arreglo['dg']['sector']); |
---|
1867 | $talentoh = count($arreglo['dg']['talentoh']); |
---|
1868 | $capacidades = count($arreglo['dg']['capacidades']); |
---|
1869 | $relacion = count($arreglo['dg']['relacion']); |
---|
1870 | $objetivosp = count($arreglo['dg']['objetivosp']); |
---|
1871 | if ($sector || $talentoh || $capacidades || $relacion || $objetivosp) { |
---|
1872 | $form['dg'] = array( |
---|
1873 | '#type' => 'fieldset', |
---|
1874 | '#title' => t('Datos Generales'), |
---|
1875 | ); |
---|
1876 | } |
---|
1877 | //Clasificación Sectorial |
---|
1878 | if ($sector) { |
---|
1879 | $form['dg']['sector'] = array( |
---|
1880 | '#type' => 'checkboxes', |
---|
1881 | '#options' => $arreglo['dg']['sector'], |
---|
1882 | '#default_value' => array(), |
---|
1883 | '#title' => t('Clasificación Sectorial'), |
---|
1884 | '#multiple' => TRUE, |
---|
1885 | ); |
---|
1886 | } |
---|
1887 | //Talento Humano |
---|
1888 | if ($talentoh) { |
---|
1889 | $form['dg']['talentoh'] = array( |
---|
1890 | '#type' => 'checkboxes', |
---|
1891 | '#options' => $arreglo['dg']['talentoh'], |
---|
1892 | '#default_value' => array(), |
---|
1893 | '#title' => t('Talento Humano'), |
---|
1894 | '#multiple' => TRUE, |
---|
1895 | ); |
---|
1896 | } |
---|
1897 | //Capacidades |
---|
1898 | if ($capacidades) { |
---|
1899 | $form['dg']['capacidades'] = array( |
---|
1900 | '#type' => 'checkboxes', |
---|
1901 | '#options' => $arreglo['dg']['capacidades'], |
---|
1902 | '#default_value' => array(), |
---|
1903 | '#title' => t('Capacidades'), |
---|
1904 | '#multiple' => TRUE, |
---|
1905 | ); |
---|
1906 | } |
---|
1907 | //Instituciones |
---|
1908 | if ($relacion) { |
---|
1909 | $form['dg']['relacion'] = array( |
---|
1910 | '#type' => 'checkboxes', |
---|
1911 | '#options' => $arreglo['dg']['relacion'], |
---|
1912 | '#default_value' => array(), |
---|
1913 | '#title' => t('Instituciones'), |
---|
1914 | '#multiple' => TRUE, |
---|
1915 | ); |
---|
1916 | } |
---|
1917 | //Objetivos del Proyecto |
---|
1918 | if ($objetivosp) { |
---|
1919 | $form['dg']['objetivosp'] = array( |
---|
1920 | '#type' => 'checkboxes', |
---|
1921 | '#options' => $arreglo['dg']['objetivosp'], |
---|
1922 | '#default_value' => array(), |
---|
1923 | '#title' => t('Objetivos del Proyecto'), |
---|
1924 | '#multiple' => TRUE, |
---|
1925 | ); |
---|
1926 | } |
---|
1927 | //INDICADORES DEL PROYECTO |
---|
1928 | $enunciadop = count($arreglo['ip']['enunciadop']); |
---|
1929 | $justificacion = count($arreglo['ip']['justificacion']); |
---|
1930 | $alcance = count($arreglo['ip']['alcance']); |
---|
1931 | $situaciona = count($arreglo['ip']['situaciona']); |
---|
1932 | $situaciono = count($arreglo['ip']['situaciono']); |
---|
1933 | $resultadop = count($arreglo['ip']['resultadop']); |
---|
1934 | if ($enunciadop || $justificacion || $alcance || $situaciona || $situaciono || $resultadop) { |
---|
1935 | $form['ip'] = array( |
---|
1936 | '#type' => 'fieldset', |
---|
1937 | '#title' => t('Indicadores del Proyecto'), |
---|
1938 | ); |
---|
1939 | } |
---|
1940 | //Enunciado del Problema |
---|
1941 | if ($enunciadop) { |
---|
1942 | $form['ip']['enunciadop'] = array( |
---|
1943 | '#type' => 'checkboxes', |
---|
1944 | '#options' => $arreglo['ip']['enunciadop'], |
---|
1945 | '#default_value' => array(), |
---|
1946 | '#title' => t('Enunciado del Problema'), |
---|
1947 | '#multiple' => TRUE, |
---|
1948 | ); |
---|
1949 | } |
---|
1950 | //Justificación del Proyecto |
---|
1951 | if ($justificacion) { |
---|
1952 | $form['ip']['justificacion'] = array( |
---|
1953 | '#type' => 'checkboxes', |
---|
1954 | '#options' => $arreglo['ip']['justificacion'], |
---|
1955 | '#default_value' => array(), |
---|
1956 | '#title' => t('Justificación del Proyecto'), |
---|
1957 | '#multiple' => TRUE, |
---|
1958 | ); |
---|
1959 | } |
---|
1960 | //Alcance del Proyecto |
---|
1961 | if ($alcance) { |
---|
1962 | $form['ip']['alcance'] = array( |
---|
1963 | '#type' => 'checkboxes', |
---|
1964 | '#options' => $arreglo['ip']['alcance'], |
---|
1965 | '#default_value' => array(), |
---|
1966 | '#title' => t('Alcance del Proyecto'), |
---|
1967 | '#multiple' => TRUE, |
---|
1968 | ); |
---|
1969 | } |
---|
1970 | //Situación Actual del Proyecto |
---|
1971 | if ($situaciona) { |
---|
1972 | $form['ip']['situaciona'] = array( |
---|
1973 | '#type' => 'checkboxes', |
---|
1974 | '#options' => $arreglo['ip']['situaciona'], |
---|
1975 | '#default_value' => array(), |
---|
1976 | '#title' => t('Situación Actual'), |
---|
1977 | '#multiple' => TRUE, |
---|
1978 | ); |
---|
1979 | } |
---|
1980 | //Situación Objetivo |
---|
1981 | if ($situaciono) { |
---|
1982 | $form['ip']['situaciono'] = array( |
---|
1983 | '#type' => 'checkboxes', |
---|
1984 | '#options' => $arreglo['ip']['situaciono'], |
---|
1985 | '#default_value' => array(), |
---|
1986 | '#title' => t('Situación Objetivo'), |
---|
1987 | '#multiple' => TRUE, |
---|
1988 | ); |
---|
1989 | } |
---|
1990 | //Indicador del resultado del Proyecto |
---|
1991 | if ($resultadop) { |
---|
1992 | $form['ip']['resultadop'] = array( |
---|
1993 | '#type' => 'checkboxes', |
---|
1994 | '#options' => $arreglo['ip']['resultadop'], |
---|
1995 | '#default_value' => array(), |
---|
1996 | '#title' => t('Indicador del resultado del Proyecto'), |
---|
1997 | '#multiple' => TRUE, |
---|
1998 | ); |
---|
1999 | } |
---|
2000 | //Acciones especificas |
---|
2001 | $form['ae'] = array( |
---|
2002 | '#type' => 'fieldset', |
---|
2003 | '#title' => t('Acciones EspecÃficas'), |
---|
2004 | ); |
---|
2005 | $arreglo['ae']['field_proyecto_accion_esp'] = t('Acciones EspecÃficas'); |
---|
2006 | //Indicador del resultado del Proyecto |
---|
2007 | $form['ae']['accionesesp'] = array( |
---|
2008 | '#type' => 'checkboxes', |
---|
2009 | '#options' => $arreglo['ae'], |
---|
2010 | '#default_value' => array(), |
---|
2011 | '#title' => t('Acciones EspecÃficas'), |
---|
2012 | '#multiple' => TRUE, |
---|
2013 | '#weight' => 99, |
---|
2014 | ); |
---|
2015 | $title_combos['accionesesp']['title'] = t('Acciones EspecÃficas'); |
---|
2016 | |
---|
2017 | |
---|
2018 | //otros |
---|
2019 | $form['otros'] = array( |
---|
2020 | '#type' => 'fieldset', |
---|
2021 | '#title' => t('Otros'), |
---|
2022 | ); |
---|
2023 | |
---|
2024 | $arreglo['otros']['proyectos_operativos_flujo'] = t('Flujo de Trabajo'); |
---|
2025 | //Indicador del resultado del Proyecto |
---|
2026 | $form['otros']['fl'] = array( |
---|
2027 | '#type' => 'checkboxes', |
---|
2028 | '#options' => $arreglo['otros'], |
---|
2029 | '#default_value' => array(), |
---|
2030 | '#title' => t('Flujo de Trabajo'), |
---|
2031 | '#multiple' => TRUE, |
---|
2032 | '#weight' => 99, |
---|
2033 | ); |
---|
2034 | $title_combos['fl']['title'] = t('Flujo de Trabajo'); |
---|
2035 | $form['#title_combos'] = $title_combos; |
---|
2036 | //$campos['proyectos_operativos_flujo'] = t('Flujo de Trabajo'); |
---|
2037 | /* |
---|
2038 | $form['proyectos_operativos_campos'] = array( |
---|
2039 | '#type' => 'checkboxes', |
---|
2040 | '#options' => $campos, |
---|
2041 | '#default_value' => array(), |
---|
2042 | '#title' => t('Campos a mostrar'), |
---|
2043 | '#multiple' => TRUE, |
---|
2044 | ); |
---|
2045 | */ |
---|
2046 | $form['buttons'] = array( |
---|
2047 | '#prefix' => '<div class="container-inline">', |
---|
2048 | '#suffix' => '</div>', |
---|
2049 | '#weight' => 100, |
---|
2050 | ); |
---|
2051 | $form['buttons']['registrar'] = array( |
---|
2052 | '#type' => 'submit', |
---|
2053 | '#default_value' => t('Mostrar'), |
---|
2054 | '#weight' => 100, |
---|
2055 | ); |
---|
2056 | $form['buttons']['cancelar'] = array( |
---|
2057 | '#type' => 'submit', |
---|
2058 | '#default_value' => t('Cancelar'), |
---|
2059 | '#weight' => 101, |
---|
2060 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
2061 | '#skip_validation' => TRUE, |
---|
2062 | ); |
---|
2063 | } |
---|
2064 | else { |
---|
2065 | $form['buttons']['cancelar'] = array( |
---|
2066 | '#type' => 'submit', |
---|
2067 | '#default_value' => t('Volver a las opciones de campo'), |
---|
2068 | '#weight' => 101, |
---|
2069 | '#skip_validation' => TRUE, |
---|
2070 | ); |
---|
2071 | } |
---|
2072 | return $form; |
---|
2073 | } |
---|
2074 | |
---|
2075 | /** |
---|
2076 | * Implementation of proyectos_operativos_proyecto_genera_campos_form_submit(). |
---|
2077 | * cambia los valores del filtro de campos. |
---|
2078 | */ |
---|
2079 | function proyectos_operativos_proyecto_genera_campos_form_submit($form, &$form_state) { |
---|
2080 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
2081 | if ($op == t('Volver a las opciones de campo')) { |
---|
2082 | unset($_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid]); |
---|
2083 | $form_state['redirect'] = 'proyectosop/' . $form['#node']->nid; |
---|
2084 | return; |
---|
2085 | } |
---|
2086 | $_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid]['#values'] = $form_state['values']; |
---|
2087 | $_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid]['#title_combos'] = $form['#title_combos']; |
---|
2088 | } |
---|
2089 | |
---|
2090 | /** |
---|
2091 | * Implementation of _proyectos_operativos_proyecto_campos(). |
---|
2092 | * Muestra los campos de un proyecto. |
---|
2093 | */ |
---|
2094 | function _proyectos_operativos_proyecto_campos($node) { |
---|
2095 | global $user; |
---|
2096 | drupal_set_title(t('Consultar Datos del Proyecto')); |
---|
2097 | //add breadcrumb |
---|
2098 | $breadcrumb = array(); |
---|
2099 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
2100 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
2101 | if ($node->nid) { |
---|
2102 | $breadcrumb[] = l(check_plain($node->title), 'proyectosop/' . $node->nid); |
---|
2103 | } |
---|
2104 | $breadcrumb[] = t('Datos del Proyecto'); |
---|
2105 | drupal_set_breadcrumb($breadcrumb); |
---|
2106 | $current_time = time(); |
---|
2107 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
2108 | $fecha = FALSE; |
---|
2109 | $ente = usuario_tiene_ente($user->uid); |
---|
2110 | $ente_planificador = 0; |
---|
2111 | if ($ente && $ente->nid) { |
---|
2112 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
2113 | } |
---|
2114 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
2115 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2116 | $fecha = TRUE; |
---|
2117 | } |
---|
2118 | if (!$fecha) { |
---|
2119 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
2120 | } |
---|
2121 | if ($fecha && $ente->nid) { |
---|
2122 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
2123 | } |
---|
2124 | $output = drupal_get_form('proyectos_operativos_proyecto_genera_campos_form', $node); |
---|
2125 | $views = array(); |
---|
2126 | if (isset($_SESSION['proyectos_operativos_mostrar_campos'][$node->nid]) && count($_SESSION['proyectos_operativos_mostrar_campos'][$node->nid])) { |
---|
2127 | $content = node_build_content($node); |
---|
2128 | $datos = $_SESSION['proyectos_operativos_mostrar_campos'][$node->nid]['#values']; |
---|
2129 | $title_combos = $_SESSION['proyectos_operativos_mostrar_campos'][$node->nid]['#title_combos']; |
---|
2130 | $valores = array(); |
---|
2131 | foreach($_SESSION['proyectos_operativos_mostrar_campos'][$node->nid]['#values'] as $id => $campos){ |
---|
2132 | if (is_array($campos) && count($campos)) { |
---|
2133 | foreach($campos as $campo) { |
---|
2134 | if ($campo) { |
---|
2135 | $valores[$id][] = $campo; |
---|
2136 | } |
---|
2137 | } |
---|
2138 | } |
---|
2139 | else { |
---|
2140 | |
---|
2141 | } |
---|
2142 | |
---|
2143 | } |
---|
2144 | foreach($_SESSION['proyectos_operativos_mostrar_campos'][$node->nid]['#title_combos'] as $id => $campos){ |
---|
2145 | if (isset($valores[$id])) { |
---|
2146 | $views[$id] = !isset($views[$id]) ? '<fieldset><legend>' . $campos['title'] . '</legend' : $views[$id]; |
---|
2147 | foreach($valores[$id] as $campo) { |
---|
2148 | if ($campo && isset($content->content[$campo])) { |
---|
2149 | $views[$id] .= drupal_render($content->content[$campo]); |
---|
2150 | } |
---|
2151 | elseif($campo == 'title') { |
---|
2152 | $views[$id] .= '<h2>' . $node->titulo_asignado . '</h2>'; |
---|
2153 | } |
---|
2154 | } |
---|
2155 | $views[$id] .= '</fieldset>'; |
---|
2156 | } |
---|
2157 | else { |
---|
2158 | foreach($campos as $id_campo => $campo) { |
---|
2159 | if (isset($valores[$id_campo])) { |
---|
2160 | $muestra = TRUE; |
---|
2161 | $views[$id] = !isset($views[$id]) ? '<fieldset><legend>' . $campos['title'] . '</legend' : $views[$id]; |
---|
2162 | $views[$id] .= '<fieldset><legend>' . $campo['title'] . '</legend'; |
---|
2163 | foreach($valores[$id_campo] as $id_field) { |
---|
2164 | if ($id_field && isset($content->content[$id_field])) { |
---|
2165 | $views[$id] .= drupal_render($content->content[$id_field]); |
---|
2166 | } |
---|
2167 | elseif($id_field == 'title') { |
---|
2168 | $views[$id] .= '<h2>' . $node->titulo_asignado . '</h2>'; |
---|
2169 | } |
---|
2170 | } |
---|
2171 | $views[$id] .= '</fieldset>'; |
---|
2172 | |
---|
2173 | } |
---|
2174 | } |
---|
2175 | if (isset($views[$id])) { |
---|
2176 | $views[$id] .= '</fieldset>'; |
---|
2177 | } |
---|
2178 | } |
---|
2179 | } |
---|
2180 | |
---|
2181 | } |
---|
2182 | if (count($views)) { |
---|
2183 | $output .= implode('', $views); |
---|
2184 | } |
---|
2185 | elseif (isset($_SESSION['proyectos_operativos_mostrar_campos'][$node->nid])) { |
---|
2186 | $output .= '<p>' . t('No ha seleccionado ningún campo que mostrar') . '</p>'; |
---|
2187 | } |
---|
2188 | return $output; |
---|
2189 | } |
---|
2190 | |
---|
2191 | /** |
---|
2192 | * Implementation of _proyectos_operativos_reformula_obtiene_estados(). |
---|
2193 | * Obtiene los estados del tipo de contenido proyecto. |
---|
2194 | */ |
---|
2195 | function _proyectos_operativos_reformula_obtiene_estados() { |
---|
2196 | static $lista_estados; |
---|
2197 | if (module_exists('workflow')) { |
---|
2198 | if (!isset($lista_estados)) { |
---|
2199 | $lista_estados = array(); |
---|
2200 | $estados = array(); |
---|
2201 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
2202 | if ($wid){ |
---|
2203 | $estados = workflow_get_states($wid); |
---|
2204 | } |
---|
2205 | $lista_estados = array( |
---|
2206 | 'wid' => $wid, |
---|
2207 | 'states' => $estados, |
---|
2208 | ); |
---|
2209 | } |
---|
2210 | } |
---|
2211 | else { |
---|
2212 | $lista_estados = array(); |
---|
2213 | } |
---|
2214 | return $lista_estados; |
---|
2215 | } |
---|
2216 | |
---|
2217 | /** |
---|
2218 | * Implementation of proyectos_operativos_search_ac_display(). |
---|
2219 | * Muestra la lista de proyectos disponibles. |
---|
2220 | */ |
---|
2221 | function proyectos_operativos_search_ac_display() { |
---|
2222 | global $user; |
---|
2223 | $current_time = time(); |
---|
2224 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
2225 | $fecha = FALSE; |
---|
2226 | $ente_planificador = 0; |
---|
2227 | $ente = usuario_tiene_ente($user->uid); |
---|
2228 | if ($ente && $ente->nid) { |
---|
2229 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
2230 | } |
---|
2231 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
2232 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2233 | $fecha = TRUE; |
---|
2234 | } |
---|
2235 | if (!$fecha) { |
---|
2236 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
2237 | } |
---|
2238 | if ($fecha && $ente->nid) { |
---|
2239 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
2240 | } |
---|
2241 | $states = array(); |
---|
2242 | $first_state = 0; |
---|
2243 | if (module_exists('workflow')) { |
---|
2244 | $states = _proyectos_operativos_reformula_obtiene_estados(); |
---|
2245 | if ($states['wid']) { |
---|
2246 | $first_state = _workflow_creation_state($states['wid']); |
---|
2247 | } |
---|
2248 | } |
---|
2249 | $output = drupal_get_form('proyectos_operativos_search_ac_form'); |
---|
2250 | $inputs = array(); |
---|
2251 | $sql = ''; |
---|
2252 | if (!user_access('admin planificador') && $user->entes) { |
---|
2253 | $inputs[] = $user->entes; |
---|
2254 | $inputs[] = variable_get('proyectos_operativos_state_naprobado', NULL); |
---|
2255 | $sql .= "SELECT ac.nid, ac.year, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS ente, ctpo.field_proyecto_titulo_value FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid LEFT JOIN {content_type_proyectos_operativos} AS ctpo ON ctpo.nid = n.nid AND ctpo.vid = n.vid WHERE ac.ente = %d AND w.sid <> %d"; |
---|
2256 | // $sql .= "SELECT ac.nid, ac.year, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS ente FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid WHERE ac.ente = %d AND w.sid <> %d"; |
---|
2257 | } |
---|
2258 | elseif (user_access('admin planificador')) { |
---|
2259 | $inputs[] = variable_get('proyectos_operativos_state_naprobado', NULL); |
---|
2260 | $sql .= "SELECT ac.nid, ac.year, ac.ente, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS enten, ctpo.field_proyecto_titulo_value FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid LEFT JOIN {content_type_proyectos_operativos} AS ctpo ON ctpo.nid = n.nid AND ctpo.vid = n.vid WHERE w.sid <> %d"; |
---|
2261 | // $sql .= "SELECT ac.nid, ac.year, ac.ente, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS enten FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid WHERE w.sid <> %d"; |
---|
2262 | $proyectos_operativos_search_ac_ente = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ente']) ? $_SESSION['proyectos_operativos']['ente'] : 0; |
---|
2263 | if ($proyectos_operativos_search_ac_ente) { |
---|
2264 | $inputs[] = $proyectos_operativos_search_ac_ente; |
---|
2265 | $sql .= ' AND ac.ente = %d'; |
---|
2266 | } |
---|
2267 | } |
---|
2268 | $proyectos_operativos_search_ac_anho_creacion = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['anho']) ? $_SESSION['proyectos_operativos']['anho'] : 0; |
---|
2269 | if ($proyectos_operativos_search_ac_anho_creacion) { |
---|
2270 | $sql .= ' AND ac.year = %d'; |
---|
2271 | $inputs[] = $proyectos_operativos_search_ac_anho_creacion; |
---|
2272 | } |
---|
2273 | $sql .= ' ORDER BY ac.year DESC, ac.ente'; |
---|
2274 | $header = array(); |
---|
2275 | $cab = 6; |
---|
2276 | if (user_access('admin planificador')) { |
---|
2277 | $header[] = array('data' => t('Ente.')); |
---|
2278 | $cab++; |
---|
2279 | } |
---|
2280 | $header[] = array('data' => t('Proyecto')); |
---|
2281 | $header[] = array('data' => t('Año')); |
---|
2282 | $header[] = array('data' => t('Estado')); |
---|
2283 | $header[] = array('data' => t('Fecha de creación')); |
---|
2284 | $header[] = array('data' => t('Autor')); |
---|
2285 | $header[] = array('data' => t('Acción')); |
---|
2286 | $result = db_query($sql, $inputs); |
---|
2287 | $rows = array(); |
---|
2288 | while($ac = db_fetch_object($result)) { |
---|
2289 | $row = array(); |
---|
2290 | if (user_access('admin planificador')) { |
---|
2291 | $row[] = array('data' => l($ac->enten, 'node/' . $ac->ente),); |
---|
2292 | } |
---|
2293 | $nombre_proyecto = $ac->field_proyecto_titulo_value ? $ac->field_proyecto_titulo_value : $ac->nombre; |
---|
2294 | $row[] = array('data' => $nombre_proyecto,); |
---|
2295 | // $row[] = array('data' => $ac->nombre,); |
---|
2296 | $row[] = array('data' => $ac->year,); |
---|
2297 | $estad0 = $ac->sid == $first_state ? t('Ingresado') : $states['states'][$ac->sid]; |
---|
2298 | $row[] = array('data' => $estad0,); |
---|
2299 | $row[] = array('data' => format_date($ac->created),); |
---|
2300 | $row[] = array('data' => l($ac->name, 'user/' . $ac->uid),); |
---|
2301 | $links = array(); |
---|
2302 | drupal_alter('proyecto_obtiene_links', $links, $ac, $fecha); |
---|
2303 | $row[] = array('data' => theme('item_list', $links),); |
---|
2304 | $rows[] = $row; |
---|
2305 | } |
---|
2306 | if (!count($rows)) { |
---|
2307 | $row[] = array('data' => t('No existen Proyectos Operativos'), 'colspan' => $cab); |
---|
2308 | $rows[] = $row; |
---|
2309 | } |
---|
2310 | $output .= theme('table', $header, $rows); |
---|
2311 | if ($fecha) { |
---|
2312 | $links = array(); |
---|
2313 | drupal_alter('proyecto_obtiene_agregar_links', $links); |
---|
2314 | $output .= '<div id="ente-planificador-agregar-proyecto">' . theme('item_list', $links) . '</div>'; |
---|
2315 | } |
---|
2316 | return $output; |
---|
2317 | } |
---|
2318 | |
---|
2319 | /* |
---|
2320 | * Implementation of hook_proyecto_obtiene_agregar_links_alter() |
---|
2321 | */ |
---|
2322 | function proyectos_operativos_proyecto_obtiene_agregar_links_alter(&$links) { |
---|
2323 | global $user; |
---|
2324 | $ente_planificador = 0; |
---|
2325 | $ente = usuario_tiene_ente($user->uid); |
---|
2326 | if ($ente && $ente->nid) { |
---|
2327 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
2328 | } |
---|
2329 | if ($ente_planificador && _proyectos_operativos_edita_datos_agregar()) { |
---|
2330 | $links['proyecto_agregar'] = array( |
---|
2331 | 'data' => l(t('Agregar proyectos operativos'), 'agregarproyectosop'), |
---|
2332 | 'class' => 'proyectos-operativos-agregar', |
---|
2333 | ); |
---|
2334 | } |
---|
2335 | if (user_access('admin planificador')) { |
---|
2336 | $links['proyecto_agregar_ente'] = array( |
---|
2337 | 'data' => l(t('Agregar proyectos operativos por ente '), 'agregar_proyectoopente'), |
---|
2338 | 'class' => 'proyectos-operativos-agregar-ente', |
---|
2339 | ); |
---|
2340 | } |
---|
2341 | } |
---|
2342 | |
---|
2343 | /** |
---|
2344 | * Implementation of proyectos_operativos_remove_ac_form() |
---|
2345 | * Eliminar accion especifica |
---|
2346 | */ |
---|
2347 | function proyectos_operativos_remove_proyectosop_form($form_state, $node = 0) { |
---|
2348 | $form = array(); |
---|
2349 | //add breadcrumb |
---|
2350 | $breadcrumb = array(); |
---|
2351 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
2352 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
2353 | $breadcrumb[] = l(check_plain($node->title), 'proyectosop/' . $node->nid); |
---|
2354 | $breadcrumb[] = t('Eliminar Proyecto'); |
---|
2355 | drupal_set_breadcrumb($breadcrumb); |
---|
2356 | $form['#node'] = $node; |
---|
2357 | $message = t('Esta seguro de eliminar el proyecto operativo @nombre?', array('@nombre' => $form['#node']->titulo_asignado)); |
---|
2358 | $caption = '<p>'. t('This action cannot be undone.') .'</p>'; |
---|
2359 | $return_path = $_REQUEST['destination'] ? $_REQUEST['destination'] : 'proyectos_operativos'; |
---|
2360 | return confirm_form($form, $message, $return_path, $caption, t('Eliminar')); |
---|
2361 | } |
---|
2362 | |
---|
2363 | /** |
---|
2364 | * Implementation of proyectos_operativos_remove_ac_form_submit(). |
---|
2365 | * Process funcion delete accion especifica. |
---|
2366 | */ |
---|
2367 | function proyectos_operativos_remove_proyectosop_form_submit($form, &$form_state) { |
---|
2368 | global $user; |
---|
2369 | $titulo = $form['#node']->titulo_asignado; |
---|
2370 | $nid = $form['#node']->nid; |
---|
2371 | node_delete($form['#node']->nid); |
---|
2372 | $texto = t('Se elimino el proyecto @nombre', array('@nombre' => $form['#node']->titulo_asignado)); |
---|
2373 | drupal_set_message($texto); |
---|
2374 | if (!$_REQUEST['destination']) { |
---|
2375 | // add redirect |
---|
2376 | $form_state['redirect'] = 'proyectos_operativos'; |
---|
2377 | } |
---|
2378 | } |
---|
2379 | |
---|
2380 | /* |
---|
2381 | * Implementation of hook_acciones_obtiene_links_alter() |
---|
2382 | */ |
---|
2383 | function proyectos_operativos_proyecto_obtiene_links_alter(&$links, $proyecto, $acceso = FALSE) { |
---|
2384 | $node_accion = node_load($proyecto->nid); |
---|
2385 | if(node_access('view', $node_accion)){ |
---|
2386 | $links['proyecto_view'] = array( |
---|
2387 | 'data' => l(t('Consultar'), 'proyectosop/' . $proyecto->nid), |
---|
2388 | 'class' => 'proyectos-operativos-ver', |
---|
2389 | ); |
---|
2390 | } |
---|
2391 | if(_proyectos_operativos_access_editar($node_accion)){ |
---|
2392 | $links['proyecto_update'] = array( |
---|
2393 | 'data' => l(t('Modificar'), 'proyectosop/' . $proyecto->nid . '/edit'), |
---|
2394 | 'class' => 'proyectos-operativos-modificar', |
---|
2395 | ); |
---|
2396 | if (_proyectos_operativos_edita_datos_ae_access($node_accion)) { |
---|
2397 | $links['proyecto_ae_update'] = array( |
---|
2398 | 'data' => l(t('Agregar Acción EspecÃfica'), 'proyectosopedit/' . $proyecto->nid . '/ae'), |
---|
2399 | 'class' => 'proyectos-operativos-ae-modificar', |
---|
2400 | ); |
---|
2401 | } |
---|
2402 | $links['proyecto_remove'] = array( |
---|
2403 | 'data' => l(t('Eliminar'), 'proyectosop/' . $proyecto->nid . '/remove'), |
---|
2404 | 'class' => 'proyectos-operativos-eliminar', |
---|
2405 | ); |
---|
2406 | |
---|
2407 | |
---|
2408 | } |
---|
2409 | if (_proyectos_operativos_edita_datos_wk_access($node_accion)) { |
---|
2410 | $links['proyecto_state'] = array( |
---|
2411 | 'data' => l(t('Cambiar el estado'), 'proyectosop/' . $proyecto->nid . '/workflow'), |
---|
2412 | 'class' => 'proyectos-operativos-estado', |
---|
2413 | ); |
---|
2414 | } |
---|
2415 | if (_proyectos_operativos_ver_datos_wk_access($node_accion)) { |
---|
2416 | $links['proyecto_ae_view'] = array( |
---|
2417 | 'data' => l(t('Consultar las Acciones Especificas'), 'proyectosop/' . $proyecto->nid . '/ae'), |
---|
2418 | 'class' => 'proyectos-operativos-ae', |
---|
2419 | ); |
---|
2420 | $links['proyecto_financial_view'] = array( |
---|
2421 | 'data' => l(t('Consultar Datos Financieros'), 'proyectosop/' . $proyecto->nid . '/finacieros'), |
---|
2422 | 'class' => 'proyectos-operativos-finacieros', |
---|
2423 | ); |
---|
2424 | } |
---|
2425 | } |
---|
2426 | |
---|
2427 | /** |
---|
2428 | * Implementation of proyectos_operativos_search_ac_form(). |
---|
2429 | * Formulario de busqueda de proyecto. |
---|
2430 | */ |
---|
2431 | function proyectos_operativos_search_ac_form($form_state) { |
---|
2432 | $form = array(); |
---|
2433 | if (user_access('admin planificador')) { |
---|
2434 | $entes = array(); |
---|
2435 | $result = db_query('SELECT e.nid, n.title FROM {ente_planificador} AS e INNER JOIN {node} AS n ON n.nid = e.nid WHERE n.status = 1'); |
---|
2436 | $entes[0] = t('Todos'); |
---|
2437 | while($ente = db_fetch_object($result)) { |
---|
2438 | $entes[$ente->nid] = $ente->title; |
---|
2439 | } |
---|
2440 | $proyectos_operativos_search_ac_ente = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ente']) ? $_SESSION['proyectos_operativos']['ente'] : 0; |
---|
2441 | $form['proyectos_operativos_search_ac_ente'] = array( |
---|
2442 | '#title' => t('Ente Planificador'), |
---|
2443 | '#type' => 'select', |
---|
2444 | '#default_value' => $proyectos_operativos_search_ac_ente, |
---|
2445 | '#options' => $entes, |
---|
2446 | ); |
---|
2447 | } |
---|
2448 | $years = array(); |
---|
2449 | $years[0] = t('Todos'); |
---|
2450 | $current_year = date("Y"); |
---|
2451 | for($i = $current_year - 10; $i <= $current_year; $i++) { |
---|
2452 | $years[$i] = $i; |
---|
2453 | } |
---|
2454 | $proyectos_operativos_search_ac_anho_creacion = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['anho']) ? $_SESSION['proyectos_operativos']['anho'] : 0; |
---|
2455 | $form['proyectos_operativos_search_ac_anho_creacion'] = array( |
---|
2456 | '#title' => t('Proyectos Operativos para el año'), |
---|
2457 | '#type' => 'select', |
---|
2458 | '#default_value' => $proyectos_operativos_search_ac_anho_creacion, |
---|
2459 | '#options' => $years, |
---|
2460 | ); |
---|
2461 | $form['buttons'] = array( |
---|
2462 | '#prefix' => '<div class="container-inline">', |
---|
2463 | '#suffix' => '</div>', |
---|
2464 | ); |
---|
2465 | $form['buttons']['submit'] = array( |
---|
2466 | '#type' => 'submit', |
---|
2467 | '#value' => t('Buscar'), |
---|
2468 | ); |
---|
2469 | return $form; |
---|
2470 | } |
---|
2471 | |
---|
2472 | /** |
---|
2473 | * Implementation of proyectos_operativos_search_ac_form_submit(). |
---|
2474 | * cambia el filtro de busqueda de proyectos. |
---|
2475 | */ |
---|
2476 | function proyectos_operativos_search_ac_form_submit($form, &$form_state) { |
---|
2477 | $_SESSION['proyectos_operativos'] = array(); |
---|
2478 | if (user_access('admin planificador')) { |
---|
2479 | $_SESSION['proyectos_operativos']['ente'] = $form_state['values']['proyectos_operativos_search_ac_ente']; |
---|
2480 | } |
---|
2481 | $_SESSION['proyectos_operativos']['anho'] = $form_state['values']['proyectos_operativos_search_ac_anho_creacion']; |
---|
2482 | } |
---|
2483 | |
---|
2484 | /* |
---|
2485 | * Implementation of hook_perm |
---|
2486 | */ |
---|
2487 | function proyectos_operativos_perm() { |
---|
2488 | return array( |
---|
2489 | 'editar datos institucionales de mi ente', |
---|
2490 | ); |
---|
2491 | } |
---|
2492 | |
---|
2493 | /** |
---|
2494 | * Implementation of proyectosop_load(). |
---|
2495 | * Leer un proyecto operativo. |
---|
2496 | */ |
---|
2497 | function proyectosop_load($nid = 0) { |
---|
2498 | if ($nid && is_numeric($nid)) { |
---|
2499 | $node_load = node_load($nid); |
---|
2500 | if ($node_load && $node_load->type == 'proyectos_operativos') { |
---|
2501 | return $node_load; |
---|
2502 | } |
---|
2503 | } |
---|
2504 | return FALSE; |
---|
2505 | } |
---|
2506 | |
---|
2507 | /** |
---|
2508 | * Implementation of accion_especifical_load(). |
---|
2509 | * Leer una accion especifica. |
---|
2510 | */ |
---|
2511 | function accion_especifical_load($nid = 0) { |
---|
2512 | if ($nid && is_numeric($nid)) { |
---|
2513 | $node_load = node_load($nid); |
---|
2514 | if ($node_load && $node_load->type == 'accion_especifica') { |
---|
2515 | return $node_load; |
---|
2516 | } |
---|
2517 | } |
---|
2518 | return FALSE; |
---|
2519 | } |
---|
2520 | |
---|
2521 | /** |
---|
2522 | * Implementation of _proyectos_operativos_proyecto_agregar_proyecto(). |
---|
2523 | * Agregar un nuevo proyecto. |
---|
2524 | */ |
---|
2525 | function _proyectos_operativos_proyecto_agregar_proyecto($ente = 0) { |
---|
2526 | $output = ''; |
---|
2527 | $output .= drupal_get_form('proyectos_operativos_proyecto_basico_form', 0, $ente); |
---|
2528 | return $output; |
---|
2529 | } |
---|
2530 | |
---|
2531 | /** |
---|
2532 | * Implementation of proyectos_operativos_proyecto_basico_form(). |
---|
2533 | * Formulario de datos basicos (proyectos operativos). |
---|
2534 | */ |
---|
2535 | function proyectos_operativos_proyecto_basico_form(&$form_state, $proyecto = 0, $ente_agregar = 0) { |
---|
2536 | global $user; |
---|
2537 | //add breadcrumb |
---|
2538 | $breadcrumb = array(); |
---|
2539 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
2540 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
2541 | if ($proyecto->nid) { |
---|
2542 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
2543 | $breadcrumb[] = t('Datos Básicos'); // Link to current URL |
---|
2544 | } |
---|
2545 | else { |
---|
2546 | $breadcrumb[] = t('Agregar Proyecto'); // Link to current URL |
---|
2547 | } |
---|
2548 | drupal_set_breadcrumb($breadcrumb); |
---|
2549 | $current_time = time(); |
---|
2550 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
2551 | $ente_planificador = 0; |
---|
2552 | if($proyecto && $proyecto->nid && $proyecto->field_proyecto_ente[0]['nid']) { |
---|
2553 | $ente_planificador = ente_planificador_leer_ente_planificadores($proyecto->field_proyecto_ente[0]['nid']); |
---|
2554 | } |
---|
2555 | else { |
---|
2556 | $ente = usuario_tiene_ente($user->uid); |
---|
2557 | if ($ente && $ente->nid) { |
---|
2558 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
2559 | } |
---|
2560 | elseif($ente_agregar && user_access('admin planificador')) { |
---|
2561 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente_agregar); |
---|
2562 | } |
---|
2563 | } |
---|
2564 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
2565 | $fecha = FALSE; |
---|
2566 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
2567 | $fecha = TRUE; |
---|
2568 | } |
---|
2569 | if (!$fecha) { |
---|
2570 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
2571 | } |
---|
2572 | if ($fecha && $ente->nid) { |
---|
2573 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
2574 | } |
---|
2575 | $fechas_validacion = array( |
---|
2576 | 'inicio' => '', |
---|
2577 | 'fin' => '', |
---|
2578 | ); |
---|
2579 | $montos_asignados = 0; |
---|
2580 | $acciones_especificas = array(); |
---|
2581 | $porcentajes = array(); |
---|
2582 | $ejecucion = 0; |
---|
2583 | if (!$proyecto) { |
---|
2584 | $proyecto_leido = new stdClass(); |
---|
2585 | $proyecto_leido->type = 'proyectos_operativos'; |
---|
2586 | $proyecto_leido->title = ''; |
---|
2587 | $proyecto_leido->field_proyecto_ente[0]['nid'] = $ente_planificador->nid; |
---|
2588 | } |
---|
2589 | else { |
---|
2590 | $proyecto_leido = $proyecto; |
---|
2591 | $proyecto_leido->field_proyecto_titulo[0]['value'] = trim($proyecto_leido->field_proyecto_titulo[0]['value']) == '' ? $proyecto_leido->title : $proyecto_leido->field_proyecto_titulo[0]['value']; |
---|
2592 | |
---|
2593 | if (isset($proyecto->field_proyecto_accion_esp)){ |
---|
2594 | foreach($proyecto->field_proyecto_accion_esp as $accion) { |
---|
2595 | if ($accion['nid']) { |
---|
2596 | $accion_load = node_load($accion['nid']); |
---|
2597 | if ($accion_load && ($fechas_validacion['inicio'] == '' || $accion_load->field_accion_esp_fechai[0]['value'] < $fechas_validacion['inicio'])) { |
---|
2598 | $fechas_validacion['inicio'] = $accion_load->field_accion_esp_fechai[0]['value']; |
---|
2599 | } |
---|
2600 | if ($accion_load && ($fechas_validacion['fin'] == '' || $accion_load->field_accion_esp_fechaf[0]['value'] > $fechas_validacion['fin'])) { |
---|
2601 | $fechas_validacion['fin'] = $accion_load->field_accion_esp_fechaf[0]['value']; |
---|
2602 | } |
---|
2603 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
2604 | if ($accion_load->field_accion_esp_programacion[0]['tid']) { |
---|
2605 | foreach($accion_load->field_accion_esp_programacion as $programacion) { |
---|
2606 | foreach($programacion as $id_value => $mesp){ |
---|
2607 | if ($id_value != 'tid') { |
---|
2608 | $montos_asignados +=$mesp; |
---|
2609 | } |
---|
2610 | } |
---|
2611 | } |
---|
2612 | } |
---|
2613 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
2614 | $porcentajes[$accion_load->field_accion_esp_ponderacion[0]['value']] = 1; |
---|
2615 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
2616 | } |
---|
2617 | } |
---|
2618 | } |
---|
2619 | } |
---|
2620 | } |
---|
2621 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
2622 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
2623 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos2.js'); |
---|
2624 | $form = array(); |
---|
2625 | $fechas_validacion['fin_texto'] = ''; |
---|
2626 | $fechas_validacion['inicio_texto'] = ''; |
---|
2627 | if ($fechas_validacion['inicio']) { |
---|
2628 | $f_aux = explode(' ', $fechas_validacion['inicio']); |
---|
2629 | $f_aux = explode('-', $f_aux[0]); |
---|
2630 | $fechas_validacion['inicio_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
2631 | $fechas_validacion['inicio_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
2632 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_i[0]['value']); |
---|
2633 | $f_aux = explode('-', $f_aux[0]); |
---|
2634 | $fechas_validacion['inicio_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
2635 | $fechas_validacion['inicio_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
2636 | } |
---|
2637 | if ($fechas_validacion['fin']) { |
---|
2638 | $f_aux = explode(' ', $fechas_validacion['fin']); |
---|
2639 | $f_aux = explode('-', $f_aux[0]); |
---|
2640 | $fechas_validacion['fin_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
2641 | $fechas_validacion['fin_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
2642 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_f[0]['value']); |
---|
2643 | $f_aux = explode('-', $f_aux[0]); |
---|
2644 | $fechas_validacion['fin_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
2645 | $fechas_validacion['fin_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
2646 | } |
---|
2647 | $format_number = array( |
---|
2648 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
2649 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
2650 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
2651 | ); |
---|
2652 | $form['#format_number'] = array('format_number' => $format_number); |
---|
2653 | drupal_add_js($form['#format_number'], 'setting'); |
---|
2654 | drupal_add_js(array('proyectos_operativos' => array('plurianual' => variable_get('proyectos_operativos_plurianual', 0))), 'setting'); |
---|
2655 | $form['#ente_planificador'] = $ente_planificador; |
---|
2656 | $form['#fechas_validacion'] = $fechas_validacion; |
---|
2657 | $form['#montos_asignados'] = $montos_asignados; |
---|
2658 | $form['#count_ae'] = count($acciones_especificas); |
---|
2659 | $node_type = content_types('proyectos_operativos'); |
---|
2660 | $fields = $node_type['fields']; |
---|
2661 | $form['#proyecto_fields'] = $fields; |
---|
2662 | $form['#proyecto_anho'] = variable_get('proyectos_operativos_anho_creacion', 0) ? variable_get('proyectos_operativos_anho_creacion', 0) : date("Y"); |
---|
2663 | $field_form = array(); |
---|
2664 | $fields_form = array(); |
---|
2665 | $fields_form_ac_d = array(); |
---|
2666 | $arreglo = array( |
---|
2667 | 'field_proyecto_titulo' => 'field_proyecto_titulo', |
---|
2668 | 'field_proyecto_codigo' => 'field_proyecto_codigo', |
---|
2669 | 'field_proyecto_fecha_i' => 'field_proyecto_fecha_i', |
---|
2670 | 'field_proyecto_fecha_f' => 'field_proyecto_fecha_f', |
---|
2671 | 'field_proyecto_status' => 'field_proyecto_status', |
---|
2672 | 'field_proyecto_situacion_p' => 'field_proyecto_situacion_p', |
---|
2673 | 'field_proyecto_plurianual' => 'field_proyecto_plurianual', |
---|
2674 | 'field_proyecto_monto_anual' => 'field_proyecto_monto_anual', |
---|
2675 | 'field_proyecto_total' => 'field_proyecto_total', |
---|
2676 | 'field_proyecto_poan' => 'field_proyecto_poan', |
---|
2677 | ); |
---|
2678 | if (is_array($fields) && count($fields)) { |
---|
2679 | foreach($fields as $field_id => $field) { |
---|
2680 | if (array_key_exists($field_id, $arreglo)) { |
---|
2681 | $field_form[] = $field_id; |
---|
2682 | $fields_form[] = $field_id; |
---|
2683 | } |
---|
2684 | elseif (variable_get('proyectos_operativos_ac_d_' . $field_id, FALSE)) { |
---|
2685 | $fields_form_ac_d[$field_id] = $field_id; |
---|
2686 | $field_form[] = $field_id; |
---|
2687 | $fields_form[] = $field_id; |
---|
2688 | } |
---|
2689 | } |
---|
2690 | } |
---|
2691 | /* |
---|
2692 | $form['title'] = array( |
---|
2693 | '#type' => 'textfield', |
---|
2694 | '#title' => t('Nombre del Proyecto'), |
---|
2695 | '#required' => TRUE, |
---|
2696 | '#default_value' => $proyecto_leido->title, |
---|
2697 | '#maxlength' => 511, |
---|
2698 | '#weight' => -5, |
---|
2699 | ); |
---|
2700 | */ |
---|
2701 | $form['#node'] = $proyecto_leido; |
---|
2702 | if (is_array($field_form) && count($field_form)) { |
---|
2703 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
2704 | foreach ($field_form as $field_id) { |
---|
2705 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
2706 | $form['#field_info'][$field_id] = $field; |
---|
2707 | $form += (array) content_field_form($form, $form_state, $field); |
---|
2708 | } |
---|
2709 | } |
---|
2710 | $field_form = array(); |
---|
2711 | $gerentes = variable_get('proyectos_operativos_muestra_gerentes', TRUE); |
---|
2712 | if ($gerentes) { |
---|
2713 | $arreglo = array( |
---|
2714 | //'field_proyecto_ente' => 'field_proyecto_ente', |
---|
2715 | 'field_proyecto_autoridad' => 'field_proyecto_autoridad', |
---|
2716 | 'field_proyecto_lider' => 'field_proyecto_lider', |
---|
2717 | 'field_proyecto_unidad_a' => 'field_proyecto_unidad_a', |
---|
2718 | 'field_proyecto_cargo' => 'field_proyecto_cargo', |
---|
2719 | 'field_proyecto_telefono' => 'field_proyecto_telefono', |
---|
2720 | 'field_proyecto_correo' => 'field_proyecto_correo', |
---|
2721 | ); |
---|
2722 | } |
---|
2723 | $fields_form_ac_di = array(); |
---|
2724 | if (is_array($fields) && count($fields)) { |
---|
2725 | foreach($fields as $field_id => $field) { |
---|
2726 | if (array_key_exists($field_id, $arreglo)) { |
---|
2727 | $field_form[] = $field_id; |
---|
2728 | $fields_form[] = $field_id; |
---|
2729 | } |
---|
2730 | elseif (variable_get('proyectos_operativos_ac_di_' . $field_id, FALSE)) { |
---|
2731 | $fields_form_ac_di[$field_id] = $field_id; |
---|
2732 | $field_form[] = $field_id; |
---|
2733 | $fields_form[] = $field_id; |
---|
2734 | } |
---|
2735 | } |
---|
2736 | } |
---|
2737 | if (is_array($field_form) && count($field_form)) { |
---|
2738 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
2739 | foreach ($field_form as $field_id) { |
---|
2740 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
2741 | $form['#field_info'][$field_id] = $field; |
---|
2742 | $form += (array) content_field_form($form, $form_state, $field); |
---|
2743 | } |
---|
2744 | } |
---|
2745 | $field_form = array(); |
---|
2746 | if (variable_get('proyectos_operativos_muestra_pndes', TRUE)) { |
---|
2747 | $arreglo['field_proyecto_pndes'] = 'field_proyecto_pndes'; |
---|
2748 | } |
---|
2749 | if (variable_get('proyectos_operativos_muestra_mcti', TRUE)) { |
---|
2750 | $arreglo['field_proyecto_mcti'] = 'field_proyecto_mcti'; |
---|
2751 | } |
---|
2752 | $fields_form_ac_p = array(); |
---|
2753 | if (is_array($fields) && count($fields)) { |
---|
2754 | foreach($fields as $field_id => $field) { |
---|
2755 | if (array_key_exists($field_id, $arreglo)) { |
---|
2756 | $field_form[] = $field_id; |
---|
2757 | $fields_form[] = $field_id; |
---|
2758 | } |
---|
2759 | elseif (variable_get('proyectos_operativos_ac_p_' . $field_id, FALSE)) { |
---|
2760 | $fields_form_ac_p[$field_id] = $field_id; |
---|
2761 | $field_form[] = $field_id; |
---|
2762 | $fields_form[] = $field_id; |
---|
2763 | } |
---|
2764 | } |
---|
2765 | } |
---|
2766 | if (is_array($field_form) && count($field_form)) { |
---|
2767 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
2768 | foreach ($field_form as $field_id) { |
---|
2769 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
2770 | $form['#field_info'][$field_id] = $field; |
---|
2771 | $form += (array) content_field_form($form, $form_state, $field); |
---|
2772 | } |
---|
2773 | } |
---|
2774 | $form['#fields_form_ac_d'] = $fields_form_ac_d; |
---|
2775 | $form['#fields_form_ac_di'] = $fields_form_ac_di; |
---|
2776 | $form['#fields_form_ac_p'] = $fields_form_ac_p; |
---|
2777 | |
---|
2778 | |
---|
2779 | |
---|
2780 | $form['#proyectos_operativos_fields'] = $fields_form; |
---|
2781 | $form['buttons'] = array( |
---|
2782 | '#prefix' => '<div class="container-inline">', |
---|
2783 | '#suffix' => '</div>', |
---|
2784 | ); |
---|
2785 | $form['buttons']['registrar'] = array( |
---|
2786 | '#type' => 'submit', |
---|
2787 | '#default_value' => t('Aceptar'), |
---|
2788 | '#weight' => 100, |
---|
2789 | ); |
---|
2790 | $form['buttons']['cancelar'] = array( |
---|
2791 | '#type' => 'submit', |
---|
2792 | '#default_value' => t('Cancelar'), |
---|
2793 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
2794 | '#weight' => 101, |
---|
2795 | ); |
---|
2796 | $form['#submit'] = array('proyectos_operativos_proyecto_basico_form_submit'); |
---|
2797 | return $form; |
---|
2798 | } |
---|
2799 | |
---|
2800 | /* |
---|
2801 | * Implementation of proyectos_operativos_proyecto_basico_form_validate() |
---|
2802 | * Validar formulario de datos basicos (proyectos operativos). |
---|
2803 | */ |
---|
2804 | function proyectos_operativos_proyecto_basico_form_validate($form, &$form_state) { |
---|
2805 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
2806 | if ($op == t('Cancelar')) { |
---|
2807 | return; |
---|
2808 | } |
---|
2809 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
2810 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
2811 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos2.js'); |
---|
2812 | //drupal_add_js($form['#format_number'], 'setting'); |
---|
2813 | $form_state['values']['field_proyecto_monto_anual'][0]['value'] = str_replace("", $form['#format_number']['format_number']['thousands_sep'], $form_state['values']['field_proyecto_monto_anual'][0]['value']); |
---|
2814 | $form_state['values']['field_proyecto_monto_anual'][0]['value'] = str_replace(".", $form['#format_number']['format_number']['dec_point'], $form_state['values']['field_proyecto_monto_anual'][0]['value']); |
---|
2815 | $form_state['values']['field_proyecto_total'][0]['value'] = str_replace("", $form['#format_number']['format_number']['thousands_sep'], $form_state['values']['field_proyecto_total'][0]['value']); |
---|
2816 | $form_state['values']['field_proyecto_total'][0]['value'] = str_replace(".", $form['#format_number']['format_number']['dec_point'], $form_state['values']['field_proyecto_total'][0]['value']); |
---|
2817 | |
---|
2818 | // garantizar el formato numerico y no exponencial con numeros grandes |
---|
2819 | $form_state['values']['field_proyecto_monto_anual'][0]['value'] = number_format($form_state['values']['field_proyecto_monto_anual'][0]['value'], $form['#format_number']['format_number']['decimals'], '.', ''); |
---|
2820 | $form_state['values']['field_proyecto_total'][0]['value'] = number_format($form_state['values']['field_proyecto_total'][0]['value'], $form['#format_number']['format_number']['decimals'], '.', ''); |
---|
2821 | if (trim($form_state['values']['field_proyecto_correo'][0]['email']) && !valid_email_address(trim($form_state['values']['field_proyecto_correo'][0]['email']))) { |
---|
2822 | form_set_error('field_proyecto_correo', t('"%mail" is not a valid email address',array('%mail' => $form_state['values']['field_proyecto_correo'][0]['email']))); |
---|
2823 | } |
---|
2824 | if ($form_state['values']['field_proyecto_monto_anual'][0]['value'] <= 0) { |
---|
2825 | form_set_error('field_proyecto_monto_anual', t('El monto anual del proyecto no puede ser negativo o cero')); |
---|
2826 | } |
---|
2827 | $start = $form_state['values']['field_proyecto_total'][0]['value']; |
---|
2828 | $value = preg_replace('@[^-0-9]@', '', $start); |
---|
2829 | if ($start != $value) { |
---|
2830 | form_set_error('field_proyecto_total', t('Solo números enteros son permitidos en el monto anual del proyecto.')); |
---|
2831 | } |
---|
2832 | $start = $form_state['values']['field_proyecto_monto_anual'][0]['value']; |
---|
2833 | $value = preg_replace('@[^-0-9]@', '', $start); |
---|
2834 | if ($start != $value) { |
---|
2835 | form_set_error('field_proyecto_monto_anual', t('Solo números enteros son permitidos en el monto total del proyecto')); |
---|
2836 | } |
---|
2837 | if ($form['#count_ae'] && $form['#montos_asignados'] > $value) { |
---|
2838 | form_set_error('field_proyecto_monto_anual', t('El monto anual del proyecto (@monto_proyecto Bs.) es inferior al asignado a las Acciones EspecÃficas (@monto_asignado Bs.)', array('@monto_proyecto' => number_format($value, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@monto_asignado' => number_format($form['#montos_asignados'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep'])))); |
---|
2839 | } |
---|
2840 | if ($form_state['values']['field_proyecto_total'][0]['value'] <= 0) { |
---|
2841 | form_set_error('field_proyecto_total', t('El monto anual del proyecto no puede ser negativo o cero')); |
---|
2842 | } |
---|
2843 | if ($form_state['values']['field_proyecto_monto_anual'][0]['value'] > $form_state['values']['field_proyecto_total'][0]['value']) { |
---|
2844 | form_set_error('field_proyecto_monto_anual', t('El monto anual debe ser menor o igual al monto total del proyecto.')); |
---|
2845 | } |
---|
2846 | //lamentablemente date no valida que from sea menor que to |
---|
2847 | if ($form_state['values']['field_proyecto_fecha_i'][0]['value'] > $form_state['values']['field_proyecto_fecha_f'][0]['value']) { |
---|
2848 | form_set_error('field_proyecto_fecha_i', t('La fecha de inicio debe ser menor a la fecha de culminación')); |
---|
2849 | } |
---|
2850 | if ($form_state['values']['field_proyecto_plurianual'][0]['value'] != variable_get('proyectos_operativos_plurianual', 0) && $form_state['values']['field_proyecto_total'][0]['value'] != $form_state['values']['field_proyecto_monto_anual'][0]['value']) { |
---|
2851 | form_set_error('field_proyecto_monto_anual', t('Cuando un proyecto no es plurianual, el monto total debe ser igual al monto anual del proyecto')); |
---|
2852 | } |
---|
2853 | //validamos el añofield_proyecto_plurianual |
---|
2854 | $fecha = explode('-', $form_state['values']['field_proyecto_fecha_i'][0]['value']); |
---|
2855 | if (is_array($fecha) && count($fecha)) { |
---|
2856 | if ($form['#proyecto_anho'] != $fecha[0]) { |
---|
2857 | form_set_error('field_proyecto_fecha_i',t('El año de inicio del proyecto debe ser igual a @year', array('@year' => $form['#proyecto_anho']))); |
---|
2858 | } |
---|
2859 | } |
---|
2860 | if ($form['#count_ae'] && $form['#fechas_validacion']['inicio'] < $form_state['values']['field_proyecto_fecha_i'][0]['value']) { |
---|
2861 | $fecha_dia = explode(' ', $fecha[2]); |
---|
2862 | form_set_error('field_proyecto_fecha_i',t('La fecha de inicio del proyecto (@fecha_inicio) es mayor a la menor fecha de inicio de las Acciones EspecÃficas (@fecha_aei)', array('@fecha_inicio' => $fecha_dia[0] . '-' . $fecha[1] . '-' . $fecha[0], '@fecha_aei' => $form['#fechas_validacion']['inicio_texto']))); |
---|
2863 | } |
---|
2864 | $fecha = explode('-', $form_state['values']['field_proyecto_fecha_f'][0]['value']); |
---|
2865 | if (is_array($fecha) && count($fecha)) { |
---|
2866 | if ($form['#proyecto_anho'] != $fecha[0]) { |
---|
2867 | form_set_error('field_proyecto_fecha_f',t('El año de finalización del debe ser igual a @year', array('@year' => $form['#proyecto_anho']))); |
---|
2868 | } |
---|
2869 | } |
---|
2870 | if ($form['#count_ae'] && $form['#fechas_validacion']['fin'] > $form_state['values']['field_proyecto_fecha_f'][0]['value']) { |
---|
2871 | $fecha_dia = explode(' ', $fecha[2]); |
---|
2872 | form_set_error('field_proyecto_fecha_f',t('La fecha de culminación del proyecto (@fecha_inicio) es menor a la menor fecha de inicio de las Acciones EspecÃficas (@fecha_aei)', array('@fecha_inicio' => $fecha_dia[0] . '-' . $fecha[1] . '-' . $fecha[0], '@fecha_aei' => $form['#fechas_validacion']['fin_texto']))); |
---|
2873 | } |
---|
2874 | } |
---|
2875 | |
---|
2876 | /* |
---|
2877 | * Implementation of proyectos_operativos_proyecto_basico_form_submit(). |
---|
2878 | * Guardar formulario de datos basicos (proyectos operativos). |
---|
2879 | */ |
---|
2880 | function proyectos_operativos_proyecto_basico_form_submit($form, &$form_state) { |
---|
2881 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
2882 | if ($op == t('Cancelar')) { |
---|
2883 | drupal_set_message(t('Se cancelo el ingreso de los datos básicos del proyecto.')); |
---|
2884 | if ($form['#node']->nid) { |
---|
2885 | $form_state['redirect'] = 'proyectosopedit/' . $form['#node']->nid; |
---|
2886 | } |
---|
2887 | else { |
---|
2888 | $form_state['redirect'] = 'proyectos_operativos'; |
---|
2889 | } |
---|
2890 | return; |
---|
2891 | } |
---|
2892 | global $user; |
---|
2893 | if (module_exists('hs_content_taxonomy')) { |
---|
2894 | foreach ($form['#field_info'] as $field_name => $field_info) { |
---|
2895 | if ($field_info['widget']['type'] == 'content_taxonomy_hs') { |
---|
2896 | // Change format of values to the one Content Taxonomy expects |
---|
2897 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
2898 | $values = array(); |
---|
2899 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
2900 | $values[] = array('value' => $tid); |
---|
2901 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
2902 | } |
---|
2903 | $form_state['values'][$field_name]['tids'] = $values; |
---|
2904 | } |
---|
2905 | else { |
---|
2906 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
2907 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
2908 | $form_state['values'][$field_name]['tids'] = $values; |
---|
2909 | } |
---|
2910 | } |
---|
2911 | } |
---|
2912 | } |
---|
2913 | if (module_exists('hs_content_taxonomy_description')) { |
---|
2914 | foreach ($form['#field_info'] as $field_name => $field_info) { |
---|
2915 | if ($field_info['widget']['type'] == 'content_taxonomy_hsd') { |
---|
2916 | // Change format of values to the one Content Taxonomy expects |
---|
2917 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
2918 | $values = array(); |
---|
2919 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
2920 | $values[] = array('value' => $tid); |
---|
2921 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
2922 | } |
---|
2923 | $form_state['values'][$field_name]['tids'] = $values; |
---|
2924 | } |
---|
2925 | else { |
---|
2926 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
2927 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
2928 | $form_state['values'][$field_name]['tids'] = $values; |
---|
2929 | } |
---|
2930 | } |
---|
2931 | } |
---|
2932 | } |
---|
2933 | $field_form = $form['#proyectos_operativos_fields']; |
---|
2934 | module_load_include('inc', 'node', 'node.pages'); |
---|
2935 | $node_load = $form['#node']; |
---|
2936 | $form_values = $form_state['values']; |
---|
2937 | //$node_load->title = check_plain($form_values['title']); |
---|
2938 | if (is_array($field_form) && count($field_form)) { |
---|
2939 | foreach ($field_form as $field_id) { |
---|
2940 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
2941 | foreach($form_values[$field_id] as $id => $value) { |
---|
2942 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
2943 | unset($form_values[$field_id][$id]['_error_element']); |
---|
2944 | } |
---|
2945 | } |
---|
2946 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
2947 | } |
---|
2948 | } |
---|
2949 | } |
---|
2950 | $node_load->title = $node_load->field_proyecto_codigo[0]['value'] && trim($node_load->field_proyecto_codigo[0]['value']) != '' ? check_plain($node_load->field_proyecto_codigo[0]['value']) : 'proyecto'; |
---|
2951 | if ($node_load->nid) { |
---|
2952 | $texto = t('Modificados los datos básicos del proyecto'); |
---|
2953 | $node_load->log = $texto; |
---|
2954 | drupal_set_message($texto); |
---|
2955 | } |
---|
2956 | else { |
---|
2957 | $node_load->uid = $user->uid; |
---|
2958 | $texto = t('Agregados los datos básicos del proyecto'); |
---|
2959 | $node_load->log = t('Agregados los datos básicos del proyecto'); |
---|
2960 | drupal_set_message($texto); |
---|
2961 | } |
---|
2962 | $node_load->revision = 1; |
---|
2963 | node_save($node_load); |
---|
2964 | if ($_REQUEST['destination']) { |
---|
2965 | $form_state['redirect'] = url('proyectosopedit/' . $node_load->nid . '/generales', |
---|
2966 | array( |
---|
2967 | 'query' => array( |
---|
2968 | 'destination' => $_REQUEST['destination'], |
---|
2969 | ), |
---|
2970 | 'absolute' => TRUE, |
---|
2971 | ) |
---|
2972 | ); |
---|
2973 | unset($_REQUEST['destination']); |
---|
2974 | } |
---|
2975 | else { |
---|
2976 | // add redirect |
---|
2977 | $form_state['redirect'] = 'proyectosopedit/' . $node_load->nid . '/generales'; |
---|
2978 | } |
---|
2979 | } |
---|
2980 | |
---|
2981 | /** |
---|
2982 | * Implementation of proyectos_operativos_proyecto_generales_form(). |
---|
2983 | * Formulario de datos generales (proyectos operativos). |
---|
2984 | */ |
---|
2985 | function proyectos_operativos_proyecto_generales_form(&$form_state, $proyecto = 0) { |
---|
2986 | global $user; |
---|
2987 | //add breadcrumb |
---|
2988 | $breadcrumb = array(); |
---|
2989 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
2990 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
2991 | if ($proyecto->nid) { |
---|
2992 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
2993 | } |
---|
2994 | $breadcrumb[] = 'Datos Generales'; // Link to current URL |
---|
2995 | drupal_set_breadcrumb($breadcrumb); |
---|
2996 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
2997 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
2998 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_generales.js'); |
---|
2999 | $format_number = array( |
---|
3000 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
3001 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
3002 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
3003 | ); |
---|
3004 | $current_time = time(); |
---|
3005 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
3006 | $fecha = FALSE; |
---|
3007 | $ente = usuario_tiene_ente($user->uid); |
---|
3008 | $ente_planificador = 0; |
---|
3009 | if ($ente && $ente->nid) { |
---|
3010 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
3011 | } |
---|
3012 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
3013 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3014 | $fecha = TRUE; |
---|
3015 | } |
---|
3016 | if (!$fecha) { |
---|
3017 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
3018 | } |
---|
3019 | if ($fecha && $ente->nid) { |
---|
3020 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
3021 | } |
---|
3022 | if (!$proyecto) { |
---|
3023 | $proyecto_leido = new stdClass(); |
---|
3024 | $proyecto_leido->type = 'proyectos_operativos'; |
---|
3025 | } |
---|
3026 | else { |
---|
3027 | $proyecto_leido = $proyecto; |
---|
3028 | if (isset($proyecto->field_proyecto_accion_esp)){ |
---|
3029 | foreach($proyecto->field_proyecto_accion_esp as $accion) { |
---|
3030 | if ($accion['nid']) { |
---|
3031 | $accion_load = node_load($accion['nid']); |
---|
3032 | if ($accion_load && ($fechas_validacion['inicio'] == '' || $accion_load->field_accion_esp_fechai[0]['value'] < $fechas_validacion['inicio'])) { |
---|
3033 | $fechas_validacion['inicio'] = $accion_load->field_accion_esp_fechai[0]['value']; |
---|
3034 | } |
---|
3035 | if ($accion_load && ($fechas_validacion['fin'] == '' || $accion_load->field_accion_esp_fechaf[0]['value'] > $fechas_validacion['fin'])) { |
---|
3036 | $fechas_validacion['fin'] = $accion_load->field_accion_esp_fechaf[0]['value']; |
---|
3037 | } |
---|
3038 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
3039 | if ($accion_load->field_accion_esp_programacion[0]['tid']) { |
---|
3040 | foreach($accion_load->field_accion_esp_programacion as $programacion) { |
---|
3041 | foreach($programacion as $id_value => $mesp){ |
---|
3042 | if ($id_value != 'tid') { |
---|
3043 | $montos_asignados +=$mesp; |
---|
3044 | } |
---|
3045 | } |
---|
3046 | } |
---|
3047 | } |
---|
3048 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
3049 | $porcentajes[$accion_load->field_accion_esp_ponderacion[0]['value']] = 1; |
---|
3050 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
3051 | } |
---|
3052 | } |
---|
3053 | } |
---|
3054 | } |
---|
3055 | } |
---|
3056 | $fechas_validacion['fin_texto'] = ''; |
---|
3057 | $fechas_validacion['inicio_texto'] = ''; |
---|
3058 | if ($fechas_validacion['inicio']) { |
---|
3059 | $f_aux = explode(' ', $fechas_validacion['inicio']); |
---|
3060 | $f_aux = explode('-', $f_aux[0]); |
---|
3061 | $fechas_validacion['inicio_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3062 | $fechas_validacion['inicio_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3063 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_i[0]['value']); |
---|
3064 | $f_aux = explode('-', $f_aux[0]); |
---|
3065 | $fechas_validacion['inicio_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3066 | $fechas_validacion['inicio_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3067 | } |
---|
3068 | if ($fechas_validacion['fin']) { |
---|
3069 | $f_aux = explode(' ', $fechas_validacion['fin']); |
---|
3070 | $f_aux = explode('-', $f_aux[0]); |
---|
3071 | $fechas_validacion['fin_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3072 | $fechas_validacion['fin_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3073 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_f[0]['value']); |
---|
3074 | $f_aux = explode('-', $f_aux[0]); |
---|
3075 | $fechas_validacion['fin_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3076 | $fechas_validacion['fin_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3077 | } |
---|
3078 | $form = array(); |
---|
3079 | $form['#fechas_validacion'] = $fechas_validacion; |
---|
3080 | $form['#montos_asignados'] = $montos_asignados; |
---|
3081 | $form['#count_ae'] = count($acciones_especificas); |
---|
3082 | $form['#node'] = $proyecto_leido; |
---|
3083 | $node_type = content_types('proyectos_operativos'); |
---|
3084 | $fields = $node_type['fields']; |
---|
3085 | $form['#proyecto_fields'] = $fields; |
---|
3086 | $form['#proyecto_anho'] = variable_get('proyectos_operativos_anho_creacion', 0) ? variable_get('proyectos_operativos_anho_creacion', 0) : date("Y"); |
---|
3087 | $field_form = array(); |
---|
3088 | $fields_form = array(); |
---|
3089 | $fields_extra_form = array(); |
---|
3090 | $arreglo = array( |
---|
3091 | 'field_proyecto_sector' => 'field_proyecto_sector', |
---|
3092 | ); |
---|
3093 | $fields_form_dg_se = array(); |
---|
3094 | if (is_array($fields) && count($fields)) { |
---|
3095 | foreach($fields as $field_id => $field) { |
---|
3096 | if (array_key_exists($field_id, $arreglo)) { |
---|
3097 | $field_form[] = $field_id; |
---|
3098 | $fields_form[] = $field_id; |
---|
3099 | } |
---|
3100 | elseif (variable_get('proyectos_operativos_dg_se_' . $field_id, FALSE)) { |
---|
3101 | $fields_form_dg_se[$field_id] = $field_id; |
---|
3102 | $field_form[] = $field_id; |
---|
3103 | $fields_form[] = $field_id; |
---|
3104 | } |
---|
3105 | } |
---|
3106 | } |
---|
3107 | if (is_array($field_form) && count($field_form)) { |
---|
3108 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3109 | foreach ($field_form as $field_id) { |
---|
3110 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3111 | $form['#field_info'][$field_id] = $field; |
---|
3112 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3113 | } |
---|
3114 | } |
---|
3115 | $arreglo = array( |
---|
3116 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
3117 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
3118 | 'field_proyecto_emindirecto' => 'field_proyecto_emindirecto', |
---|
3119 | 'field_proyecto_efindirecto' => 'field_proyecto_efindirecto', |
---|
3120 | ); |
---|
3121 | if (is_array($fields) && count($fields)) { |
---|
3122 | foreach($fields as $field_id => $field) { |
---|
3123 | if (array_key_exists($field_id, $arreglo)) { |
---|
3124 | $field_form[] = $field_id; |
---|
3125 | $fields_form[] = $field_id; |
---|
3126 | } |
---|
3127 | } |
---|
3128 | } |
---|
3129 | if (is_array($field_form) && count($field_form)) { |
---|
3130 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3131 | foreach ($field_form as $field_id) { |
---|
3132 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3133 | $form['#field_info'][$field_id] = $field; |
---|
3134 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3135 | } |
---|
3136 | } |
---|
3137 | if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { |
---|
3138 | $arreglo = array( |
---|
3139 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
3140 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
3141 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
3142 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
3143 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
3144 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
3145 | ); |
---|
3146 | $form['talento'] = array( |
---|
3147 | '#type' => 'fieldset', |
---|
3148 | '#title' => t('Talento Humano'), |
---|
3149 | ); |
---|
3150 | $prefixC = ''; |
---|
3151 | $fields_extra_form1 = array(); |
---|
3152 | foreach($arreglo as $field_id => $field) { |
---|
3153 | $fields_extra_form1[] = $field_id; |
---|
3154 | $prefixC .= '<th>' . $fields[$field_id]['widget']['label'] . '</th>'; |
---|
3155 | } |
---|
3156 | $fields_extra_form['talento'] = $fields_extra_form1; |
---|
3157 | $tamano_array = array(); |
---|
3158 | foreach($arreglo as $field_id => $field) { |
---|
3159 | $tamano_array[] = count($proyecto_leido->{$field_id}); |
---|
3160 | } |
---|
3161 | $cantidad_talento = max($tamano_array); |
---|
3162 | for ($i = 0; $i < $cantidad_talento; $i++) { |
---|
3163 | $prefix = ''; |
---|
3164 | if ($i == 0) { |
---|
3165 | $prefix = '<div id="talento-humano-modificar"><table><tr>' . $prefixC . '</tr><tr><td>'; |
---|
3166 | } |
---|
3167 | else { |
---|
3168 | $prefix .= '<tr><td>'; |
---|
3169 | } |
---|
3170 | $aux = ''; |
---|
3171 | $aui = ''; |
---|
3172 | foreach($arreglo as $field_id => $field) { |
---|
3173 | $valor_d = ($field_id == 'field_proyecto_esfuerzo') ? 0 : ''; |
---|
3174 | $form['talento'][$field_id . '_' . $i] = array( |
---|
3175 | '#type' => 'textfield', |
---|
3176 | '#default_value' => isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : $valor_d, |
---|
3177 | '#size' => 18, |
---|
3178 | '#maxlength' => $fields[$field_id]['max_length'], |
---|
3179 | '#prefix' => $prefix, |
---|
3180 | '#suffix' => '</td>', |
---|
3181 | ); |
---|
3182 | if ($field_id == 'field_proyecto_esfuerzo') { |
---|
3183 | $form['talento'][$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); |
---|
3184 | } |
---|
3185 | $aux = $field_id; |
---|
3186 | $aui = $i; |
---|
3187 | $prefix = '<td>'; |
---|
3188 | } |
---|
3189 | $form['talento'][$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
3190 | } |
---|
3191 | $form['talento'][$aux . '_' . $aui]['#suffix'] .= '</table>AAA'; |
---|
3192 | $form['talento']['cantidad_talento'] = array('#type' => 'hidden', '#value' => $cantidad_talento, '#suffix' => '</div>'); |
---|
3193 | $form['talento']['agrega_' . 'talento'] = array( |
---|
3194 | '#type' => 'submit', |
---|
3195 | '#default_value' => t('Agregar otro campo'), |
---|
3196 | '#weight' => 100, |
---|
3197 | '#ahah' => array( |
---|
3198 | 'path' => 'proyectos_operativos_proyecto_generales_agrega_talento_js_util/talento', |
---|
3199 | 'wrapper' => 'talento-humano-modificar', |
---|
3200 | 'method' => 'replace', |
---|
3201 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
3202 | ), |
---|
3203 | ); |
---|
3204 | } |
---|
3205 | if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { |
---|
3206 | $arreglo = array( |
---|
3207 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
3208 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
3209 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
3210 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
3211 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
3212 | ); |
---|
3213 | $form['capacidades'] = array( |
---|
3214 | '#type' => 'fieldset', |
---|
3215 | '#title' => t('Capacidades'), |
---|
3216 | ); |
---|
3217 | $prefixC = ''; |
---|
3218 | $fields_extra_form1 = array(); |
---|
3219 | $tamano_array = array(); |
---|
3220 | foreach($arreglo as $field_id => $field) { |
---|
3221 | $tamano_array[] = count($proyecto_leido->{$field_id}); |
---|
3222 | } |
---|
3223 | $cantidad_capacidades = max($tamano_array); |
---|
3224 | foreach($arreglo as $field_id => $field) { |
---|
3225 | $fields_extra_form1[] = $field_id; |
---|
3226 | $prefixC .= '<th>' . $fields[$field_id]['widget']['label'] . '</th>'; |
---|
3227 | } |
---|
3228 | $fields_extra_form['capacidades'] = $fields_extra_form1; |
---|
3229 | for ($i = 0; $i < $cantidad_capacidades; $i++) { |
---|
3230 | $prefix = ''; |
---|
3231 | if ($i == 0) { |
---|
3232 | $prefix = '<div id="capacidades-modificar"><table><tr>' . $prefixC . '</tr><tr><td>'; |
---|
3233 | } |
---|
3234 | else { |
---|
3235 | $prefix .= '<tr><td>'; |
---|
3236 | } |
---|
3237 | $aux = ''; |
---|
3238 | $aui = ''; |
---|
3239 | foreach($arreglo as $field_id => $field) { |
---|
3240 | $form['capacidades'][$field_id . '_' . $i] = array( |
---|
3241 | '#type' => 'textfield', |
---|
3242 | '#default_value' => isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : '', |
---|
3243 | '#size' => 18, |
---|
3244 | '#maxlength' => $fields[$field_id]['max_length'], |
---|
3245 | '#prefix' => $prefix, |
---|
3246 | '#suffix' => '</td>', |
---|
3247 | ); |
---|
3248 | $aux = $field_id; |
---|
3249 | $aui = $i; |
---|
3250 | $prefix = '<td>'; |
---|
3251 | } |
---|
3252 | $form['capacidades'][$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
3253 | } |
---|
3254 | $form['capacidades'][$aux . '_' . $aui]['#suffix'] .= '</table>'; |
---|
3255 | $form['capacidades']['cantidad_capacidades'] = array('#type' => 'hidden', '#value' => $cantidad_capacidades, '#suffix' => '</div>'); |
---|
3256 | $form['capacidades']['agrega_' . 'capacidades'] = array( |
---|
3257 | '#type' => 'submit', |
---|
3258 | '#default_value' => t('Agregar otro campo'), |
---|
3259 | '#weight' => 100, |
---|
3260 | '#ahah' => array( |
---|
3261 | 'path' => 'proyectos_operativos_proyecto_generales_agrega_talento_js_util/capacidades', |
---|
3262 | 'wrapper' => 'capacidades-modificar', |
---|
3263 | 'method' => 'replace', |
---|
3264 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
3265 | ), |
---|
3266 | ); |
---|
3267 | } |
---|
3268 | $field_form = array(); |
---|
3269 | $arreglo = array( |
---|
3270 | 'field_proyecto_relacion' => 'field_proyecto_relacion', |
---|
3271 | ); |
---|
3272 | $fields_form_dg_r = array(); |
---|
3273 | if (is_array($fields) && count($fields)) { |
---|
3274 | foreach($fields as $field_id => $field) { |
---|
3275 | if (array_key_exists($field_id, $arreglo)) { |
---|
3276 | $field_form[] = $field_id; |
---|
3277 | $fields_form[] = $field_id; |
---|
3278 | } |
---|
3279 | elseif (variable_get('proyectos_operativos_dg_r_' . $field_id, FALSE)) { |
---|
3280 | $fields_form_dg_r[$field_id] = $field_id; |
---|
3281 | $field_form[] = $field_id; |
---|
3282 | $fields_form[] = $field_id; |
---|
3283 | } |
---|
3284 | } |
---|
3285 | } |
---|
3286 | if (is_array($field_form) && count($field_form)) { |
---|
3287 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3288 | foreach ($field_form as $field_id) { |
---|
3289 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3290 | $form['#field_info'][$field_id] = $field; |
---|
3291 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3292 | } |
---|
3293 | } |
---|
3294 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { |
---|
3295 | $arreglo = array( |
---|
3296 | 'field_proyecto_beneficiario' => 'field_proyecto_beneficiario', |
---|
3297 | 'field_proyectos_masculino_d' => 'field_proyectos_masculino_d', |
---|
3298 | 'field_proyectos_femenino_d' => 'field_proyectos_femenino_d', |
---|
3299 | ); |
---|
3300 | if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { |
---|
3301 | $arreglo['field_proyectos_masculino_i'] = 'field_proyectos_masculino_i'; |
---|
3302 | $arreglo['field_proyectos_femenino_i'] = 'field_proyectos_femenino_i'; |
---|
3303 | } |
---|
3304 | |
---|
3305 | |
---|
3306 | $form['beneficiario'] = array( |
---|
3307 | '#type' => 'fieldset', |
---|
3308 | '#title' => t('Beneficiario'), |
---|
3309 | ); |
---|
3310 | $prefixC = ''; |
---|
3311 | $fields_extra_form1 = array(); |
---|
3312 | foreach($arreglo as $field_id => $field) { |
---|
3313 | $fields_extra_form1[] = $field_id; |
---|
3314 | $prefixC .= '<th>' . $fields[$field_id]['widget']['label'] . '</th>'; |
---|
3315 | } |
---|
3316 | $prefixC .= '<th>' . t('Total') . '</th>'; |
---|
3317 | $fields_extra_form['beneficiario'] = $fields_extra_form1; |
---|
3318 | $totales = 0; |
---|
3319 | $total_arreglo = array(); |
---|
3320 | $sumas['beneficiarios'] = array(); |
---|
3321 | $vid = variable_get('proyectos_operativos_extra_bene', 0); |
---|
3322 | //$terms = taxonomy_get_tree($vid); |
---|
3323 | $tree = taxonomy_get_tree($vid); |
---|
3324 | $options = array(); |
---|
3325 | $options[''] = t('Seleccionar'); |
---|
3326 | if ($tree) { |
---|
3327 | foreach ($tree as $term) { |
---|
3328 | $options[$term->name] = $term->name; |
---|
3329 | } |
---|
3330 | } |
---|
3331 | $tamano_array = array(); |
---|
3332 | foreach($arreglo as $field_id => $field) { |
---|
3333 | $tamano_array[] = count($proyecto_leido->{$field_id}); |
---|
3334 | } |
---|
3335 | $cantidad_beneficiario = max($tamano_array); |
---|
3336 | for ($i = 0; $i < $cantidad_beneficiario; $i++) { |
---|
3337 | $subtotal = 0; |
---|
3338 | $prefix = ''; |
---|
3339 | if ($i == 0) { |
---|
3340 | $prefix = '<div id="beneficiario-modificar"><table align="center"><tr>' . $prefixC . '</tr><tr><td>'; |
---|
3341 | } |
---|
3342 | else { |
---|
3343 | $prefix .= '<tr><td>'; |
---|
3344 | } |
---|
3345 | $aux = ''; |
---|
3346 | $aui = ''; |
---|
3347 | foreach($arreglo as $field_id => $field) { |
---|
3348 | $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : ''; |
---|
3349 | if ($field_id == 'field_proyecto_beneficiario') { |
---|
3350 | $form['beneficiario'][$field_id . '_' . $i] = array( |
---|
3351 | '#type' => 'select', |
---|
3352 | '#default_value' => $valor, |
---|
3353 | '#options' => $options, |
---|
3354 | '#prefix' => $prefix, |
---|
3355 | '#suffix' => '</td>', |
---|
3356 | ); |
---|
3357 | } |
---|
3358 | else { |
---|
3359 | $form['beneficiario'][$field_id . '_' . $i] = array( |
---|
3360 | '#type' => 'textfield', |
---|
3361 | '#default_value' => $valor, |
---|
3362 | '#size' => 10, |
---|
3363 | '#maxlength' => $fields[$field_id]['max_length'], |
---|
3364 | '#prefix' => $prefix, |
---|
3365 | '#suffix' => '</td>', |
---|
3366 | ); |
---|
3367 | } |
---|
3368 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
3369 | if (!isset($total_arreglo[$field_id])) { |
---|
3370 | $total_arreglo[$field_id] = 0; |
---|
3371 | } |
---|
3372 | $subtotal += (int) $valor; |
---|
3373 | $totales += (int) $valor; |
---|
3374 | $total_arreglo[$field_id] += (int) $valor; |
---|
3375 | $sumas['beneficiarios']['beneficiario_' . $i] = 'beneficiario_' . $i; |
---|
3376 | $form['beneficiario'][$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); |
---|
3377 | $form['beneficiario'][$field_id . '_' . $i]['#attributes'] = array('class' => 'number beneficiario_' . $i . ' todosbeneficiarios beneficiarios_' . $field_id, 'onchange' => "sumabeneficiario('beneficiario_$i');sumabeneficiario('todosbeneficiarios');sumabeneficiario('beneficiarios_$field_id');"); |
---|
3378 | } |
---|
3379 | $aux = $field_id; |
---|
3380 | $aui = $i; |
---|
3381 | $prefix = '<td align="center">'; |
---|
3382 | } |
---|
3383 | $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="beneficiario_' . $i . '_total">' . $subtotal . '</div></td>'; |
---|
3384 | $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '</tr>'; |
---|
3385 | } |
---|
3386 | $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '<tr align="right"><td><b>' . t('TOTAL') . '</b></td>'; |
---|
3387 | foreach($arreglo as $field_id => $field) { |
---|
3388 | if ($field_id != 'field_proyecto_beneficiario') { |
---|
3389 | $sumas['beneficiarios']['beneficiarios_' . $field_id] = 'beneficiarios_' . $field_id; |
---|
3390 | $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="beneficiarios_' . $field_id . '_total">' . $total_arreglo[$field_id] . '</div></td>'; |
---|
3391 | } |
---|
3392 | } |
---|
3393 | $sumas['beneficiarios']['todosbeneficiarios'] = 'todosbeneficiarios'; |
---|
3394 | $sumas['beneficiarios']['empleos_generados'] = 'empleos_generados'; |
---|
3395 | drupal_add_js($sumas, 'setting'); |
---|
3396 | $form['#sumas'] = $sumas; |
---|
3397 | $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '<td align="center"><div class="todosbeneficiarios_total">' . $totales . '</div></td></tr>'; |
---|
3398 | $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '</table>'; |
---|
3399 | $form['beneficiario']['cantidad_beneficiario'] = array('#type' => 'hidden', '#value' => $cantidad_beneficiario, '#suffix' => '</div>'); |
---|
3400 | $form['beneficiario']['agrega_' . 'beneficiario'] = array( |
---|
3401 | '#type' => 'submit', |
---|
3402 | '#default_value' => t('Agregar otro campo'), |
---|
3403 | '#weight' => 100, |
---|
3404 | '#ahah' => array( |
---|
3405 | 'path' => 'proyectos_operativos_proyecto_generales_agrega_talento_js_util/beneficiario', |
---|
3406 | 'wrapper' => 'beneficiario-modificar', |
---|
3407 | 'method' => 'replace', |
---|
3408 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
3409 | ), |
---|
3410 | ); |
---|
3411 | } |
---|
3412 | $field_form = array(); |
---|
3413 | $arreglo = array( |
---|
3414 | 'field_proyecto_og' => 'field_proyecto_og', |
---|
3415 | 'field_proyecto_oe' => 'field_proyecto_oe', |
---|
3416 | ); |
---|
3417 | $fields_form_dg_o = array(); |
---|
3418 | if (is_array($fields) && count($fields)) { |
---|
3419 | foreach($fields as $field_id => $field) { |
---|
3420 | if (array_key_exists($field_id, $arreglo)) { |
---|
3421 | $field_form[] = $field_id; |
---|
3422 | $fields_form[] = $field_id; |
---|
3423 | } |
---|
3424 | elseif (variable_get('proyectos_operativos_dg_o_' . $field_id, FALSE)) { |
---|
3425 | $fields_form_dg_o[$field_id] = $field_id; |
---|
3426 | $field_form[] = $field_id; |
---|
3427 | $fields_form[] = $field_id; |
---|
3428 | } |
---|
3429 | } |
---|
3430 | } |
---|
3431 | $form['#format_number'] = array('format_number' => $format_number); |
---|
3432 | drupal_add_js($form['#format_number'], 'setting'); |
---|
3433 | $form['#proyectos_operativos_fields_extra'] = $fields_extra_form; |
---|
3434 | $form['#fields_form_dg_o'] = $fields_form_dg_o; |
---|
3435 | $form['#fields_form_dg_se'] = $fields_form_dg_se; |
---|
3436 | $form['#fields_form_dg_r'] = $fields_form_dg_r; |
---|
3437 | $form['#proyectos_operativos_fields_extra'] = $fields_extra_form; |
---|
3438 | $form['#proyectos_operativos_fields'] = $fields_form; |
---|
3439 | if (is_array($field_form) && count($field_form)) { |
---|
3440 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3441 | foreach ($field_form as $field_id) { |
---|
3442 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3443 | $form['#field_info'][$field_id] = $field; |
---|
3444 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3445 | } |
---|
3446 | } |
---|
3447 | $form['buttons'] = array( |
---|
3448 | '#prefix' => '<div class="container-inline">', |
---|
3449 | '#suffix' => '</div>', |
---|
3450 | ); |
---|
3451 | $form['buttons']['registrar'] = array( |
---|
3452 | '#type' => 'submit', |
---|
3453 | '#default_value' => t('Aceptar'), |
---|
3454 | '#weight' => 100, |
---|
3455 | ); |
---|
3456 | $form['buttons']['cancelar'] = array( |
---|
3457 | '#type' => 'submit', |
---|
3458 | '#default_value' => t('Cancelar'), |
---|
3459 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
3460 | '#weight' => 101, |
---|
3461 | ); |
---|
3462 | $form['#submit'] = array('proyectos_operativos_proyecto_generales_form_submit'); |
---|
3463 | return $form; |
---|
3464 | } |
---|
3465 | |
---|
3466 | /** |
---|
3467 | * Implementation of proyectos_operativos_number_integer_validate2(). |
---|
3468 | * Validar si el dato suministrado es un entero. |
---|
3469 | */ |
---|
3470 | function proyectos_operativos_number_integer_validate2($element, &$form_state) { |
---|
3471 | $start = $element['#value']; |
---|
3472 | $value = preg_replace('@[^-0-9]@', '', $start); |
---|
3473 | if ($start != $value) { |
---|
3474 | $fielda = explode('_', $element['#name']); |
---|
3475 | $i = array_pop($fielda); |
---|
3476 | $field = implode('_', $fielda); |
---|
3477 | form_set_error($field . '_' . $i, t('Solo números enteros son permitidos')); |
---|
3478 | } |
---|
3479 | } |
---|
3480 | |
---|
3481 | |
---|
3482 | /** |
---|
3483 | * Implementation of proyectos_operativos_proyecto_generales_form_validate(). |
---|
3484 | * Validar formulario de datos generales (proyectos operativos). |
---|
3485 | */ |
---|
3486 | function proyectos_operativos_proyecto_generales_form_validate($form, &$form_state) { |
---|
3487 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
3488 | if ($op == t('Cancelar')) { |
---|
3489 | return; |
---|
3490 | } |
---|
3491 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
3492 | drupal_add_js($form['#format_number'], 'setting'); |
---|
3493 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
3494 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_generales.js'); |
---|
3495 | drupal_add_js($form['#sumas'], 'setting'); |
---|
3496 | if (count($form['#proyectos_operativos_fields_extra'])) { |
---|
3497 | foreach($form['#proyectos_operativos_fields_extra'] as $id => $arreglo) { |
---|
3498 | $all_null = TRUE; |
---|
3499 | $cantidad = $form_state['values']['cantidad_' . $id]; |
---|
3500 | for($i = 0; $i < $cantidad; $i++) { |
---|
3501 | $null = TRUE; |
---|
3502 | $first_campo = FALSE; |
---|
3503 | $suma = 0; |
---|
3504 | foreach($arreglo as $campo) { |
---|
3505 | if (!$first_campo) { |
---|
3506 | $first_campo = $campo; |
---|
3507 | } |
---|
3508 | if ($form_state['values'][$campo . '_' . $i] && trim($form_state['values'][$campo . '_' . $i]) != '') { |
---|
3509 | $all_null = FALSE; |
---|
3510 | $null = FALSE; |
---|
3511 | } |
---|
3512 | if ($campo == 'field_proyecto_esfuerzo' || $campo == 'field_proyectos_masculino_d' || $campo == 'field_proyectos_masculino_i' || $campo == 'field_proyectos_femenino_d' || $campo == 'field_proyectos_femenino_i') { |
---|
3513 | $start = $form_state['values'][$campo . '_' . $i]; |
---|
3514 | $value = (int) $start; |
---|
3515 | $suma += $value; |
---|
3516 | if ($start != $value) { |
---|
3517 | form_set_error($campo . '_' . $i, t('Solo números enteros son permitidos en el campo %field.' . $start, array('%field' => t($form['#proyecto_fields'][$campo]['widget']['label'])))); |
---|
3518 | } |
---|
3519 | elseif ($value < 0) { |
---|
3520 | form_set_error($campo . '_' . $i, t('Solo números enteros positivos son permitidos en el campo %field.' . $start, array('%field' => t($form['#proyecto_fields'][$campo]['widget']['label'])))); |
---|
3521 | } |
---|
3522 | } |
---|
3523 | } |
---|
3524 | if (!$null) { |
---|
3525 | foreach($arreglo as $campo) { |
---|
3526 | if (trim($form_state['values'][$campo . '_' . $i]) == '') { |
---|
3527 | form_set_error($campo . '_' . $i, t('El campo @campo_name no puede estar vacio', array('@campo_name' => $form['#proyecto_fields'][$campo]['widget']['label']))); |
---|
3528 | } |
---|
3529 | elseif($campo == 'field_proyecto_beneficiario' && ($suma < 0 || !$suma)) { |
---|
3530 | form_set_error($campo . '_' . $i, t('La suma de @campo_name debe ser mayor que cero', array('@campo_name' => $form['#proyecto_fields'][$campo]['widget']['label']))); |
---|
3531 | } |
---|
3532 | } |
---|
3533 | } |
---|
3534 | } |
---|
3535 | if ($all_null) { |
---|
3536 | form_set_error($first_campo . '_0', t('Debe llenar al menos un campo')); |
---|
3537 | } |
---|
3538 | } |
---|
3539 | } |
---|
3540 | } |
---|
3541 | |
---|
3542 | /** |
---|
3543 | * Implementation of proyectos_operativos_proyecto_generales_form_submit(). |
---|
3544 | * Guardar formulario de datos generales (proyectos operativos). |
---|
3545 | */ |
---|
3546 | function proyectos_operativos_proyecto_generales_form_submit($form, &$form_state) { |
---|
3547 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
3548 | if ($op == t('Cancelar')) { |
---|
3549 | drupal_set_message(t('Se cancelo el ingreso de los datos generales del proyecto.')); |
---|
3550 | $form_state['redirect'] = 'proyectosopedit/' . $form['#node']->nid; |
---|
3551 | return; |
---|
3552 | } |
---|
3553 | if (module_exists('hs_content_taxonomy')) { |
---|
3554 | foreach ($form['#field_info'] as $field_name => $field_info) { |
---|
3555 | if ($field_info['widget']['type'] == 'content_taxonomy_hs') { |
---|
3556 | // Change format of values to the one Content Taxonomy expects |
---|
3557 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
3558 | $values = array(); |
---|
3559 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
3560 | $values[] = array('value' => $tid); |
---|
3561 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
3562 | } |
---|
3563 | $form_state['values'][$field_name]['tids'] = $values; |
---|
3564 | } |
---|
3565 | else { |
---|
3566 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
3567 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
3568 | $form_state['values'][$field_name]['tids'] = $values; |
---|
3569 | } |
---|
3570 | } |
---|
3571 | } |
---|
3572 | } |
---|
3573 | $field_form = $form['#proyectos_operativos_fields']; |
---|
3574 | module_load_include('inc', 'node', 'node.pages'); |
---|
3575 | $node_load = $form['#node']; |
---|
3576 | if (count($form['#proyectos_operativos_fields_extra'])) { |
---|
3577 | foreach($form['#proyectos_operativos_fields_extra'] as $id => $arreglo) { |
---|
3578 | foreach($arreglo as $campo) { |
---|
3579 | $node_load->{$campo} = array(); |
---|
3580 | } |
---|
3581 | $all_null = TRUE; |
---|
3582 | $cantidad = $form_state['values']['cantidad_' . $id]; |
---|
3583 | for($i = 0; $i < $cantidad; $i++) { |
---|
3584 | $null = TRUE; |
---|
3585 | $first_campo = FALSE; |
---|
3586 | foreach($arreglo as $campo) { |
---|
3587 | if (!$first_campo) { |
---|
3588 | $first_campo = $campo; |
---|
3589 | } |
---|
3590 | if (trim($form_state['values'][$campo . '_' . $i]) != '') { |
---|
3591 | $all_null = FALSE; |
---|
3592 | $null = FALSE; |
---|
3593 | } |
---|
3594 | } |
---|
3595 | if (!$null) { |
---|
3596 | foreach($arreglo as $campo) { |
---|
3597 | $node_load->{$campo}[] = array('value' => trim($form_state['values'][$campo . '_' . $i])); |
---|
3598 | } |
---|
3599 | } |
---|
3600 | } |
---|
3601 | } |
---|
3602 | } |
---|
3603 | $form_values = $form_state['values']; |
---|
3604 | if (is_array($field_form) && count($field_form)) { |
---|
3605 | foreach ($field_form as $field_id) { |
---|
3606 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
3607 | foreach($form_values[$field_id] as $id => $value) { |
---|
3608 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
3609 | unset($form_values[$field_id][$id]['_error_element']); |
---|
3610 | } |
---|
3611 | } |
---|
3612 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
3613 | } |
---|
3614 | } |
---|
3615 | } |
---|
3616 | if ($node_load->nid) { |
---|
3617 | $texto = t('Modificados los datos generales del proyecto'); |
---|
3618 | $node_load->log = $texto; |
---|
3619 | drupal_set_message($texto); |
---|
3620 | } |
---|
3621 | else { |
---|
3622 | $texto = t('Agregados los datos generales del proyecto'); |
---|
3623 | $node_load->log = $texto; |
---|
3624 | drupal_set_message($texto); |
---|
3625 | } |
---|
3626 | $node_load->revision = 1; |
---|
3627 | node_save($node_load); |
---|
3628 | if ($_REQUEST['destination']) { |
---|
3629 | $form_state['redirect'] = url('proyectosopedit/' . $node_load->nid . '/indicadores', |
---|
3630 | array( |
---|
3631 | 'query' => array( |
---|
3632 | 'destination' => $_REQUEST['destination'], |
---|
3633 | ), |
---|
3634 | 'absolute' => TRUE, |
---|
3635 | ) |
---|
3636 | ); |
---|
3637 | unset($_REQUEST['destination']); |
---|
3638 | } |
---|
3639 | else { |
---|
3640 | // add redirect |
---|
3641 | $form_state['redirect'] = 'proyectosopedit/' . $node_load->nid . '/indicadores'; |
---|
3642 | } |
---|
3643 | } |
---|
3644 | |
---|
3645 | /** |
---|
3646 | * Implementation of proyectos_operativos_proyecto_indicadores_form(). |
---|
3647 | * Formulario de indicadores (proyectos operativos). |
---|
3648 | */ |
---|
3649 | function proyectos_operativos_proyecto_indicadores_form(&$form_state, $proyecto = 0) { |
---|
3650 | global $user; |
---|
3651 | //add breadcrumb |
---|
3652 | $breadcrumb = array(); |
---|
3653 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
3654 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
3655 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
3656 | $breadcrumb[] = 'Indicadores del Proyecto'; // Link to current URL |
---|
3657 | drupal_set_breadcrumb($breadcrumb); |
---|
3658 | $current_time = time(); |
---|
3659 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
3660 | $fecha = FALSE; |
---|
3661 | $ente = usuario_tiene_ente($user->uid); |
---|
3662 | $ente_planificador = 0; |
---|
3663 | if ($ente && $ente->nid) { |
---|
3664 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
3665 | } |
---|
3666 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
3667 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
3668 | $fecha = TRUE; |
---|
3669 | } |
---|
3670 | if (!$fecha) { |
---|
3671 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
3672 | } |
---|
3673 | if ($fecha && $ente->nid) { |
---|
3674 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
3675 | } |
---|
3676 | if (!$proyecto) { |
---|
3677 | $proyecto_leido = new stdClass(); |
---|
3678 | $proyecto_leido->type = 'proyectos_operativos'; |
---|
3679 | } |
---|
3680 | else { |
---|
3681 | $proyecto_leido = $proyecto; |
---|
3682 | if (isset($proyecto->field_proyecto_accion_esp)){ |
---|
3683 | foreach($proyecto->field_proyecto_accion_esp as $accion) { |
---|
3684 | if ($accion['nid']) { |
---|
3685 | $accion_load = node_load($accion['nid']); |
---|
3686 | if ($accion_load && ($fechas_validacion['inicio'] == '' || $accion_load->field_accion_esp_fechai[0]['value'] < $fechas_validacion['inicio'])) { |
---|
3687 | $fechas_validacion['inicio'] = $accion_load->field_accion_esp_fechai[0]['value']; |
---|
3688 | } |
---|
3689 | if ($accion_load && ($fechas_validacion['fin'] == '' || $accion_load->field_accion_esp_fechaf[0]['value'] > $fechas_validacion['fin'])) { |
---|
3690 | $fechas_validacion['fin'] = $accion_load->field_accion_esp_fechaf[0]['value']; |
---|
3691 | } |
---|
3692 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
3693 | if ($accion_load->field_accion_esp_programacion[0]['tid']) { |
---|
3694 | foreach($accion_load->field_accion_esp_programacion as $programacion) { |
---|
3695 | foreach($programacion as $id_value => $mesp){ |
---|
3696 | if ($id_value != 'tid') { |
---|
3697 | $montos_asignados +=$mesp; |
---|
3698 | } |
---|
3699 | } |
---|
3700 | } |
---|
3701 | } |
---|
3702 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
3703 | $porcentajes[$accion_load->field_accion_esp_ponderacion[0]['value']] = 1; |
---|
3704 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
3705 | } |
---|
3706 | } |
---|
3707 | } |
---|
3708 | } |
---|
3709 | } |
---|
3710 | $fechas_validacion['fin_texto'] = ''; |
---|
3711 | $fechas_validacion['inicio_texto'] = ''; |
---|
3712 | if ($fechas_validacion['inicio']) { |
---|
3713 | $f_aux = explode(' ', $fechas_validacion['inicio']); |
---|
3714 | $f_aux = explode('-', $f_aux[0]); |
---|
3715 | $fechas_validacion['inicio_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3716 | $fechas_validacion['inicio_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3717 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_i[0]['value']); |
---|
3718 | $f_aux = explode('-', $f_aux[0]); |
---|
3719 | $fechas_validacion['inicio_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3720 | $fechas_validacion['inicio_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3721 | } |
---|
3722 | if ($fechas_validacion['fin']) { |
---|
3723 | $f_aux = explode(' ', $fechas_validacion['fin']); |
---|
3724 | $f_aux = explode('-', $f_aux[0]); |
---|
3725 | $fechas_validacion['fin_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3726 | $fechas_validacion['fin_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3727 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_f[0]['value']); |
---|
3728 | $f_aux = explode('-', $f_aux[0]); |
---|
3729 | $fechas_validacion['fin_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
3730 | $fechas_validacion['fin_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
3731 | } |
---|
3732 | $form = array(); |
---|
3733 | $form['#fechas_validacion'] = $fechas_validacion; |
---|
3734 | $form['#montos_asignados'] = $montos_asignados; |
---|
3735 | $form['#count_ae'] = count($acciones_especificas); |
---|
3736 | $form['#node'] = $proyecto_leido; |
---|
3737 | $node_type = content_types('proyectos_operativos'); |
---|
3738 | $fields = $node_type['fields']; |
---|
3739 | $field_form = array(); |
---|
3740 | $fields_form = array(); |
---|
3741 | if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { |
---|
3742 | $arreglo = array( |
---|
3743 | 'field_proyecto_causas' => 'field_proyecto_causas', |
---|
3744 | 'field_proyecto_problemas' => 'field_proyecto_problemas', |
---|
3745 | 'field_proyecto_consecuencias' => 'field_proyecto_consecuencias', |
---|
3746 | ); |
---|
3747 | $fields_form_ip_in = array(); |
---|
3748 | if (is_array($fields) && count($fields)) { |
---|
3749 | foreach($fields as $field_id => $field) { |
---|
3750 | if (array_key_exists($field_id, $arreglo)) { |
---|
3751 | $field_form[] = $field_id; |
---|
3752 | $fields_form[] = $field_id; |
---|
3753 | } |
---|
3754 | elseif (variable_get('proyectos_operativos_ip_in_' . $field_id, FALSE)) { |
---|
3755 | $fields_form_ip_in[$field_id] = $field_id; |
---|
3756 | $field_form[] = $field_id; |
---|
3757 | $fields_form[] = $field_id; |
---|
3758 | } |
---|
3759 | } |
---|
3760 | } |
---|
3761 | $form['#datos_institucionales_fields_datos1'] = $field_form; |
---|
3762 | if (is_array($field_form) && count($field_form)) { |
---|
3763 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3764 | foreach ($field_form as $field_id) { |
---|
3765 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3766 | $form['#field_info'][$field_id] = $field; |
---|
3767 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3768 | } |
---|
3769 | } |
---|
3770 | } |
---|
3771 | if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { |
---|
3772 | $field_form = array(); |
---|
3773 | $arreglo = array( |
---|
3774 | 'field_proyecto_justificacion' => 'field_proyecto_justificacion', |
---|
3775 | ); |
---|
3776 | $fields_form_ip_ju = array(); |
---|
3777 | if (is_array($fields) && count($fields)) { |
---|
3778 | foreach($fields as $field_id => $field) { |
---|
3779 | if (array_key_exists($field_id, $arreglo)) { |
---|
3780 | $field_form[] = $field_id; |
---|
3781 | $fields_form[] = $field_id; |
---|
3782 | } |
---|
3783 | elseif (variable_get('proyectos_operativos_ip_ju_' . $field_id, FALSE)) { |
---|
3784 | $fields_form_ip_ju[$field_id] = $field_id; |
---|
3785 | $field_form[] = $field_id; |
---|
3786 | $fields_form[] = $field_id; |
---|
3787 | } |
---|
3788 | } |
---|
3789 | } |
---|
3790 | $form['#datos_institucionales_fields_datosds'] = $field_form; |
---|
3791 | if (is_array($field_form) && count($field_form)) { |
---|
3792 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3793 | foreach ($field_form as $field_id) { |
---|
3794 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3795 | $form['#field_info'][$field_id] = $field; |
---|
3796 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3797 | } |
---|
3798 | } |
---|
3799 | } |
---|
3800 | if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { |
---|
3801 | $field_form = array(); |
---|
3802 | $arreglo = array( |
---|
3803 | 'field_proyecto_alcance' => 'field_proyecto_alcance', |
---|
3804 | ); |
---|
3805 | $fields_form_ip_al = array(); |
---|
3806 | if (is_array($fields) && count($fields)) { |
---|
3807 | foreach($fields as $field_id => $field) { |
---|
3808 | if (array_key_exists($field_id, $arreglo)) { |
---|
3809 | $field_form[] = $field_id; |
---|
3810 | $fields_form[] = $field_id; |
---|
3811 | } |
---|
3812 | elseif (variable_get('proyectos_operativos_ip_al_' . $field_id, FALSE)) { |
---|
3813 | $fields_form_ip_al[$field_id] = $field_id; |
---|
3814 | $field_form[] = $field_id; |
---|
3815 | $fields_form[] = $field_id; |
---|
3816 | } |
---|
3817 | } |
---|
3818 | } |
---|
3819 | $form['#datos_institucionales_fields_datosds1'] = $field_form; |
---|
3820 | if (is_array($field_form) && count($field_form)) { |
---|
3821 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3822 | foreach ($field_form as $field_id) { |
---|
3823 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3824 | $form['#field_info'][$field_id] = $field; |
---|
3825 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3826 | } |
---|
3827 | } |
---|
3828 | } |
---|
3829 | $sa = variable_get('proyectos_operativos_muestra_sa', TRUE); |
---|
3830 | $so = variable_get('proyectos_operativos_muestra_so', TRUE); |
---|
3831 | if ($sa || $so) { |
---|
3832 | $form['indicador'] = array( |
---|
3833 | '#type' => 'fieldset', |
---|
3834 | '#title' => t('Indicador de la Situación'), |
---|
3835 | ); |
---|
3836 | } |
---|
3837 | if ($sa) { |
---|
3838 | $field_form = array(); |
---|
3839 | $arreglo = array( |
---|
3840 | 'field_proyecto_sa_descripcion' => 'field_proyecto_sa_descripcion', |
---|
3841 | ); |
---|
3842 | if (variable_get('proyectos_operativos_muestra_sa_cuantificacion', TRUE)) { |
---|
3843 | $arreglo['field_proyecto_sa_cuantificacion'] = 'field_proyecto_sa_cuantificacion'; |
---|
3844 | } |
---|
3845 | $arreglo['field_proyecto_sa_formulai'] = 'field_proyecto_sa_formulai'; |
---|
3846 | $arreglo['field_proyecto_sa_fuentei'] = 'field_proyecto_sa_fuentei'; |
---|
3847 | $arreglo['field_proyecto_sa_fecha'] = 'field_proyecto_sa_fecha'; |
---|
3848 | $fields_form_ip_sa = array(); |
---|
3849 | if (is_array($fields) && count($fields)) { |
---|
3850 | foreach($fields as $field_id => $field) { |
---|
3851 | if (array_key_exists($field_id, $arreglo)) { |
---|
3852 | $field_form[] = $field_id; |
---|
3853 | $fields_form[] = $field_id; |
---|
3854 | } |
---|
3855 | elseif (variable_get('proyectos_operativos_ip_sa_' . $field_id, FALSE)) { |
---|
3856 | $fields_form_ip_sa[$field_id] = $field_id; |
---|
3857 | $field_form[] = $field_id; |
---|
3858 | $fields_form[] = $field_id; |
---|
3859 | } |
---|
3860 | } |
---|
3861 | } |
---|
3862 | $form['indicador']['sa'] = array( |
---|
3863 | '#type' => 'fieldset', |
---|
3864 | '#title' => t('Situación Actual'), |
---|
3865 | ); |
---|
3866 | $form['#datos_institucionales_fields_datosds1'] = $field_form; |
---|
3867 | if (is_array($field_form) && count($field_form)) { |
---|
3868 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3869 | foreach ($field_form as $field_id) { |
---|
3870 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3871 | $form['#field_info'][$field_id] = $field; |
---|
3872 | $form['indicador']['sa'] += (array) content_field_form($form, $form_state, $field); |
---|
3873 | } |
---|
3874 | } |
---|
3875 | } |
---|
3876 | if ($so) { |
---|
3877 | $field_form = array(); |
---|
3878 | $arreglo = array( |
---|
3879 | 'field_proyecto_so_descripcion' => 'field_proyecto_so_descripcion', |
---|
3880 | 'field_proyecto_so_cuantificacion' => 'field_proyecto_so_cuantificacion', |
---|
3881 | 'field_proyecto_tiempoi' => 'field_proyecto_tiempoi', |
---|
3882 | ); |
---|
3883 | $fields_form_ip_so = array(); |
---|
3884 | if (is_array($fields) && count($fields)) { |
---|
3885 | foreach($fields as $field_id => $field) { |
---|
3886 | if (array_key_exists($field_id, $arreglo)) { |
---|
3887 | $field_form[] = $field_id; |
---|
3888 | $fields_form[] = $field_id; |
---|
3889 | } |
---|
3890 | elseif (variable_get('proyectos_operativos_ip_so_' . $field_id, FALSE)) { |
---|
3891 | $fields_form_ip_so[$field_id] = $field_id; |
---|
3892 | $field_form[] = $field_id; |
---|
3893 | $fields_form[] = $field_id; |
---|
3894 | } |
---|
3895 | } |
---|
3896 | } |
---|
3897 | $form['indicador']['so'] = array( |
---|
3898 | '#type' => 'fieldset', |
---|
3899 | '#title' => t('Situación Objetivo'), |
---|
3900 | ); |
---|
3901 | $form['#datos_institucionales_fields_datosds1'] = $field_form; |
---|
3902 | if (is_array($field_form) && count($field_form)) { |
---|
3903 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3904 | foreach ($field_form as $field_id) { |
---|
3905 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3906 | $form['#field_info'][$field_id] = $field; |
---|
3907 | $form['indicador']['so'] += (array) content_field_form($form, $form_state, $field); |
---|
3908 | } |
---|
3909 | } |
---|
3910 | } |
---|
3911 | $field_form = array(); |
---|
3912 | $arreglo = array(); |
---|
3913 | $arreglo['field_proyecto_descripcion_bien'] = 'field_proyecto_descripcion_bien'; |
---|
3914 | $arreglo['field_proyecto_unidadm'] = 'field_proyecto_unidadm'; |
---|
3915 | $personas = variable_get('proyectos_operativos_allow_unidpersona', array()); |
---|
3916 | if (count($personas)) { |
---|
3917 | $arreglo['field_proyecto_meta_m'] = 'field_proyecto_meta_m'; |
---|
3918 | $arreglo['field_proyecto_meta_f'] = 'field_proyecto_meta_f'; |
---|
3919 | } |
---|
3920 | $form['#personas'] = $personas; |
---|
3921 | $arreglo['field_proyecto_meta_fisica'] = 'field_proyecto_meta_fisica'; |
---|
3922 | |
---|
3923 | $fields_form_ip_re = array(); |
---|
3924 | if (is_array($fields) && count($fields)) { |
---|
3925 | foreach($fields as $field_id => $field) { |
---|
3926 | if (array_key_exists($field_id, $arreglo)) { |
---|
3927 | $field_form[] = $field_id; |
---|
3928 | $fields_form[] = $field_id; |
---|
3929 | } |
---|
3930 | elseif (variable_get('proyectos_operativos_ip_re_' . $field_id, FALSE)) { |
---|
3931 | $fields_form_ip_re[$field_id] = $field_id; |
---|
3932 | $field_form[] = $field_id; |
---|
3933 | $fields_form[] = $field_id; |
---|
3934 | } |
---|
3935 | } |
---|
3936 | } |
---|
3937 | if (is_array($field_form) && count($field_form)) { |
---|
3938 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
3939 | foreach ($field_form as $field_id) { |
---|
3940 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
3941 | $form['#field_info'][$field_id] = $field; |
---|
3942 | $form += (array) content_field_form($form, $form_state, $field); |
---|
3943 | } |
---|
3944 | } |
---|
3945 | //obtener la fecha de inicio y fin |
---|
3946 | $mes = explode('-', $form['#node']->field_proyecto_fecha_i[0]['value']); |
---|
3947 | $mes_inicio = 0; |
---|
3948 | if (count($mes)) { |
---|
3949 | $mes_inicio = $mes[1] - 1; |
---|
3950 | } |
---|
3951 | //obtener la fecha de inicio y fin |
---|
3952 | $mes = explode('-', $form['#node']->field_proyecto_fecha_f[0]['value']); |
---|
3953 | $mes_final = 0; |
---|
3954 | if (count($mes)) { |
---|
3955 | $mes_final = $mes[1] - 1; |
---|
3956 | } |
---|
3957 | |
---|
3958 | $form['#fields_form_ip_al'] = $fields_form_ip_al; |
---|
3959 | $form['#fields_form_ip_in'] = $fields_form_ip_in; |
---|
3960 | $form['#fields_form_ip_ju'] = $fields_form_ip_ju; |
---|
3961 | $form['#fields_form_ip_sa'] = $fields_form_ip_sa; |
---|
3962 | $form['#fields_form_ip_so'] = $fields_form_ip_so; |
---|
3963 | $form['#fields_form_ip_re'] = $fields_form_ip_re; |
---|
3964 | |
---|
3965 | |
---|
3966 | |
---|
3967 | $form['#proyectos_operativos_fecha'] = array(); |
---|
3968 | $form['#proyectos_operativos_fecha'][0] = $mes_inicio; |
---|
3969 | $form['#proyectos_operativos_fecha'][1] = $mes_final; |
---|
3970 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
3971 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
3972 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos1.js'); |
---|
3973 | drupal_add_js(array('proyectos_operativos' => array('fecha' => $form['#proyectos_operativos_fecha'], 'unidadmpers' => $personas)), 'setting'); |
---|
3974 | $format_number = array( |
---|
3975 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
3976 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
3977 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
3978 | ); |
---|
3979 | $form['#format_number'] = array('format_number' => $format_number); |
---|
3980 | drupal_add_js($form['#format_number'], 'setting'); |
---|
3981 | $form['#proyectos_operativos_fields'] = $fields_form; |
---|
3982 | $form['buttons'] = array( |
---|
3983 | '#prefix' => '<div class="container-inline">', |
---|
3984 | '#suffix' => '</div>', |
---|
3985 | ); |
---|
3986 | $form['buttons']['registrar'] = array( |
---|
3987 | '#type' => 'submit', |
---|
3988 | '#default_value' => t('Aceptar'), |
---|
3989 | '#weight' => 100, |
---|
3990 | ); |
---|
3991 | $form['buttons']['cancelar'] = array( |
---|
3992 | '#type' => 'submit', |
---|
3993 | '#default_value' => t('Cancelar'), |
---|
3994 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
3995 | '#weight' => 101, |
---|
3996 | ); |
---|
3997 | $form['#submit'] = array('proyectos_operativos_proyecto_indicadores_form_submit'); |
---|
3998 | return $form; |
---|
3999 | } |
---|
4000 | |
---|
4001 | /** |
---|
4002 | * Implementation of proyectos_operativos_proyecto_indicadores_form_validate(). |
---|
4003 | * Validar formulario de indicadores (proyectos operativos). |
---|
4004 | */ |
---|
4005 | function proyectos_operativos_proyecto_indicadores_form_validate($form, &$form_state) { |
---|
4006 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
4007 | if ($op == t('Cancelar')) { |
---|
4008 | return; |
---|
4009 | } |
---|
4010 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
4011 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
4012 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos1.js'); |
---|
4013 | drupal_add_js(array('proyectos_operativos' => array('fecha' => $form['#proyectos_operativos_fecha'], 'unidadmpers' => $form['#personas'])), 'setting'); |
---|
4014 | drupal_add_js($form['#format_number'], 'setting'); |
---|
4015 | if (isset($form_state['values']['field_proyecto_meta_fisica'])) { |
---|
4016 | $suma = 0; |
---|
4017 | for ($i = 0; $i < 12; $i++) { |
---|
4018 | if ($form['#proyectos_operativos_fecha'][0] <= $i && $form['#proyectos_operativos_fecha'][1] >= $i) { |
---|
4019 | $valor = $i ? 'value_' . $i : 'value'; |
---|
4020 | $suma += $form_state['values']['field_proyecto_meta_fisica'][0][$valor]; |
---|
4021 | } |
---|
4022 | } |
---|
4023 | if (!$suma) { |
---|
4024 | form_set_error('field_proyecto_meta_fisica', t('La Distribución de la Meta FisÃca del Proyecto debe tener al menos un resultado')); |
---|
4025 | } |
---|
4026 | $personas = $form['#personas']; |
---|
4027 | if (count($personas) && isset($personas[$form_state['values']['field_proyecto_unidadm'][0]['value']])) { |
---|
4028 | $totalpersonas = $form_state['values']['field_proyecto_meta_m'][0]['value'] + $form_state['values']['field_proyecto_meta_f'][0]['value']; |
---|
4029 | if ($totalpersonas != $suma) { |
---|
4030 | form_set_error('field_proyecto_meta_m', t('El total de Distribución de la Meta FisÃca del Proyecto debe ser igual a la cantidad de personas')); |
---|
4031 | } |
---|
4032 | } |
---|
4033 | } |
---|
4034 | } |
---|
4035 | |
---|
4036 | /** |
---|
4037 | * Implementation of proyectos_operativos_proyecto_indicadores_form_submit(). |
---|
4038 | * Guardar formulario de indicadores (proyectos operativos). |
---|
4039 | */ |
---|
4040 | function proyectos_operativos_proyecto_indicadores_form_submit($form, &$form_state) { |
---|
4041 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
4042 | if ($op == t('Cancelar')) { |
---|
4043 | drupal_set_message(t('Se cancelo el ingreso de los indicadores del proyecto.')); |
---|
4044 | $form_state['redirect'] = 'proyectosopedit/' . $form['#node']->nid; |
---|
4045 | return; |
---|
4046 | } |
---|
4047 | if (module_exists('hs_content_taxonomy')) { |
---|
4048 | foreach ($form['#field_info'] as $field_name => $field_info) { |
---|
4049 | if ($field_info['widget']['type'] == 'content_taxonomy_hs') { |
---|
4050 | // Change format of values to the one Content Taxonomy expects |
---|
4051 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
4052 | $values = array(); |
---|
4053 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
4054 | $values[] = array('value' => $tid); |
---|
4055 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
4056 | } |
---|
4057 | $form_state['values'][$field_name]['tids'] = $values; |
---|
4058 | } |
---|
4059 | else { |
---|
4060 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
4061 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
4062 | $form_state['values'][$field_name]['tids'] = $values; |
---|
4063 | } |
---|
4064 | } |
---|
4065 | } |
---|
4066 | } |
---|
4067 | $field_form = $form['#proyectos_operativos_fields']; |
---|
4068 | module_load_include('inc', 'node', 'node.pages'); |
---|
4069 | $node_load = $form['#node']; |
---|
4070 | if (isset($form_state['values']['field_proyecto_meta_fisica'])) { |
---|
4071 | $suma = 0; |
---|
4072 | for ($i = 0; $i < 12; $i++) { |
---|
4073 | $valor = $i ? 'value_' . $i : 'value'; |
---|
4074 | if ($form['#proyectos_operativos_fecha'][0] <= $i && $form['#proyectos_operativos_fecha'][1] >= $i) { |
---|
4075 | $suma += $form_state['values']['field_proyecto_meta_fisica'][0][$valor]; |
---|
4076 | } |
---|
4077 | else { |
---|
4078 | $form_state['values']['field_proyecto_meta_fisica'][0][$valor] = 0; |
---|
4079 | } |
---|
4080 | } |
---|
4081 | } |
---|
4082 | $form_values = $form_state['values']; |
---|
4083 | if (is_array($field_form) && count($field_form)) { |
---|
4084 | foreach ($field_form as $field_id) { |
---|
4085 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
4086 | foreach($form_values[$field_id] as $id => $value) { |
---|
4087 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
4088 | unset($form_values[$field_id][$id]['_error_element']); |
---|
4089 | } |
---|
4090 | } |
---|
4091 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
4092 | } |
---|
4093 | } |
---|
4094 | } |
---|
4095 | if ($node_load->nid) { |
---|
4096 | $texto = t('Modificados los indicadores del proyecto'); |
---|
4097 | $node_load->log = $texto; |
---|
4098 | drupal_set_message($texto); |
---|
4099 | } |
---|
4100 | else { |
---|
4101 | $texto = t('Agregados los indicadores del proyecto'); |
---|
4102 | $node_load->log = $texto; |
---|
4103 | drupal_set_message($texto); |
---|
4104 | } |
---|
4105 | $node_load->revision = 1; |
---|
4106 | node_save($node_load); |
---|
4107 | if ($_REQUEST['destination']) { |
---|
4108 | $form_state['redirect'] = url('proyectosopedit/' . $node_load->nid . '/ae', |
---|
4109 | array( |
---|
4110 | 'query' => array( |
---|
4111 | 'destination' => $_REQUEST['destination'], |
---|
4112 | ), |
---|
4113 | 'absolute' => TRUE, |
---|
4114 | ) |
---|
4115 | ); |
---|
4116 | unset($_REQUEST['destination']); |
---|
4117 | } |
---|
4118 | else { |
---|
4119 | // add redirect |
---|
4120 | $form_state['redirect'] = 'proyectosopedit/' . $node_load->nid . '/ae'; |
---|
4121 | } |
---|
4122 | } |
---|
4123 | |
---|
4124 | /** |
---|
4125 | * Implementation of _proyectos_operativos_proyecto_ae(). |
---|
4126 | * Formulario de acciones especificas (proyectos operativos). |
---|
4127 | */ |
---|
4128 | function _proyectos_operativos_proyecto_ae($proyecto = 0, $ae = 0) { |
---|
4129 | global $user; |
---|
4130 | $current_time = time(); |
---|
4131 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
4132 | $fecha = FALSE; |
---|
4133 | $ente = usuario_tiene_ente($user->uid); |
---|
4134 | $ente_planificador = 0; |
---|
4135 | if ($ente && $ente->nid) { |
---|
4136 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
4137 | } |
---|
4138 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
4139 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
4140 | $fecha = TRUE; |
---|
4141 | } |
---|
4142 | if (!$fecha) { |
---|
4143 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
4144 | } |
---|
4145 | if ($fecha && $ente->nid) { |
---|
4146 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
4147 | } |
---|
4148 | $output = ''; |
---|
4149 | $output .= drupal_get_form('proyectos_operativos_accion_especifica_crear_form', $proyecto, $ae); |
---|
4150 | return $output; |
---|
4151 | } |
---|
4152 | |
---|
4153 | /** |
---|
4154 | * Implementation of _proyectos_operativos_proyecto_financieros(). |
---|
4155 | * Ver datos financieros (proyectos operativos). |
---|
4156 | */ |
---|
4157 | function _proyectos_operativos_proyecto_financieros($proyecto = 0) { |
---|
4158 | drupal_set_title(t('Consultar Datos Financieros')); |
---|
4159 | //add breadcrumb |
---|
4160 | $breadcrumb = array(); |
---|
4161 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
4162 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
4163 | if ($proyecto->nid) { |
---|
4164 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
4165 | } |
---|
4166 | $breadcrumb[] = t('Datos Financieros'); |
---|
4167 | drupal_set_breadcrumb($breadcrumb); |
---|
4168 | global $user; |
---|
4169 | $format_number = array( |
---|
4170 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
4171 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
4172 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
4173 | ); |
---|
4174 | $current_time = time(); |
---|
4175 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
4176 | $fecha = FALSE; |
---|
4177 | $ente = usuario_tiene_ente($user->uid); |
---|
4178 | $ente_planificador = 0; |
---|
4179 | if ($ente && $ente->nid) { |
---|
4180 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
4181 | } |
---|
4182 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
4183 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
4184 | $fecha = TRUE; |
---|
4185 | } |
---|
4186 | if (!$fecha) { |
---|
4187 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
4188 | } |
---|
4189 | if ($fecha && $ente->nid) { |
---|
4190 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
4191 | } |
---|
4192 | $output = ''; |
---|
4193 | $ejecucion = 0; |
---|
4194 | $acciones_especificas = array(); |
---|
4195 | $arreglo_anual = array(); |
---|
4196 | $arreglo_partida = array(); |
---|
4197 | $titles = array(); |
---|
4198 | $partidas = array(); |
---|
4199 | $node_type = content_types('accion_especifica'); |
---|
4200 | $fields = $node_type['fields']; |
---|
4201 | |
---|
4202 | $titulos_campos = array(); |
---|
4203 | $valores = array(); |
---|
4204 | $campos = array(); |
---|
4205 | |
---|
4206 | //financiamiento |
---|
4207 | $arreglo_financiamiento = array(); |
---|
4208 | $accion_especifica_number_fields = variable_get('accion_especifica_number_fields', 4); |
---|
4209 | if ($accion_especifica_number_fields > 0) { |
---|
4210 | for($i = 0; $i < $accion_especifica_number_fields; $i++) { |
---|
4211 | $arreglo_financiamiento['financiamiento_' . $i] = variable_get('accion_especifica_financiamiento_label_' . $i, '') ? variable_get('accion_especifica_financiamiento_label_' . $i, '') : ''; |
---|
4212 | $arreglo_financiamiento_fields['financiamiento_' . $i] = variable_get('accion_especifica_financiamiento_options_' . $i, array()); |
---|
4213 | } |
---|
4214 | } |
---|
4215 | if (is_array($fields) && count($fields)) { |
---|
4216 | foreach($fields as $field_id => $field) { |
---|
4217 | $titulos_campos[$field_id] = $field['widget']['label']; |
---|
4218 | } |
---|
4219 | } |
---|
4220 | |
---|
4221 | |
---|
4222 | $valores_financiamiento = array(); |
---|
4223 | foreach($proyecto->field_proyecto_accion_esp as $accion) { |
---|
4224 | if ($accion['nid']) { |
---|
4225 | $accion_load = node_load($accion['nid']); |
---|
4226 | if ($accion_load && $accion_load->type == 'accion_especifica') { |
---|
4227 | foreach($campos as $field) { |
---|
4228 | $valores[$field] += $accion_load->{$field}[0]['value']; |
---|
4229 | } |
---|
4230 | $titles[$accion_load->nid] = $accion_load->titulo_asignado; |
---|
4231 | $acciones_especificas[$accion_load->nid] = $accion_load; |
---|
4232 | $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value']; |
---|
4233 | foreach($accion_load->field_accion_esp_programacion as $accion) { |
---|
4234 | if ($accion['tid']) { |
---|
4235 | $partidas[$accion['tid']] = $accion['tid']; |
---|
4236 | for ($i = 0; $i < 12; $i++) { |
---|
4237 | $valor = $i ? 'value_' . $i : 'value'; |
---|
4238 | if (!isset($arreglo_partida[$accion_load->nid][$accion['tid']])) { |
---|
4239 | $arreglo_partida[$accion_load->nid][$accion['tid']] = 0; |
---|
4240 | } |
---|
4241 | if (!isset($arreglo_anual[$accion_load->nid][$valor])) { |
---|
4242 | $arreglo_anual[$accion_load->nid][$valor] = 0; |
---|
4243 | } |
---|
4244 | $arreglo_partida[$accion_load->nid][$accion['tid']] += $accion[$valor]; |
---|
4245 | $arreglo_anual[$accion_load->nid][$valor] += $accion[$valor]; |
---|
4246 | } |
---|
4247 | } |
---|
4248 | } |
---|
4249 | foreach($arreglo_financiamiento as $id => $titulo) { |
---|
4250 | foreach($arreglo_financiamiento_fields[$id] as $field) { |
---|
4251 | if (!isset($valores_financiamiento[$field])) { |
---|
4252 | $valores_financiamiento[$field] = 0; |
---|
4253 | } |
---|
4254 | $valores_financiamiento[$field] += $accion_load->{$field}[0]['value']; |
---|
4255 | } |
---|
4256 | } |
---|
4257 | } |
---|
4258 | } |
---|
4259 | } |
---|
4260 | $ftypes = array( |
---|
4261 | 'value' => t('ENE'), |
---|
4262 | 'value_1' => t('FEB'), |
---|
4263 | 'value_2' => t('MAR'), |
---|
4264 | 'value_3' => t('ABR'), |
---|
4265 | 'value_4' => t('MAY'), |
---|
4266 | 'value_5' => t('JUN'), |
---|
4267 | 'value_6' => t('JUL'), |
---|
4268 | 'value_7' => t('AGO'), |
---|
4269 | 'value_8' => t('SEP'), |
---|
4270 | 'value_9' => t('OCT'), |
---|
4271 | 'value_10' => t('NOV'), |
---|
4272 | 'value_11' => t('DEC'), |
---|
4273 | ); |
---|
4274 | $rows = array(); |
---|
4275 | $row = array(); |
---|
4276 | $row[] = array('data' => '<b>' . t('Acciones Especificas') . '</b>', 'rowspan' => 2, 'align' => 'center'); |
---|
4277 | $row[] = array('data' => '<b>' . t('Mes') . '</b>', 'colspan' => 12, 'align' => 'center'); |
---|
4278 | $row[] = array('data' => '<b>' . t('Total') . '</b>', 'rowspan' => 2, 'align' => 'center'); |
---|
4279 | $rows[] = $row; |
---|
4280 | $row = array(); |
---|
4281 | foreach($ftypes as $valor) { |
---|
4282 | $row[] = array('data' => '<b>' . $valor . '</b>', 'align' => 'center'); |
---|
4283 | } |
---|
4284 | $rows[] = $row; |
---|
4285 | $i = 1; |
---|
4286 | $suma_mes = array(); |
---|
4287 | if (count($arreglo_anual)) { |
---|
4288 | foreach($arreglo_anual as $nid => $valore) { |
---|
4289 | $suma = 0; |
---|
4290 | $row = array(); |
---|
4291 | $row[] = array('data' => $titles[$nid], 'align' => 'center'); |
---|
4292 | foreach($ftypes as $id => $valor) { |
---|
4293 | $suma += $valore[$id]; |
---|
4294 | if (!isset($suma_mes[$id])) { |
---|
4295 | $suma_mes[$id] = 0; |
---|
4296 | } |
---|
4297 | $suma_mes[$valor] += $valore[$id]; |
---|
4298 | $row[] = array('data' => number_format($valore[$id], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4299 | } |
---|
4300 | $row[] = array('data' => number_format($suma, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4301 | $rows[] = $row; |
---|
4302 | } |
---|
4303 | $row = array(); |
---|
4304 | $row[] = array('data' => '<b>' . t('TOTAL') . '</b>', 'align' => 'right'); |
---|
4305 | $suma = 0; |
---|
4306 | foreach($ftypes as $valor) { |
---|
4307 | $row[] = array('data' => number_format($suma_mes[$valor], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4308 | $suma += $suma_mes[$valor]; |
---|
4309 | } |
---|
4310 | $style = ''; |
---|
4311 | if ($suma != $proyecto->field_proyecto_monto_anual[0]['value']) { |
---|
4312 | $style = 'color: red'; |
---|
4313 | } |
---|
4314 | $row[] = array('data' => number_format($suma, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center', 'style' => $style); |
---|
4315 | $rows[] = $row; |
---|
4316 | } |
---|
4317 | else { |
---|
4318 | $row = array(); |
---|
4319 | $row[] = array('data' => t('No existen acciones especificas'), 'colspan' => 12, 'align' => 'center'); |
---|
4320 | } |
---|
4321 | $output .= '<fieldset><legend>' . t('Resumen financiero de las acciones') . '</legend>' . '<div class="field-label"><b>' . t('Monto total para el año en curso:') . '</b> ' . number_format($proyecto->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div>' . theme('table', array(), $rows) . '</fieldset>'; |
---|
4322 | $rows = array(); |
---|
4323 | $row = array(); |
---|
4324 | $row[] = array('data' => '<b>' . t('Acciones Especificas') . '</b>', 'rowspan' => 2, 'align' => 'center'); |
---|
4325 | $row[] = array('data' => '<b>' . t('Partidas') . '</b>', 'colspan' => count($partidas), 'align' => 'center'); |
---|
4326 | $row[] = array('data' => '<b>' . t('Total') . '</b>', 'rowspan' => 2, 'align' => 'center'); |
---|
4327 | $rows[] = $row; |
---|
4328 | $row = array(); |
---|
4329 | foreach($partidas as $valor) { |
---|
4330 | $term = taxonomy_get_term($valor); |
---|
4331 | // If this term's vocabulary supports localization. |
---|
4332 | if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) { |
---|
4333 | $term->name = tt("taxonomy:term:$term->tid:name", $term->name); |
---|
4334 | } |
---|
4335 | $row[] = array('data' => '<b>' . $term->name . '</b>', 'align' => 'center'); |
---|
4336 | } |
---|
4337 | $rows[] = $row; |
---|
4338 | $suma_mes = array(); |
---|
4339 | if (count($arreglo_partida)) { |
---|
4340 | foreach($arreglo_partida as $nid => $valore) { |
---|
4341 | $suma = 0; |
---|
4342 | $row = array(); |
---|
4343 | $row[] = array('data' => $titles[$nid], 'align' => 'center'); |
---|
4344 | foreach($partidas as $valor) { |
---|
4345 | if (!$valore[$valor]) { |
---|
4346 | $valore[$valor] = 0; |
---|
4347 | } |
---|
4348 | $suma += $valore[$valor]; |
---|
4349 | if (!isset($suma_mes[$valor])) { |
---|
4350 | $suma_mes[$valor] = 0; |
---|
4351 | } |
---|
4352 | $suma_mes[$valor] += $valore[$valor]; |
---|
4353 | $row[] = array('data' => number_format($valore[$valor], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4354 | } |
---|
4355 | $row[] = array('data' => number_format($suma, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4356 | $rows[] = $row; |
---|
4357 | } |
---|
4358 | $row = array(); |
---|
4359 | $row[] = array('data' => '<b>' . t('TOTAL') . '</b>', 'align' => 'right'); |
---|
4360 | $suma = 0; |
---|
4361 | foreach($partidas as $valor) { |
---|
4362 | $row[] = array('data' => number_format($suma_mes[$valor], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4363 | $suma += $suma_mes[$valor]; |
---|
4364 | } |
---|
4365 | $style = ''; |
---|
4366 | if ($suma != $proyecto->field_proyecto_monto_anual[0]['value']) { |
---|
4367 | $style = 'color: red'; |
---|
4368 | } |
---|
4369 | $row[] = array('data' => number_format($suma, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center', 'style' => $style); |
---|
4370 | $rows[] = $row; |
---|
4371 | } |
---|
4372 | else { |
---|
4373 | $row = array(); |
---|
4374 | $row[] = array('data' => t('No existen acciones especificas'), 'colspan' => 12, 'align' => 'center'); |
---|
4375 | } |
---|
4376 | $output .= '<fieldset><legend>' . t('Distribución por partida presupuestaria') . '</legend>' . '<div class="field-label"><b>' . t('Monto total para el año en curso:') . '</b> ' . number_format($proyecto->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div>' . theme('table', array(), $rows) . '</fieldset>'; |
---|
4377 | $rows = array(); |
---|
4378 | $row = array(); |
---|
4379 | $totales_fin = array(); |
---|
4380 | foreach($arreglo_financiamiento as $id => $titulo) { |
---|
4381 | $output1 = '<fieldset><legend>' . $titulo . '</legend>'; |
---|
4382 | foreach($arreglo_financiamiento_fields[$id] as $field) { |
---|
4383 | if ($field) { |
---|
4384 | if (!isset($totales_fin[$id])) { |
---|
4385 | $totales_fin[$id] = 0; |
---|
4386 | } |
---|
4387 | //$valores[$field] = $valores_financiamiento[$field]; |
---|
4388 | $totales_fin[$id] += $valores_financiamiento[$field]; |
---|
4389 | $output1 .= '<div class="field-label"><b>' . $titulos_campos[$field] . ':</b> ' . number_format($valores_financiamiento[$field], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div>'; |
---|
4390 | } |
---|
4391 | } |
---|
4392 | $output1 .= '</fieldset>'; |
---|
4393 | $row[] = array('data' => $output1, 'align' => 'center'); |
---|
4394 | } |
---|
4395 | $rows[] = $row; |
---|
4396 | $row = array(); |
---|
4397 | $total_total = 0; |
---|
4398 | foreach($arreglo_financiamiento as $id => $arreglo) { |
---|
4399 | $total_total += $totales_fin[$id]; |
---|
4400 | $row[] = array('data' => number_format($totales_fin[$id], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center'); |
---|
4401 | } |
---|
4402 | $rows[] = $row; |
---|
4403 | $row = array(); |
---|
4404 | $row[] = array('data' => '<b>' . t('TOTAL FUENTES DE FINANCIAMIENTO') . ': </b>' . number_format($total_total, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), 'align' => 'center', 'colspan' => count($arreglo_financiamiento)); |
---|
4405 | $rows[] = $row; |
---|
4406 | $output .= '<fieldset><legend>' . t('Fuentes de financiamiento') . '</legend>' . '<div class="field-label"><b>' . t('Monto total para el año en curso:') . '</b> ' . number_format($proyecto->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div>' . theme('table', array(), $rows) . '</fieldset>'; |
---|
4407 | if (_proyectos_operativos_access_editar($proyecto)) { |
---|
4408 | $output .= _proyectos_operativos_proyecto_ver_workflow($proyecto); |
---|
4409 | } |
---|
4410 | return $output; |
---|
4411 | } |
---|
4412 | |
---|
4413 | /** |
---|
4414 | * Implementation of hook_planner_items_toolbar(). |
---|
4415 | */ |
---|
4416 | function proyectos_operativos_planner_items_toolbar($ente_planificador, $handler_icon) { |
---|
4417 | $link = array(); |
---|
4418 | $icon_path = entes_planificadores_toolbar_get_icon_path('planner', 'proyectosop', $handler_icon); |
---|
4419 | $link[] = array( |
---|
4420 | 'path' => 'proyectos_operativos', |
---|
4421 | 'icon_path' => $icon_path, |
---|
4422 | 'icon' => theme('image', $icon_path, t('Consultar Información de los proyectos operativos del actor planificador'), t('Consultar Información de los proyectos operativos del actor planificador'), array('class' => 'handler-icon-' . $handler_icon)), |
---|
4423 | 'title' => t('Proyectos operativos'), |
---|
4424 | 'description' => t('Consultar Información de los proyectos operativos del actor planificador'), |
---|
4425 | 'category' => 'planner', |
---|
4426 | ); |
---|
4427 | return $link; |
---|
4428 | } |
---|
4429 | |
---|
4430 | /** |
---|
4431 | * Implementation of hook_admin_items_toolbar(). |
---|
4432 | */ |
---|
4433 | function proyectos_operativos_admin_items_toolbar($handler_icon) { |
---|
4434 | $link = array(); |
---|
4435 | $icon_path = entes_planificadores_toolbar_get_icon_path('admin', 'proyectosop', $handler_icon); |
---|
4436 | $link[] = array( |
---|
4437 | 'path' => 'proyectos_operativos', |
---|
4438 | 'icon_path' => $icon_path, |
---|
4439 | 'icon' => theme('image', $icon_path, t('Consultar Información de los proyectos operativos del actor planificador'), t('Consultar Información de los proyectos operativos del actor planificador'), array('class' => 'handler-icon-' . $handler_icon)), |
---|
4440 | 'title' => t('Proyectos operativos'), |
---|
4441 | 'description' => t('Consultar Información de los proyectos operativos del actor planificador'), |
---|
4442 | 'category' => 'planner', |
---|
4443 | ); |
---|
4444 | return $link; |
---|
4445 | } |
---|
4446 | |
---|
4447 | /** |
---|
4448 | * Implementation of hook_theme(). |
---|
4449 | */ |
---|
4450 | function proyectos_operativos_theme() { |
---|
4451 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos') . '/templates'; |
---|
4452 | return array( |
---|
4453 | 'proyectos_operativos_proyecto_basico_form' => array( |
---|
4454 | 'arguments' => array('form' => NULL), |
---|
4455 | ), |
---|
4456 | 'proyectos_operativos_proyecto_generales_form' => array( |
---|
4457 | 'arguments' => array('form' => NULL), |
---|
4458 | ), |
---|
4459 | 'proyectos_operativos_proyecto_indicadores_form' => array( |
---|
4460 | 'arguments' => array('form' => NULL), |
---|
4461 | ), |
---|
4462 | 'proyectos_operativos_ficha_proyecto' => array( |
---|
4463 | 'arguments' => array( |
---|
4464 | 'proyecto' => array(), |
---|
4465 | ), |
---|
4466 | 'template' => 'proyectos-operativos-ficha-proyecto', |
---|
4467 | 'path' => $proyectos_operativos_path, |
---|
4468 | ), |
---|
4469 | 'proyecto_operativos_flujo_avance' => array( |
---|
4470 | 'arguments' => array( |
---|
4471 | 'proyecto' => array(), |
---|
4472 | 'states' => array(), |
---|
4473 | ), |
---|
4474 | 'template' => 'proyectos-operativos-flujo-avance', |
---|
4475 | 'path' => $proyectos_operativos_path, |
---|
4476 | ), |
---|
4477 | ); |
---|
4478 | } |
---|
4479 | |
---|
4480 | /** |
---|
4481 | * @ingroup themeable |
---|
4482 | * @see proyectos_operativos_proyecto_basico_form |
---|
4483 | */ |
---|
4484 | function theme_proyectos_operativos_proyecto_basico_form($form) { |
---|
4485 | $output = ''; |
---|
4486 | $fecha_inicio = $form['#fechas_validacion']['inicio']; |
---|
4487 | if ($form['#count_ae']) { |
---|
4488 | $format_number = array( |
---|
4489 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
4490 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
4491 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
4492 | ); |
---|
4493 | $mensaje_mostrar = t('Existen @count_ae Acciones EspecÃficas asignadas, con un monto total de @montos_asignados Bs asignados. y fechas de Inicio @inicio y fin @fin. Tome en consideración estos valores al momento de modificar los valores de los campos @title_fecha_i, @final title_fecha_f y @title_monto_total_proyecto_year', array('@count_ae' => $form['#count_ae'], '@montos_asignados' => number_format($form['#montos_asignados'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '@inicio' => $form['#fechas_validacion']['inicio_texto'], '@fin' => $form['#fechas_validacion']['fin_texto'], '@title_fecha_i' => $form['field_proyecto_fecha_i']['#title'], '@final title_fecha_f' => $form['field_proyecto_fecha_f']['#title'], '@title_monto_total_proyecto_year' => $form['field_proyecto_monto_anual']['#title'] )); |
---|
4494 | $output .= '<div id="mensaje-mostrar" class="mensaje mensaje-mostrar" style="color:red;font-weight: bold;">' . $mensaje_mostrar . '</div>'; |
---|
4495 | } |
---|
4496 | $output .= '<fieldset><legend>' . t('Datos Básicos de Identificación del Proyecto'); |
---|
4497 | $output .= '</legend>' . drupal_render($form['field_proyecto_titulo']); |
---|
4498 | if (isset($form['field_proyecto_codigo']) && $form['field_proyecto_codigo']['#access']) { |
---|
4499 | $output .= drupal_render($form['field_proyecto_codigo']); |
---|
4500 | } |
---|
4501 | if (isset($form['field_proyecto_fecha_i']) && $form['field_proyecto_fecha_i']['#access']) { |
---|
4502 | $output .= drupal_render($form['field_proyecto_fecha_i']); |
---|
4503 | } |
---|
4504 | if (isset($form['field_proyecto_fecha_f']) && $form['field_proyecto_fecha_f']['#access']) { |
---|
4505 | $output .= drupal_render($form['field_proyecto_fecha_f']); |
---|
4506 | } |
---|
4507 | if (isset($form['field_proyecto_status']) && $form['field_proyecto_status']['#access']) { |
---|
4508 | $output .= drupal_render($form['field_proyecto_status']); |
---|
4509 | } |
---|
4510 | if (isset($form['field_proyecto_situacion_p']) && $form['field_proyecto_situacion_p']['#access']) { |
---|
4511 | $output .= drupal_render($form['field_proyecto_situacion_p']); |
---|
4512 | } |
---|
4513 | if (isset($form['field_proyecto_plurianual']) && $form['field_proyecto_plurianual']['#access']) { |
---|
4514 | $output .= drupal_render($form['field_proyecto_plurianual']); |
---|
4515 | } |
---|
4516 | if (isset($form['field_proyecto_monto_anual']) && $form['field_proyecto_monto_anual']['#access']) { |
---|
4517 | $output .= drupal_render($form['field_proyecto_monto_anual']); |
---|
4518 | } |
---|
4519 | if (isset($form['field_proyecto_total']) && $form['field_proyecto_total']['#access']) { |
---|
4520 | $output .= drupal_render($form['field_proyecto_total']); |
---|
4521 | } |
---|
4522 | if (isset($form['field_proyecto_poan']) && $form['field_proyecto_poan']['#access']) { |
---|
4523 | $output .= drupal_render($form['field_proyecto_poan']); |
---|
4524 | } |
---|
4525 | if (is_array($form['#fields_form_ac_d']) && count($form['#fields_form_ac_d'])) { |
---|
4526 | foreach($form['#fields_form_ac_d'] as $id_a) { |
---|
4527 | $output .= drupal_render($form[$id_a]); |
---|
4528 | } |
---|
4529 | } |
---|
4530 | $output .= '</fieldset>'; |
---|
4531 | $gerentes = variable_get('proyectos_operativos_muestra_gerentes', TRUE); |
---|
4532 | $output .= '<fieldset><legend>' . t('Gerente del Proyecto') . '</legend>'; |
---|
4533 | if ($gerentes) { |
---|
4534 | $output .= '<div id="edit-field-proyecto-ente-nid-nid-wrapper" class="form-item"><label for="edit-field-proyecto-ente-nid-nid">Institucion:</label>' . check_plain($form['#ente_planificador']->title) . '</div>'; |
---|
4535 | if (isset($form['field_proyecto_ente']) && $form['field_proyecto_ente']['#access']) { |
---|
4536 | $output .= drupal_render($form['field_proyecto_ente']); |
---|
4537 | } |
---|
4538 | if (isset($form['field_proyecto_autoridad']) && $form['field_proyecto_autoridad']['#access']) { |
---|
4539 | $output .= drupal_render($form['field_proyecto_autoridad']); |
---|
4540 | } |
---|
4541 | if (isset($form['field_proyecto_lider']) && $form['field_proyecto_lider']['#access']) { |
---|
4542 | $output .= drupal_render($form['field_proyecto_lider']); |
---|
4543 | } |
---|
4544 | if (isset($form['field_proyecto_unidad_a']) && $form['field_proyecto_unidad_a']['#access']) { |
---|
4545 | $output .= drupal_render($form['field_proyecto_unidad_a']); |
---|
4546 | } |
---|
4547 | if (isset($form['field_proyecto_cargo']) && $form['field_proyecto_cargo']['#access']) { |
---|
4548 | $output .= drupal_render($form['field_proyecto_cargo']); |
---|
4549 | } |
---|
4550 | if (isset($form['field_proyecto_telefono']) && $form['field_proyecto_telefono']['#access']) { |
---|
4551 | $output .= drupal_render($form['field_proyecto_telefono']); |
---|
4552 | } |
---|
4553 | if (isset($form['field_proyecto_correo']) && $form['field_proyecto_correo']['#access']) { |
---|
4554 | $output .= drupal_render($form['field_proyecto_correo']); |
---|
4555 | } |
---|
4556 | } |
---|
4557 | if (is_array($form['#fields_form_ac_di']) && count($form['#fields_form_ac_di'])) { |
---|
4558 | foreach($form['#fields_form_ac_d'] as $id_a) { |
---|
4559 | $output .= drupal_render($form[$id_a]); |
---|
4560 | } |
---|
4561 | } |
---|
4562 | $output .= '</fieldset>'; |
---|
4563 | $pndes = variable_get('proyectos_operativos_muestra_pndes', TRUE); |
---|
4564 | $mcti = variable_get('proyectos_operativos_muestra_mcti', TRUE); |
---|
4565 | $count_ac_p = count($form['#fields_form_ac_p']); |
---|
4566 | |
---|
4567 | if ($pndes || $mcti || $count_ac_p) { |
---|
4568 | $output .= '<fieldset><legend>' . t('Ãrea Estrategica') . '</legend>'; |
---|
4569 | if ($pndes) { |
---|
4570 | $output .= drupal_render($form['field_proyecto_pndes']); |
---|
4571 | } |
---|
4572 | if ($mcti) { |
---|
4573 | $output .= drupal_render($form['field_proyecto_mcti']); |
---|
4574 | } |
---|
4575 | if ($count_ac_p) { |
---|
4576 | foreach($form['#fields_form_ac_p'] as $id_a) { |
---|
4577 | $output .= drupal_render($form[$id_a]); |
---|
4578 | } |
---|
4579 | } |
---|
4580 | $output .= '</fieldset>'; |
---|
4581 | } |
---|
4582 | $output .= drupal_render($form); |
---|
4583 | return $output; |
---|
4584 | } |
---|
4585 | |
---|
4586 | /** |
---|
4587 | * @ingroup themeable |
---|
4588 | * @see proyectos_operativos_proyecto_generales_form |
---|
4589 | */ |
---|
4590 | function theme_proyectos_operativos_proyecto_generales_form($form) { |
---|
4591 | $arreglo = array( |
---|
4592 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
4593 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
4594 | 'field_proyecto_emindirecto' => 'field_proyecto_emindirecto', |
---|
4595 | 'field_proyecto_efindirecto' => 'field_proyecto_efindirecto', |
---|
4596 | ); |
---|
4597 | $output = ''; |
---|
4598 | if ($form['#count_ae'] && $form['#montos_asignados']!= $form['#node']->field_proyecto_monto_anual[0]['value']) { |
---|
4599 | $link_acciones = l(t('Modificar Acciones especÃficas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); |
---|
4600 | $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); |
---|
4601 | $format_number = array( |
---|
4602 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
4603 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
4604 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
4605 | ); |
---|
4606 | $mensaje_mostrar = t('Existen @count_ae Acciones EspecÃficas asignadas con un monto total de @montos_asignados Bs, el cual difiere con el monto asignado en el proyecto para el @title_monto_total_proyecto_year (@monto_proyecto). Modifique los montos de las Acciones EspecÃficas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@montos_asignados' => number_format($form['#montos_asignados'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '@title_monto_total_proyecto_year' => $form['#proyecto_fields']['field_proyecto_monto_anual']['widget']['label'], '@monto_proyecto' => number_format($form['#node']->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); |
---|
4607 | $output .= '<div id="mensaje-mostrar-monto" class="mensaje mensaje-mostrar" style="color:red;font-weight: bold;">' . $mensaje_mostrar . '</div>'; |
---|
4608 | } |
---|
4609 | if ($form['#count_ae'] && $fechas_validacion['inicio'] && $fechas_validacion['fin'] && ($fechas_validacion['inicio_time'] < $fechas_validacion['inicio_current_time'] || $fechas_validacion['fin_current_time'] < $fechas_validacion['fin_time'])) { |
---|
4610 | $link_acciones = l(t('Modificar Acciones especÃficas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); |
---|
4611 | $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); |
---|
4612 | $mensaje_mostrar = t('Existen @count_ae Acciones EspecÃficas asignadas que difieren con la @title_fecha_de_inicio o @title_fecha_de_final del Proyecto. Modifique los montos de las Acciones EspecÃficas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@title_fecha_de_inicio' => $form['#proyecto_fields']['field_proyecto_fecha_i']['widget']['label'], '@title_fecha_de_final' => $form['#proyecto_fields']['field_proyecto_fecha_f']['widget']['label'], '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); |
---|
4613 | $output .= '<div id="mensaje-mostrar-time" class="mensaje mensaje-mostrar" style="color:red;font-weight: bold;">' . $mensaje_mostrar . '</div>'; |
---|
4614 | } |
---|
4615 | $output .= '<fieldset><legend>' . t('Clasificación Sectorial') . '</legend>' . drupal_render($form['field_proyecto_sector']); |
---|
4616 | if (count($form['#fields_form_dg_se'])) { |
---|
4617 | foreach($form['#fields_form_dg_se'] as $id_c) { |
---|
4618 | $output .= drupal_render($form[$id_c]); |
---|
4619 | } |
---|
4620 | } |
---|
4621 | $output .= '</fieldset>'; |
---|
4622 | |
---|
4623 | |
---|
4624 | if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { |
---|
4625 | $output .= drupal_render($form['talento']); |
---|
4626 | } |
---|
4627 | if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { |
---|
4628 | $output .= drupal_render($form['capacidades']); |
---|
4629 | } |
---|
4630 | $output .= '<fieldset><legend>' . t('Instituciones') . '</legend>' . drupal_render($form['field_proyecto_relacion']); |
---|
4631 | if (count($form['#fields_form_dg_r'])) { |
---|
4632 | foreach($form['#fields_form_dg_r'] as $id_c) { |
---|
4633 | $output .= drupal_render($form[$id_c]); |
---|
4634 | } |
---|
4635 | } |
---|
4636 | $output .= '</fieldset>'; |
---|
4637 | $output .= '<fieldset><legend>' . t('Empleos Generados') . '</legend>' . t('Nro Estimados de Empleos:'); |
---|
4638 | $output .= '<table><tr>'; |
---|
4639 | $output1 = '<tr>'; |
---|
4640 | foreach($arreglo as $empleo) { |
---|
4641 | $output .= '<th>' . $form[$empleo]['#title'] . '</th>'; |
---|
4642 | $form[$empleo][0]['value']['#title'] = ''; |
---|
4643 | $output1 .= '<td>' . drupal_render($form[$empleo]) . '</td>'; |
---|
4644 | } |
---|
4645 | $output1 .= '<td><div class="empleos_generados_total"></div></td>'; |
---|
4646 | $output .= '<th>' . t('TOTAL') . '</th>'; |
---|
4647 | $output1 .= '</tr>'; |
---|
4648 | $output .= '</tr>' . $output1 .'</table></fieldset>'; |
---|
4649 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { |
---|
4650 | $output .= drupal_render($form['beneficiario']); |
---|
4651 | } |
---|
4652 | $output .= '<fieldset><legend>' . t('Objetivos del Proyecto') . '</legend>' . drupal_render($form['field_proyecto_og']) . drupal_render($form['field_proyecto_oe']); |
---|
4653 | if (count($form['#fields_form_dg_o'])) { |
---|
4654 | foreach($form['#fields_form_dg_o'] as $id_c) { |
---|
4655 | $output .= drupal_render($form[$id_c]); |
---|
4656 | } |
---|
4657 | } |
---|
4658 | $output .= '</fieldset>'; |
---|
4659 | |
---|
4660 | |
---|
4661 | $output .= drupal_render($form); |
---|
4662 | return $output; |
---|
4663 | } |
---|
4664 | |
---|
4665 | /** |
---|
4666 | * @ingroup themeable |
---|
4667 | * @see proyectos_operativos_proyecto_indicadores_form |
---|
4668 | */ |
---|
4669 | function theme_proyectos_operativos_proyecto_indicadores_form($form) { |
---|
4670 | $output = ''; |
---|
4671 | if ($form['#count_ae'] && $form['#montos_asignados']!= $form['#node']->field_proyecto_monto_anual[0]['value']) { |
---|
4672 | $format_number = array( |
---|
4673 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
4674 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
4675 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
4676 | ); |
---|
4677 | $link_acciones = l(t('Modificar Acciones especÃficas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); |
---|
4678 | $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); |
---|
4679 | $mensaje_mostrar = t('Existen @count_ae Acciones EspecÃficas asignadas con un monto total de @montos_asignados Bs, el cual difiere con el monto asignado en el proyecto para el @title_monto_total_proyecto_year (@monto_proyecto). Modifique los montos de las Acciones EspecÃficas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@montos_asignados' => number_format($form['#montos_asignados'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '@title_monto_total_proyecto_year' => $form['#proyecto_fields']['field_proyecto_monto_anual']['widget']['label'], '@monto_proyecto' => number_format($form['#node']->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); |
---|
4680 | $output .= '<div id="mensaje-mostrar-monto" class="mensaje mensaje-mostrar" style="color:red;font-weight: bold;">' . $mensaje_mostrar . '</div>'; |
---|
4681 | } |
---|
4682 | if ($form['#count_ae'] && $fechas_validacion['inicio'] && $fechas_validacion['fin'] && ($fechas_validacion['inicio_time'] < $fechas_validacion['inicio_current_time'] || $fechas_validacion['fin_current_time'] < $fechas_validacion['fin_time'])) { |
---|
4683 | $link_acciones = l(t('Modificar Acciones especÃficas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); |
---|
4684 | $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); |
---|
4685 | $mensaje_mostrar = t('Existen @count_ae Acciones EspecÃficas asignadas que difieren con la @title_fecha_de_inicio o @title_fecha_de_final del Proyecto. Modifique los montos de las Acciones EspecÃficas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@title_fecha_de_inicio' => $form['#proyecto_fields']['field_proyecto_fecha_i']['widget']['label'], '@title_fecha_de_final' => $form['#proyecto_fields']['field_proyecto_fecha_f']['widget']['label'], '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); |
---|
4686 | $output .= '<div id="mensaje-mostrar-time" class="mensaje mensaje-mostrar" style="color:red;font-weight: bold;">' . $mensaje_mostrar . '</div>'; |
---|
4687 | } |
---|
4688 | if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { |
---|
4689 | $output .= '<fieldset><legend>' . t('Enunciado del Problema') . '</legend>' . drupal_render($form['field_proyecto_causas']) . drupal_render($form['field_proyecto_problemas']) . drupal_render($form['field_proyecto_consecuencias']); |
---|
4690 | if (count($form['#fields_form_ip_in'])) { |
---|
4691 | foreach($form['#fields_form_ip_in'] as $id_c) { |
---|
4692 | $output .= drupal_render($form[$id_c]); |
---|
4693 | } |
---|
4694 | } |
---|
4695 | $output .= '</fieldset>'; |
---|
4696 | } |
---|
4697 | if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { |
---|
4698 | $output .= '<fieldset><legend>' . t('Justificación del Proyecto') . '</legend>' . drupal_render($form['field_proyecto_justificacion']); |
---|
4699 | if (count($form['#fields_form_ip_ju'])) { |
---|
4700 | foreach($form['#fields_form_ip_ju'] as $id_c) { |
---|
4701 | $output .= drupal_render($form[$id_c]); |
---|
4702 | } |
---|
4703 | } |
---|
4704 | $output .= '</fieldset>'; |
---|
4705 | } |
---|
4706 | if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { |
---|
4707 | $output .= '<fieldset><legend>' . t('Alcance del Proyecto') . '</legend>' . drupal_render($form['field_proyecto_alcance']); |
---|
4708 | if (count($form['#fields_form_ip_al'])) { |
---|
4709 | foreach($form['#fields_form_ip_al'] as $id_c) { |
---|
4710 | $output .= drupal_render($form[$id_c]); |
---|
4711 | } |
---|
4712 | } |
---|
4713 | $output .= '</fieldset>'; |
---|
4714 | } |
---|
4715 | $sa = variable_get('proyectos_operativos_muestra_sa', TRUE); |
---|
4716 | $so = variable_get('proyectos_operativos_muestra_so', TRUE); |
---|
4717 | if ($sa || $so) { |
---|
4718 | $output .= drupal_render($form['indicador']); |
---|
4719 | } |
---|
4720 | $output .= '<fieldset><legend>' . t('Indicador del resultado del Proyecto') . '</legend>' ; |
---|
4721 | $output .= drupal_render($form['field_proyecto_descripcion_bien']); |
---|
4722 | $output .= drupal_render($form['field_proyecto_unidadm']); |
---|
4723 | if (isset($form['field_proyecto_meta_m']) && $form['field_proyecto_meta_f']) { |
---|
4724 | $output .= '<div id="meta-unidm-pers"><table id="unidm-persona" style="width:400px"><tr><th>' . $form['field_proyecto_meta_m']['#title'] . '</th><th>' . $form['field_proyecto_meta_f']['#title'] . '</th><th>' . t('Total') . '</th></tr><tr>'; |
---|
4725 | $form['field_proyecto_meta_m'][0]['value']['#title'] = ''; |
---|
4726 | $form['field_proyecto_meta_f'][0]['value']['#title'] = ''; |
---|
4727 | $total = $form['field_proyecto_meta_m'][0]['#value']['value'] + $form['field_proyecto_meta_f'][0]['#value']['value']; |
---|
4728 | $output .= '<td>' . drupal_render($form['field_proyecto_meta_m']) . '</td>'; |
---|
4729 | $output .= '<td>' . drupal_render($form['field_proyecto_meta_f']) . '</td>'; |
---|
4730 | |
---|
4731 | $output .= '<td style="width:100px; text-align: center"><div class="unidad_personas_total">' . number_format($total, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '</div></td></tr></table></div>'; |
---|
4732 | } |
---|
4733 | |
---|
4734 | $output .= drupal_render($form['field_proyecto_meta_fisica']); |
---|
4735 | |
---|
4736 | if (count($form['#fields_form_ip_re'])) { |
---|
4737 | foreach($form['#fields_form_ip_re'] as $id_c) { |
---|
4738 | $output .= drupal_render($form[$id_c]); |
---|
4739 | } |
---|
4740 | } |
---|
4741 | $output .= '</fieldset>'; |
---|
4742 | $output .= drupal_render($form); |
---|
4743 | return $output; |
---|
4744 | } |
---|
4745 | |
---|
4746 | function proyectos_operativos_theme_registry_alter(&$theme_registry) { |
---|
4747 | $theme_registry['hierarchical_select_select']['function'] = 'proyectos_operativos_hierarchical_select_select'; |
---|
4748 | } |
---|
4749 | |
---|
4750 | |
---|
4751 | /** |
---|
4752 | * Format a select in the .hierarchial-select div: prevent it from being |
---|
4753 | * wrapped in a div. This simplifies the CSS and JS code. |
---|
4754 | * |
---|
4755 | * @param $element |
---|
4756 | * An associative array containing the properties of the element. |
---|
4757 | * @return |
---|
4758 | * A themed HTML string representing the form element. |
---|
4759 | */ |
---|
4760 | function proyectos_operativos_hierarchical_select_select($element) { |
---|
4761 | $display_label = ''; |
---|
4762 | foreach($element['#options'] as $id => $label) { |
---|
4763 | if ($label && !is_numeric($id)) { |
---|
4764 | $display_label = '<label>' . $label . ':</label>'; |
---|
4765 | $element['#options'][$id] = t('seleccione'); |
---|
4766 | } |
---|
4767 | } |
---|
4768 | $select = ''; |
---|
4769 | $size = $element['#size'] ? ' size="'. $element['#size'] .'"' : ''; |
---|
4770 | $class = array('form-select'); |
---|
4771 | if (form_get_error($element) === '') { |
---|
4772 | $class = array_merge($class, array('error')); |
---|
4773 | } |
---|
4774 | _form_set_class($element, $class); |
---|
4775 | $multiple = isset($element['#multiple']) && $element['#multiple']; |
---|
4776 | return $display_label . '<select name="'. $element['#name'] .''. ($multiple ? '[]' : '') .'"'. ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="'. $element['#id'] .'" '. $size .'>'. _hierarchical_select_options($element) .'</select>'; |
---|
4777 | } |
---|
4778 | |
---|
4779 | /** |
---|
4780 | * Implementation of hook_views_api(). |
---|
4781 | */ |
---|
4782 | function proyectos_operativos_views_api() { |
---|
4783 | return array( |
---|
4784 | 'api' => '2.0', |
---|
4785 | 'path' => drupal_get_path('module', 'proyectos_operativos') . '/views', |
---|
4786 | ); |
---|
4787 | } |
---|
4788 | |
---|
4789 | /** |
---|
4790 | * Implementation of proyectos_operativos_search_ac_display(). |
---|
4791 | * Muestra la lista de proyectos disponibles. |
---|
4792 | */ |
---|
4793 | function proyectos_operativos_agregar_proyectoente() { |
---|
4794 | global $user; |
---|
4795 | //add breadcrumb |
---|
4796 | $breadcrumb = array(); |
---|
4797 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
4798 | $breadcrumb[] = t('Proyectos Operativos'); |
---|
4799 | drupal_set_breadcrumb($breadcrumb); |
---|
4800 | $view_id = 'Agregar_proyecto'; |
---|
4801 | $view = views_get_view($view_id); |
---|
4802 | $display_id = 'default'; |
---|
4803 | $view->set_display($display_id); |
---|
4804 | $view->override_path = $_GET['q']; |
---|
4805 | $view->pre_execute(); |
---|
4806 | $view->execute(); |
---|
4807 | $output = $view->render(); |
---|
4808 | return $output; |
---|
4809 | } |
---|
4810 | |
---|
4811 | /** |
---|
4812 | * Implementation of hook_block(). |
---|
4813 | * |
---|
4814 | * Genera un bloque con el estatus de la planificación |
---|
4815 | */ |
---|
4816 | function proyectos_operativos_block($op = 'list', $delta = 0) { |
---|
4817 | if (module_exists('workflow')) { |
---|
4818 | $wid = workflow_get_workflow_for_type('proyectos_operativos'); |
---|
4819 | if ($wid) { |
---|
4820 | if ($op == 'list') { |
---|
4821 | $blocks[0]['info'] = t('Estatus del Avance de proyectos'); |
---|
4822 | return $blocks; |
---|
4823 | } |
---|
4824 | else if ($op == 'view' && user_access('ver planificador')) { |
---|
4825 | if((arg(0) == 'proyectosop' && is_numeric(arg(1)))) { |
---|
4826 | $states = workflow_get_states($wid); |
---|
4827 | $proyecto = node_load(arg(1)); |
---|
4828 | $block['subject'] = t('Avance del Proyecto'); |
---|
4829 | $block['content'] = _proyecto_operativos_flujo_avance_theme($proyecto, $states); |
---|
4830 | } |
---|
4831 | return $block; |
---|
4832 | } |
---|
4833 | } |
---|
4834 | } |
---|
4835 | } |
---|
4836 | |
---|
4837 | /** |
---|
4838 | * Implementation of _proyecto_operativos_flujo_avance_theme(). |
---|
4839 | */ |
---|
4840 | function _proyecto_operativos_flujo_avance_theme($proyecto = 0, $states = 0) { |
---|
4841 | if (count($states)) { |
---|
4842 | return theme('proyecto_operativos_flujo_avance', $proyecto, $states); |
---|
4843 | } |
---|
4844 | else { |
---|
4845 | return t('No se han definido estados para Proyectos Operativos'); |
---|
4846 | } |
---|
4847 | } |
---|