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 2013 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 - Msc. Juan Vizcarrondo |
---|
24 | * @date 2015-03-09 // (año-mes-dia) |
---|
25 | * @version 0.2 // (0.1) |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /* |
---|
30 | * Implementation of hook_perm |
---|
31 | */ |
---|
32 | function continuarproyectosopplurianual_perm() { |
---|
33 | return array( |
---|
34 | 'Agregar proyecto Plurianual', |
---|
35 | ); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | /* |
---|
40 | * Implementation of hook_menu() |
---|
41 | */ |
---|
42 | function continuarproyectosopplurianual_menu() { |
---|
43 | //agregar proyecto operativo |
---|
44 | $items['continuarproyectosopplurianual/%proyectosop'] = array( |
---|
45 | 'title' => t('Continuar Proyecto Plurianual'), |
---|
46 | 'page callback' => '_continuarproyectosopplurianual', |
---|
47 | 'page arguments' => array(1), |
---|
48 | 'access callback' => '_proyectosopplurianual_access_add', |
---|
49 | 'access arguments' => array(1), |
---|
50 | 'weight' => -7, |
---|
51 | 'type' => MENU_NORMAL_ITEM, |
---|
52 | ); |
---|
53 | return $items; |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * Implementation of _proyectos_operativos_access_editar() |
---|
58 | * Menu access control callback. Determina si un usuario tiene acceso a editar un proyecto |
---|
59 | */ |
---|
60 | function _proyectosopplurianual_access_add($node) { |
---|
61 | global $user; |
---|
62 | if (!user_access('Agregar proyecto Plurianual')) { |
---|
63 | return FALSE; |
---|
64 | } |
---|
65 | if ($node->field_proyecto_plurianual[0]['value'] != variable_get('proyectos_operativos_plurianual', 0)) { |
---|
66 | return FALSE; |
---|
67 | } |
---|
68 | if (module_exists('workflow')) { |
---|
69 | $estado_aprobado = variable_get('proyectos_operativos_state_aprobado', NULL); |
---|
70 | if ($node->_workflow != $estado_aprobado) { |
---|
71 | return FALSE; |
---|
72 | } |
---|
73 | } |
---|
74 | if ($node->anhoproyectos_operativos != variable_get('proyectos_operativos_anho_creacion', 0) - 1) { |
---|
75 | return FALSE; |
---|
76 | } |
---|
77 | $ente_planificador = ente_planificador_leer_ente_planificadores($node->field_proyecto_ente[0]['nid']); |
---|
78 | if (!$ente_planificador || !$ente_planificador->nid) { |
---|
79 | return FALSE; |
---|
80 | } |
---|
81 | $current_time = time(); |
---|
82 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
83 | $fecha = FALSE; |
---|
84 | $ente = usuario_tiene_ente($user->uid); |
---|
85 | if ($ente_planificador->nid != $ente->nid && !user_access('admin planificador')) { |
---|
86 | return FALSE; |
---|
87 | } |
---|
88 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
89 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
90 | $fecha = TRUE; |
---|
91 | } |
---|
92 | if ($fecha) { |
---|
93 | if ($ente->nid == $ente_planificador->nid) { |
---|
94 | $fecha = TRUE; |
---|
95 | } |
---|
96 | elseif (!user_access('admin planificador')) { |
---|
97 | $fecha = FALSE; |
---|
98 | } |
---|
99 | } |
---|
100 | return $fecha && $roles_perm; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | /** |
---|
105 | * Implementation of _proyectos_operativos_proyecto_agregar_proyecto($proyecto). |
---|
106 | * Agregar un nuevo proyecto. |
---|
107 | */ |
---|
108 | function _continuarproyectosopplurianual($proyecto = 0) { |
---|
109 | $output = ''; |
---|
110 | $output .= drupal_get_form('continuarproyectosopplurianual_agregar_proyectos_operativo_form', $proyecto); |
---|
111 | return $output; |
---|
112 | } |
---|
113 | |
---|
114 | /** |
---|
115 | * Implementation of proyectos_operativos_proyecto_basico_form(). |
---|
116 | * Formulario de datos basicos (proyectos operativos). |
---|
117 | */ |
---|
118 | function continuarproyectosopplurianual_agregar_proyectos_operativo_form(&$form_state, $proyecto = 0) { |
---|
119 | global $user; |
---|
120 | //add breadcrumb |
---|
121 | $breadcrumb = array(); |
---|
122 | $breadcrumb[] = l(t('Home'), '<front>'); |
---|
123 | $breadcrumb[] = l(t('Proyectos Operativos'), 'proyectos_operativos'); |
---|
124 | if ($proyecto->nid) { |
---|
125 | $breadcrumb[] = l(check_plain($proyecto->title), 'proyectosop/' . $proyecto->nid); |
---|
126 | } |
---|
127 | $breadcrumb[] = t('Continuar Proyecto Plurianual'); // Link to current URL |
---|
128 | drupal_set_breadcrumb($breadcrumb); |
---|
129 | $current_time = time(); |
---|
130 | $tipo_plan = 'proyectos_operativos_formular'; |
---|
131 | $ente_planificador = 0; |
---|
132 | if($proyecto && $proyecto->nid && $proyecto->field_proyecto_ente[0]['nid']) { |
---|
133 | $ente_planificador = ente_planificador_leer_ente_planificadores($proyecto->field_proyecto_ente[0]['nid']); |
---|
134 | } |
---|
135 | $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, $ente_planificador); |
---|
136 | $fecha = FALSE; |
---|
137 | if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { |
---|
138 | $fecha = TRUE; |
---|
139 | } |
---|
140 | if (!$fecha) { |
---|
141 | muestra_mensaje($tipo_plan, $ente_planificador); |
---|
142 | } |
---|
143 | if ($fecha && $ente->nid) { |
---|
144 | muestra_mensaje($tipo_plan, $ente_planificador, 0); |
---|
145 | } |
---|
146 | $fechas_validacion = array( |
---|
147 | 'inicio' => '', |
---|
148 | 'fin' => '', |
---|
149 | ); |
---|
150 | $montos_asignados = 0; |
---|
151 | $acciones_especificas = array(); |
---|
152 | $porcentajes = array(); |
---|
153 | $ejecucion = 0; |
---|
154 | $proyecto_leido = new stdClass(); |
---|
155 | $proyecto_leido->type = 'proyectos_operativos'; |
---|
156 | $proyecto_leido->title = ''; |
---|
157 | $proyecto_leido->field_proyecto_ente[0]['nid'] = $ente_planificador->nid; |
---|
158 | $proyecto_leido->field_proyecto_plurianualb[0]['nid'] = $proyecto->nid; |
---|
159 | $arreglo = array( |
---|
160 | 'field_proyecto_titulo' => 'field_proyecto_titulo', |
---|
161 | 'field_proyecto_codigo' => 'field_proyecto_codigo', |
---|
162 | 'field_proyecto_status' => 'field_proyecto_status', |
---|
163 | 'field_proyecto_situacion_p' => 'field_proyecto_situacion_p', |
---|
164 | 'field_proyecto_plurianual' => 'field_proyecto_plurianual', |
---|
165 | 'field_proyecto_total' => 'field_proyecto_total', |
---|
166 | 'field_proyecto_poan' => 'field_proyecto_poan', |
---|
167 | 'field_proyecto_autoridad' => 'field_proyecto_autoridad', |
---|
168 | 'field_proyecto_lider' => 'field_proyecto_lider', |
---|
169 | 'field_proyecto_unidad_a' => 'field_proyecto_unidad_a', |
---|
170 | 'field_proyecto_cargo' => 'field_proyecto_cargo', |
---|
171 | 'field_proyecto_telefono' => 'field_proyecto_telefono', |
---|
172 | 'field_proyecto_correo' => 'field_proyecto_correo', |
---|
173 | 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', |
---|
174 | 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', |
---|
175 | 'field_proyecto_emindirecto' => 'field_proyecto_emindirecto', |
---|
176 | 'field_proyecto_efindirecto' => 'field_proyecto_efindirecto', |
---|
177 | 'field_proyecto_og' => 'field_proyecto_og', |
---|
178 | 'field_proyecto_oe' => 'field_proyecto_oe', |
---|
179 | ); |
---|
180 | if (variable_get('proyectos_operativos_muestra_pndes', TRUE)) { |
---|
181 | $arreglo['field_proyecto_pndes'] = 'field_proyecto_pndes'; |
---|
182 | } |
---|
183 | if (variable_get('proyectos_operativos_muestra_mcti', TRUE)) { |
---|
184 | $arreglo['field_proyecto_mcti'] = 'field_proyecto_mcti'; |
---|
185 | } |
---|
186 | if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { |
---|
187 | $arreglo += array( |
---|
188 | 'field_proyecto_institucionth' => 'field_proyecto_institucionth', |
---|
189 | 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', |
---|
190 | 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', |
---|
191 | 'field_proyecto_rol_th' => 'field_proyecto_rol_th', |
---|
192 | 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', |
---|
193 | 'field_proyecto_formacion' => 'field_proyecto_formacion', |
---|
194 | ); |
---|
195 | |
---|
196 | } |
---|
197 | if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { |
---|
198 | $arreglo += array( |
---|
199 | 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', |
---|
200 | 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', |
---|
201 | 'field_proyecto_equipos' => 'field_proyecto_equipos', |
---|
202 | 'field_proyecto_insumos' => 'field_proyecto_insumos', |
---|
203 | 'field_proyectos_servicios' => 'field_proyectos_servicios', |
---|
204 | ); |
---|
205 | } |
---|
206 | if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { |
---|
207 | $arreglo += array( |
---|
208 | 'field_proyecto_beneficiario' => 'field_proyecto_beneficiario', |
---|
209 | 'field_proyectos_masculino_d' => 'field_proyectos_masculino_d', |
---|
210 | 'field_proyectos_femenino_d' => 'field_proyectos_femenino_d', |
---|
211 | ); |
---|
212 | if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { |
---|
213 | $arreglo['field_proyectos_masculino_i'] = 'field_proyectos_masculino_i'; |
---|
214 | $arreglo['field_proyectos_femenino_i'] = 'field_proyectos_femenino_i'; |
---|
215 | } |
---|
216 | } |
---|
217 | if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { |
---|
218 | $arreglo += array( |
---|
219 | 'field_proyecto_causas' => 'field_proyecto_causas', |
---|
220 | 'field_proyecto_problemas' => 'field_proyecto_problemas', |
---|
221 | 'field_proyecto_consecuencias' => 'field_proyecto_consecuencias', |
---|
222 | ); |
---|
223 | } |
---|
224 | if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { |
---|
225 | $arreglo += array( |
---|
226 | 'field_proyecto_justificacion' => 'field_proyecto_justificacion', |
---|
227 | ); |
---|
228 | } |
---|
229 | if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { |
---|
230 | $arreglo += array( |
---|
231 | 'field_proyecto_alcance' => 'field_proyecto_alcance', |
---|
232 | ); |
---|
233 | } |
---|
234 | $sa = variable_get('proyectos_operativos_muestra_sa', TRUE); |
---|
235 | $so = variable_get('proyectos_operativos_muestra_so', TRUE); |
---|
236 | if ($sa) { |
---|
237 | $arreglo += array( |
---|
238 | 'field_proyecto_sa_descripcion' => 'field_proyecto_sa_descripcion', |
---|
239 | ); |
---|
240 | if (variable_get('proyectos_operativos_muestra_sa_cuantificacion', TRUE)) { |
---|
241 | $arreglo['field_proyecto_sa_cuantificacion'] = 'field_proyecto_sa_cuantificacion'; |
---|
242 | } |
---|
243 | $arreglo['field_proyecto_sa_formulai'] = 'field_proyecto_sa_formulai'; |
---|
244 | $arreglo['field_proyecto_sa_fuentei'] = 'field_proyecto_sa_fuentei'; |
---|
245 | $arreglo['field_proyecto_sa_fecha'] = 'field_proyecto_sa_fecha'; |
---|
246 | } |
---|
247 | if ($so) { |
---|
248 | $arreglo += array( |
---|
249 | 'field_proyecto_so_descripcion' => 'field_proyecto_so_descripcion', |
---|
250 | 'field_proyecto_so_cuantificacion' => 'field_proyecto_so_cuantificacion', |
---|
251 | 'field_proyecto_tiempoi' => 'field_proyecto_tiempoi', |
---|
252 | ); |
---|
253 | } |
---|
254 | $arreglo['field_proyecto_descripcion_bien'] = 'field_proyecto_descripcion_bien'; |
---|
255 | $arreglo['field_proyecto_unidadm'] = 'field_proyecto_unidadm'; |
---|
256 | $personas = variable_get('proyectos_operativos_allow_unidpersona', array()); |
---|
257 | if (count($personas)) { |
---|
258 | $arreglo['field_proyecto_meta_m'] = 'field_proyecto_meta_m'; |
---|
259 | $arreglo['field_proyecto_meta_f'] = 'field_proyecto_meta_f'; |
---|
260 | } |
---|
261 | $arreglo['field_proyecto_meta_fisica'] = 'field_proyecto_meta_fisica'; |
---|
262 | foreach ($arreglo as $indice) { |
---|
263 | $proyecto_leido->{$indice} = $proyecto->{$indice}; |
---|
264 | } |
---|
265 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
266 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
267 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos2.js'); |
---|
268 | $form = array(); |
---|
269 | $fechas_validacion['fin_texto'] = ''; |
---|
270 | $fechas_validacion['inicio_texto'] = ''; |
---|
271 | if ($fechas_validacion['inicio']) { |
---|
272 | $f_aux = explode(' ', $fechas_validacion['inicio']); |
---|
273 | $f_aux = explode('-', $f_aux[0]); |
---|
274 | $fechas_validacion['inicio_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
275 | $fechas_validacion['inicio_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
276 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_i[0]['value']); |
---|
277 | $f_aux = explode('-', $f_aux[0]); |
---|
278 | $fechas_validacion['inicio_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
279 | $fechas_validacion['inicio_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
280 | } |
---|
281 | if ($fechas_validacion['fin']) { |
---|
282 | $f_aux = explode(' ', $fechas_validacion['fin']); |
---|
283 | $f_aux = explode('-', $f_aux[0]); |
---|
284 | $fechas_validacion['fin_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
285 | $fechas_validacion['fin_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
286 | $f_aux = explode(' ', $proyecto_leido->field_proyecto_fecha_f[0]['value']); |
---|
287 | $f_aux = explode('-', $f_aux[0]); |
---|
288 | $fechas_validacion['fin_current_texto'] = $f_aux[2] . '-' . $f_aux[1] . '-' . $f_aux[0]; |
---|
289 | $fechas_validacion['fin_current_time'] = mktime(0, 0, 0, $f_aux[1], $f_aux[2], $f_aux[0]); |
---|
290 | } |
---|
291 | $format_number = array( |
---|
292 | 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), |
---|
293 | 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), |
---|
294 | 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), |
---|
295 | ); |
---|
296 | $node_type = content_types('proyectos_operativos'); |
---|
297 | $fields = $node_type['fields']; |
---|
298 | $form['#format_number'] = array('format_number' => $format_number); |
---|
299 | drupal_add_js($form['#format_number'], 'setting'); |
---|
300 | drupal_add_js(array('proyectos_operativos' => array('plurianual' => variable_get('proyectos_operativos_plurianual', 0))), 'setting'); |
---|
301 | $form['#ente_planificador'] = $ente_planificador; |
---|
302 | $form['#fechas_validacion'] = $fechas_validacion; |
---|
303 | $field_form = array(); |
---|
304 | $fields_form = array(); |
---|
305 | $fields_form_ac_d = array(); |
---|
306 | $arreglo = array( |
---|
307 | //'field_proyecto_titulo' => 'field_proyecto_titulo', |
---|
308 | //'field_proyecto_codigo' => 'field_proyecto_codigo', |
---|
309 | 'field_proyecto_fecha_i' => 'field_proyecto_fecha_i', |
---|
310 | 'field_proyecto_fecha_f' => 'field_proyecto_fecha_f', |
---|
311 | ); |
---|
312 | if (is_array($fields) && count($fields)) { |
---|
313 | foreach($fields as $field_id => $field) { |
---|
314 | if (array_key_exists($field_id, $arreglo)) { |
---|
315 | $field_form[] = $field_id; |
---|
316 | $fields_form[] = $field_id; |
---|
317 | } |
---|
318 | elseif (variable_get('proyectos_operativos_ac_d_' . $field_id, FALSE)) { |
---|
319 | $fields_form_ac_d[$field_id] = $field_id; |
---|
320 | $field_form[] = $field_id; |
---|
321 | $fields_form[] = $field_id; |
---|
322 | } |
---|
323 | } |
---|
324 | } |
---|
325 | $form['#node'] = $proyecto_leido; |
---|
326 | if (is_array($field_form) && count($field_form)) { |
---|
327 | module_load_include('inc', 'content', 'includes/content.node_form'); |
---|
328 | foreach ($field_form as $field_id) { |
---|
329 | $field = content_fields($field_id, 'proyectos_operativos'); |
---|
330 | $form['#field_info'][$field_id] = $field; |
---|
331 | $form += (array) content_field_form($form, $form_state, $field); |
---|
332 | } |
---|
333 | } |
---|
334 | $form['#proyecto_anho'] = variable_get('proyectos_operativos_anho_creacion', 0) ? variable_get('proyectos_operativos_anho_creacion', 0) : date("Y"); |
---|
335 | $form['#proyectos_operativos_fields'] = $fields_form; |
---|
336 | $form['buttons'] = array( |
---|
337 | '#prefix' => '<div class="container-inline">', |
---|
338 | '#suffix' => '</div>', |
---|
339 | '#weight' => 200, |
---|
340 | ); |
---|
341 | $form['buttons']['registrar'] = array( |
---|
342 | '#type' => 'submit', |
---|
343 | '#default_value' => t('Continuar Proyecto Plurianual'), |
---|
344 | '#weight' => 100, |
---|
345 | ); |
---|
346 | $form['buttons']['cancelar'] = array( |
---|
347 | '#type' => 'submit', |
---|
348 | '#default_value' => t('Cancelar'), |
---|
349 | '#attributes' => array('onClick' => 'window.location="' . base_path() .$_GET['q'] . '"; return false;'), |
---|
350 | '#weight' => 101, |
---|
351 | ); |
---|
352 | $form['#submit'] = array('continuarproyectosopplurianual_agregar_proyectos_operativo_form_submit'); |
---|
353 | return $form; |
---|
354 | } |
---|
355 | |
---|
356 | |
---|
357 | /* |
---|
358 | * Implementation of proyectos_operativos_proyecto_basico_form_validate() |
---|
359 | * Validar formulario de datos basicos (proyectos operativos). |
---|
360 | */ |
---|
361 | function continuarproyectosopplurianual_agregar_proyectos_operativo_form_validate($form, &$form_state) { |
---|
362 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
363 | if ($op == t('Cancelar')) { |
---|
364 | return; |
---|
365 | } |
---|
366 | $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); |
---|
367 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); |
---|
368 | drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos2.js'); |
---|
369 | //lamentablemente date no valida que from sea menor que to |
---|
370 | if ($form_state['values']['field_proyecto_fecha_i'][0]['value'] > $form_state['values']['field_proyecto_fecha_f'][0]['value']) { |
---|
371 | form_set_error('field_proyecto_fecha_i', t('La fecha de inicio debe ser menor a la fecha de culminación')); |
---|
372 | } |
---|
373 | $fecha = explode('-', $form_state['values']['field_proyecto_fecha_f'][0]['value']); |
---|
374 | if (is_array($fecha) && count($fecha)) { |
---|
375 | if ($form['#proyecto_anho'] != $fecha[0]) { |
---|
376 | 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']))); |
---|
377 | } |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | /* |
---|
382 | * Implementation of proyectos_operativos_proyecto_basico_form_submit(). |
---|
383 | * Guardar formulario de datos basicos (proyectos operativos). |
---|
384 | */ |
---|
385 | function continuarproyectosopplurianual_agregar_proyectos_operativo_form_submit($form, &$form_state) { |
---|
386 | $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; |
---|
387 | if ($op == t('Cancelar')) { |
---|
388 | drupal_set_message(t('Se cancelo el ingreso de los datos básicos del proyecto.')); |
---|
389 | if ($form['#node']->nid) { |
---|
390 | $form_state['redirect'] = 'proyectosopedit/' . $form['#node']->nid; |
---|
391 | } |
---|
392 | else { |
---|
393 | $form_state['redirect'] = 'proyectos_operativos'; |
---|
394 | } |
---|
395 | return; |
---|
396 | } |
---|
397 | global $user; |
---|
398 | $field_form = $form['#proyectos_operativos_fields']; |
---|
399 | module_load_include('inc', 'node', 'node.pages'); |
---|
400 | $node_load = $form['#node']; |
---|
401 | $form_values = $form_state['values']; |
---|
402 | //$node_load->title = check_plain($form_values['title']); |
---|
403 | if (is_array($field_form) && count($field_form)) { |
---|
404 | foreach ($field_form as $field_id) { |
---|
405 | if (isset($form_values[$field_id]) && is_array($form_values[$field_id])) { |
---|
406 | foreach($form_values[$field_id] as $id => $value) { |
---|
407 | if (is_numeric($id) && isset($form_values[$field_id][$id]['_error_element'])) { |
---|
408 | unset($form_values[$field_id][$id]['_error_element']); |
---|
409 | } |
---|
410 | } |
---|
411 | $node_load->{$field_id} = $form_values[$field_id]; |
---|
412 | } |
---|
413 | } |
---|
414 | } |
---|
415 | $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'; |
---|
416 | if ($node_load->nid) { |
---|
417 | $texto = t('Modificados los datos básicos del proyecto'); |
---|
418 | $node_load->log = $texto; |
---|
419 | drupal_set_message($texto); |
---|
420 | } |
---|
421 | else { |
---|
422 | $node_load->uid = $user->uid; |
---|
423 | $texto = t('Agregado la continuación del proyecto Plurianual'); |
---|
424 | $node_load->log = t('Agregado la continuación del proyecto Plurianual'); |
---|
425 | drupal_set_message($texto); |
---|
426 | } |
---|
427 | $node_load->revision = 1; |
---|
428 | node_save($node_load); |
---|
429 | if ($_REQUEST['destination']) { |
---|
430 | $form_state['redirect'] = url('proyectosopedit/' . $node_load->nid, |
---|
431 | array( |
---|
432 | 'query' => array( |
---|
433 | 'destination' => $_REQUEST['destination'], |
---|
434 | ), |
---|
435 | 'absolute' => TRUE, |
---|
436 | ) |
---|
437 | ); |
---|
438 | unset($_REQUEST['destination']); |
---|
439 | } |
---|
440 | else { |
---|
441 | // add redirect |
---|
442 | $form_state['redirect'] = 'proyectosopedit/' . $node_load->nid; |
---|
443 | } |
---|
444 | } |
---|
445 | |
---|
446 | /* |
---|
447 | * Implementation of hook_proyecto_obtiene_links_alter() |
---|
448 | */ |
---|
449 | function continuarproyectosopplurianual_proyecto_obtiene_links_alter(&$links, $proyecto, $acceso = FALSE) { |
---|
450 | if (_proyectosopplurianual_access_add($proyecto)) { |
---|
451 | $nid_proyecto_base = (isset($proyecto->field_proyecto_plurianualb[0]['nid']) && $proyecto->field_proyecto_plurianualb[0]['nid'])? $proyecto->field_proyecto_plurianualb[0]['nid'] : $proyecto->nid; |
---|
452 | $links['proyecto_plurianual'] = array( |
---|
453 | 'data' => l(t('Continuar Proyecto Plurianual'), 'continuarproyectosopplurianual/' . $nid_proyecto_base), |
---|
454 | 'class' => 'continuar-proyectos-operativos', |
---|
455 | ); |
---|
456 | } |
---|
457 | } |
---|