1 | <?php |
---|
2 | |
---|
3 | /* |
---|
4 | * Implementation of hook_planificador_block() |
---|
5 | */ |
---|
6 | function entes_planificadores_exportar_block($op = 'list', $delta = 0, $edit = array()) { |
---|
7 | if ($op == 'list') { |
---|
8 | $blocks[0] = array( |
---|
9 | 'info' => t('Exportar planificación'), |
---|
10 | ); |
---|
11 | return $blocks; |
---|
12 | } |
---|
13 | else if ($op == 'view') { |
---|
14 | switch ($delta) { |
---|
15 | case 0: |
---|
16 | global $user; |
---|
17 | if (arg(0) == 'planificacion' && is_numeric(arg(1))) { |
---|
18 | $nid = arg(1); |
---|
19 | global $user; |
---|
20 | $ente = usuario_tiene_ente($user->uid); |
---|
21 | if ($user->uid == 1 || $ente->nid == $nid) { |
---|
22 | $block = array( |
---|
23 | 'subject' => t('Importar planificación'), |
---|
24 | 'content' => l(t('Importar planificación desde otros entes'), 'planificacion/' . $nid . '/exportar'), |
---|
25 | ); |
---|
26 | return $block; |
---|
27 | } |
---|
28 | } |
---|
29 | return $block; |
---|
30 | break; |
---|
31 | } |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | /* |
---|
38 | * Implementation of hook_menu() |
---|
39 | */ |
---|
40 | function entes_planificadores_exportar_menu() { |
---|
41 | $items = array(); |
---|
42 | $items['planificacion/%ente_planificador_menu/exportar'] = array( |
---|
43 | 'title' => t('Importar planificación'), |
---|
44 | 'page callback' => '_entes_planificadores_exportar', |
---|
45 | 'page arguments' => array(1), |
---|
46 | 'access arguments' => array('exportar planificador'), |
---|
47 | 'weight' => -8, |
---|
48 | 'type' => MENU_CALLBACK, |
---|
49 | ); |
---|
50 | return $items; |
---|
51 | } |
---|
52 | /* |
---|
53 | * Implementation of hook_perm |
---|
54 | */ |
---|
55 | function entes_planificadores_exportar_perm() { |
---|
56 | return array( |
---|
57 | 'exportar planificador', |
---|
58 | ); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | /* |
---|
63 | * entes_planificadores |
---|
64 | * Listar entes planificador |
---|
65 | */ |
---|
66 | function _entes_planificadores_exportar($ente_planificador, $tipo = '') { |
---|
67 | $output = ''; |
---|
68 | $situacion_actual_preliminar = module_exists('situacion_actual_preliminar'); |
---|
69 | $situacion_actual = module_exists('situacion_actual'); |
---|
70 | $tipos = array(); |
---|
71 | if ($situacion_actual_preliminar) { |
---|
72 | $tipos['situacion_actual_preliminar'] = t('Interpretación - Versión Preliminar'); |
---|
73 | } |
---|
74 | /* |
---|
75 | if ($situacion_actual) { |
---|
76 | $tipos['situacion_actual'] = t('Situacional actual'); |
---|
77 | } |
---|
78 | */ |
---|
79 | $links = array(); |
---|
80 | |
---|
81 | foreach($tipos as $id => $value) { |
---|
82 | $links[] = array('data' => l($value, 'planificacion/' . $ente_planificador->nid . '/exportar/' . $id)); |
---|
83 | } |
---|
84 | |
---|
85 | $output .= theme('item_list', $links); |
---|
86 | $output .= '<p><b>Ente planificador:</b> ' . l($ente_planificador->title, 'planificacion/' . c) . ' (Destino)</p>'; |
---|
87 | if($tipos[$tipo]) { |
---|
88 | $step = 1; |
---|
89 | $sqlcount = "SELECT count(n.nid) from {node} n, {node_revisions} rv where n.vid = rv.vid AND (n.type in ('ente_planificador')) AND (n.status <> 0)"; |
---|
90 | $sql = "SELECT n.nid as nid, n.title as title from {node} n, {node_revisions} rv where n.vid = rv.vid AND (n.type in ('ente_planificador')) AND (n.status <> 0)"; |
---|
91 | $result = pager_query($sql, $step, 0, $sqlcount); |
---|
92 | while($entes = db_fetch_object($result)) { |
---|
93 | $output .= '<p><b>Ente planificador:</b> ' . $entes->title . ' (Fuente)</p>'; |
---|
94 | if ($situacion_actual_preliminar && $tipo == 'situacion_actual_preliminar') { |
---|
95 | drupal_set_title(t('Importar @tipo', array('@tipo' => $tipos[$tipo]))); |
---|
96 | $sql_query = "SELECT nid FROM {content_type_situacion_actual_preliminar} WHERE field_version_planificador_nid = %d"; |
---|
97 | $explicacion = db_fetch_object(db_query($sql_query, $entes->nid)); |
---|
98 | if ($explicacion->nid) { |
---|
99 | $explicacion_load = node_load($explicacion->nid); |
---|
100 | $headers_table = array(); |
---|
101 | $headers_table[] = array('data' => t('Descriptores de la situación actual')); |
---|
102 | $headers_table[] = array('data' => t('Cambios ideales')); |
---|
103 | $headers_table[] = array('data' => t('Causas')); |
---|
104 | $headers_table[] = array('data' => t('Cambios de la situación actual')); |
---|
105 | $row = array(); |
---|
106 | $row[] = array('data' => drupal_get_form('entes_planificadores_exportar_hechos_form', $ente_planificador, $explicacion_load, 'field_pre_hechos_verifi')); |
---|
107 | $row[] = array('data' => drupal_get_form('entes_planificadores_exportar_cambios_form', $ente_planificador, $explicacion_load, 'field_pre_cambios_ideales')); |
---|
108 | $row[] = array('data' => drupal_get_form('entes_planificadores_exportar_causas_form', $ente_planificador, $explicacion_load, 'field_pre_cambios_causas')); |
---|
109 | $row[] = array('data' => drupal_get_form('entes_planificadores_exportar_situacion_form', $ente_planificador, $explicacion_load, 'field_pre_cambios_situacion')); |
---|
110 | $rows[] = $row; |
---|
111 | $output .= theme('table', $headers_table, $rows); |
---|
112 | } |
---|
113 | |
---|
114 | } |
---|
115 | elseif($situacion_actual && $tipo == 'situacion_actual') { |
---|
116 | drupal_set_title(t('Importar @tipo', array('@tipo' => $tipos[$tipo]))); |
---|
117 | $headers_table = array(); |
---|
118 | $headers_table[] = array('data' => t('Descriptores de la situación actual')); |
---|
119 | $headers_table[] = array('data' => t('Causas de la situación actual')); |
---|
120 | $row = array(); |
---|
121 | //SE OBTIENEN LAS CAUSAS |
---|
122 | $sql_query = "SELECT c.nid FROM {content_type_descriptores} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_descriptores_planificador_nid = %d ORDER BY c.nid"; |
---|
123 | $result = db_query($sql_query, $entes->nid); |
---|
124 | $descriptores = array(); |
---|
125 | while($descriptor = db_fetch_object($result)) { |
---|
126 | $descriptor_load = node_load($descriptor->nid); |
---|
127 | $descriptores[$descriptor_load->nid] = $descriptor_load; |
---|
128 | } |
---|
129 | if (count($descriptores)) { |
---|
130 | $row[] = array('data' => drupal_get_form('entes_planificadores_exportar_situacion_actual_descriptor_form', $ente_planificador, $descriptores)); |
---|
131 | } |
---|
132 | else { |
---|
133 | $row[] = array('data' => t('El ente aun no ha introducido los descriptores')); |
---|
134 | } |
---|
135 | //SE OBTIENEN LAS CAUSAS |
---|
136 | $sql_query = "SELECT c.nid FROM {content_type_causas} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid WHERE c.field_ente_planifiador_nid = %d ORDER BY c.nid"; |
---|
137 | $result = db_query($sql_query, $entes->nid); |
---|
138 | $causas = array(); |
---|
139 | while($causa = db_fetch_object($result)) { |
---|
140 | $causa_load = node_load($causa->nid); |
---|
141 | $causas[$causa_load->nid] = $causa_load; |
---|
142 | } |
---|
143 | if (count($causas)) { |
---|
144 | $row[] = array('data' => drupal_get_form('entes_planificadores_exportar_situacion_actual_causas_form', $ente_planificador, $causas)); |
---|
145 | } |
---|
146 | else { |
---|
147 | $row[] = array('data' => t('El ente aun no ha introducido causas')); |
---|
148 | } |
---|
149 | $rows[] = $row; |
---|
150 | $output .= theme('table', $headers_table, $rows); |
---|
151 | } |
---|
152 | } |
---|
153 | $output .= theme('pager', NULL); |
---|
154 | } |
---|
155 | return $output; |
---|
156 | } |
---|
157 | |
---|
158 | |
---|
159 | //causas |
---|
160 | |
---|
161 | function entes_planificadores_exportar_causas_form($form_state, $ente_planificador, $planificacion = 0) { |
---|
162 | $campo = 'field_pre_cambios_causas'; |
---|
163 | $form = array(); |
---|
164 | $form['#ente_planificador'] = $ente_planificador; |
---|
165 | $form['#planificacion'] = $planificacion; |
---|
166 | $options = $planificacion->{$campo}; |
---|
167 | $opciones = array(); |
---|
168 | if (count($options)) { |
---|
169 | foreach ($options as $id => $value) { |
---|
170 | if ($value['value']) { |
---|
171 | $opciones['campo_' . $id] = $value['value']; |
---|
172 | } |
---|
173 | } |
---|
174 | } |
---|
175 | $form['#opciones'] = $opciones; |
---|
176 | $causas = array(); |
---|
177 | if (count($opciones)) { |
---|
178 | foreach ($opciones as $id => $value) { |
---|
179 | $form[$id] = array( |
---|
180 | '#type' => 'checkbox', |
---|
181 | '#title' => $value, |
---|
182 | ); |
---|
183 | } |
---|
184 | $form['buttons']['submit'] = array( |
---|
185 | '#type' => 'submit', |
---|
186 | '#value' => t('Submit'), |
---|
187 | '#weight' => 20 |
---|
188 | ); |
---|
189 | } |
---|
190 | return $form; |
---|
191 | } |
---|
192 | function entes_planificadores_exportar_causas_form_submit($form, &$form_state) { |
---|
193 | $ente_planificador = $form['#ente_planificador']; |
---|
194 | $opciones = $form['#opciones']; |
---|
195 | $values = array(); |
---|
196 | if (count($opciones)) { |
---|
197 | foreach ($opciones as $id => $value) { |
---|
198 | if ($form_state['values'][$id]) { |
---|
199 | $values[] = $value; |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | module_load_include('inc', 'node', 'node.pages'); |
---|
204 | $sql_query = "SELECT nid FROM {content_type_situacion_actual_preliminar} WHERE field_version_planificador_nid = %d"; |
---|
205 | $explicacion = db_fetch_object(db_query($sql_query, $ente_planificador->nid)); |
---|
206 | if (!$explicacion->nid) { |
---|
207 | $explicacion1 = new stdClass(); |
---|
208 | $explicacion1->type = 'situacion_actual_preliminar'; |
---|
209 | node_object_prepare($explicacion1); |
---|
210 | $explicacion1->title = t('Explicación situacional @ente', array('@ente' => $ente_planificador->title)); |
---|
211 | $explicacion1->uid = $user->uid; |
---|
212 | $explicacion1->field_pre_cambios_ideales = array(); |
---|
213 | $explicacion1->field_pre_cambios_ideales[] = array('value' => ''); |
---|
214 | $explicacion1->field_pre_hechos_verifi = array(); |
---|
215 | $explicacion1->field_pre_hechos_verifi[] = array('value' => ''); |
---|
216 | $explicacion1->field_pre_cambios_causas = array(); |
---|
217 | $explicacion1->field_pre_cambios_causas[] = array('nid' => ''); |
---|
218 | $explicacion1->field_pre_cambios_situacion = array(); |
---|
219 | $explicacion1->field_pre_cambios_situacion[] = array('value' => ''); |
---|
220 | $explicacion1->field_version_planificador = array(); |
---|
221 | $explicacion1->field_version_planificador[0] = array('nid' => $ente_planificador->nid); |
---|
222 | node_save($explicacion1); |
---|
223 | $explicacion = $explicacion1; |
---|
224 | } |
---|
225 | $explicacion_load = node_load($explicacion->nid); |
---|
226 | if ($explicacion_load->type == 'situacion_actual_preliminar' && count($values)){ |
---|
227 | node_object_prepare($explicacion_load); |
---|
228 | $campo = 'field_pre_cambios_causas'; |
---|
229 | $counter = 0; |
---|
230 | foreach ($values as $value) { |
---|
231 | $explicacion_load->{$campo}[]['value'] = $value; |
---|
232 | $counter++; |
---|
233 | } |
---|
234 | node_save($explicacion_load); |
---|
235 | drupal_set_message(t('Se agregaron @counter causas', array('@counter' => $counter))); |
---|
236 | |
---|
237 | } |
---|
238 | } |
---|
239 | |
---|
240 | function entes_planificadores_exportar_hechos_form($form_state, $ente_planificador, $planificacion = 0) { |
---|
241 | $campo = 'field_pre_hechos_verifi'; |
---|
242 | $form = array(); |
---|
243 | $form['#ente_planificador'] = $ente_planificador; |
---|
244 | $form['#planificacion'] = $planificacion; |
---|
245 | $options = $planificacion->{$campo}; |
---|
246 | $opciones = array(); |
---|
247 | if (count($options)) { |
---|
248 | foreach ($options as $id => $value) { |
---|
249 | if ($value['value']) { |
---|
250 | $opciones['campo_' . $id] = $value['value']; |
---|
251 | } |
---|
252 | } |
---|
253 | } |
---|
254 | $form['#opciones'] = $opciones; |
---|
255 | $causas = array(); |
---|
256 | if (count($opciones)) { |
---|
257 | foreach ($opciones as $id => $value) { |
---|
258 | $form[$id] = array( |
---|
259 | '#type' => 'checkbox', |
---|
260 | '#title' => $value, |
---|
261 | ); |
---|
262 | } |
---|
263 | $form['buttons']['submit'] = array( |
---|
264 | '#type' => 'submit', |
---|
265 | '#value' => t('Submit'), |
---|
266 | '#weight' => 20 |
---|
267 | ); |
---|
268 | } |
---|
269 | return $form; |
---|
270 | } |
---|
271 | function entes_planificadores_exportar_hechos_form_submit($form, &$form_state) { |
---|
272 | $ente_planificador = $form['#ente_planificador']; |
---|
273 | $opciones = $form['#opciones']; |
---|
274 | $values = array(); |
---|
275 | if (count($opciones)) { |
---|
276 | foreach ($opciones as $id => $value) { |
---|
277 | if ($form_state['values'][$id]) { |
---|
278 | $values[] = $value; |
---|
279 | } |
---|
280 | } |
---|
281 | } |
---|
282 | module_load_include('inc', 'node', 'node.pages'); |
---|
283 | $sql_query = "SELECT nid FROM {content_type_situacion_actual_preliminar} WHERE field_version_planificador_nid = %d"; |
---|
284 | $explicacion = db_fetch_object(db_query($sql_query, $ente_planificador->nid)); |
---|
285 | if (!$explicacion->nid) { |
---|
286 | $explicacion1 = new stdClass(); |
---|
287 | $explicacion1->type = 'situacion_actual_preliminar'; |
---|
288 | node_object_prepare($explicacion1); |
---|
289 | $explicacion1->title = t('Explicación situacional @ente', array('@ente' => $ente_planificador->title)); |
---|
290 | $explicacion1->uid = $user->uid; |
---|
291 | $explicacion1->field_pre_cambios_ideales = array(); |
---|
292 | $explicacion1->field_pre_cambios_ideales[] = array('value' => ''); |
---|
293 | $explicacion1->field_pre_hechos_verifi = array(); |
---|
294 | $explicacion1->field_pre_hechos_verifi[] = array('value' => ''); |
---|
295 | $explicacion1->field_pre_cambios_causas = array(); |
---|
296 | $explicacion1->field_pre_cambios_causas[] = array('nid' => ''); |
---|
297 | $explicacion1->field_pre_cambios_situacion = array(); |
---|
298 | $explicacion1->field_pre_cambios_situacion[] = array('value' => ''); |
---|
299 | $explicacion1->field_version_planificador = array(); |
---|
300 | $explicacion1->field_version_planificador[0] = array('nid' => $ente_planificador->nid); |
---|
301 | node_save($explicacion1); |
---|
302 | $explicacion = $explicacion1; |
---|
303 | } |
---|
304 | $explicacion_load = node_load($explicacion->nid); |
---|
305 | if ($explicacion_load->type == 'situacion_actual_preliminar' && count($values)){ |
---|
306 | node_object_prepare($explicacion_load); |
---|
307 | $campo = 'field_pre_hechos_verifi'; |
---|
308 | $counter = 0; |
---|
309 | foreach ($values as $value) { |
---|
310 | $explicacion_load->{$campo}[]['value'] = $value; |
---|
311 | $counter++; |
---|
312 | } |
---|
313 | node_save($explicacion_load); |
---|
314 | drupal_set_message(t('Se agregaron @counter Descriptores de la situación actual', array('@counter' => $counter))); |
---|
315 | } |
---|
316 | } |
---|
317 | |
---|
318 | function entes_planificadores_exportar_cambios_form($form_state, $ente_planificador, $planificacion = 0) { |
---|
319 | $campo = 'field_pre_cambios_ideales'; |
---|
320 | $form = array(); |
---|
321 | $form['#ente_planificador'] = $ente_planificador; |
---|
322 | $form['#planificacion'] = $planificacion; |
---|
323 | $options = $planificacion->{$campo}; |
---|
324 | $opciones = array(); |
---|
325 | if (count($options)) { |
---|
326 | foreach ($options as $id => $value) { |
---|
327 | if ($value['value']) { |
---|
328 | $opciones['campo_' . $id] = $value['value']; |
---|
329 | } |
---|
330 | } |
---|
331 | } |
---|
332 | $form['#opciones'] = $opciones; |
---|
333 | $causas = array(); |
---|
334 | if (count($opciones)) { |
---|
335 | foreach ($opciones as $id => $value) { |
---|
336 | $form[$id] = array( |
---|
337 | '#type' => 'checkbox', |
---|
338 | '#title' => $value, |
---|
339 | ); |
---|
340 | } |
---|
341 | $form['buttons']['submit'] = array( |
---|
342 | '#type' => 'submit', |
---|
343 | '#value' => t('Submit'), |
---|
344 | '#weight' => 20 |
---|
345 | ); |
---|
346 | } |
---|
347 | return $form; |
---|
348 | } |
---|
349 | function entes_planificadores_exportar_cambios_form_submit($form, &$form_state) { |
---|
350 | $ente_planificador = $form['#ente_planificador']; |
---|
351 | $opciones = $form['#opciones']; |
---|
352 | $values = array(); |
---|
353 | if (count($opciones)) { |
---|
354 | foreach ($opciones as $id => $value) { |
---|
355 | if ($form_state['values'][$id]) { |
---|
356 | $values[] = $value; |
---|
357 | } |
---|
358 | } |
---|
359 | } |
---|
360 | module_load_include('inc', 'node', 'node.pages'); |
---|
361 | $sql_query = "SELECT nid FROM {content_type_situacion_actual_preliminar} WHERE field_version_planificador_nid = %d"; |
---|
362 | $explicacion = db_fetch_object(db_query($sql_query, $ente_planificador->nid)); |
---|
363 | if (!$explicacion->nid) { |
---|
364 | $explicacion1 = new stdClass(); |
---|
365 | $explicacion1->type = 'situacion_actual_preliminar'; |
---|
366 | node_object_prepare($explicacion1); |
---|
367 | $explicacion1->title = t('Explicación situacional @ente', array('@ente' => $ente_planificador->title)); |
---|
368 | $explicacion1->uid = $user->uid; |
---|
369 | $explicacion1->field_pre_cambios_ideales = array(); |
---|
370 | $explicacion1->field_pre_cambios_ideales[] = array('value' => ''); |
---|
371 | $explicacion1->field_pre_hechos_verifi = array(); |
---|
372 | $explicacion1->field_pre_hechos_verifi[] = array('value' => ''); |
---|
373 | $explicacion1->field_pre_cambios_causas = array(); |
---|
374 | $explicacion1->field_pre_cambios_causas[] = array('nid' => ''); |
---|
375 | $explicacion1->field_pre_cambios_situacion = array(); |
---|
376 | $explicacion1->field_pre_cambios_situacion[] = array('value' => ''); |
---|
377 | $explicacion1->field_version_planificador = array(); |
---|
378 | $explicacion1->field_version_planificador[0] = array('nid' => $ente_planificador->nid); |
---|
379 | node_save($explicacion1); |
---|
380 | $explicacion = $explicacion1; |
---|
381 | } |
---|
382 | $explicacion_load = node_load($explicacion->nid); |
---|
383 | if ($explicacion_load->type == 'situacion_actual_preliminar' && count($values)){ |
---|
384 | node_object_prepare($explicacion_load); |
---|
385 | $campo = 'field_pre_cambios_ideales'; |
---|
386 | $counter = 0; |
---|
387 | foreach ($values as $value) { |
---|
388 | $explicacion_load->{$campo}[]['value'] = $value; |
---|
389 | $counter++; |
---|
390 | } |
---|
391 | node_save($explicacion_load); |
---|
392 | drupal_set_message(t('Se agregaron @counter Cambios ideales', array('@counter' => $counter))); |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | function entes_planificadores_exportar_situacion_form($form_state, $ente_planificador, $planificacion = 0) { |
---|
397 | $campo = 'field_pre_cambios_situacion'; |
---|
398 | $form = array(); |
---|
399 | $form['#ente_planificador'] = $ente_planificador; |
---|
400 | $form['#planificacion'] = $planificacion; |
---|
401 | $options = $planificacion->{$campo}; |
---|
402 | $opciones = array(); |
---|
403 | if (count($options)) { |
---|
404 | foreach ($options as $id => $value) { |
---|
405 | if ($value['value']) { |
---|
406 | $opciones['campo_' . $id] = $value['value']; |
---|
407 | } |
---|
408 | } |
---|
409 | } |
---|
410 | $form['#opciones'] = $opciones; |
---|
411 | $causas = array(); |
---|
412 | if (count($opciones)) { |
---|
413 | foreach ($opciones as $id => $value) { |
---|
414 | $form[$id] = array( |
---|
415 | '#type' => 'checkbox', |
---|
416 | '#title' => $value, |
---|
417 | ); |
---|
418 | } |
---|
419 | $form['buttons']['submit'] = array( |
---|
420 | '#type' => 'submit', |
---|
421 | '#value' => t('Submit'), |
---|
422 | '#weight' => 20 |
---|
423 | ); |
---|
424 | } |
---|
425 | return $form; |
---|
426 | } |
---|
427 | function entes_planificadores_exportar_situacion_form_submit($form, &$form_state) { |
---|
428 | $ente_planificador = $form['#ente_planificador']; |
---|
429 | $opciones = $form['#opciones']; |
---|
430 | $values = array(); |
---|
431 | if (count($opciones)) { |
---|
432 | foreach ($opciones as $id => $value) { |
---|
433 | if ($form_state['values'][$id]) { |
---|
434 | $values[] = $value; |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | module_load_include('inc', 'node', 'node.pages'); |
---|
439 | $sql_query = "SELECT nid FROM {content_type_situacion_actual_preliminar} WHERE field_version_planificador_nid = %d"; |
---|
440 | $explicacion = db_fetch_object(db_query($sql_query, $ente_planificador->nid)); |
---|
441 | if (!$explicacion->nid) { |
---|
442 | $explicacion1 = new stdClass(); |
---|
443 | $explicacion1->type = 'situacion_actual_preliminar'; |
---|
444 | node_object_prepare($explicacion1); |
---|
445 | $explicacion1->title = t('Explicación situacional @ente', array('@ente' => $ente_planificador->title)); |
---|
446 | $explicacion1->uid = $user->uid; |
---|
447 | $explicacion1->field_pre_cambios_ideales = array(); |
---|
448 | $explicacion1->field_pre_cambios_ideales[] = array('value' => ''); |
---|
449 | $explicacion1->field_pre_hechos_verifi = array(); |
---|
450 | $explicacion1->field_pre_hechos_verifi[] = array('value' => ''); |
---|
451 | $explicacion1->field_pre_cambios_causas = array(); |
---|
452 | $explicacion1->field_pre_cambios_causas[] = array('nid' => ''); |
---|
453 | $explicacion1->field_pre_cambios_situacion = array(); |
---|
454 | $explicacion1->field_pre_cambios_situacion[] = array('value' => ''); |
---|
455 | $explicacion1->field_version_planificador = array(); |
---|
456 | $explicacion1->field_version_planificador[0] = array('nid' => $ente_planificador->nid); |
---|
457 | node_save($explicacion1); |
---|
458 | $explicacion = $explicacion1; |
---|
459 | } |
---|
460 | $explicacion_load = node_load($explicacion->nid); |
---|
461 | if ($explicacion_load->type == 'situacion_actual_preliminar' && count($values)){ |
---|
462 | node_object_prepare($explicacion_load); |
---|
463 | $campo = 'field_pre_cambios_situacion'; |
---|
464 | $counter = 0; |
---|
465 | foreach ($values as $value) { |
---|
466 | $explicacion_load->{$campo}[]['value'] = $value; |
---|
467 | $counter++; |
---|
468 | } |
---|
469 | node_save($explicacion_load); |
---|
470 | drupal_set_message(t('Se agregaron @counter Cambios de la situación actual', array('@counter' => $counter))); |
---|
471 | } |
---|
472 | } |
---|
473 | |
---|
474 | |
---|
475 | |
---|
476 | |
---|
477 | function entes_planificadores_exportar_situacion_actual_causas_form($form_state, $ente_planificador, $causas = array()) { |
---|
478 | $campo = 'field_pre_cambios_situacion'; |
---|
479 | $form = array(); |
---|
480 | $form['#ente_planificador'] = $ente_planificador; |
---|
481 | $form['#causas'] = $causas; |
---|
482 | if (count($causas)) { |
---|
483 | foreach ($causas as $id => $value) { |
---|
484 | $form[$id] = array( |
---|
485 | '#type' => 'checkbox', |
---|
486 | '#title' => $value->title, |
---|
487 | ); |
---|
488 | } |
---|
489 | $form['buttons']['submit'] = array( |
---|
490 | '#type' => 'submit', |
---|
491 | '#value' => t('Submit'), |
---|
492 | '#weight' => 20 |
---|
493 | ); |
---|
494 | } |
---|
495 | return $form; |
---|
496 | } |
---|
497 | function entes_planificadores_exportar_situacion_actual_causas_form_submit($form, &$form_state) { |
---|
498 | $ente_planificador = $form['#ente_planificador']; |
---|
499 | $opciones = $form['#causas']; |
---|
500 | if (count($opciones)) { |
---|
501 | $counter = 0; |
---|
502 | module_load_include('inc', 'node', 'node.pages'); |
---|
503 | foreach ($opciones as $id => $node) { |
---|
504 | if ($form_state['values'][$id]) { |
---|
505 | $node->nid = 0; |
---|
506 | $node->vid = 0; |
---|
507 | $node->type = 'causas'; |
---|
508 | node_object_prepare($node); |
---|
509 | $node->field_ente_planifiador[0]['nid'] = $ente_planificador->nid; |
---|
510 | $node->field_ente_planifiador[0]['nid'] = $ente_planificador->nid; |
---|
511 | $node->field_descriptores_causa = array(); |
---|
512 | node_save($node); |
---|
513 | $counter++; |
---|
514 | } |
---|
515 | } |
---|
516 | drupal_set_message(t('Se agregaron @counter causas de la situación actual', array('@counter' => $counter))); |
---|
517 | } |
---|
518 | } |
---|
519 | |
---|
520 | |
---|
521 | |
---|
522 | |
---|
523 | |
---|
524 | |
---|
525 | |
---|
526 | function entes_planificadores_exportar_situacion_actual_descriptor_form($form_state, $ente_planificador, $descriptor = array()) { |
---|
527 | $campo = 'field_pre_cambios_situacion'; |
---|
528 | $form = array(); |
---|
529 | $form['#ente_planificador'] = $ente_planificador; |
---|
530 | $form['#descriptor'] = $descriptor; |
---|
531 | if (count($descriptor)) { |
---|
532 | foreach ($descriptor as $id => $value) { |
---|
533 | $form[$id] = array( |
---|
534 | '#type' => 'checkbox', |
---|
535 | '#title' => $value->title, |
---|
536 | ); |
---|
537 | } |
---|
538 | $form['buttons']['submit'] = array( |
---|
539 | '#type' => 'submit', |
---|
540 | '#value' => t('Submit'), |
---|
541 | '#weight' => 20 |
---|
542 | ); |
---|
543 | } |
---|
544 | return $form; |
---|
545 | } |
---|
546 | function entes_planificadores_exportar_situacion_actual_descriptor_form_submit($form, &$form_state) { |
---|
547 | $ente_planificador = $form['#ente_planificador']; |
---|
548 | $opciones = $form['#descriptor']; |
---|
549 | if (count($opciones)) { |
---|
550 | $counter = 0; |
---|
551 | module_load_include('inc', 'node', 'node.pages'); |
---|
552 | foreach ($opciones as $id => $node) { |
---|
553 | if ($form_state['values'][$id]) { |
---|
554 | $node->nid = 0; |
---|
555 | $node->vid = 0; |
---|
556 | $node->type = 'descriptores'; |
---|
557 | node_object_prepare($node); |
---|
558 | $node->field_descriptores_planificador[0]['nid'] = $ente_planificador->nid; |
---|
559 | $node->field_descriptores_causa = array(); |
---|
560 | $node->field_causas_relacion = array(); |
---|
561 | $node->field_causa_descriptores = array(); |
---|
562 | $node->field_causa_metas = array(); |
---|
563 | $node->field_causa_solucion = array(); |
---|
564 | $node->field_causa_sectores = array(); |
---|
565 | $node->field_causa_palabras = array(); |
---|
566 | $node->field_causa_posible = array('value' => 0); |
---|
567 | $node->field_causa_critica = array('value' => 0); |
---|
568 | node_save($node); |
---|
569 | $counter++; |
---|
570 | } |
---|
571 | } |
---|
572 | drupal_set_message(t('Se agregaron @counter descriptores de la situación actual', array('@counter' => $counter))); |
---|
573 | } |
---|
574 | } |
---|