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