1 | <?php |
---|
2 | /** |
---|
3 | * Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
4 | * @file politicas_proyectos.module |
---|
5 | * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP) |
---|
6 | * Copyright 2017 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or modify |
---|
9 | * it under the terms of the GNU General Public License as published by |
---|
10 | * the Free Software Foundation; either version 2 of the License, or |
---|
11 | * (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
21 | * |
---|
22 | * @author Cenditel Merida - Msc. Juan Vizcarrondo |
---|
23 | * @date 2017-08-15 // (año-mes-dia) |
---|
24 | * @version 0.3 // (0.3) |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | |
---|
29 | /* |
---|
30 | * Implementation of hook_menu() |
---|
31 | */ |
---|
32 | function politicas_proyectos_menu() { |
---|
33 | $items = array(); |
---|
34 | $items['politicas_proyectos_get_politicas_js'] = array( |
---|
35 | 'title' => 'Ente Planificador', |
---|
36 | 'page callback' => 'politicas_proyectos_get_politicas_js', |
---|
37 | 'access arguments' => array('ver planificador'), |
---|
38 | 'type' => MENU_CALLBACK, |
---|
39 | ); |
---|
40 | return $items; |
---|
41 | } |
---|
42 | |
---|
43 | function politicas_proyectos_get_politicas_js($campo = '') { |
---|
44 | $form_state = array('submitted' => FALSE); |
---|
45 | $form_build_id = $_POST['form_build_id']; |
---|
46 | $form = form_get_cache($form_build_id, $form_state); |
---|
47 | $politica = array(); |
---|
48 | $arreglo = array(); |
---|
49 | if (isset($_POST[$form['#politicas_campo']]['nid']) && is_array($_POST[$form['#politicas_campo']]['nid'])) { |
---|
50 | $arreglo = $_POST[$form['#politicas_campo']]['nid']; |
---|
51 | } |
---|
52 | elseif (isset($_POST[$form['#politicas_campo']]) && is_array($_POST[$form['#politicas_campo']])) { |
---|
53 | $arreglo = $_POST[$form['#politicas_campo']]; |
---|
54 | } |
---|
55 | foreach($arreglo as $valor) { |
---|
56 | $valor = intval($valor); |
---|
57 | if ($valor) { |
---|
58 | $politica[$valor] = $valor; |
---|
59 | } |
---|
60 | } |
---|
61 | $form['#causas'] = array(); |
---|
62 | $form['#cambios'] = array(); |
---|
63 | $form['#descriptores'] = array(); |
---|
64 | $form['#formas_solucion'] = array(); |
---|
65 | $form['#carabobo'] = array(); |
---|
66 | $form['#all_descriptores'] = array(); |
---|
67 | $form['#formas_solucion'] = array(); |
---|
68 | $form['#pdlp'] = array(); |
---|
69 | $form['#politica'] = $politica; |
---|
70 | $output = t('No ha seleccionado una politica'); |
---|
71 | if ($politica) { |
---|
72 | $busca_causas = array(); |
---|
73 | foreach($politica as $id) { |
---|
74 | $busca_causas += $form['#causas_criticas'][$id]; |
---|
75 | } |
---|
76 | $descriptores_c = _politicas_proyectos_get_causas_all_causas('criticas', $busca_causas); |
---|
77 | $form['#formas_solucion'] = politicas_proyectos_get_formas_solucion($busca_causas); |
---|
78 | $all_descriptores = _politicas_proyectos_situacion_actual_listar_all_descriptores($descriptores_c); |
---|
79 | $form['#all_descriptores'] = $all_descriptores; |
---|
80 | $form['#descriptores'] = $all_descriptores['descriptores']; |
---|
81 | $form['#causas'] = $all_descriptores['causas']; |
---|
82 | $form['#cambios'] = $all_descriptores['cambios']; |
---|
83 | $form['#pdlp'] = $all_descriptores['pdlp']; |
---|
84 | $form['#carabobo'] = $all_descriptores['carabobo']; |
---|
85 | $output = _politicas_proyectos_display_politicas($form['#all_descriptores'], $form['#formas_solucion']); |
---|
86 | } |
---|
87 | //$form += $new_form; |
---|
88 | form_set_cache($form_build_id, $form, $form_state); |
---|
89 | $form += array( |
---|
90 | '#post' => $_POST, |
---|
91 | '#programmed' => FALSE, |
---|
92 | ); |
---|
93 | // Rebuild the form. |
---|
94 | $form = form_builder($_POST['form_id'], $form, $form_state); |
---|
95 | // Add the new element to the stored form. Without adding the element to the |
---|
96 | // form, Drupal is not aware of this new elements existence and will not |
---|
97 | // process it. We retreive the cached form, add the element, and resave. |
---|
98 | print drupal_to_js(array('data' => $output, 'status' => true)); |
---|
99 | exit(); |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | /* |
---|
104 | * Implementation of _politicas_proyectos_situacion_actual_listar_all_descriptores() |
---|
105 | * Get ente's descriptores |
---|
106 | * Inputs: |
---|
107 | - $ente_planificador (integer): ente planificador nid |
---|
108 | - $tipo (integer): plann type |
---|
109 | - $year (integer): descriptor year creation, if no available 'situacional_actual_preliminar_anho_creacion' variable will be used |
---|
110 | * Outputs: |
---|
111 | - Descriptores (array nid descriptor): |
---|
112 | + body: Description descriptor |
---|
113 | + title: Acronimo |
---|
114 | + nid: Descriptor nid node reference |
---|
115 | + year: descriptor year creation |
---|
116 | + clasificacion: descriptor type |
---|
117 | / tid: taxonomy term |
---|
118 | + causas: causas list (array nid causa-descriptor): |
---|
119 | / body: Description causa |
---|
120 | / title: Acronimo causa |
---|
121 | / nid: Causa nid node reference |
---|
122 | / descriptor: Descriptor nid node reference |
---|
123 | + solucion: solucion list (array nid solucion-descriptor): |
---|
124 | / body: Description solucion |
---|
125 | / title: Acronimo solucion |
---|
126 | / nid: Solucion nid node reference |
---|
127 | / descriptor: Descriptor nid node reference |
---|
128 | */ |
---|
129 | function _politicas_proyectos_situacion_actual_listar_all_descriptores($causas = array()) { |
---|
130 | //se obtienen los descriptores |
---|
131 | $descriptores = array(); |
---|
132 | $causas_load = array(); |
---|
133 | $cambios_load = array(); |
---|
134 | $pdlp_load = array(); |
---|
135 | $carabobo_load = array(); |
---|
136 | $sql = "SELECT c.nid, n.title, nr.body FROM {content_type_descriptores} AS c INNER JOIN {node} AS n ON c.nid = n.nid AND c.vid = n.vid AND n.type = 'descriptores' INNER JOIN {node_revisions} AS nr ON c.nid = nr.nid AND c.vid = nr.vid"; |
---|
137 | $inputs = array(); |
---|
138 | $inputs_c = array(); |
---|
139 | if (is_array($causas) && count($causas)) { |
---|
140 | $implode_causas_sql = array(); |
---|
141 | foreach($causas as $id => $descriptoresl) { |
---|
142 | $implode_causas_sql[] = '%d'; |
---|
143 | $inputs_c[] = $id; |
---|
144 | foreach($descriptoresl as $descriptor) { |
---|
145 | $implode_sql[] = '%d'; |
---|
146 | $inputs[] = $descriptor; |
---|
147 | } |
---|
148 | } |
---|
149 | if (count($implode_sql)) { |
---|
150 | $sql .= ' WHERE c.nid IN (' . implode(', ', $implode_sql) . ')'; |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | $tipo_plan = 'situacion_actual'; |
---|
155 | $planns = _situacion_actual_preliminar_get_planns(); |
---|
156 | $plan = $planns[$tipo_plan]; |
---|
157 | |
---|
158 | $sql .=' AND c.field_descriptores_' . $plan['short'] . '_value = %d'; |
---|
159 | $inputs[] = 1; |
---|
160 | |
---|
161 | $sql .=' ORDER BY c.nid'; |
---|
162 | $result = db_query($sql, $inputs); |
---|
163 | $inpunts = array(); |
---|
164 | $inpunts_values = array(); |
---|
165 | $solucion = array(); |
---|
166 | while($descriptor = db_fetch_object($result)) { |
---|
167 | $descriptores[$descriptor->nid] = array( |
---|
168 | 'body' => $descriptor->body, |
---|
169 | 'title' => $descriptor->title, |
---|
170 | 'nid' => $descriptor->nid, |
---|
171 | 'year' => $year_display, |
---|
172 | 'clasificacion' => array(), |
---|
173 | 'causas' => array(), |
---|
174 | 'cambios' => array(), |
---|
175 | ); |
---|
176 | $inpunts[] = '%d'; |
---|
177 | $inpunts_values[] = $descriptor->nid; |
---|
178 | } |
---|
179 | if (count($inpunts)) { |
---|
180 | $implode = implode(',', $inpunts); |
---|
181 | //Se obtienen la clasificacion de los descriptores |
---|
182 | $sql = 'SELECT c.field_descriptores_clasificacion_value AS tid, c.nid FROM {content_field_descriptores_clasificacion} AS c INNER JOIN {node} AS n ON n.nid = c.nid AND n.vid = c.vid WHERE c.nid IN (' . $implode . ')'; |
---|
183 | $result = db_query($sql, $inpunts_values); |
---|
184 | while($clasificacion = db_fetch_object($result)) { |
---|
185 | $descriptores[$clasificacion->nid]['clasificacion'][$clasificacion->tid] = $clasificacion->tid; |
---|
186 | } |
---|
187 | //se obtienen las causas |
---|
188 | //field_descriptores_causa |
---|
189 | $sql = "SELECT c.field_descriptores_causa_nid as nid, c.nid as descriptor, n.title, nr.body FROM {content_field_descriptores_causa} AS c INNER JOIN {node} AS n ON c.field_descriptores_causa_nid = n.nid AND n.type = 'causas' INNER JOIN {node} AS n1 ON c.nid = n1.nid AND c.vid = n1.vid INNER JOIN {node_revisions} AS nr ON n.nid = nr.nid AND n.vid = nr.vid WHERE c.nid IN (" . $implode . ")"; |
---|
190 | $inpunts_d = $inpunts_values; |
---|
191 | if (count($implode_causas_sql)) { |
---|
192 | $sql .= ' AND c.field_descriptores_causa_nid IN (' . implode(', ', $implode_causas_sql) . ')'; |
---|
193 | $inpunts_d = array_merge($inpunts_values, $inputs_c); |
---|
194 | } |
---|
195 | $sql .= ' ORDER BY c.field_descriptores_causa_nid'; |
---|
196 | $result = db_query($sql, $inpunts_d); |
---|
197 | while($causa = db_fetch_object($result)) { |
---|
198 | $causas_load[$causa->nid] = array( |
---|
199 | 'descriptor' => $causa->descriptor, |
---|
200 | 'body' => $causa->body, |
---|
201 | 'nid' => $causa->nid, |
---|
202 | ); |
---|
203 | $descriptores[$causa->descriptor]['causas'][$causa->nid] = array( |
---|
204 | 'body' => $causa->body, |
---|
205 | 'nid' => $causa->nid, |
---|
206 | 'title' => $causa->title, |
---|
207 | 'descriptor' => $causa->descriptor, |
---|
208 | ); |
---|
209 | } |
---|
210 | //se obtienen los cambios |
---|
211 | //field_descriptor_cambio_nid |
---|
212 | $sql_implode_cambios = array(); |
---|
213 | $inputs_cambios = array(); |
---|
214 | $sql = "SELECT c.field_descriptor_cambio_nid as nid, c.nid as descriptor, n.title, nr.body FROM {content_field_descriptor_cambio} AS c INNER JOIN {node} AS n ON c.field_descriptor_cambio_nid = n.nid AND n.type = 'cambios' INNER JOIN {node} AS n1 ON c.nid = n1.nid AND c.vid = n1.vid INNER JOIN {node_revisions} AS nr ON n.nid = nr.nid AND n.vid = nr.vid WHERE c.nid IN (" . $implode . ") ORDER BY c.field_descriptor_cambio_nid"; |
---|
215 | $result = db_query($sql, $inpunts_values); |
---|
216 | while($meta = db_fetch_object($result)) { |
---|
217 | $cambios_load[$meta->nid] = array( |
---|
218 | 'descriptor' => $meta->descriptor, |
---|
219 | 'body' => $meta->body, |
---|
220 | 'nid' => $meta->nid, |
---|
221 | 'pdlp' => array(), |
---|
222 | 'carabobo' => array(), |
---|
223 | ); |
---|
224 | $sql_implode_cambios[] = '%d'; |
---|
225 | $inputs_cambios[] = $meta->nid; |
---|
226 | $descriptores[$meta->descriptor]['cambios'][$meta->nid] = array( |
---|
227 | 'body' => $meta->body, |
---|
228 | 'nid' => $meta->nid, |
---|
229 | 'title' => $meta->title, |
---|
230 | 'descriptor' => $meta->descriptor, |
---|
231 | 'pdlp' => array(), |
---|
232 | 'carabobo' => array(), |
---|
233 | ); |
---|
234 | } |
---|
235 | //se obtienen pdlp y carabobo |
---|
236 | if (count($inputs_cambios)) { |
---|
237 | $implode = implode(', ', $sql_implode_cambios); |
---|
238 | $sql = "SELECT p.*, t.name, t.description FROM {content_field_cambios_pdp} AS p INNER JOIN {node} AS n ON n.nid = p.nid AND n.vid = p.vid AND n.type = 'cambios' INNER JOIN {term_data} AS t ON t.tid = p.field_cambios_pdp_value WHERE p.nid IN (" . $implode . ") ORDER BY t.name"; |
---|
239 | |
---|
240 | $result = db_query($sql, $inputs_cambios); |
---|
241 | while($meta = db_fetch_object($result)) { |
---|
242 | if ($meta->field_cambios_pdp_value) { |
---|
243 | $descriptores[$cambios_load[$meta->nid]['descriptor']]['cambios'][$meta->nid]['pdlp'][$meta->delta][$meta->field_cambios_pdp_value] = $meta->name . ' ' . $meta->description; |
---|
244 | $cambios_load[$meta->nid]['pdlp'][$meta->delta][$meta->field_cambios_pdp_value] = $meta->name . ' ' . $meta->description; |
---|
245 | $pdlp_load[$meta->delta][$meta->field_cambios_pdp_value] = $meta->name . ' ' . $meta->description; |
---|
246 | } |
---|
247 | } |
---|
248 | $sql = "SELECT p.*, t.plan_carabobo_meta_value AS carabobo FROM {content_field_cambios_carabobo} AS p INNER JOIN {node} AS n ON n.nid = p.nid AND n.vid = p.vid AND n.type = 'cambios' INNER JOIN {term_fields_term} AS t ON t.tid = p.field_cambios_carabobo_value WHERE p.nid IN (" . implode(', ', $inputs_cambios) . ")"; |
---|
249 | $result = db_query($sql, $inputs_cambios); |
---|
250 | while($meta = db_fetch_object($result)) { |
---|
251 | if ($meta->field_cambios_carabobo_value) { |
---|
252 | $descriptores[$cambios_load[$meta->nid]['descriptor']]['cambios'][$meta->nid]['carabobo'][$meta->delta][$meta->field_cambios_carabobo_value] = $meta->carabobo; |
---|
253 | $cambios_load[$meta->nid]['carabobo'][$meta->delta][$meta->field_cambios_carabobo_value] = $meta->carabobo; |
---|
254 | $carabobo_load[$meta->field_cambios_carabobo_value] = $meta->carabobo; |
---|
255 | } |
---|
256 | } |
---|
257 | } |
---|
258 | } |
---|
259 | return array( |
---|
260 | 'descriptores' => $descriptores, |
---|
261 | 'causas' => $causas_load, |
---|
262 | 'cambios' => $cambios_load, |
---|
263 | 'pdlp' => $pdlp_load, |
---|
264 | 'carabobo' => $carabobo_load, |
---|
265 | ); |
---|
266 | } |
---|
267 | |
---|
268 | /* |
---|
269 | * hook_form_alter() |
---|
270 | */ |
---|
271 | function politicas_proyectos_form_alter(&$form, $form_state, $form_id) { |
---|
272 | if ($form_id == 'proyectos_operativos_proyecto_basico_form') { |
---|
273 | $new_submit = array(); |
---|
274 | //se coloca el submit de pd |
---|
275 | $new_submit[] = '_politicas_proyectos_basico_form_pd_submit'; |
---|
276 | $new_submit[] = '_politicas_proyectos_basico_form_pd_1_submit'; |
---|
277 | foreach($form['#submit'] as $submit) { |
---|
278 | $new_submit[] = $submit; |
---|
279 | } |
---|
280 | $form['#submit'] = $new_submit; |
---|
281 | //se agregan los nuevos campos |
---|
282 | if (isset($form['field_proyecto_pndes'])) { |
---|
283 | unset($form['field_proyecto_pndes']); |
---|
284 | } |
---|
285 | $form['field_proyecto_pndes']['#access'] = FALSE; |
---|
286 | $form['#proyectos_operativos_fields'][] = 'field_proyecto_problemas'; |
---|
287 | $form['#proyectos_operativos_fields'][] = 'field_proyectos_descript'; |
---|
288 | $form['#proyectos_operativos_fields'][] = 'field_proyecto_causas'; |
---|
289 | $form['#proyectos_operativos_fields'][] = 'field_proyectos_causasc'; |
---|
290 | $form['#proyectos_operativos_fields'][] = 'field_proyectos_cambios'; |
---|
291 | $form['#proyectos_operativos_fields'][] = 'field_proyectos_solucion'; |
---|
292 | $form['#proyectos_operativos_fields'][] = 'field_proyectos_carabobo'; |
---|
293 | $politicas = _politicas_proyectos_references($form['#ente_planificador']->nid, 1); |
---|
294 | $form['#politicas'] = $politicas; |
---|
295 | $form['#causas'] = array(); |
---|
296 | $form['#cambios'] = array(); |
---|
297 | $form['#descriptores'] = array(); |
---|
298 | $form['#formas_solucion'] = array(); |
---|
299 | $form['#mpcc'] = array(); |
---|
300 | $form['#pdlp'] = array(); |
---|
301 | $causas_criticas = _politicas_proyectos_get_politicas_causas($form['#politicas']['politicas']); |
---|
302 | $politicas = array(); |
---|
303 | //solo deje aquellas politicas que contengan causas criticas |
---|
304 | foreach($form['#politicas']['politicas'] as $id => $pol) { |
---|
305 | if (isset($causas_criticas[$id]) && is_array($causas_criticas[$id]) && count($causas_criticas[$id])) { |
---|
306 | $politicas[$id] = $pol; |
---|
307 | } |
---|
308 | } |
---|
309 | $form['#politicas']['politicas'] = $politicas; |
---|
310 | $form['#causas_criticas'] = $causas_criticas; |
---|
311 | $form['#carabobo'] = array(); |
---|
312 | $politica = array(); |
---|
313 | if (isset($form['#node']->field_proyecto_mcti) && is_array($form['#node']->field_proyecto_mcti)) { |
---|
314 | foreach($form['#node']->field_proyecto_mcti as $valor) { |
---|
315 | if ($valor['nid']) { |
---|
316 | $politica[$valor['nid']] = $valor['nid']; |
---|
317 | } |
---|
318 | } |
---|
319 | } |
---|
320 | //no deje enviar el formulario si no existen politicas para este ente |
---|
321 | $form['buttons']['registrar']['#access'] = is_array($form['#politicas']['politicas']) && count($form['#politicas']['politicas']); |
---|
322 | |
---|
323 | if (!count($politica) && is_array($form['#politicas']['politicas']) && count($form['#politicas']['politicas'])) { |
---|
324 | //se obtiene el primer elemento del arreglo |
---|
325 | $key = key($form['#politicas']['politicas']); |
---|
326 | $politica[$key] = $key; |
---|
327 | } |
---|
328 | $form['#politicas_campo'] = 'field_proyecto_mcti'; |
---|
329 | $form['#politica'] = $politica; |
---|
330 | if (count($form['#politica'])) { |
---|
331 | $busca_causas = array(); |
---|
332 | foreach($form['#politica'] as $id) { |
---|
333 | if (isset($form['#causas_criticas'][$id]) && is_array($form['#causas_criticas'][$id]) && count($form['#causas_criticas'][$id])) { |
---|
334 | foreach($form['#causas_criticas'][$id] as $causa) { |
---|
335 | $busca_causas[$causa] = $causa; |
---|
336 | } |
---|
337 | } |
---|
338 | } |
---|
339 | $descriptores_c = _politicas_proyectos_get_causas_all_causas('criticas', $busca_causas); |
---|
340 | $form['#formas_solucion'] = politicas_proyectos_get_formas_solucion($busca_causas); |
---|
341 | $all_descriptores = _politicas_proyectos_situacion_actual_listar_all_descriptores($descriptores_c); |
---|
342 | $form['#all_descriptores'] = $all_descriptores; |
---|
343 | $form['#descriptores'] = $all_descriptores['descriptores']; |
---|
344 | $form['#causas'] = $all_descriptores['causas']; |
---|
345 | $form['#cambios'] = $all_descriptores['cambios']; |
---|
346 | $form['#pdlp'] = $all_descriptores['pdlp']; |
---|
347 | $form['#carabobo'] = $all_descriptores['carabobo']; |
---|
348 | } |
---|
349 | } |
---|
350 | if ($form_id == 'proyectos_operativos_proyecto_indicadores_form') { |
---|
351 | $arreglo = array( |
---|
352 | 'field_proyecto_causas' => 'field_proyecto_causas', |
---|
353 | 'field_proyecto_problemas' => 'field_proyecto_problemas', |
---|
354 | 'field_proyecto_consecuencias' => 'field_proyecto_consecuencias', |
---|
355 | ); |
---|
356 | foreach($arreglo as $id) { |
---|
357 | if (isset($form['field_proyecto_causas'])) { |
---|
358 | unset($form[$id]); |
---|
359 | $title = $form['#field_info'][$id]['widget']['label']; |
---|
360 | unset($form['#field_info'][$id]); |
---|
361 | $items = array(); |
---|
362 | if ($id != field_proyecto_consecuencias) { |
---|
363 | foreach($form['#node']->{$id} as $valor) { |
---|
364 | $items[] = $valor['value']; |
---|
365 | } |
---|
366 | $form[$id] = array( |
---|
367 | '#value' => '<div id="edit-field-proyecto-' . $id . '-0-value-wrapper" class="form-item"><label for="edit-field-proyecto-' . $id . '-0-value">' . $title . '</label>' . theme('item_list', $items) . '</div>', |
---|
368 | ); |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | $new_fields = array(); |
---|
373 | foreach($form['#proyectos_operativos_fields'] as $id) { |
---|
374 | if (!isset($arreglo[$id])) { |
---|
375 | $new_fields[] = $id; |
---|
376 | } |
---|
377 | } |
---|
378 | $form['#proyectos_operativos_fields'] = $new_fields; |
---|
379 | } |
---|
380 | } |
---|
381 | |
---|
382 | /* |
---|
383 | * Implementation of proyectos_operativos_proyecto_basico_form_submit(). |
---|
384 | * Guardar formulario de datos basicos (proyectos operativos). |
---|
385 | */ |
---|
386 | function _politicas_proyectos_basico_form_pd_submit($form, &$form_state) { |
---|
387 | //se agregan los valores de descriptores, causas y cambios |
---|
388 | $arreglo = array(); |
---|
389 | $arregloi = array(); |
---|
390 | $campos = array( |
---|
391 | 'descriptores' => array( |
---|
392 | 'value' => 'field_proyecto_problemas', |
---|
393 | 'nid' => 'field_proyectos_descript', |
---|
394 | ), |
---|
395 | 'causas' => array( |
---|
396 | 'value' => 'field_proyecto_causas', |
---|
397 | 'nid' => 'field_proyectos_causasc', |
---|
398 | ), |
---|
399 | 'cambios' => array( |
---|
400 | 'nid' => 'field_proyectos_cambios', |
---|
401 | ), |
---|
402 | ); |
---|
403 | $solucion = array(); |
---|
404 | foreach($campos as $id1 => $tipos) { |
---|
405 | foreach($tipos as $valor => $campo) { |
---|
406 | $arreglo = array(); |
---|
407 | foreach($form['#' . $id1] as $id => $nodo) { |
---|
408 | $arreglo[][$valor] = $valor == 'nid'? $id : check_plain($nodo['body']); |
---|
409 | if ($id1 == 'causas' && $valor == 'value') { |
---|
410 | foreach($form['#formas_solucion'][$id] as $texto) { |
---|
411 | $solucion[][$valor] = $texto; |
---|
412 | } |
---|
413 | } |
---|
414 | } |
---|
415 | $form_state['values'][$campo] = $arreglo; |
---|
416 | } |
---|
417 | } |
---|
418 | //se agregan los valores de formas de solucion |
---|
419 | $form_state['values']['field_proyectos_solucion'] = $solucion; |
---|
420 | //se agregan los valores de plan de la patria |
---|
421 | $pdlp = array(); |
---|
422 | for($i = 0; $i < 4 ; $i++) { |
---|
423 | if (is_array($form['#pdlp'][$i])) { |
---|
424 | foreach($form['#pdlp'][$i] as $id => $valor) { |
---|
425 | if ($id) { |
---|
426 | $pdlp[] = $id; |
---|
427 | } |
---|
428 | } |
---|
429 | } |
---|
430 | } |
---|
431 | $form_state['values']['field_proyecto_pndes']['tids'] = $pdlp; |
---|
432 | //carabobo |
---|
433 | $arreglo = array(); |
---|
434 | foreach($form['#carabobo'] as $id => $valor) { |
---|
435 | if ($id) { |
---|
436 | $arreglo[]['value'] = $id; |
---|
437 | } |
---|
438 | } |
---|
439 | $form_state['values']['field_proyectos_carabobo'] = $arreglo; |
---|
440 | $form_state['values']['field_proyecto_mcti'] = array(); |
---|
441 | foreach($form['#politica'] as $politica) { |
---|
442 | $form_state['values']['field_proyecto_mcti'][]['nid'] = $politica; |
---|
443 | } |
---|
444 | } |
---|
445 | |
---|
446 | |
---|
447 | function _politicas_proyectos_display_politicas($descriptores, $formas_solucion) { |
---|
448 | $output = ''; |
---|
449 | $arreglot = array( |
---|
450 | 'descriptores' => t('Problemas (Descriptores)'), |
---|
451 | 'causas' => t('Causas'), |
---|
452 | 'cambios' => t('Cambios en la Situación Actual'), |
---|
453 | ); |
---|
454 | $solucion = array(); |
---|
455 | foreach($arreglot as $id1 => $texto) { |
---|
456 | $output .= '<div id="proyectos-' . $id1 . '"><label for="edit-field-' . $id1 . '-value">' . $texto . ':</label>'; |
---|
457 | $arreglo = array(); |
---|
458 | foreach($descriptores[$id1] as $id => $nodo) { |
---|
459 | $arreglo[] = $nodo['body']; |
---|
460 | if ($id1 == 'causas') { |
---|
461 | $solucion = array_merge($solucion, $formas_solucion[$id]); |
---|
462 | } |
---|
463 | } |
---|
464 | $output .= theme('item_list', $arreglo); |
---|
465 | $output .= '</div>'; |
---|
466 | if ($id1 == 'causas') { |
---|
467 | $output .= '<div id="proyectos-solucion"><label for="edit-field-solucion-value">' . t('Formas de solución') . ':</label>'; |
---|
468 | $output .= theme('item_list', $solucion); |
---|
469 | $output .= '</div>'; |
---|
470 | } |
---|
471 | } |
---|
472 | //pdlp |
---|
473 | $output .= '<fieldset><legend>' . t('Plan de la Patria') . '</legend>'; |
---|
474 | $arreglo = array(t('Objetivos Históricos'), t('Objetivos Nacionales'), t('Objetivos Estratégicos'), t('Objetivos Generales')); |
---|
475 | foreach($arreglo as $id => $texto) { |
---|
476 | $output .= '<div id="proyectos-objetivo-' . $id . '"><label for="edit-field-proyectos-objetivo-' . $id . '-value">' . $texto . ':</label>'; |
---|
477 | $output .= theme('item_list', $descriptores['pdlp'][$id]); |
---|
478 | $output .= '</div>'; |
---|
479 | } |
---|
480 | $output .= '</fieldset>'; |
---|
481 | $output .= '<div id="proyectos-carabobo"><label for="edit-field-carabobo-value">' . t('Metas del Plan Campaña Carabobo') . ':</label>'; |
---|
482 | $output .= theme('item_list', $descriptores['carabobo']); |
---|
483 | $output .= '</div>'; |
---|
484 | return $output; |
---|
485 | } |
---|
486 | |
---|
487 | function _politicas_proyectos_get_politicas_causas($politicas = array()) { |
---|
488 | $causas = array(); |
---|
489 | if (count($politicas)) { |
---|
490 | $sql = "SELECT p.field_politicas_causas_nid AS causa, p.nid FROM {content_field_politicas_causas} AS p INNER JOIN {node} AS n ON n.nid = p.nid AND n.vid = p.vid INNER JOIN {node} AS nc ON nc.nid = p.field_politicas_causas_nid INNER JOIN {content_type_causas} AS cc ON cc.nid = nc.nid AND cc.vid = nc.vid AND cc.field_causa_critica_value = '1' WHERE p.nid in("; |
---|
491 | $inputs = array(); |
---|
492 | $implode_sql = array(); |
---|
493 | foreach($politicas as $id => $politica) { |
---|
494 | $causas[$id] = array(); |
---|
495 | $implode_sql[] = '%d'; |
---|
496 | $inputs[] = $id; |
---|
497 | } |
---|
498 | $sql .= implode(', ', $implode_sql) . ')'; |
---|
499 | $result = db_query($sql, $inputs); |
---|
500 | while($causa = db_fetch_object($result)) { |
---|
501 | $causas[$causa->nid][$causa->causa] = $causa->causa; |
---|
502 | } |
---|
503 | } |
---|
504 | return $causas; |
---|
505 | } |
---|
506 | |
---|
507 | /* |
---|
508 | * Implementation of _politicas_proyectos_get_causas_all_causas() |
---|
509 | * Obtiene las causas criticas por tipo de plan |
---|
510 | */ |
---|
511 | function _politicas_proyectos_get_causas_all_causas($tipo = 'posibles', $causas = array()){ |
---|
512 | $tabla = ($tipo == 'posibles')? 'content_field_descriptores_posibles' : 'content_field_descriptores_criticas'; |
---|
513 | $campo = 'field_descriptores_' . $tipo . '_nid'; |
---|
514 | $descriptores = array(); |
---|
515 | if (count($causas)) { |
---|
516 | $sql = "SELECT d.*, ds." . $campo . " AS causa FROM {" . $tabla . "} AS ds INNER JOIN {content_type_descriptores} AS d ON d.nid = ds.nid AND d.vid = ds.vid INNER JOIN {node} AS n ON n.nid = ds.nid AND n.vid = ds.vid INNER JOIN {node} AS nc ON nc.nid = ds." . $campo . " INNER JOIN {content_type_causas} AS cc ON cc.nid = nc.nid AND cc.vid = nc.vid AND cc.field_causa_critica_value = '1' WHERE "; |
---|
517 | $inputs = array(); |
---|
518 | foreach($causas as $causa) { |
---|
519 | $implode_sql[] = '%d'; |
---|
520 | $inputs[] = $causa; |
---|
521 | } |
---|
522 | $sql .= ' ds.' . $campo . ' in (' . implode(', ', $implode_sql) . ')'; |
---|
523 | $result = db_query($sql, $inputs); |
---|
524 | $descriptores = array(); |
---|
525 | while($descriptor = db_fetch_object($result)) { |
---|
526 | if ($descriptor->nid && $descriptor->causa) { |
---|
527 | $descriptores[$descriptor->causa][$descriptor->nid] = $descriptor->nid; |
---|
528 | } |
---|
529 | } |
---|
530 | } |
---|
531 | return $descriptores; |
---|
532 | } |
---|
533 | |
---|
534 | function politicas_proyectos_get_formas_solucion($causas = array()) { |
---|
535 | $soluciones = array(); |
---|
536 | if (count($causas)) { |
---|
537 | $implode_sql = array(); |
---|
538 | $inputs = array(); |
---|
539 | $sql = "SELECT c.field_causa_solucion_value as value, c.delta, c.nid FROM {content_field_causa_solucion} AS c INNER JOIN {node} AS n ON n.nid = c.nid AND n.vid = c.vid WHERE c.nid IN ("; |
---|
540 | foreach($causas as $causa) { |
---|
541 | $implode_sql[] = '%d'; |
---|
542 | $inputs[] = $causa; |
---|
543 | } |
---|
544 | $sql .= implode(', ', $implode_sql) . ')'; |
---|
545 | $soluciones = array(); |
---|
546 | $result = db_query($sql, $inputs); |
---|
547 | while($solucion = db_fetch_object($result)) { |
---|
548 | $soluciones[$solucion->nid][$solucion->delta] = $solucion->value; |
---|
549 | } |
---|
550 | } |
---|
551 | return $soluciones; |
---|
552 | } |
---|
553 | /** |
---|
554 | * Implementation of hook_theme(). |
---|
555 | */ |
---|
556 | function politicas_proyectos_theme() { |
---|
557 | return array( |
---|
558 | 'politicas_direccionales_select' => array( |
---|
559 | 'arguments' => array('element' => NULL), |
---|
560 | ), |
---|
561 | 'politicas_proyectos_formatter_body' => array( |
---|
562 | 'arguments' => array('element'), |
---|
563 | 'function' => 'theme_politicas_proyectos_formatter_body', |
---|
564 | ), |
---|
565 | ); |
---|
566 | } |
---|
567 | |
---|
568 | /** |
---|
569 | * Proxy theme function for 'full' and 'teaser' nodereference field formatters. |
---|
570 | */ |
---|
571 | function theme_politicas_proyectos_formatter_body($element) { |
---|
572 | static $recursion_queue = array(); |
---|
573 | $output = ''; |
---|
574 | if (!empty($element['#item']['safe']['nid'])) { |
---|
575 | $nid = $element['#item']['safe']['nid']; |
---|
576 | $node = $element['#node']; |
---|
577 | $field = content_fields($element['#field_name'], $element['#type_name']); |
---|
578 | // If no 'referencing node' is set, we are starting a new 'reference thread' |
---|
579 | if (!isset($node->referencing_node)) { |
---|
580 | $recursion_queue = array(); |
---|
581 | } |
---|
582 | $recursion_queue[] = $node->nid; |
---|
583 | if (in_array($nid, $recursion_queue)) { |
---|
584 | // Prevent infinite recursion caused by reference cycles: |
---|
585 | // if the node has already been rendered earlier in this 'thread', |
---|
586 | // we fall back to 'default' (node title) formatter. |
---|
587 | return theme('nodereference_formatter_default', $element); |
---|
588 | } |
---|
589 | $referenced_node = _politicas_proyectos_load_politica($nid); |
---|
590 | if ($referenced_node) { |
---|
591 | $referenced_node->referencing_node = $node; |
---|
592 | $referenced_node->referencing_field = $field; |
---|
593 | $output = check_plain($referenced_node->body); |
---|
594 | } |
---|
595 | } |
---|
596 | return $output; |
---|
597 | } |
---|
598 | |
---|
599 | /** |
---|
600 | * Implementation of _politicas_proyectos_load_politica(). |
---|
601 | * Load node |
---|
602 | */ |
---|
603 | function _politicas_proyectos_load_politica($nid){ |
---|
604 | $node = 0; |
---|
605 | if ($nid) { |
---|
606 | $sql = 'SELECT n.nid, nr.body FROM {node} AS n INNER JOIN {node_revisions} AS nr ON nr.nid = n.nid AND nr.vid = n.vid WHERE n.nid = %d'; |
---|
607 | $result = db_query($sql, $nid); |
---|
608 | $node = db_fetch_object($result); |
---|
609 | } |
---|
610 | return $node; |
---|
611 | } |
---|
612 | |
---|
613 | |
---|
614 | |
---|
615 | |
---|
616 | //---------------------------------------------------------------------------- |
---|
617 | // CCK hooks. |
---|
618 | |
---|
619 | /** |
---|
620 | * Implementation of hook_widget_info(). |
---|
621 | */ |
---|
622 | function politicas_proyectos_widget_info() { |
---|
623 | return array( |
---|
624 | 'politicas_direccionales_select' => array( |
---|
625 | 'label' => 'Enlace a Politicas Direccionales', |
---|
626 | 'field types' => array('nodereference'), |
---|
627 | 'multiple values' => CONTENT_HANDLE_MODULE, |
---|
628 | 'callbacks' => array( |
---|
629 | 'default value' => CONTENT_CALLBACK_DEFAULT, |
---|
630 | ), |
---|
631 | ), |
---|
632 | ); |
---|
633 | } |
---|
634 | |
---|
635 | /** |
---|
636 | * Implementation of hook_field_formatter_info(). |
---|
637 | */ |
---|
638 | function politicas_proyectos_field_formatter_info() { |
---|
639 | return array( |
---|
640 | 'body' => array( |
---|
641 | 'label' => t('Body'), |
---|
642 | 'field types' => array('nodereference'), |
---|
643 | 'multiple values' => CONTENT_HANDLE_CORE, |
---|
644 | ), |
---|
645 | ); |
---|
646 | } |
---|
647 | |
---|
648 | /** |
---|
649 | * Implementation of hook_widget_settings(). |
---|
650 | */ |
---|
651 | function politicas_proyectos_widget_settings($op, $widget) { |
---|
652 | switch ($op) { |
---|
653 | case 'form': |
---|
654 | $form = array(); |
---|
655 | $situacion_actual = isset($widget['situacion_actual']) ? $widget['situacion_actual'] : FALSE; |
---|
656 | if ($widget['type'] == 'politicas_direccionales_select') { |
---|
657 | $form['situacion_actual'] = array( |
---|
658 | '#type' => 'checkbox', |
---|
659 | '#title' => t('Permitir solo entes que tienen S.A:'), |
---|
660 | '#default_value' => $situacion_actual, |
---|
661 | ); |
---|
662 | } |
---|
663 | else { |
---|
664 | $form['situacion_actual'] = array('#type' => 'hidden', '#value' => $match); |
---|
665 | } |
---|
666 | return $form; |
---|
667 | |
---|
668 | case 'save': |
---|
669 | return array('situacion_actual'); |
---|
670 | } |
---|
671 | } |
---|
672 | |
---|
673 | /** |
---|
674 | * Implementation of hook_widget(). |
---|
675 | * |
---|
676 | * Attach a single form element to the form. It will be built out and |
---|
677 | * validated in the callback(s) listed in hook_elements. We build it |
---|
678 | * out in the callbacks rather than here in hook_widget so it can be |
---|
679 | * plugged into any module that can provide it with valid |
---|
680 | * $field information. |
---|
681 | * |
---|
682 | * Content module will set the weight, field name and delta values |
---|
683 | * for each form element. This is a change from earlier CCK versions |
---|
684 | * where the widget managed its own multiple values. |
---|
685 | * |
---|
686 | * If there are multiple values for this field, the content module will |
---|
687 | * call this function as many times as needed. |
---|
688 | * |
---|
689 | * @param $form |
---|
690 | * the entire form array, $form['#node'] holds node information |
---|
691 | * @param $form_state |
---|
692 | * the form_state, $form_state['values'][$field['field_name']] |
---|
693 | * holds the field's form values. |
---|
694 | * @param $field |
---|
695 | * the field array |
---|
696 | * @param $items |
---|
697 | * array of default values for this field |
---|
698 | * @param $delta |
---|
699 | * the order of this item in the array of subelements (0, 1, 2, etc) |
---|
700 | * |
---|
701 | * @return |
---|
702 | * the form item for a single element for this field |
---|
703 | */ |
---|
704 | function politicas_proyectos_widget(&$form, &$form_state, $field, $items, $delta = 0) { |
---|
705 | switch ($field['widget']['type']) { |
---|
706 | case 'politicas_direccionales_select': |
---|
707 | $element = array( |
---|
708 | '#type' => 'politicas_direccionales_select', |
---|
709 | '#default_value' => $items, |
---|
710 | ); |
---|
711 | break; |
---|
712 | } |
---|
713 | return $element; |
---|
714 | } |
---|
715 | |
---|
716 | /** |
---|
717 | * Implementation of FAPI hook_elements(). |
---|
718 | * |
---|
719 | * Any FAPI callbacks needed for individual widgets can be declared here, |
---|
720 | * and the element will be passed to those callbacks for processing. |
---|
721 | * |
---|
722 | * Drupal will automatically theme the element using a theme with |
---|
723 | * the same name as the hook_elements key. |
---|
724 | * |
---|
725 | * Autocomplete_path is not used by text_widget but other widgets can use it |
---|
726 | * (see nodereference and userreference). |
---|
727 | */ |
---|
728 | function politicas_proyectos_elements() { |
---|
729 | return array( |
---|
730 | 'politicas_direccionales_select' => array( |
---|
731 | '#input' => TRUE, |
---|
732 | '#columns' => array('uid'), '#delta' => 0, |
---|
733 | '#process' => array('politicas_direccionales_select_process'), |
---|
734 | ), |
---|
735 | ); |
---|
736 | } |
---|
737 | |
---|
738 | /** |
---|
739 | * FAPI theme for an individual elements. |
---|
740 | * |
---|
741 | * The textfield or select is already rendered by the |
---|
742 | * textfield or select themes and the html output |
---|
743 | * lives in $element['#children']. Override this theme to |
---|
744 | * make custom changes to the output. |
---|
745 | * |
---|
746 | * $element['#field_name'] contains the field name |
---|
747 | * $element['#delta] is the position of this element in the group |
---|
748 | */ |
---|
749 | function theme_politicas_direccionales_select($element) { |
---|
750 | return $element['#children']; |
---|
751 | } |
---|
752 | |
---|
753 | /** |
---|
754 | * Process an individual element. |
---|
755 | * |
---|
756 | * Build the form element. When creating a form using FAPI #process, |
---|
757 | * note that $element['#value'] is already set. |
---|
758 | * |
---|
759 | * The $fields array is in $form['#field_info'][$element['#field_name']]. |
---|
760 | */ |
---|
761 | function politicas_direccionales_select_process($element, $edit, $form_state, $form) { |
---|
762 | global $user; |
---|
763 | $field_name = $element['#field_name']; |
---|
764 | $field = $form['#field_info'][$field_name]; |
---|
765 | $field_key = $element['#columns'][0]; |
---|
766 | $default = isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : $form['#politica']; |
---|
767 | $options = array(); |
---|
768 | if (!isset($form['#politicas']['politicas']) && count($form['#politicas']['politicas'])) { |
---|
769 | $sa = isset($form['#field_info'][$element['#field_name']]['widget']['situacion_actual']) ? $form['#field_info'][$element['#field_name']]['widget']['situacion_actual'] : 0; |
---|
770 | // The nodereference_select widget doesn't need to create its own |
---|
771 | // element, it can wrap around the optionwidgets_select element. |
---|
772 | // This will create a new, nested instance of the field. |
---|
773 | // Add a validation step where the value can be unwrapped. |
---|
774 | $ente_nid = isset($form['#ente_planificador']) && isset($form['#ente_planificador']->nid) ? $form['#ente_planificador']->nid : 0; |
---|
775 | if (!$ente_nid) { |
---|
776 | $ente = usuario_tiene_ente($user->uid); |
---|
777 | $ente_nid = $ente->nid; |
---|
778 | } |
---|
779 | $field_key = $element['#columns'][0]; |
---|
780 | $politicas = _politicas_proyectos_references($ente_nid, $sa); |
---|
781 | $options = $politicas['politicas']; |
---|
782 | } |
---|
783 | else { |
---|
784 | $options = $form['#politicas']['politicas']; |
---|
785 | |
---|
786 | } |
---|
787 | $element[$field_key] = array( |
---|
788 | '#type' => 'select', |
---|
789 | '#title' => $element['#title'], |
---|
790 | '#description' => $element['#description'], |
---|
791 | '#required' => isset($element['#required']) ? $element['#required'] : $field['required'], |
---|
792 | '#multiple' => isset($element['#multiple']) ? $element['#multiple'] : $field['multiple'], |
---|
793 | '#options' => $options, |
---|
794 | '#default_value' => $default, |
---|
795 | '#entes' => $options['entes'], |
---|
796 | ); |
---|
797 | if (isset($form['#politica'])) { |
---|
798 | $display = $form['#politica'] && count($form['#all_descriptores'])? _politicas_proyectos_display_politicas($form['#all_descriptores'], $form['#formas_solucion']) : t('No ha seleccionado una politica'); |
---|
799 | if (!is_array($form['#politicas']['politicas']) || !count($form['#politicas']['politicas'])){ |
---|
800 | $element[$field_key]['#prefix'] = '<div id="politicas-alert" class="color:red;font-weight: bold">' . t('El ente planificador aún no posee PolÃticas Direccionales.') . '</div>'; |
---|
801 | } |
---|
802 | |
---|
803 | $element[$field_key]['#suffix'] = '<div id ="proyecto-operativo-' . $field_key . '" class="form-item">' . $display . '</div>'; |
---|
804 | $element[$field_key]['#ahah'] = array( |
---|
805 | 'event' => 'change', |
---|
806 | 'path' => 'politicas_proyectos_get_politicas_js', |
---|
807 | 'wrapper' => 'proyecto-operativo-' . $field_key, |
---|
808 | 'method' => 'replace', |
---|
809 | 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), |
---|
810 | ); |
---|
811 | |
---|
812 | } |
---|
813 | if (empty($element[$field_key]['#element_validate'])) { |
---|
814 | $element[$field_key]['#element_validate'] = array(); |
---|
815 | } |
---|
816 | array_unshift($element[$field_key]['#element_validate'], 'nodereference_optionwidgets_validate'); |
---|
817 | return $element; |
---|
818 | } |
---|
819 | |
---|
820 | /** |
---|
821 | * Implementation of _politicas_direccionales_references(). |
---|
822 | */ |
---|
823 | function _politicas_proyectos_references($ente_id = 0, $sa = 0) { |
---|
824 | static $results = array(); |
---|
825 | if (!$results[$ente_id]) { |
---|
826 | $fathers = _ente_planificador_hierarchical_get_desc($ente_id, 1); |
---|
827 | if ($sa) { |
---|
828 | $planns = _situacion_actual_preliminar_get_planns(); |
---|
829 | $plan = $planns['situacion_actual']; |
---|
830 | } |
---|
831 | $inputs = array(); |
---|
832 | $implode_sql = array(); |
---|
833 | $max_level = 0; |
---|
834 | foreach($fathers as $ente){ |
---|
835 | if ($max_level < $ente['level']) { |
---|
836 | $max_level = $ente['level']; |
---|
837 | } |
---|
838 | if (!$sa) { |
---|
839 | $implode_sql[] = '%d'; |
---|
840 | $inputs[] = $ente['nid']; |
---|
841 | } |
---|
842 | elseif (isset($plan['ente_type'][$ente['level']])) { |
---|
843 | $implode_sql[] = '%d'; |
---|
844 | $inputs[] = $ente['nid']; |
---|
845 | } |
---|
846 | } |
---|
847 | //si el propio ente tiene politicas |
---|
848 | if (isset($plan['ente_type'][$max_level + 1])) { |
---|
849 | $implode_sql[] = '%d'; |
---|
850 | $inputs[] = $ente_id; |
---|
851 | } |
---|
852 | $sql = 'SELECT n.nid, nr.body, pd.field_politicas_ente_nid FROM {content_type_politicas_direccionales} AS pd INNER JOIN {node} AS n ON n.nid = pd.nid AND n.vid = pd.vid INNER JOIN {node_revisions} AS nr ON n.nid = nr.nid AND n.vid = nr.vid WHERE'; |
---|
853 | if (count($implode_sql)) { |
---|
854 | $sql .= ' pd.field_politicas_ente_nid IN (' . implode (', ', $implode_sql) . ') AND'; |
---|
855 | } |
---|
856 | $sql .= ' field_politicas_direcc_year_value = %d AND field_politicas_seleccionada_value = %d'; |
---|
857 | $inputs[] = variable_get('situacional_actual_preliminar_anho_creacion', 0); |
---|
858 | $inputs[] = 1; |
---|
859 | $result = db_query($sql, $inputs); |
---|
860 | $results[$field['#ente_id']] = array(); |
---|
861 | while($politica = db_fetch_object($result)) { |
---|
862 | $results[$ente_id]['politicas'][$politica->nid] = $politica->body; |
---|
863 | $results[$ente_id]['entes'][$politica->field_politicas_ente_nid] = $politica->field_politicas_ente_nid; |
---|
864 | } |
---|
865 | } |
---|
866 | return $results[$ente_id]; |
---|
867 | } |
---|