1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
5 | * @file continuarproyectosopplurianual.module |
---|
6 | * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
7 | * Copyright 2017 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or modify |
---|
10 | * it under the terms of the GNU General Public License as published by |
---|
11 | * the Free Software Foundation; either version 2 of the License, or |
---|
12 | * (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | * |
---|
23 | * @author Cenditel Merida - Phd. Juan Vizcarrondo |
---|
24 | * @date 2017-08-09 // (año-mes-dia) |
---|
25 | * @version 0.3 // (0.1) |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /* |
---|
30 | * hook_form_alter |
---|
31 | */ |
---|
32 | function proyectos_reformulacion_form_alter(&$form, $form_state, $form_id) { |
---|
33 | |
---|
34 | if ($form_id == 'workflow_tab_form' && $form['node'] && $form['node']['#value']->type == 'proyectos_operativos' && $form['node']['#value']->field_proyecto_reformulab[0]['nid']) { |
---|
35 | if (isset($form_state['storage']['confirma'])) { |
---|
36 | $next = $form_state['storage']['page_one_values']['workflow']; |
---|
37 | $count = count($form['node']['#value']->field_proyectos_reforall) - 1; |
---|
38 | $nid = 0; |
---|
39 | if ($count >= 0) { |
---|
40 | $form['description']['#value'] = theme('proyectos_reformulacion_ver_proyecto', $form['node']['#value']) . $form['description']['#value']; |
---|
41 | $nid = $form['node']['#value']->field_proyectos_reforall[$count]['nid']; |
---|
42 | } |
---|
43 | if ($nid && is_numeric($nid)) { |
---|
44 | $node_prev = node_load($nid); |
---|
45 | $state_aprobado = variable_get('proyectos_reformulacion_state_aprobado', NULL); |
---|
46 | if ($node_prev->type == 'proyectos_operativos' && $node_prev->_workflow == $state_aprobado && $next == $state_aprobado) { |
---|
47 | $choices = _proyectos_operativos_reformula_obtiene_estados(); |
---|
48 | //se coloca el proiyecto anterior en reformulado |
---|
49 | $node_prev->workflow_comment = t('Proyecto enviado al estado @estado por una nueva reformulación aprobada (!enlace)', array('@estado' => $choices['states'][variable_get('proyectos_reformulacion_state_reformulado', NULL)], '!enlace' => l($form['node']['#value']->title,'proyectosop/' . $form['node']['#value']->title->nid))); |
---|
50 | $form['#node_reformular'] = $node_prev; |
---|
51 | $description = explode('</p>', $form['description']['#value']); |
---|
52 | $form['description']['#value'] = $description[0] . '.</p><p style="color:red"><b>' . t('El proyecto Actual !codigo en estado "@estadoa" se pasara a estado "@estado"', array('!codigo' => l($form['node']['#value']->title,'proyectosop/' . $form['node']['#value']->title->nid), '@estadoa' => $choices['states'][$node_prev->_workflow], '@estado' => $choices['states'][variable_get('proyectos_reformulacion_state_reformulado', NULL)])) . '.</b></p>' . $description[1]; |
---|
53 | $form['#submit'][] = 'proyectos_reformulacion_workflow_prev_submit'; |
---|
54 | } |
---|
55 | } |
---|
56 | } |
---|
57 | else { |
---|
58 | drupal_set_title(t('Reformulación del proyecto @title (Cantidad de reformulaciones: @cant)', array('@title' => $form['node']['#value']->title, '@cant' => count($form['node']['#value']->field_proyectos_reforall)))); |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * Implementation of proyectos_operativos_cambia_redirect_paso2_submit. |
---|
65 | * envia el formulario normalmente. |
---|
66 | */ |
---|
67 | function proyectos_reformulacion_workflow_prev_submit($form, &$form_state) { |
---|
68 | $node = $form['#node_reformular']; |
---|
69 | // Call node_save() to make sure any handlers that use the |
---|
70 | // new workflow values will see them. |
---|
71 | workflow_execute_transition($node, variable_get('proyectos_reformulacion_state_reformulado', NULL), isset($node->workflow_comment) ? $node->workflow_comment : NULL, TRUE); |
---|
72 | |
---|
73 | node_save($node); |
---|
74 | } |
---|
75 | |
---|
76 | /* |
---|
77 | * Implementation of hook_menu() |
---|
78 | */ |
---|
79 | function proyectos_reformulacion_menu() { |
---|
80 | $items['proyectos_operativos/reformulaciones'] = array( |
---|
81 | 'title' => t('Reformulaciones'), |
---|
82 | 'access arguments' => array('ver planificador'), |
---|
83 | 'page callback' => '_proyectos_reformulacion_reformula_list_page', |
---|
84 | 'page arguments' => array(NULL, 'all'), |
---|
85 | 'type' => MENU_LOCAL_TASK, |
---|
86 | ); |
---|
87 | //agregar proyecto operativo |
---|
88 | $items['proyectosop/%proyectosop/reformular'] = array( |
---|
89 | 'title' => 'Reformulaciones', |
---|
90 | 'type' => MENU_LOCAL_TASK, |
---|
91 | 'access callback' => '_proyectos_reformulacion_reformula_node_tab_access', |
---|
92 | 'access arguments' => array(1), |
---|
93 | 'page callback' => '_proyectos_reformulacion_reformula_list_page', |
---|
94 | 'page arguments' => array(1, 'single'), |
---|
95 | 'weight' => 2, |
---|
96 | ); |
---|
97 | $items['proyectosop/%proyectosop/reformular/list'] = array( |
---|
98 | 'title' => 'Reformulaciones', |
---|
99 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
---|
100 | 'weight' => -10 |
---|
101 | ); |
---|
102 | $items['proyectosop/%proyectosop/reformular/add'] = array( |
---|
103 | 'title' => 'Agregar Reformulación', |
---|
104 | 'type' => MENU_LOCAL_TASK, |
---|
105 | 'access callback' => '_proyectos_reformulacion_access_add', |
---|
106 | 'access arguments' => array(1), |
---|
107 | 'page callback' => 'drupal_get_form', |
---|
108 | 'page arguments' => array('proyectos_reformulacion_reformula_tab_page_form', 1), |
---|
109 | 'weight' => 2, |
---|
110 | ); |
---|
111 | /** ahah para el cambio de vista en el admin **/ |
---|
112 | $items['proyectos_reformulacion'] = array( |
---|
113 | 'title' => 'Vista por tipo de proceso', |
---|
114 | 'page callback' => 'proyectos_reformulacion_views_js', |
---|
115 | 'access arguments' => array('admin planificador'), |
---|
116 | 'type' => MENU_CALLBACK, |
---|
117 | ); |
---|
118 | $items['admin/settings/ente_planificador/proyectos_operativos/reformular'] = array( |
---|
119 | 'title' => t('Reformulaciones'), |
---|
120 | 'page callback' => 'drupal_get_form', |
---|
121 | 'page arguments' => array('proyectos_reformulacion_admin_settings'), |
---|
122 | 'access arguments' => array('admin planificador'), |
---|
123 | 'weight' => -5, |
---|
124 | 'type' => MENU_LOCAL_TASK, |
---|
125 | 'file' => 'proyectos_reformulacion.admin.inc', |
---|
126 | ); |
---|
127 | return $items; |
---|
128 | } |
---|
129 | |
---|
130 | /* |
---|
131 | * Implementation of _proyectos_reformulacion_reformula_list_page() |
---|
132 | * Listar las reformulaciones |
---|
133 | */ |
---|
134 | function _proyectos_reformulacion_reformula_list_page($proyecto = 0, $type = 'all') { |
---|
135 | $valid_proyecto = $proyecto && is_object($proyecto) && property_exists($proyecto, 'field_proyecto_reformulab'); |
---|
136 | $title = $valid_proyecto? t('Reformulaciones para el proyecto @name', array('@name' => $proyecto->title)) : t('Reformulaciones'); |
---|
137 | drupal_set_title($title); |
---|
138 | $output = t('Aun no se encuentra una vista configurada para este path'); |
---|
139 | $view_id = variable_get('proyectos_reformulacion_' . $type . '_views', 0); |
---|
140 | if ($view_id && $view = views_get_view($view_id)) { |
---|
141 | $display_id = variable_get('proyectos_reformulacion_' . $type . '_display', 0); |
---|
142 | foreach ($view->display as $key => $display) { |
---|
143 | $options_display[$key] = $display->display_title; |
---|
144 | } |
---|
145 | if ($display_id && isset($options_display[$display_id])) { |
---|
146 | $view->set_display($display_id); |
---|
147 | if ($valid_proyecto) { |
---|
148 | $view->set_arguments(array($proyecto->field_proyecto_reformulab[0]['nid'])); |
---|
149 | } |
---|
150 | $view->override_path = $_GET['q']; |
---|
151 | $view->pre_execute(); |
---|
152 | $view->execute(); |
---|
153 | $output = $view->render(); |
---|
154 | } |
---|
155 | } |
---|
156 | return $output; |
---|
157 | } |
---|
158 | |
---|
159 | /** |
---|
160 | * Menu access control callback. Determine access to reformula tab. |
---|
161 | */ |
---|
162 | function _proyectos_reformulacion_reformula_node_tab_access($node = NULL) { |
---|
163 | $estado_aprobado = variable_get('proyectos_reformulacion_state_aprobado', NULL); |
---|
164 | return (user_access('ver planificador') && $node->type == 'proyectos_operativos' && $node->_workflow == $estado_aprobado); |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * Implementation of _proyectos_operativos_access_editar() |
---|
169 | * Menu access control callback. Determina si un usuario tiene acceso a reformular un proyecto |
---|
170 | */ |
---|
171 | function _proyectos_reformulacion_access_add($node = 0) { |
---|
172 | global $user; |
---|
173 | if (module_exists('workflow')) { |
---|
174 | $estado_aprobado = variable_get('proyectos_reformulacion_state_aprobado', NULL); |
---|
175 | if ($node->_workflow != $estado_aprobado) { |
---|
176 | return FALSE; |
---|
177 | } |
---|
178 | } |
---|
179 | $ente = usuario_tiene_ente($user->uid); |
---|
180 | $ente_planificador = 0; |
---|
181 | if ($ente && $ente->nid) { |
---|
182 | $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); |
---|
183 | } |
---|
184 | elseif (user_access('admin planificador') && $node) { |
---|
185 | $ente_planificador = ente_planificador_leer_ente_planificadores($node->field_proyecto_ente[0]['nid']); |
---|
186 | } |
---|
187 | if (!$ente_planificador) { |
---|
188 | return FALSE; |
---|
189 | } |
---|
190 | $entes_permitidos = variable_get('proyectos_reformulacion_add_entes', array()); |
---|
191 | $tam = count($entes_permitidos); |
---|
192 | if (!variable_get('proyectos_reformulacion_perm_nuevos', TRUE) && module_exists('ente_planificador_hierarchical')) { |
---|
193 | $permiso_padres = FALSE; |
---|
194 | if ($tam && count($ente_planificador->ente_planificador_hierarchical['fathers'])) { |
---|
195 | foreach($ente_planificador->ente_planificador_hierarchical['fathers'] as $valor) { |
---|
196 | if (isset($valor['nid']) && in_array($valor['nid'], $entes_permitidos)) { |
---|
197 | $permiso_padres = TRUE; |
---|
198 | } |
---|
199 | } |
---|
200 | } |
---|
201 | if (!$tam && !$permiso_padres) { |
---|
202 | return FALSE; |
---|
203 | } |
---|
204 | if (!isset($entes_permitidos[$ente_planificador->nid]) && !$permiso_padres) { |
---|
205 | return FALSE; |
---|
206 | } |
---|
207 | } |
---|
208 | else if(!variable_get('proyectos_reformulacion_perm_nuevos', TRUE)){ |
---|
209 | return $tam && in_array($ente_planificador->nid, $entes_permitidos); |
---|
210 | } |
---|
211 | $year_p = variable_get('proyectos_reformulacion_anho', 0); |
---|
212 | //se verifica que no exista otra reformulacion creado para este periodo |
---|
213 | $sql = 'SELECT p.nid, n.title FROM {content_type_proyectos_operativos} AS p INNER JOIN {node} AS n ON n.nid = p.nid AND n.vid = p.vid AND n.status > 0 INNER JOIN {proyectos_operativos} AS po ON po.nid = p.nid INNER JOIN {workflow_node} AS w ON w.nid = p.nid AND w.sid != %d AND w.sid != %d WHERE (p.field_proyecto_reformulab_nid = %d OR p.nid = %d) AND po.year = %d'; |
---|
214 | $inpunts = array(); |
---|
215 | $inpunts[] = variable_get('proyectos_operativos_state_naprobado', NULL); |
---|
216 | $inpunts[] = variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
217 | $inpunts[] = $node->nid; |
---|
218 | $inpunts[] = $node->nid; |
---|
219 | $inpunts[] = $year_p; |
---|
220 | $result = db_query($sql, $inpunts); |
---|
221 | $proy = db_fetch_object($result); |
---|
222 | if ($proy) { |
---|
223 | return FALSE; |
---|
224 | } |
---|
225 | $first_state = 0; |
---|
226 | if (!user_access('admin planificador') && module_exists('workflow')) { |
---|
227 | $states = _proyectos_operativos_reformula_obtiene_estados(); |
---|
228 | if ($states['wid']) { |
---|
229 | $first_state = _workflow_creation_state($states['wid']); |
---|
230 | } |
---|
231 | if ($first_state) { |
---|
232 | $roles_perm = FALSE; |
---|
233 | $roles_allow = variable_get('proyectos_operativos_state_m_' . $first_state, array()); |
---|
234 | $roles = array_keys($user->roles); |
---|
235 | if (count($roles)) { |
---|
236 | foreach($roles as $rol) { |
---|
237 | if($roles_allow[$rol]) { |
---|
238 | $roles_perm = TRUE; |
---|
239 | } |
---|
240 | elseif ($rol == -1 && $node->uid == $user->uid) { |
---|
241 | $roles_perm = TRUE; |
---|
242 | } |
---|
243 | } |
---|
244 | } |
---|
245 | if (!$roles_perm) { |
---|
246 | return FALSE; |
---|
247 | } |
---|
248 | } |
---|
249 | } |
---|
250 | return $node->field_proyecto_ente[0]['nid']; |
---|
251 | } |
---|
252 | |
---|
253 | /** |
---|
254 | * Implementation of hook_theme(). |
---|
255 | */ |
---|
256 | function proyectos_reformulacion_theme() { |
---|
257 | return array( |
---|
258 | 'proyectos_reformulacion_ver_proyecto' => array( |
---|
259 | 'arguments' => array('proyecto' => NULL), |
---|
260 | ), |
---|
261 | 'proyectos_reformulacion_reformula_tab_page_form' => array( |
---|
262 | 'arguments' => array('form' => NULL), |
---|
263 | ), |
---|
264 | ); |
---|
265 | } |
---|
266 | |
---|
267 | /** |
---|
268 | * @ingroup themeable |
---|
269 | * @see proyectos_operativos_proyecto_basico_form |
---|
270 | */ |
---|
271 | function theme_proyectos_reformulacion_ver_proyecto($proyecto) { |
---|
272 | $proyecto->build_mode = NODE_BUILD_NORMAL; |
---|
273 | $node_type = content_types('proyectos_operativos'); |
---|
274 | $fields = $node_type['fields']; |
---|
275 | $header = array(); |
---|
276 | $header[] = array('data' => check_plain($proyecto->field_proyecto_titulo[0]['value']), 'colspan' => 2, 'align' => center); |
---|
277 | $rows = array(); |
---|
278 | $row = array(); |
---|
279 | $row[] = array('data' => '<b>' . $fields['field_proyecto_codigo']['widget']['label'] . ':</b> ' . check_plain($proyecto->title)); |
---|
280 | $nombre_field = 'field_proyecto_ente'; |
---|
281 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'plain', $proyecto); |
---|
282 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
283 | $rows[] = $row; |
---|
284 | $row = array(); |
---|
285 | $nombre_field = 'field_proyecto_plurianual'; |
---|
286 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
287 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
288 | $nombre_field = 'field_proyecto_situacion_p'; |
---|
289 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
290 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
291 | $rows[] = $row; |
---|
292 | $row = array(); |
---|
293 | $nombre_field = 'field_proyecto_fecha_i'; |
---|
294 | $fecha = explode(' ', $proyecto->{$nombre_field}[0]['value']); |
---|
295 | $fecha = explode('-', $fecha[0]); |
---|
296 | $campo = $fecha[2] . '/' . $fecha[1] . '/' . $fecha[0]; |
---|
297 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
298 | $nombre_field = 'field_proyecto_fecha_f'; |
---|
299 | $fecha = explode(' ', $proyecto->{$nombre_field}[0]['value']); |
---|
300 | $fecha = explode('-', $fecha[0]); |
---|
301 | $campo = $fecha[2] . '/' . $fecha[1] . '/' . $fecha[0]; |
---|
302 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
303 | $rows[] = $row; |
---|
304 | $row = array(); |
---|
305 | $nombre_field = 'field_proyecto_monto_anual'; |
---|
306 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'be_0', $proyecto); |
---|
307 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
308 | $nombre_field = 'field_proyecto_total'; |
---|
309 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'be_0', $proyecto); |
---|
310 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
311 | $rows[] = $row; |
---|
312 | $row = array(); |
---|
313 | $nombre_field = 'field_proyecto_esp_monto_finan'; |
---|
314 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'be_0', $proyecto); |
---|
315 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
316 | $nombre_field = 'field_proyecto_poan'; |
---|
317 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
318 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo); |
---|
319 | $rows[] = $row; |
---|
320 | $row = array(); |
---|
321 | $nombre_field = 'field_proyecto_descripcion_bien'; |
---|
322 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
323 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo, 'colspan' => 2); |
---|
324 | $rows[] = $row; |
---|
325 | $row = array(); |
---|
326 | $nombre_field = 'field_proyecto_unidadm'; |
---|
327 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
328 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo, 'colspan' => 2); |
---|
329 | $rows[] = $row; |
---|
330 | $row = array(); |
---|
331 | $nombre_field = 'field_proyecto_meta_fisica'; |
---|
332 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
333 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo, 'colspan' => 2); |
---|
334 | $rows[] = $row; |
---|
335 | //si reformulaciones |
---|
336 | $count = count($proyecto->field_proyectos_reforall); |
---|
337 | if ($count) { |
---|
338 | $row = array(); |
---|
339 | $row[] = array('data' => '<b>' . t('Cantidad de Reformulaciones') . ':</b> ' . $count,); |
---|
340 | $links = array(); |
---|
341 | foreach($proyecto->field_proyectos_reforall as $delta => $field) { |
---|
342 | $links[] = l(t('Reformulación : @numero', array('@numero' => ($delta + 1))), 'proyectosop/' . $field['nid']); |
---|
343 | } |
---|
344 | $campo = theme('item_list', $links); |
---|
345 | $row[] = array('data' => '<b>' . t('Reformulaciones') . ':</b> ' . $campo,); |
---|
346 | $rows[] = $row; |
---|
347 | //Se muestra los datos del responsable de la institución |
---|
348 | $row = array(); |
---|
349 | $nombre_field = 'field_proyecto_nombre_resp'; |
---|
350 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
351 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
352 | $nombre_field = 'field_proyecto_apelli_resp'; |
---|
353 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
354 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
355 | $rows[] = $row; |
---|
356 | $row = array(); |
---|
357 | $nombre_field = 'field_proyecto_cedul_resp'; |
---|
358 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
359 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
360 | $nombre_field = 'field_proyecto_filegace'; |
---|
361 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
362 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
363 | $rows[] = $row; |
---|
364 | //Se muestra los datos del responsable tecnico |
---|
365 | $row = array(); |
---|
366 | $nombre_field = 'field_proyecto_nombre_tecn'; |
---|
367 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
368 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
369 | $nombre_field = 'field_proyecto_apelli_tecn'; |
---|
370 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
371 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
372 | $rows[] = $row; |
---|
373 | $row = array(); |
---|
374 | $nombre_field = 'field_proyecto_cedul_tecn'; |
---|
375 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
376 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
377 | $nombre_field = 'field_proyecto_filesol'; |
---|
378 | $campo = content_format($nombre_field, $proyecto->{$nombre_field}[0], 'default', $proyecto); |
---|
379 | $row[] = array('data' => '<b>' . $fields[$nombre_field]['widget']['label'] . ':</b> ' . $campo,); |
---|
380 | $rows[] = $row; |
---|
381 | } |
---|
382 | return theme('table', $header, $rows); |
---|
383 | } |
---|
384 | |
---|
385 | /** |
---|
386 | * Implementation of proyectos_reformulacion_reformula_tab_page_form. |
---|
387 | * Formulario de para agregar una reformulacion al proyecto operativo. |
---|
388 | */ |
---|
389 | function proyectos_reformulacion_reformula_tab_page_form(&$form_state, $proyecto = 0) { |
---|
390 | global $user; |
---|
391 | //add breadcrumb |
---|
392 | $breadcrumb = array(); |
---|
393 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
394 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
395 | if ($proyecto->nid) { |
---|
396 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
397 | $breadcrumb[] = l(t('Reformulaciones'), 'proyectosop/' . $proyecto->nid . '/reformular'); |
---|
398 | } |
---|
399 | $breadcrumb[] = t('Agregar Reformulación'); // Link to current URL |
---|
400 | drupal_set_breadcrumb($breadcrumb); |
---|
401 | drupal_set_title(t('Reformular proyecto @title (Cantidad de reformulaciones: @cant)', array('@title' => $proyecto->title, '@cant' => count($proyecto->field_proyectos_reforall)))); |
---|
402 | $current_time = time(); |
---|
403 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
404 | $ente_planificador = 0; |
---|
405 | if($proyecto && $proyecto->nid && $proyecto->field_proyecto_ente[0]['nid']) { |
---|
406 | $ente_planificador = ente_planificador_leer_ente_planificadores($proyecto->field_proyecto_ente[0]['nid']); |
---|
407 | } |
---|
408 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
409 | $fecha = FALSE; |
---|
410 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
411 | $fecha = TRUE; |
---|
412 | } |
---|
413 | if (!$fecha) { |
---|
414 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
415 | } |
---|
416 | if ($fecha && $ente->nid) { |
---|
417 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
418 | } |
---|
419 | $fechas_validacion = array( |
---|
420 | 'inicio' => '', |
---|
421 | 'fin' => '', |
---|
422 | ); |
---|
423 | $form = array(); |
---|
424 | $form['#node'] = $proyecto; |
---|
425 | $form['reformula_proyecto'] = array( |
---|
426 | '#value' => theme('proyectos_reformulacion_ver_proyecto', $proyecto), |
---|
427 | ); |
---|
428 | //Se obtienen las AE disponibles para el nuevo proyecto |
---|
429 | $sql = "SELECT aet.field_accion_titulo_value AS titulo, aet.nid, aet.field_accion_esp_fechai_value AS fechai, aet.field_accion_esp_fechaf_value AS fechaf, aet.field_accion_esp_monto_finan_value as monto, aet.field_accion_esp_total_fuent_value AS montof FROM {content_type_proyectos_operativos} AS po INNER JOIN {content_field_proyecto_accion_esp} AS ae ON ae.nid = po.nid AND ae.vid = po.vid INNER JOIN {node} AS n ON n.nid = ae.field_proyecto_accion_esp_nid INNER JOIN {content_type_accion_especifica} AS aet ON aet.nid = n.nid AND aet.vid = n.vid WHERE po.nid = %d AND po.vid = %d"; |
---|
430 | $inpunts = array(); |
---|
431 | $inpunts[] = $proyecto->nid; |
---|
432 | $inpunts[] = $proyecto->vid; |
---|
433 | if (variable_get('continuarproyectosopplurianual_aes', 0)) { |
---|
434 | $year = variable_get('proyectos_operativos_anho_creacion', 0); |
---|
435 | $sql .= " AND aet.field_accion_esp_fechai_value <= '%s' AND aet.field_accion_esp_fechaf_value >= '%s'"; |
---|
436 | $inpunts[] = ($year + 1) . '-01-01 00:00:00'; |
---|
437 | $inpunts[] = ($year - 1) . '-12-31 00:00:00'; |
---|
438 | } |
---|
439 | $result = db_query($sql, $inpunts); |
---|
440 | $aes = array(); |
---|
441 | $form['ae'] = array( |
---|
442 | '#type' => 'fieldset', |
---|
443 | '#title' => t('Acciones EspecÃficas'), |
---|
444 | '#description' => t('Acciones EspecÃficas en el proyecto'), |
---|
445 | '#collapsible' => TRUE, |
---|
446 | '#collapsed' => FALSE, |
---|
447 | ); |
---|
448 | $i = 1; |
---|
449 | while($ae = db_fetch_object($result)) { |
---|
450 | $fechai = explode(' ', $ae->fechai); |
---|
451 | $fechai = explode('-', $fechai[0]); |
---|
452 | $fechaf = explode(' ', $ae->fechaf); |
---|
453 | $fechaf = explode('-', $fechaf[0]); |
---|
454 | $fechas = array(); |
---|
455 | //solo deje agregar ae que tienen bien establecidas sus fechas |
---|
456 | if (count($fechai) == 3 && count($fechaf) == 3) { |
---|
457 | $fechas[0] = $fechai[2] . '/' . $fechai[1] . '/' . $fechai[0]; |
---|
458 | $fechas[1] = $fechaf[2] . '/' . $fechaf[1] . '/' . $fechaf[0]; |
---|
459 | $titulo = t('AE-@number: @AE (Fechas de ejecución: @fechai al @fechaf).', array('@AE' => $ae->titulo, '@fechai' => $fechas[0], '@fechaf' => $fechas[1], '@number' => $i)); |
---|
460 | $i++; |
---|
461 | $form['ae']['ae_' . $ae->nid] = array( |
---|
462 | '#value' => '<div id="' . 'ae_' . $ae->nid . ' "><b>' . check_plain($titulo) . '</b></div>', |
---|
463 | ); |
---|
464 | $aes[$ae->nid] = $ae->titulo; |
---|
465 | } |
---|
466 | } |
---|
467 | $field_form = array(); |
---|
468 | $fields_form = array(); |
---|
469 | $arreglo = array( |
---|
470 | 'field_proyecto_nombre_resp' => 'field_proyecto_nombre_resp', |
---|
471 | 'field_proyecto_apelli_resp' => 'field_proyecto_apelli_resp', |
---|
472 | 'field_proyecto_cedul_resp' => 'field_proyecto_cedul_resp', |
---|
473 | 'field_proyecto_filegace' => 'field_proyecto_filegace', |
---|
474 | 'field_proyecto_nombre_tecn' => 'field_proyecto_nombre_tecn', |
---|
475 | 'field_proyecto_apelli_tecn' => 'field_proyecto_apelli_tecn', |
---|
476 | 'field_proyecto_cedul_tecn' => 'field_proyecto_cedul_tecn', |
---|
477 | 'field_proyecto_filesol' => 'field_proyecto_monto_anual', |
---|
478 | ); |
---|
479 | $node_type = content_types('proyectos_operativos'); |
---|
480 | $fields = $node_type['fields']; |
---|
481 | if (is_array($fields) && count($fields)) { |
---|
482 | foreach($fields as $field_id => $field) { |
---|
483 | if (array_key_exists($field_id, $arreglo)) { |
---|
484 | $field_form[] = $field_id; |
---|
485 | $fields_form[$field_id] = $field_id; |
---|
486 | } |
---|
487 | } |
---|
488 | } |
---|
489 | if (is_array($field_form) && count($field_form)) { |
---|
490 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
491 | foreach ($field_form as $field_id) { |
---|
492 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
493 | $form['#field_info'][$field_id] = $field; |
---|
494 | $form += (array) content_field_form($form, $form_state, $field); |
---|
495 | } |
---|
496 | } |
---|
497 | $form['#proyectos_operativos_fields'] = $fields_form; |
---|
498 | |
---|
499 | $form['#ae'] = $aes; |
---|
500 | $form['buttons'] = array( |
---|
501 | '#prefix' => '<div class="container-inline">', |
---|
502 | '#suffix' => '</div>', |
---|
503 | '#weight' => 1000, |
---|
504 | ); |
---|
505 | $form['buttons']['registrar'] = array( |
---|
506 | '#type' => 'submit', |
---|
507 | '#default_value' => t('Reformular Proyecto'), |
---|
508 | '#weight' => 100, |
---|
509 | ); |
---|
510 | $form['buttons']['cancelar'] = array( |
---|
511 | '#type' => 'submit', |
---|
512 | '#default_value' => t('Cancelar'), |
---|
513 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
514 | '#weight' => 101, |
---|
515 | ); |
---|
516 | $form['#submit'] = array('proyectos_reformulacion_reformula_tab_page_form_submit'); |
---|
517 | return $form; |
---|
518 | } |
---|
519 | |
---|
520 | /** |
---|
521 | * @ingroup themeable |
---|
522 | * @see proyectos_operativos_proyecto_basico_form |
---|
523 | */ |
---|
524 | function theme_proyectos_reformulacion_reformula_tab_page_form($form) { |
---|
525 | $output = ''; |
---|
526 | $output .= drupal_render($form['reformula_proyecto']); |
---|
527 | $output .= drupal_render($form['ae']); |
---|
528 | $header = array(); |
---|
529 | $form['field_proyecto_nombre_resp'][0]['value']['#title'] = t('Nombre'); |
---|
530 | $form['field_proyecto_nombre_resp'][0]['value']['#size'] = 20; |
---|
531 | $form['field_proyecto_apelli_resp'][0]['value']['#title'] = t('Apellido'); |
---|
532 | $form['field_proyecto_apelli_resp'][0]['value']['#size'] = 20; |
---|
533 | $form['field_proyecto_cedul_resp'][0]['value']['#title'] = t('Cédula de Identidad'); |
---|
534 | $form['field_proyecto_cedul_resp'][0]['value']['#size'] = 20; |
---|
535 | $form['field_proyecto_nombre_tecn'][0]['value']['#title'] = t('Nombre'); |
---|
536 | $form['field_proyecto_nombre_tecn'][0]['value']['#size'] = 20; |
---|
537 | $form['field_proyecto_apelli_tecn'][0]['value']['#title'] = t('Apellido'); |
---|
538 | $form['field_proyecto_apelli_tecn'][0]['value']['#size'] = 20; |
---|
539 | $form['field_proyecto_cedul_tecn'][0]['value']['#title'] = t('Cédula de Identidad'); |
---|
540 | $form['field_proyecto_cedul_tecn'][0]['value']['#size'] = 20; |
---|
541 | $header[] = array('data' => t('Responsable de la Institución'), 'colspan' => 3, 'align' => center); |
---|
542 | $rows = array(); |
---|
543 | $row = array(); |
---|
544 | $row[] = array('data' => drupal_render($form['field_proyecto_nombre_resp']),); |
---|
545 | $row[] = array('data' => drupal_render($form['field_proyecto_apelli_resp']),); |
---|
546 | $row[] = array('data' => drupal_render($form['field_proyecto_cedul_resp']),); |
---|
547 | $rows[] = $row; |
---|
548 | $row = array(); |
---|
549 | $row[] = array('data' => drupal_render($form['field_proyecto_filegace']), 'colspan' => 3); |
---|
550 | $rows[] = $row; |
---|
551 | $output .= theme('table', $header, $rows); |
---|
552 | $header = array(); |
---|
553 | $header[] = array('data' => t('Reponsable técnico de solicitar y/o ejecutar la reformulación'), 'colspan' => 3, 'align' => center); |
---|
554 | $rows = array(); |
---|
555 | $row = array(); |
---|
556 | $row[] = array('data' => drupal_render($form['field_proyecto_nombre_tecn']),); |
---|
557 | $row[] = array('data' => drupal_render($form['field_proyecto_apelli_tecn']),); |
---|
558 | $row[] = array('data' => drupal_render($form['field_proyecto_cedul_tecn']),); |
---|
559 | $rows[] = $row; |
---|
560 | $row = array(); |
---|
561 | $row[] = array('data' => drupal_render($form['field_proyecto_filesol']), 'colspan' => 3); |
---|
562 | $rows[] = $row; |
---|
563 | $output .= theme('table', $header, $rows); |
---|
564 | $output .= drupal_render($form); |
---|
565 | return $output; |
---|
566 | } |
---|
567 | |
---|
568 | /* |
---|
569 | * Implementation of continuarproyectosopplurianual_agregar_proyectos_operativo_form_submit(). |
---|
570 | * Guardar el nuevo proyecto operativo. |
---|
571 | */ |
---|
572 | function proyectos_reformulacion_reformula_tab_page_form_submit($form, &$form_state) { |
---|
573 | global $user; |
---|
574 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
575 | if ($op == t('Cancelar')) { |
---|
576 | $form_state['redirect'] = 'proyectos_operativos'; |
---|
577 | return; |
---|
578 | } |
---|
579 | module_load_include('inc', 'node', 'node.pages'); |
---|
580 | $proyecto = $form['#node']; |
---|
581 | if (!isset($proyecto->field_proyecto_reformulab) || !$proyecto->field_proyecto_reformulab[0]['nid'] || !is_numeric($proyecto->field_proyecto_reformulab[0]['nid'])) { |
---|
582 | $proyecto->field_proyecto_reformulab[0]['nid'] = $proyecto->nid; |
---|
583 | node_save($proyecto); |
---|
584 | } |
---|
585 | //se crea el nuevo proyecto plurianual |
---|
586 | $nuevo_proyecto = _reformulacion_clonar_proyecto_aes($proyecto->nid); |
---|
587 | if (module_exists('hs_content_taxonomy') || module_exists('hs_content_taxonomy_description')) { |
---|
588 | foreach ($form['#field_info'] as $field_name => $field_info) { |
---|
589 | if ($field_info['widget']['type'] == 'content_taxonomy_hs') { |
---|
590 | // Change format of values to the one Content Taxonomy expects |
---|
591 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
592 | $values = array(); |
---|
593 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
594 | $values[] = array('value' => $tid); |
---|
595 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
596 | } |
---|
597 | $form_state['values'][$field_name]['tids'] = $values; |
---|
598 | } |
---|
599 | else { |
---|
600 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
601 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
602 | $form_state['values'][$field_name]['tids'] = $values; |
---|
603 | } |
---|
604 | } |
---|
605 | elseif ($field_info['widget']['type'] == 'content_taxonomy_hsd') { |
---|
606 | // Change format of values to the one Content Taxonomy expects |
---|
607 | if (is_array($form_state['values'][$field_name]['tids'])) { |
---|
608 | $values = array(); |
---|
609 | foreach($form_state['values'][$field_name]['tids'] as $tid) { |
---|
610 | $values[] = array('value' => $tid); |
---|
611 | array_unshift($form_state['values'][$field_name], array('value' => $tid)); |
---|
612 | } |
---|
613 | $form_state['values'][$field_name]['tids'] = $values; |
---|
614 | } |
---|
615 | else { |
---|
616 | $values[] = array('value' => $form_state['values'][$field_name]['tids']); |
---|
617 | array_unshift($form_state['values'][$field_name],array('value' => $form_state['values'][$field_name]['tids'])); |
---|
618 | $form_state['values'][$field_name]['tids'] = $values; |
---|
619 | } |
---|
620 | } |
---|
621 | |
---|
622 | } |
---|
623 | } |
---|
624 | $field_form = $form['#proyectos_operativos_fields']; |
---|
625 | module_load_include('inc', 'node', 'node.pages'); |
---|
626 | $form_values = $form_state['values']; |
---|
627 | //$node_load->title = check_plain($form_values['title']); |
---|
628 | if (is_array($field_form) && count($field_form)) { |
---|
629 | foreach ($field_form as $field_id) { |
---|
630 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
631 | foreach($form_values[$field_id] as $id => $value) { |
---|
632 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
633 | unset($form_values[$field_id][$id]['_error_element']); |
---|
634 | } |
---|
635 | } |
---|
636 | $nuevo_proyecto->{$field_id} = $form_values[$field_id]; |
---|
637 | } |
---|
638 | } |
---|
639 | } |
---|
640 | if ($nuevo_proyecto && $nuevo_proyecto->nid) { |
---|
641 | $new_aes = array(); |
---|
642 | $new_aes_title = array(); |
---|
643 | foreach($proyecto->field_proyecto_accion_esp as $nid) { |
---|
644 | if ($nid['nid'] && is_numeric($nid['nid'])) { |
---|
645 | $nueva_ae = _reformulacion_clonar_proyecto_aes($nid['nid'], $nuevo_proyecto->nid); |
---|
646 | if ($nueva_ae && $nueva_ae->nid) { |
---|
647 | $new_aes[]['nid'] = $nueva_ae->nid; |
---|
648 | $new_aes_title[$nueva_ae->nid] = $title; |
---|
649 | } |
---|
650 | } |
---|
651 | } |
---|
652 | if (count($new_aes_title)) { |
---|
653 | $nuevo_proyecto->field_proyecto_accion_esp = $new_aes; |
---|
654 | $nuevo_proyecto->log = t('Se agregarón las AE: @aes', array('@aes' => theme('item_list', $new_aes_title))); |
---|
655 | $nuevo_proyecto->revision = 1; |
---|
656 | node_save($nuevo_proyecto); |
---|
657 | } |
---|
658 | } |
---|
659 | if ($_REQUEST['destination']) { |
---|
660 | $form_state['redirect'] = url('proyectosopedit/' . $nuevo_proyecto->nid, |
---|
661 | array( |
---|
662 | 'query' => array( |
---|
663 | 'destination' => $_REQUEST['destination'], |
---|
664 | ), |
---|
665 | 'absolute' => TRUE, |
---|
666 | ) |
---|
667 | ); |
---|
668 | unset($_REQUEST['destination']); |
---|
669 | } |
---|
670 | else { |
---|
671 | // add redirect |
---|
672 | $form_state['redirect'] = 'proyectosopedit/' . $nuevo_proyecto->nid; |
---|
673 | } |
---|
674 | } |
---|
675 | |
---|
676 | /** |
---|
677 | * Implementation of _continuar_clonar_proyecto_aes(). |
---|
678 | * clonar un proyecto o ae. |
---|
679 | */ |
---|
680 | function _reformulacion_clonar_proyecto_aes($nid = 0, $nodefather = 0) { |
---|
681 | global $user; |
---|
682 | $node_load = 0; |
---|
683 | $seudonimo = array( |
---|
684 | 'proyectos_operativos' => 'proyecto', |
---|
685 | 'accion_especifica' => 'ae', |
---|
686 | ); |
---|
687 | if ($nid && is_numeric($nid)) { |
---|
688 | $node = node_load($nid); |
---|
689 | $campos = _reformulacion_get_fieldsbyformstep(); |
---|
690 | if (isset($campos[$node->type])) { |
---|
691 | $node_load = clone $node; |
---|
692 | unset($node_load->nid); |
---|
693 | unset($node_load->vid); |
---|
694 | unset($node_load->created); |
---|
695 | unset($node_load->changed); |
---|
696 | unset($node_load->revision_uid); |
---|
697 | unset($node_load->path); |
---|
698 | unset($node_load->data); |
---|
699 | unset($node_load->current_revision_id); |
---|
700 | unset($node_load->is_current); |
---|
701 | unset($node_load->num_revisions); |
---|
702 | $node_load->log = t('Se Agregó @tipo como reformulación de (@nombre)', array('@nombre' => check_plain($node->title),'@tipo' => $node->type)); |
---|
703 | $node_load->uid = $user->uid; |
---|
704 | $node_load->revision = 1; |
---|
705 | foreach($campos[$node->type] as $tipo => $campo) { |
---|
706 | foreach($campo as $id) { |
---|
707 | unset($node_load->{$id}); |
---|
708 | } |
---|
709 | } |
---|
710 | $key = 'field_' . $seudonimo[$node->type] . '_reformulab'; |
---|
711 | $node_load->{$key} = array(); |
---|
712 | $enlace = array(); |
---|
713 | $valor = isset($node->{$key}[0]['nid'])? $node->{$key}[0]['nid'] : 0; |
---|
714 | $enlace[]['nid'] = ($valor && is_numeric($valor))? $valor : $node->nid; |
---|
715 | $node_load->{$key} = $enlace; |
---|
716 | if ($node->type == 'accion_especifica') { |
---|
717 | $enlace = array(); |
---|
718 | $valor = isset($node->{'field_ae_proyectorbase'}[0]['nid'])? $node->{'field_ae_proyectorbase'}[0]['nid'] : 0; |
---|
719 | $enlace[]['nid'] = ($valor && is_numeric($valor)) ? $valor : $node->field_accion_esp_proyecto[0]['nid']; |
---|
720 | $node_load->field_ae_proyectobase = $enlace; |
---|
721 | if ($nodefather && is_numeric($nodefather)) { |
---|
722 | $node_load->field_accion_esp_proyecto = array(); |
---|
723 | $node_load->field_accion_esp_proyecto[]['nid'] = $nodefather; |
---|
724 | } |
---|
725 | } |
---|
726 | elseif($node->type == 'proyectos_operativos') { |
---|
727 | $node_load->field_proyectos_segui_reforall = array(); |
---|
728 | $node_load->field_proyecto_accion_esp = array(); |
---|
729 | $node_load->field_proyectos_reforall[]['nid'] = $node->nid; |
---|
730 | $node_load->_workflow = variable_get('proyectos_reformulacion_state_reformulacion', 0); |
---|
731 | } |
---|
732 | node_save($node_load); |
---|
733 | } |
---|
734 | } |
---|
735 | return $node_load; |
---|
736 | } |
---|
737 | |
---|
738 | /** |
---|
739 | * Implementation of _reformulacion_get_fieldsbyformstep(). |
---|
740 | * obtiene los campos a editar en un proyecto o ae. |
---|
741 | */ |
---|
742 | function _reformulacion_get_fieldsbyformstep(){ |
---|
743 | $arreglo = array( |
---|
744 | 'proyectos_operativos' => array( |
---|
745 | 'proyectos_operativos_proyecto_basico_form' => array( |
---|
746 | //colocar el id del campo que no se quiere clonar (node_save colocara el valor por defecto), Ejemplo: |
---|
747 | /* |
---|
748 | 'field_proyecto_monto_ant' => 'field_proyecto_monto_ant', |
---|
749 | */ |
---|
750 | ), |
---|
751 | 'proyectos_operativos_proyecto_generales_form' => array( |
---|
752 | ), |
---|
753 | 'proyectos_operativos_proyecto_indicadores_form' => array( |
---|
754 | ), |
---|
755 | 'otros' => array( |
---|
756 | ), |
---|
757 | ), |
---|
758 | 'accion_especifica' => array( |
---|
759 | 'proyectos_operativos_accion_especifica_crear_form' => array( |
---|
760 | ), |
---|
761 | 'otros' => array( |
---|
762 | ), |
---|
763 | ), |
---|
764 | ); |
---|
765 | return $arreglo; |
---|
766 | } |
---|
767 | |
---|
768 | /* |
---|
769 | * Implementation of hook_proyecto_obtiene_links_alter() |
---|
770 | */ |
---|
771 | function proyectos_reformulacion_proyecto_obtiene_links_alter(&$links, $proyecto, $acceso = FALSE) { |
---|
772 | $aprobado = $proyecto->_workflow == variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
773 | if($aprobado){ |
---|
774 | $links['reformulacion'] = array( |
---|
775 | 'data' => l(t('Reformulaciones'), 'proyectosop/' . $proyecto->nid . '/reformular'), |
---|
776 | 'class' => 'proyectos-operativos-reformulaciones', |
---|
777 | ); |
---|
778 | } |
---|
779 | if ($aprobado && _proyectos_reformulacion_access_add($proyecto)) { |
---|
780 | $links['reformulacion_add'] = array( |
---|
781 | 'data' => l(t('Reformular proyecto'), 'proyectosop/' . $proyecto->nid . '/reformular/add'), |
---|
782 | 'class' => 'continuar-proyectos-reformulaciones-add', |
---|
783 | ); |
---|
784 | } |
---|
785 | } |
---|
786 | |
---|
787 | /** |
---|
788 | * Genera el ahah para el display de cada vista |
---|
789 | */ |
---|
790 | function proyectos_reformulacion_views_js($element = 0) { |
---|
791 | $view_id = 'proyectos_reformulacion_' . $element . '_views'; |
---|
792 | $view_name = $element && isset($_POST[$view_id])? $_POST[$view_id] : 0; |
---|
793 | $output = $view_id; |
---|
794 | if ($view_name && $view = views_get_view($view_name)) { |
---|
795 | $form_state = array('submitted' => FALSE); |
---|
796 | $form_build_id = $_POST['form_build_id']; |
---|
797 | // Add the new element to the stored form. Without adding the element to the |
---|
798 | // form, Drupal is not aware of this new elements existence and will not |
---|
799 | // process it. We retreive the cached form, add the element, and resave. |
---|
800 | $form = form_get_cache($form_build_id, $form_state); |
---|
801 | $options = array('_none' => 'Ninguna'); |
---|
802 | foreach ($view->display as $key => $display) { |
---|
803 | $options[$key] = $display->display_title; |
---|
804 | } |
---|
805 | $display = 'proyectos_reformulacion_' . $element . '_display'; |
---|
806 | $form['proyectos_reformulacion'][$element][$display] = array( |
---|
807 | '#title' => t("Seleccione el display de la vista"), |
---|
808 | '#type' => 'select', |
---|
809 | '#default_value' => variable_get($element . '_display', 0), |
---|
810 | '#options' => $options, |
---|
811 | '#requerid' => TRUE, |
---|
812 | ); |
---|
813 | form_set_cache($form_build_id, $form, $form_state); |
---|
814 | $form += array( |
---|
815 | '#post' => $_POST, |
---|
816 | '#programmed' => FALSE, |
---|
817 | ); |
---|
818 | // Rebuild the form. |
---|
819 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
820 | $new_form = array(); |
---|
821 | unset($form['proyectos_reformulacion'][$element][$display]['#prefix']); |
---|
822 | unset($form['proyectos_reformulacion'][$element][$display]['#suffix']); |
---|
823 | $new_form['proyectos_reformulacion'][$element][$display] = $form['proyectos_reformulacion'][$element][$display]; |
---|
824 | $output = drupal_render($new_form); |
---|
825 | } |
---|
826 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
827 | exit(); |
---|
828 | } |
---|
829 | |
---|
830 | /** |
---|
831 | * Implementation of hook_views_api(). |
---|
832 | */ |
---|
833 | function proyectos_reformulacion_views_api() { |
---|
834 | return array( |
---|
835 | 'api' => '2', |
---|
836 | 'path' => drupal_get_path('module', 'proyectos_reformulacion') . '/views', |
---|
837 | ); |
---|
838 | } |
---|