source: sipes/0.3-modules/sipp_pdf/sipp_pdf.module @ 5c8c203

stableversion-3.0
Last change on this file since 5c8c203 was 71f23a2, checked in by lhernandez <lhernandez@…>, 8 años ago

se modifico el hook_menu agregando los condicionales respectivos

  • Propiedad mode establecida a 100755
File size: 62.3 KB
Línea 
1<?php
2
3function _sipp_pdf_pdf_init() {
4  $author = variable_get('site_name', '');
5  module_load_include('module', 'libraries', 'libraries');
6  $path = libraries_get_path('tcpdf');
7
8
9  if (($path) && (file_exists($path . '/config/lang/spa.php'))) {
10    require_once($path . '/config/lang/spa.php');
11  }
12  else {
13    drupal_set_message(t('TCPDF library not found!'), 'error');
14    return FALSE;
15  }
16
17  if (($path) && (file_exists($path . '/tcpdf.php'))) {
18    require_once($path . '/tcpdf.php');
19  }
20  else {
21    drupal_set_message(t('TCPDF library not found!'), 'error');
22    return FALSE;
23  }
24  // create new PDF documentsite_slogan
25  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
26  // set document information
27  $pdf->SetCreator($author);
28  $pdf->SetAuthor($author);
29  // set default header data
30  $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
31  // set header and footer fonts
32  $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
33  $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
34  // set default monospaced font
35  $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
36  //set margins
37  $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
38  $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
39  $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
40  //set auto page breaks
41  $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
42  //set image scale factor
43  $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
44  //set some language-dependent strings
45  $pdf->setLanguageArray($l);
46  // ---------------------------------------------------------
47  // set font
48  $font_size = variable_get('sipp_pdf_font_size', 8);
49  $pdf->SetFont('dejavusans', '', $font_size);
50  // add a page
51  $pdf->AddPage();
52  return $pdf;
53}
54
55/*
56 * Implementation of hook_proyecto_obtiene_links_alter()
57 */
58function sipp_pdf_proyecto_obtiene_links_alter(&$links, $proyecto, $acceso = FALSE) {
59  $node_accion = node_load($proyecto->nid);
60  if(_sipp_pdf_ver_datos_wk_access($node_accion)){
61    $links[] = array(
62      'data' => l(t('Obtener Campos del Proyecto en PDF'), 'proyectosop/' . $proyecto->nid . '/pdf'),
63      'class' => 'proyectos-operativos-ver-pdf',
64    );
65  }
66  if(_proyectos_operativos_ver_datos_wk_access($node_accion)){
67    $links[] = array(
68      'data' => l(t('Obtener Acciones Específicas del Proyecto en PDF'), 'proyectosop/' . $proyecto->nid . '/ae/pdf'),
69      'class' => 'proyectos-operativos-ver-ae-pdf',
70    );
71    $links[] = array(
72      'data' => l(t('Obtener Datos Financieros del Proyecto en PDF'), 'proyectosop/' . $proyecto->nid . '/finacieros/pdf'),
73      'class' => 'proyectos-operativos-ver-datos-financieros-pdf',
74    );
75  }
76  if(_proyectos_reformulacion_reformula_node_tab_access($node_accion)){
77    $links[] = array(
78      'data' => l(t('Obtener Reformulaciones del Proyecto en PDF'), 'proyectosop/' . $proyecto->nid . '/reformular/pdf'),
79      'class' => 'proyectos-operativos-reformulaciones-pdf',
80    );
81  }
82
83}
84
85/*
86 * Implementation of hook_proyecto_accion_obtiene_links_alter()
87 */
88function sipp_pdf_proyecto_accion_obtiene_links_alter(&$links, $proyecto, $accion, $acceso = FALSE) {
89
90  if(_proyectos_operativos_ver_datos_wk_access($proyecto)){
91    $links[] = array(
92      'data' => l(t('Obtener Acción específica en PDF'), 'proyectosop/' . $proyecto->nid . '/ae/' . $accion->nid . '/pdf'),
93      'class' => 'proyectos-operativos-acciones_especificas-pdf',
94    );
95  }
96}
97/*
98 * Implementation of hook_proyecto_accion_obtiene_links_alter()
99 */
100function sipp_pdf_proyecto_reformula_obtiene_links_alter(&$links, $proyecto, $reformular, $acceso = FALSE) {
101
102  if(_proyectos_reformulacion_reformula_node_tab_access($proyecto)){
103    $links[] = array(
104      'data' => l(t('Obtener Reformulación en PDF'), 'proyectosop/' . $proyecto->nid . '/reformular/' . $reformular->id_ref . '/pdf'),
105      'class' => 'proyectos-operativos-ver-reformulacion-pdf',
106    );
107  }
108}
109
110/*
111 * Implementation of hook_proyecto_accion_obtiene_links_alter()
112 */
113function sipp_pdf_proyecto_reformula_accion_obtiene_links_alter(&$links, $proyecto, $reformular, $accion, $acceso = FALSE) {
114
115  if(_proyectos_reformulacion_reformula_node_tab_access($proyecto, $reformular)){
116    $links[] = array(
117      'data' => l(t('Obtener Reformulación de la Acción Específica en PDF'), 'proyectosop/' . $proyecto->nid . '/reformular/' . $reformular->id_ref . '/ae/' . $accion->nid . '/pdf'),
118      'class' => 'proyectos-operativos-ver-reformulacion-accion-pdf',
119    );
120  }
121}
122
123
124/**
125 * Implementation of hook_theme().accioncent_ver_pdfaccioncent_seguimiento_pdf
126*/
127function sipp_pdf_theme() {
128  $sipp_pdf_path = drupal_get_path('module', 'sipp_pdf') . '/templates';
129  return array(
130    'accioncent_ver_pdf' => array(
131      'arguments' => array(
132        'accion' => array(),
133      ),
134      'template' => 'accioncent-ver-pdf',
135      'path' => $sipp_pdf_path,
136    ),
137    'accioncent_reformulaciones_pdf' => array(
138      'arguments' => array(
139        'accion' => array(),
140      ),
141      'template' => 'accioncent-reformulaciones-pdf',
142      'path' => $sipp_pdf_path,
143    ),
144    'accioncent_reformulaciones_ver_pdf' => array(
145      'arguments' => array(
146        'accion' => array(),
147        'reformulacion_load' => array(),
148      ),
149      'template' => 'accioncent-reformulaciones-ver-pdf',
150      'path' => $sipp_pdf_path,
151    ),
152    'accioncent_seguimiento_pdf' => array(
153      'arguments' => array(
154        'accion' => array(),
155      ),
156      'template' => 'accioncent-seguimiento-pdf',
157      'path' => $sipp_pdf_path,
158    ),
159    'accioncent_seguimiento_ver_campos_pdf' => array(
160      'arguments' => array(
161        'accion' => array(),
162        'campo' => '',
163        'mes' => 0,
164      ),
165      'template' => 'accioncent-seguimiento-ver-campos-pdf',
166      'path' => $sipp_pdf_path,
167    ),
168    'proyecto_campos_ver_pdf' => array(
169      'arguments' => array(
170        'proyecto' => array(),
171        'campos' => array(),
172      ),
173      'template' => 'proyecto-campos-ver-pdf',
174      'path' => $sipp_pdf_path,
175    ),
176    'proyectos_operativos_datos_ae_list_pdf' => array(
177      'arguments' => array(
178        'proyecto' => array(),
179      ),
180      'template' => 'proyectos-operativos-datos-ae-list-pdf',
181      'path' => $sipp_pdf_path,
182    ),
183    'proyectos_operativos_datos_financieros_pdf' => array(
184      'arguments' => array(
185        'proyecto' => array(),
186      ),
187      'template' => 'proyectos-operativos-datos-financieros-pdf',
188      'path' => $sipp_pdf_path,
189    ),
190    'proyectos_reformulacion_reformula_obtiene_list_pdf' => array(
191      'arguments' => array(
192        'proyecto' => array(),
193      ),
194      'template' => 'proyecto-reformulacion-lista-pdf',
195      'path' => $sipp_pdf_path,
196    ),
197    'proyectos_reformulacion_reformula_tab_page_pdf' => array(
198      'arguments' => array(
199        'proyecto' => array(),
200        'reformulacion_load' => array(),
201        'id_ref' => 0,
202        'reformula' => array(),
203        'variaciones' => array(),
204      ),
205      'template' => 'proyectos-ver-reformulacion-pdf',
206      'path' => $sipp_pdf_path,
207    ),
208    'proyectos_reformulacion_reformula_tab_ae_page_pdf' => array(
209      'arguments' => array(
210        'proyecto' => array(),
211        'reformulacion_load' => array(),
212        'ae' => array(),
213        'id_ref' => 0,
214        'reformula' => array(),
215        'variaciones' => array(),
216      ),
217      'template' => 'proyectos-ver-reformulacion-ae-pdf',
218      'path' => $sipp_pdf_path,
219    ),
220  );
221}
222
223function _sipp_pdf_ver_datos_wk_access($node) {
224  return (isset($_SESSION['proyectos_operativos_mostrar_campos']) && count($_SESSION['proyectos_operativos_mostrar_campos']) && _proyectos_operativos_ver_datos_wk_access($node));
225}
226
227function _acciones_centralizadas_verpdf($node) {
228  return ($node->type == 'accion_centralizada' && (user_access('ver planificador') || user_access('admin planificador')));
229}
230
231
232
233
234
235/*
236 * Implementation of hook_menu()
237 */
238function sipp_pdf_menu() {
239  $items = array();
240  if (module_exists('acciones_centralizadas')) {
241    //Acciones centralizadas
242    $items['node/%node/pdf'] = array(
243      'title' => 'Ver en pdf',
244      'type' => MENU_LOCAL_TASK,
245      'access callback' => '_acciones_centralizadas_verpdf',
246      'access arguments' => array(1),
247      'page callback' => '_sipp_pdf_accionesp_ver_pdf',
248      'page arguments' => array(1),
249      'weight' => 2,
250    );
251    $items['node/%node/reformular/pdf'] = array(
252      'title' => 'Reformulaciones PDF',
253      'type' => MENU_LOCAL_TASK,
254      'access callback' => '_acciones_centralizadas_reformula_node_tab_access',
255      'access arguments' => array(1),
256      'page callback' => '_sipp_pdf_reformulaciones_accioncent',
257      'page arguments' => array(1),
258      'weight' => 2,
259    );
260    $items['node/%node/reformular/%acciones_centralizadas_menu_reformulacion/pdf'] = array(
261      'title' => 'AC PDF',
262      'type' => MENU_LOCAL_TASK,
263      'access callback' => '_acciones_centralizadas_reformula_node_tab_access',
264      'access arguments' => array(1),
265      'page callback' => '_sipp_pdf_reformulaciones_accioncent_ver',
266      'page arguments' => array(1, 3),
267      'weight' => 3,
268    );
269  }
270  if (module_exists('seguimiento')) {
271    $items['node/%node/seguimiento/list'] = array(
272      'title' =>  t('Seguimiento'),
273      'type' => MENU_DEFAULT_LOCAL_TASK,
274      'weight' => -10
275    );
276  }
277  if (module_exists('acciones_centralizadas')) {
278    $items['node/%node/seguimiento/pdf'] = array(
279      'title' => 'Seguimientos PDF',
280      'type' => MENU_LOCAL_TASK,
281      'access callback' => '_acciones_centralizadas_seguimiento_node_tab_access',
282      'access arguments' => array(1),
283      'page callback' => '_sipp_pdf_seguimiento_accioncent',
284      'page arguments' => array(1),
285      'weight' => 2,
286    );
287    $items['node/%node/seguimiento/%acciones_centralizadas_menu_campo/%acciones_centralizadas_menu_mes/pdf'] = array(
288      'title' => 'Seguimiento Mes PDF',
289      'type' => MENU_LOCAL_TASK,
290      'access callback' => '_acciones_centralizadas_seguimiento_node_tab_access',
291      'access arguments' => array(1),
292      'page callback' => '_sipp_pdf_seguimiento_ver_campos_accioncent',
293      'page arguments' => array(1, 3, 4),
294      'weight' => 2,
295    );
296  }
297  //proyectos operativos
298  $items['proyectosop/%proyectosop/pdf'] = array(
299    'title' => t('Ver en PDF'),
300    'page callback' => '_sipp_pdf_proyecto_campos_pdf',
301    'page arguments' => array(1),
302    'access callback' => '_sipp_pdf_ver_datos_wk_access',
303    'access arguments' => array(1),
304    'weight' => -7,
305    'type' => MENU_LOCAL_TASK,
306  );
307  $items['proyectosop/%proyectosop/ae/%accion_especifical/pdf'] = array(
308    'title' => t('Ver AE en PDF'),
309    'page callback' => '_sipp_pdf_datosaeview',
310    'page arguments' => array(3),
311    'access callback' => '_proyectos_operativos_ver_datos_wk_access',
312    'access arguments' => array(1),
313    'weight' => -4,
314    'type' => MENU_LOCAL_TASK,
315  );
316
317  $items['proyectosop/%proyectosop/ae/ver'] = array(
318    'title' =>  t('AES'),
319    'type' => MENU_DEFAULT_LOCAL_TASK,
320    'weight' => -10
321  );
322
323  $items['proyectosop/%proyectosop/ae/pdf'] = array(
324    'title' => t('AE PDF'),
325    'page callback' => '_sipp_pdf_datosaelist',
326    'page arguments' => array(1),
327    'access callback' => '_proyectos_operativos_ver_datos_wk_access',
328    'access arguments' => array(1),
329    'weight' => -5,
330    'type' => MENU_LOCAL_TASK,
331  );
332  $items['proyectosop/%proyectosop/ficha/ver'] = array(
333    'title' =>  t('Ficha del Proyecto'),
334    'type' => MENU_DEFAULT_LOCAL_TASK,
335    'weight' => -10
336  );
337  $items['proyectosop/%proyectosop/ficha/pdf'] = array(
338    'title' => t('Proyecto en PDF'),
339    'page callback' => '_sipp_pdf_datosfichaview',
340    'page arguments' => array(1),
341    'access callback' => '_proyectos_operativos_ver_datos_wk_access',
342    'access arguments' => array(1),
343    'weight' => -4,
344    'type' => MENU_LOCAL_TASK,
345  );
346
347  $items['proyectosop/%proyectosop/finacieros/ver'] = array(
348    'title' =>  t('Datos Financieros'),
349    'type' => MENU_DEFAULT_LOCAL_TASK,
350    'weight' => -10
351  );
352  //consulta proyecto operativo (datos financieros)
353  $items['proyectosop/%proyectosop/finacieros/pdf'] = array(
354    'title' => t('Datos Financieros PDF'),
355    'page callback' => '_sipp_pdf_datosfinancierosview',
356    'page arguments' => array(1),
357    'access callback' => '_proyectos_operativos_ver_datos_wk_access',
358    'access arguments' => array(1),
359    'weight' => -4,
360    'type' => MENU_LOCAL_TASK,
361  );
362  if (module_exists('proyectos_reformulacion')) {
363    $items['proyectosop/%proyectosop/reformular/%proyectosop_menu_reformulacion/ae/%accionesp_menu_r/pdf'] = array(
364      'title' => 'AEs PDF',
365      'type' => MENU_LOCAL_TASK,
366      'access callback' => '_proyectos_reformulacion_reformula_node_tab_access',
367      'access arguments' => array(1, 3),
368      'page callback' => '_sipp_pdf_aeview',
369      'page arguments' => array(1, 3, 5),
370      'weight' => 3,
371    );
372    $items['proyectosop/%proyectosop/reformular/%proyectosop_menu_reformulacion/pdf'] = array(
373      'title' => 'Reformulación PDF',
374      'type' => MENU_LOCAL_TASK,
375      'access callback' => '_proyectos_reformulacion_reformula_node_tab_access',
376      'access arguments' => array(1),
377      'page callback' => '_sipp_pdf_reformulaview',
378      'page arguments' => array(1, 3),
379      'weight' => 2,
380    );
381    $items['proyectosop/%proyectosop/reformular/pdf'] = array(
382      'title' => 'Reformulaciones PDF',
383      'type' => MENU_LOCAL_TASK,
384      'access callback' => '_proyectos_reformulacion_reformula_node_tab_access',
385      'access arguments' => array(1),
386      'page callback' => '_proyectos_reformulacion_reformula_list_pdf',
387      'page arguments' => array(1),
388      'weight' => 2,
389    );
390  }
391  return $items;
392}
393
394function _sipp_pdf_reformulaciones_accioncent($node) {
395  $pdf = _sipp_pdf_pdf_init();
396  $html = theme('accioncent_reformulaciones_pdf', $node);
397  if ($pdf) {
398    $title = t('Acciones Centralizada');
399    $pdf->SetTitle($title);
400    $pdf->SetSubject($title);
401    $pdf->writeHTML($html, true, false, true, false, '');
402    $pdf->lastPage();
403    header('Content-type: text/plain');
404    $name = 'acciones_centralizada_' . $node->nid . '.pdf';
405    header('Content-Disposition: attachment; filename="' . $name . '"');
406    print $pdf->Output($name, 'I');
407    exit();
408  }
409  else {
410    return $html;
411  }
412}
413
414
415function template_preprocess_accioncent_reformulaciones_pdf(&$variables) {
416  $accion = $variables['accion'];
417  $ente_planificador = node_load($accion->field_acciones_ente[0]['nid']);
418  $variables['ente_planificador'] = $ente_planificador;
419  $variables['states'] = _acciones_centralizadas_reformula_obtiene_estados();
420
421  $first_state = 0;
422  if ($states['wid']) {
423    $first_state = _workflow_creation_state($states['wid']);
424  }
425  $variables['first_state'] = $first_state;
426  $estado_naprobado = variable_get('acciones_centralizadas_state_naprobado', NULL);
427  $result = db_query('SELECT re.*, u.name, u.uid FROM {accion_reformular} re INNER JOIN {users} u ON u.uid = re.uid WHERE nid = %d AND estado <> %d ORDER BY id_ref DESC', $accion->nid, $estado_naprobado);
428  $reformulaciones = array();
429  while($reformular = db_fetch_object($result)) {
430    $reformulaciones[$reformular->id_ref] = $reformular;
431  }
432  $variables['reformulaciones'] = $reformulaciones;
433}
434
435
436function _sipp_pdf_reformulaciones_accioncent_ver($node, $reformulacion_load) {
437  $pdf = _sipp_pdf_pdf_init();
438  $html = theme('accioncent_reformulaciones_ver_pdf', $node, $reformulacion_load);
439  if ($pdf) {
440    $title = t('Acción Centralizada');
441    $pdf->SetTitle($title);
442    $pdf->SetSubject($title);
443    $pdf->writeHTML($html, true, false, true, false, '');
444    $pdf->lastPage();
445    header('Content-type: text/plain');
446    $name = 'acciones_centralizada_' . $node->nid . '_reformulacion.pdf';
447    header('Content-Disposition: attachment; filename="' . $name . '"');
448    print $pdf->Output($name, 'I');
449    exit();
450  }
451  else {
452    return $html;
453  }
454}
455
456function template_preprocess_accioncent_reformulaciones_ver_pdf(&$variables) {
457  $accion = $variables['accion'];
458  $ente_planificador = node_load($accion->field_acciones_ente[0]['nid']);
459  $variables['ente_planificador'] = $ente_planificador;
460  $reformulacion_load = $variables['reformulacion_load'];
461  $ente_planificador = node_load($accion->field_acciones_ente[0]['nid']);
462  $id_ref = $reformulacion_load ? $reformulacion_load->id_ref : 0;
463  $reformula = _acciones_centralizadas_reformula_load($accion, $id_ref);
464  $variaciones = _acciones_centralizadas_reformula_all_partidas_load($accion, $id_ref);
465  $variables['id_ref'] = $id_ref;
466  $variables['reformula'] = $reformula;
467  $variables['variaciones'] = $variaciones;
468  $grupos = fieldgroup_groups('accion_centralizada');
469  $grupos_form = array();
470  $grupos_fields = array();
471  foreach($grupos as $id => $grupo) {
472    if (count($grupo['fields'])) {
473      foreach($grupo['fields'] as $id_field => $field) {
474        $grupos_fields[$id_field] = $id;
475      }
476    }
477  }
478  $variables['grupos'] = $grupos;
479  $variables['grupos_fields'] = $grupos_fields;
480  $campos = array(
481    'field_ac_ac1_ae1',
482    'field_ac_ac1_ae2',
483    'field_ac_ac2_ae2',
484    'field_ac_ac2_ae3',
485    'field_ac_ac3_ae1',
486    'field_ac_ac4_ae1',
487  );
488  $variables['campos'] = $campos;
489  $ftypes = array(
490    'value' => t('January'),
491    'value_1' => t('February'),
492    'value_2' => t('March'),
493    'value_3' => t('April'),
494    'value_4' => t('May'),
495    'value_5' => t('June'),
496    'value_6' => t('July'),
497    'value_7' => t('August'),
498    'value_8' => t('September'),
499    'value_9' => t('Octuber'),
500    'value_10' => t('November'),
501    'value_11' => t('December'),
502  );
503  $variables['ftypes'] = $ftypes;
504  $valores = array();
505  foreach($ftypes as $id_field => $texto) {
506    $valores[$id_field] = 0;
507
508  }
509  $partidas_nodo = array();
510  foreach ($campos as $id) {
511    if (count($accion->{$id})) {
512      foreach($accion->{$id} as $partida) {
513        if(!empty($partida['tid'])) {
514          $partidas_nodo[$id][$partida['tid']] = $partida['tid'];
515        }
516      }
517    }
518  }
519  if (count($variaciones)) {
520    foreach($variaciones as $field_l => $partidas) {
521      if (count($partidas)) {
522        foreach($partidas as $tid => $partida) {
523          if (!isset($partidas_nodo[$field_l][$tid])) {
524            $valores['tid'] = $tid;
525            $accion->{$field_l}[] = $valores;
526            $partidas_nodo[$field_l][$tid] = $tid;
527          }
528        }
529      }
530    }
531  }
532  if (count($reformula)) {
533    foreach($reformula as $field_l => $partidas) {
534      if (count($partidas)) {
535        foreach($partidas as $tid => $partida) {
536          if (!isset($partidas_nodo[$field_l][$tid])) {
537            $valores['tid'] = $tid;
538            $accion->{$field_l}[] = $valores;
539            $partidas_nodo[$field_l][$tid] = $tid;
540          }
541        }
542      }
543    }
544  }
545  $fields_title = array();
546  foreach ($campos as $id) {
547    $field_load = content_fields($id, 'accion_centralizada');
548    $fields_title[$id] = $field_load['widget']['label'];
549  }
550  $variables['fields_title'] = $fields_title;
551  $variables['accion'] = $accion;
552  $historys = array();
553  $states = array();
554  if (module_exists('workflow')) {
555    $states = _acciones_centralizadas_reformula_obtiene_estados();
556    $result = db_query('SELECT re.*, u.name, u.uid FROM {accion_reformular_state} re INNER JOIN {users} u ON u.uid = re.uid WHERE nid = %d AND id_ref = %d ORDER BY date DESC', $accion->nid, $id_ref);
557    while($history = db_fetch_object($result)) {
558      $historys[] = $history;
559    }
560  }
561  $variables['historys'] = $historys;
562  $variables['states'] = $states;
563  $partida_nombre = array();
564  foreach ($campos as $id) {
565    if (count($accion->{$id})) {
566      foreach($accion->{$id} as $partida) {
567        if(!empty($partida['tid'])) {
568          $term = taxonomy_get_term($partida['tid']);
569          $partida_nombre[$partida['tid']] = $term->name;
570        }
571      }
572    }
573  }
574  $variables['partida_nombre'] = $partida_nombre;
575}
576
577
578
579
580function _sipp_pdf_seguimiento_accioncent($node) {
581  $pdf = _sipp_pdf_pdf_init();
582  $html = theme('accioncent_seguimiento_pdf', $node);
583  if ($pdf) {
584    $title = t('Acciones Centralizada');
585    $pdf->SetTitle($title);
586    $pdf->SetSubject($title);
587    $pdf->writeHTML($html, true, false, true, false, '');
588    $pdf->lastPage();
589    header('Content-type: text/plain');
590    $name = 'acciones_centralizada_' . $node->nid . '_seguimiento.pdf';
591    header('Content-Disposition: attachment; filename="' . $name . '"');
592    print $pdf->Output($name, 'I');
593    exit();
594  }
595  else {
596    return $html;
597  }
598}
599
600
601
602
603function template_preprocess_accioncent_seguimiento_pdf(&$variables) {
604  $accion = $variables['accion'];
605  $ente_planificador = node_load($accion->field_acciones_ente[0]['nid']);
606  $variables['ente_planificador'] = $ente_planificador;
607  $reformulacion_load = $variables['reformulacion_load'];
608  $year = variable_get('acciones_centralizadas_anho_seguimiento', 0);
609  $variables['year'] = $year;
610  $mes_segu = variable_get('acciones_centralizadas_mes_seguimiento', 0);
611  $variables['mes_segu'] = $mes_segu;
612  $output = '';
613  $ftypes = array(
614    'value' => t('January'),
615    'value_1' => t('February'),
616    'value_2' => t('March'),
617    'value_3' => t('April'),
618    'value_4' => t('May'),
619    'value_5' => t('June'),
620    'value_6' => t('July'),
621    'value_7' => t('August'),
622    'value_8' => t('September'),
623    'value_9' => t('Octuber'),
624    'value_10' => t('November'),
625    'value_11' => t('December'),
626  );
627  $variables['ftypes'] = $ftypes;
628  $id_ref = $reformulacion_load ? $reformulacion_load->id_ref : 0;
629  $variaciones = _acciones_centralizadas_reformula_all_partidas_load($accion, $id_ref);
630  $reformula = _acciones_centralizadas_reformula_load($accion);
631  $variables['id_ref'] = $id_ref;
632  $variables['reformula'] = $reformula;
633  $variables['variaciones'] = $variaciones;
634  $actual = array();
635  $meses = array(
636    0 => t('January'),
637    1 => t('February'),
638    2 => t('March'),
639    3 => t('April'),
640    4 => t('May'),
641    5 => t('June'),
642    6 => t('July'),
643    7 => t('August'),
644    8 => t('September'),
645    9 => t('Octuber'),
646    10 => t('November'),
647    11 => t('December'),
648  );
649  $variables['meses'] = $meses;
650  $campos = array(
651    'field_ac_ac1_ae1' => 'field_ac_ac1_ae1',
652    'field_ac_ac1_ae2' => 'field_ac_ac1_ae2',
653    'field_ac_ac2_ae2' => 'field_ac_ac2_ae2',
654    'field_ac_ac2_ae3' => 'field_ac_ac2_ae3',
655    'field_ac_ac3_ae1' => 'field_ac_ac3_ae1',
656    'field_ac_ac4_ae1' => 'field_ac_ac4_ae1',
657  );
658  $variables['campos'] = $campos;
659  $valores = array();
660  foreach($ftypes as $id_field => $texto) {
661    $valores[$id_field] = 0;
662
663  }
664  $partidas_nodo = array();
665  $campos_f = array();
666  foreach ($campos as $id) {
667    $field_load = content_fields($id, 'accion_centralizada');
668    $campos_f[$id] = $field_load;
669    if (!$accion->{$id}[0]['tid']) {
670      $accion->{$id} = array();
671    }
672    if (count($accion->{$id})) {
673      foreach($accion->{$id} as $partida) {
674        if(!empty($partida['tid'])) {
675          $partidas_nodo[$id][$partida['tid']] = $partida['tid'];
676        }
677      }
678    }
679  }
680  $variables['campos_f'] = $campos_f;
681  if (count($variaciones)) {
682    foreach($variaciones as $field_l => $partidas) {
683      if (count($partidas)) {
684        foreach($partidas as $tid => $partida) {
685          if (!isset($partidas_nodo[$field_l][$tid])) {
686            if (empty($accion->{$field_l}[0]['tid']) || !$accion->{$field_l}[0]['tid']) {
687              $accion->{$field_l} = array();
688            }
689            $valores['tid'] = $tid;
690            $accion->{$field_l}[] = $valores;
691            $partidas_nodo[$field_l][$tid] = $tid;
692          }
693        }
694      }
695    }
696  }
697  if (count($reformula)) {
698    foreach($reformula as $field_l => $partidas) {
699      if (count($partidas)) {
700        foreach($partidas as $tid => $partida) {
701          if (!isset($partidas_nodo[$field_l][$tid])) {
702            if (empty($accion->{$field_l}[0]['tid']) || !$accion->{$field_l}[0]['tid']) {
703              $accion->{$field_l} = array();
704            }
705            $valores['tid'] = $tid;
706            $accion->{$field_l}[] = $valores;
707            $partidas_nodo[$field_l][$tid] = $tid;
708          }
709        }
710      }
711    }
712  }
713  foreach($meses as $mes => $nombre) {
714    $valor = $mes > 0 ? 'value_' . $mes : 'value';
715    foreach($campos as $ids) {
716      $actualP = _acciones_centralizadas_seguimiento_load($accion, $ids, $mes);
717      $mensajes[$ids][$valor] =  $actualP['values'];
718      if (isset($actualP['comprometido'][$ids])) {
719        foreach($actualP['comprometido'][$ids] as $tid => $value) {
720          $actual['comprometido'][$ids][$tid][$valor] = $value[$valor];
721        }
722        foreach($actualP['pagado'][$ids] as $tid => $value) {
723          $actual['pagado'][$ids][$tid][$valor] = $value[$valor];
724        }
725        foreach($actualP['causado'][$ids] as $tid => $value) {
726          $actual['causado'][$ids][$tid][$valor] = $value[$valor];
727        }
728      }
729    }
730  }
731  $variables['mensajes'] = $mensajes;
732  $variables['actual'] = $actual;
733  $comprometido = isset($actual['comprometido']) ? $actual['comprometido'] : array();
734  $causado = isset($actual['causado']) ? $actual['causado'] : array();
735  $pagado = isset($actual['pagado']) ? $actual['pagado'] : array();
736  $variables['comprometido'] = $comprometido;
737  $variables['causado'] = $causado;
738  $variables['pagado'] = $pagado;
739  $grupos = fieldgroup_groups('accion_centralizada');
740  $variables['grupos'] = $grupos;
741  $colores = array();
742  $colores[0] = array(
743    'texto' => variable_get('acciones_centralizadas_texto_default', 'No hay planificación'),
744    'tcolor' => variable_get('acciones_centralizadas_colort_default', '#FFFFFF'),
745    'color' => variable_get('acciones_centralizadas_color_default', '#633303'),
746  );
747  $colores[1] = array(
748    'texto' => variable_get('acciones_centralizadas_texto_critica', 'Zona crítica'),
749    'tcolor' => variable_get('acciones_centralizadas_colort_critica', '#FFFFFF'),
750    'color' => variable_get('acciones_centralizadas_color_critica', '#fd0002'),
751  );
752  $colores[2] = array(
753    'texto' => variable_get('acciones_centralizadas_texto_discreta', 'Zona discreta'),
754    'tcolor' => variable_get('acciones_centralizadas_colort_discreta', '#FFFFFF'),
755    'color' => variable_get('acciones_centralizadas_color_discreta', '#cc6733'),
756  );
757  $colores[3] = array(
758    'texto' => variable_get('acciones_centralizadas_texto_moderada', 'Zona moderada'),
759    'tcolor' => variable_get('acciones_centralizadas_colort_moderada', '#000000'),
760    'color' => variable_get('acciones_centralizadas_color_moderada', '#fdff00'),
761  );
762  $colores[4] = array(
763    'texto' => variable_get('acciones_centralizadas_texto_optima', 'Zona optima'),
764    'tcolor' => variable_get('acciones_centralizadas_colort_optima', '#000000'),
765    'color' => variable_get('acciones_centralizadas_color_optima', '#20ff21'),
766  );
767  $colores[5] = array(
768    'texto' => variable_get('acciones_centralizadas_texto_sejecucion', 'Sobre ejecución'),
769    'tcolor' => variable_get('acciones_centralizadas_colort_sejecucion', '#000000'),
770    'color' => variable_get('acciones_centralizadas_color_sejecucion', '#9966cd'),
771  );
772  $variables['colores'] = $colores;
773  $variables['accion'] = $accion;
774}
775
776
777function _sipp_pdf_seguimiento_ver_campos_accioncent($node, $campo = '', $mes = 0) {
778  $pdf = _sipp_pdf_pdf_init();
779  $meses = array(
780    0 => t('January'),
781    1 => t('February'),
782    2 => t('March'),
783    3 => t('April'),
784    4 => t('May'),
785    5 => t('June'),
786    6 => t('July'),
787    7 => t('August'),
788    8 => t('September'),
789    9 => t('Octuber'),
790    10 => t('November'),
791    11 => t('December'),
792  );
793  $html = theme('accioncent_seguimiento_ver_campos_pdf', $node, $campo, $mes);
794  if ($pdf) {
795    $title = t('Acciones Centralizada para el mes: #mes_load', array('#mes_load' => $meses[$mes]));
796    $pdf->SetTitle($title);
797    $pdf->SetSubject($title);
798    $pdf->writeHTML($html, true, false, true, false, '');
799    $pdf->lastPage();
800    header('Content-type: text/plain');
801    $name = 'acciones_centralizada_' . $node->nid . '_seguimiento.pdf';
802    header('Content-Disposition: attachment; filename="' . $name . '"');
803    print $pdf->Output($name, 'I');
804    exit();
805  }
806  else {
807    return $html;
808  }
809}
810
811function template_preprocess_accioncent_seguimiento_ver_campos_pdf(&$variables) {
812  $campo = $variables['campo'];
813  $node = $variables['accion'];
814
815  $mes = $variables['mes'];
816  $variables['campo'] = $campo;
817  $ente_planificador = node_load($node->field_acciones_ente[0]['nid']);
818  $variables['ente_planificador'] = $ente_planificador;
819  $year = variable_get('acciones_centralizadas_anho_creacion', 0);
820  $variables['year'] = $year;
821  $meses = array(
822    0 => t('January'),
823    1 => t('February'),
824    2 => t('March'),
825    3 => t('April'),
826    4 => t('May'),
827    5 => t('June'),
828    6 => t('July'),
829    7 => t('August'),
830    8 => t('September'),
831    9 => t('Octuber'),
832    10 => t('November'),
833    11 => t('December'),
834  );
835  $ftypes = array(
836    'value' => t('January'),
837    'value_1' => t('February'),
838    'value_2' => t('March'),
839    'value_3' => t('April'),
840    'value_4' => t('May'),
841    'value_5' => t('June'),
842    'value_6' => t('July'),
843    'value_7' => t('August'),
844    'value_8' => t('September'),
845    'value_9' => t('Octuber'),
846    'value_10' => t('November'),
847    'value_11' => t('December'),
848  );
849  $variables['meses'] = $meses;
850  $variables['ftypes'] = $ftypes;
851  $id_ref = 0;
852  $variaciones = _acciones_centralizadas_reformula_all_partidas_load($node, $id_ref);
853  $reformula = _acciones_centralizadas_reformula_load($node);
854  $variables['id_ref'] = $id_ref;
855  $variables['variaciones'] = $variaciones;
856  $variables['reformula'] = $reformula;
857  $campos = array(
858    'field_ac_ac1_ae1',
859    'field_ac_ac1_ae2',
860    'field_ac_ac2_ae2',
861    'field_ac_ac2_ae3',
862    'field_ac_ac3_ae1',
863    'field_ac_ac4_ae1',
864  );
865  $valores = array();
866  foreach($ftypes as $id_field => $texto) {
867    $valores[$id_field] = 0;
868  }
869  $partidas_nodo = array();
870  foreach ($campos as $id) {
871    if (count($node->{$id})) {
872      foreach($node->{$id} as $partida) {
873        if(!empty($partida['tid'])) {
874          $partidas_nodo[$id][$partida['tid']] = $partida['tid'];
875        }
876      }
877    }
878  }
879  if (count($variaciones)) {
880    foreach($variaciones as $field_l => $partidas) {
881      if (count($partidas)) {
882        foreach($partidas as $tid => $partida) {
883          if (!isset($partidas_nodo[$field_l][$tid])) {
884            $valores['tid'] = $tid;
885            $node->{$field_l}[] = $valores;
886            if ($field_l == $campo['field']) {
887              $campo['values'][] = $valores;
888            }
889          }
890        }
891      }
892    }
893  }
894  if (count($reformula)) {
895    foreach($reformula as $field_l => $partidas) {
896      if (count($partidas)) {
897        foreach($partidas as $tid => $partida) {
898          if (!isset($partidas_nodo[$field_l][$tid])) {
899            $valores['tid'] = $tid;
900            $node->{$field_l}[] = $valores;
901            if ($field_l == $campo['field']) {
902              $campo['values'][] = $valores;
903            }
904          }
905        }
906      }
907    }
908  }
909  $actual = _acciones_centralizadas_seguimiento_load($node, $campo['field'], $mes);
910  $comprometido = isset($actual['comprometido']) ? $actual['comprometido'] : array();
911  $causado = isset($actual['causado']) ? $actual['causado'] : array();
912  $pagado = isset($actual['pagado']) ? $actual['pagado'] : array();
913  $variables['actual'] = $actual;
914  $variables['comprometido'] = $comprometido;
915  $variables['causado'] = $causado;
916  $variables['pagado'] = $pagado;
917  $grupos = fieldgroup_groups('accion_centralizada');
918  $variables['grupos'] = $grupos;
919  $field_load = content_fields($campo['field'], 'accion_centralizada');
920  $variables['field_load'] = $field_load;
921  $colores = array();
922  $colores[0] = array(
923    'texto' => variable_get('acciones_centralizadas_texto_default', 'No hay planificación'),
924    'tcolor' => variable_get('acciones_centralizadas_colort_default', '#FFFFFF'),
925    'color' => variable_get('acciones_centralizadas_color_default', '#633303'),
926  );
927  $colores[1] = array(
928    'texto' => variable_get('acciones_centralizadas_texto_critica', 'Zona crítica'),
929    'tcolor' => variable_get('acciones_centralizadas_colort_critica', '#FFFFFF'),
930    'color' => variable_get('acciones_centralizadas_color_critica', '#fd0002'),
931  );
932  $colores[2] = array(
933    'texto' => variable_get('acciones_centralizadas_texto_discreta', 'Zona discreta'),
934    'tcolor' => variable_get('acciones_centralizadas_colort_discreta', '#FFFFFF'),
935    'color' => variable_get('acciones_centralizadas_color_discreta', '#cc6733'),
936  );
937  $colores[3] = array(
938    'texto' => variable_get('acciones_centralizadas_texto_moderada', 'Zona moderada'),
939    'tcolor' => variable_get('acciones_centralizadas_colort_moderada', '#000000'),
940    'color' => variable_get('acciones_centralizadas_color_moderada', '#fdff00'),
941  );
942  $colores[4] = array(
943    'texto' => variable_get('acciones_centralizadas_texto_optima', 'Zona optima'),
944    'tcolor' => variable_get('acciones_centralizadas_colort_optima', '#000000'),
945    'color' => variable_get('acciones_centralizadas_color_optima', '#20ff21'),
946  );
947  $colores[5] = array(
948    'texto' => variable_get('acciones_centralizadas_texto_sejecucion', 'Sobre ejecución'),
949    'tcolor' => variable_get('acciones_centralizadas_colort_sejecucion', '#000000'),
950    'color' => variable_get('acciones_centralizadas_color_sejecucion', '#9966cd'),
951  );
952  $variables['colores'] = $colores;
953  $partidas_nombre = array();
954  foreach ($campo['values'] as $partida) {
955    if ($partida['tid']) {
956      $term = taxonomy_get_term($partida['tid']);
957      // If this term's vocabulary supports localization.
958      if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) {
959        $term->name = t("taxonomy:term:$term->tid:name", $term->name);
960      }
961    $partidas_nombre[$partida['tid']] = $term->name;
962    }
963  }
964  $variables['partidas_nombre'] = $partidas_nombre;
965  $variables['accion'] = $node;
966  $variables['campo'] = $campo;
967  $grupos_fields = array();
968  foreach($grupos as $id => $grupo) {
969    if (count($grupo['fields'])) {
970      foreach($grupo['fields'] as $id_field => $field) {
971        if ($id_field == $campo['field']) {
972          $grupos_fields = $grupos[$id];
973        }
974      }
975    }
976  }
977  $variables['grupos_fields'] = $grupos_fields;
978  $historys = array();
979  $states = array();
980  if (module_exists('workflow')) {
981    $cid_seg = isset($actual['values']) && isset($actual['values']['id_seg']) ? $actual['values']['id_seg'] : 0;
982    $states = _acciones_centralizadas_reformula_obtiene_estados();
983    if ($cid_seg) {
984      $result = db_query('SELECT re.*, u.name, u.uid FROM {accion_seguimiento_state} re INNER JOIN {users} u ON u.uid = re.uid WHERE nid = %d AND id_seg = %d ORDER BY date DESC', $node->nid, $cid_seg);
985      while($history = db_fetch_object($result)) {
986        $historys[] = $history;
987      }
988    }
989  }
990  $variables['states'] = $states;
991  $variables['historys'] = $historys;
992  $variables['estado_aprobado'] = variable_get('acciones_centralizadas_state_aprobado', NULL);
993  $variables['estado_naprobado']= variable_get('acciones_centralizadas_state_naprobado', NULL);
994  $variables['current_estado']= isset($actual['values']) && isset($actual['values']['estado']) ? $actual['values']['estado'] : -1;
995  $variables['cid_seg']= isset($actual['values']) && isset($actual['values']['id_seg']) ? $actual['values']['id_seg'] : 0;
996  $variables['grupo'] = explode('-', $grupos_fields['label']);
997}
998
999
1000
1001function _sipp_pdf_accionesp_ver_pdf($ac) {
1002  $pdf = _sipp_pdf_pdf_init();
1003  $html = theme('accioncent_ver_pdf', $ac);
1004  if ($pdf) {
1005    $title = t('Acción Centralizada : @ac', array('@proyecto' => check_plain($ac->title)));
1006    $pdf->SetTitle($title);
1007    $pdf->SetSubject($title);
1008    $pdf->writeHTML($html, true, false, true, false, '');
1009    $pdf->lastPage();
1010    header('Content-type: text/plain');
1011    $name = 'accion_centralizada_' . $ac->nid . '.pdf';
1012    header('Content-Disposition: attachment; filename="' . $name . '"');
1013    print $pdf->Output($name, 'I');
1014    exit();
1015  }
1016  else {
1017    return $html;
1018  }
1019}
1020
1021
1022
1023function _sipp_pdf_proyecto_campos_pdf($node) {
1024  $pdf = _sipp_pdf_pdf_init();
1025  $html = theme('proyecto_campos_ver_pdf', $node, $_SESSION[$node->nid]['proyectos_operativos_mostrar_campos']);
1026  if ($pdf) {
1027    $title = t('Proyecto Operativo : @title', array('@title' => check_plain($node->title)));
1028    $pdf->SetTitle($title);
1029    $pdf->SetSubject($title);
1030    $pdf->writeHTML($html, true, false, true, false, '');
1031    $pdf->lastPage();
1032    header('Content-type: text/plain');
1033    $name = 'proyecto_operativo_' . $node->nid . '.pdf';
1034    header('Content-Disposition: attachment; filename="' . $name . '"');
1035    print $pdf->Output($name, 'I');
1036    exit();
1037  }
1038  else {
1039    return $html;
1040  }
1041}
1042
1043function _sipp_pdf_datosfichaview($node) {
1044  $pdf = _sipp_pdf_pdf_init();
1045  $html = theme('proyectos_operativos_ficha_proyecto', $node);
1046  if ($pdf) {
1047    $title = t('Ficha del Proyecto Operativo : @title', array('@title' => check_plain($node->title)));
1048    $pdf->SetTitle($title);
1049    $pdf->SetSubject($title);
1050    $pdf->writeHTML($html, true, false, true, false, '');
1051    $pdf->lastPage();
1052    header('Content-type: text/plain');
1053    $name = 'ficha_proyecto_operativo_' . $node->nid . '.pdf';
1054    header('Content-Disposition: attachment; filename="' . $name . '"');
1055    print $pdf->Output($name, 'I');
1056    exit();
1057  }
1058  else {
1059    return $html;
1060  }
1061}
1062
1063
1064function _sipp_pdf_datosaeview($ae) {
1065  $pdf = _sipp_pdf_pdf_init();
1066  $html = node_view($ae);
1067  if ($pdf) {
1068    $title = t('Acción Específica : @ae', array('@proyecto' => check_plain($ae->title)));
1069    $pdf->SetTitle($title);
1070    $pdf->SetSubject($title);
1071    $pdf->writeHTML($html, true, false, true, false, '');
1072    $pdf->lastPage();
1073    header('Content-type: text/plain');
1074    $name = 'accion_especifica_' . $ae->nid . '.pdf';
1075    header('Content-Disposition: attachment; filename="' . $name . '"');
1076    print $pdf->Output($name, 'I');
1077    exit();
1078  }
1079  else {
1080    return $html;
1081  }
1082}
1083
1084function _sipp_pdf_datosaelist($node) {
1085  $pdf = _sipp_pdf_pdf_init();
1086  $html = theme('proyectos_operativos_datos_ae_list_pdf', $node);
1087  if ($pdf) {
1088    $title = t('Acciones Específicas del Proyecto: @proyecto', array('@proyecto' => check_plain($node->title)));
1089    $pdf->SetTitle($title);
1090    $pdf->SetSubject($title);
1091    $pdf->writeHTML($html, true, false, true, false, '');
1092    $pdf->lastPage();
1093    header('Content-type: text/plain');
1094    $name = 'acciones_especificas_' . $node->nid . '.pdf';
1095    header('Content-Disposition: attachment; filename="' . $name . '"');
1096    print $pdf->Output($name, 'I');
1097    exit();
1098  }
1099  else {
1100    return $html;
1101  }
1102}
1103
1104function template_preprocess_proyectos_operativos_datos_ae_list_pdf(&$variables) {
1105  $proyecto = $variables['proyecto'];
1106  $acciones_especificas = array();
1107  foreach($proyecto->field_proyecto_accion_esp as $accion) {
1108    if ($accion['nid'] && $nid != $accion['nid']) {
1109      $accion_load = node_load($accion['nid']);
1110      if ($accion_load && $accion_load->type == 'accion_especifica') {
1111        $acciones_especificas[$accion_load->nid] = $accion_load;
1112        $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value'];
1113      }
1114    }
1115    elseif($nid = $accion['nid']) {
1116      $acciones_especificas[$ae->nid] = $ae;
1117    }
1118  }
1119  $variables['acciones_especificas'] = $acciones_especificas;
1120  $ente_planificador = node_load($proyecto->field_proyecto_ente[0]['nid']);
1121  $variables['ente_planificador'] = $ente_planificador;
1122}
1123
1124
1125function _sipp_pdf_datosfinancierosview($node) {
1126  $pdf = _sipp_pdf_pdf_init();
1127  $html = theme('proyectos_operativos_datos_financieros_pdf', $node);
1128  if ($pdf) {
1129    $title = t('Datos Financieros del Proyecto: @proyecto', array('@proyecto' => check_plain($node->title)));
1130    $pdf->SetTitle($title);
1131    $pdf->SetSubject($title);
1132    $pdf->writeHTML($html, true, false, true, false, '');
1133    $pdf->lastPage();
1134    header('Content-type: text/plain');
1135    $name = 'datosfinancieros_' . $node->nid . '.pdf';
1136    header('Content-Disposition: attachment; filename="' . $name . '"');
1137    print $pdf->Output($name, 'I');
1138    exit();
1139  }
1140  else {
1141    return $html;
1142  }
1143}
1144
1145function template_preprocess_proyectos_operativos_datos_financieros_pdf(&$variables) {
1146  global $user;
1147  $proyecto = $variables['proyecto'];
1148  $ejecucion = 0;
1149  $acciones_especificas = array();
1150  $arreglo_anual = array();
1151  $arreglo_partida = array();
1152  $titles = array();
1153  $partidas = array();
1154  $node_type = content_types('accion_especifica');
1155  $fields = $node_type['fields'];
1156  $title = array();
1157  $title['ordinarios'] = t('Recursos Ordinarios');
1158  $fields_financiamiento = array();
1159  $fields_financiamiento['ordinarios'] = array();
1160  $titulos_campos = array();
1161  $valores = array();
1162  $campos = array();
1163  $arreglo = array(
1164    'field_accion_esp_transferencias' => 'field_accion_esp_transferencias',
1165    'field_accion_esp_creditosa' => 'field_accion_esp_creditosa',
1166    'field_accion_esp_mcti' => 'field_accion_esp_mcti',
1167  );
1168  if (is_array($fields) && count($fields)) {
1169    foreach($fields as $field_id => $field) {
1170      if (array_key_exists($field_id, $arreglo)) {
1171        $fields_financiamiento['ordinarios'][] = $field_id;
1172        $valores[$field_id] = 0;
1173        $campos[] = $field_id;
1174        $titulos_campos[$field_id] = $field['widget']['label'];
1175      }
1176      elseif (variable_get('proyectos_operativos_ac_fo_' . $field_id, FALSE)) {
1177        $fields_financiamiento['ordinarios'][] = $field_id;
1178        $valores[$field_id] = 0;
1179        $campos[] = $field_id;
1180        $titulos_campos[$field_id] = $field['widget']['label'];
1181      }
1182    }
1183  }
1184  $title['propios'] = t('Recursos Propios');
1185  $fields_financiamiento['propios'] = array();
1186  $arreglo = array(
1187    'field_accion_esp_venta_act' => 'field_accion_esp_venta_act',
1188    'field_accion_esp_activos' => 'field_accion_esp_activos',
1189    'field_accion_esp_flujocaja' => 'field_accion_esp_flujocaja',
1190    'field_accion_esp_ventapro' => 'field_accion_esp_ventapro',
1191  );
1192  if (is_array($fields) && count($fields)) {
1193    foreach($fields as $field_id => $field) {
1194      if (array_key_exists($field_id, $arreglo)) {
1195        $fields_financiamiento['propios'][] = $field_id;
1196        $valores[$field_id] = 0;
1197        $campos[] = $field_id;
1198        $titulos_campos[$field_id] = $field['widget']['label'];
1199      }
1200      elseif (variable_get('proyectos_operativos_ac_fp_' . $field_id, FALSE)) {
1201        $fields_financiamiento['propios'][] = $field_id;
1202        $valores[$field_id] = 0;
1203        $campos[] = $field_id;
1204        $titulos_campos[$field_id] = $field['widget']['label'];
1205      }
1206    }
1207  }
1208  $title['transferencias'] = t('Transferencias');
1209  $fields_financiamiento['transferencias'] = array();
1210  $arreglo = array(
1211    'field_accion_esp_donaciones' => 'field_accion_esp_donaciones',
1212  );
1213  if (is_array($fields) && count($fields)) {
1214    foreach($fields as $field_id => $field) {
1215      if (array_key_exists($field_id, $arreglo)) {
1216        $fields_financiamiento['transferencias'][] = $field_id;
1217        $valores[$field_id] = 0;
1218        $campos[] = $field_id;
1219        $titulos_campos[$field_id] = $field['widget']['label'];
1220      }
1221      elseif (variable_get('proyectos_operativos_ac_fd_' . $field_id, FALSE)) {
1222        $fields_financiamiento['transferencias'][] = $field_id;
1223        $valores[$field_id] = 0;
1224        $campos[] = $field_id;
1225        $titulos_campos[$field_id] = $field['widget']['label'];
1226      }
1227    }
1228  }
1229  $title['otros'] = t('Otros');
1230  $fields_financiamiento['otros'] = array();
1231  $arreglo = array(
1232    'field_accion_esp_gobernacion' => 'field_accion_esp_gobernacion',
1233    'field_accion_esp_misionc' => 'field_accion_esp_misionc',
1234    'field_accion_esp_bid_fona' => 'field_accion_esp_bid_fona',
1235    'field_accion_esp_fonacit' => 'field_accion_esp_fonacit',
1236    'field_accion_esp_fonden' => 'field_accion_esp_fonden',
1237    'field_accion_esp_locti' => 'field_accion_esp_locti',
1238    'field_accion_esp_fondoidi' => 'field_accion_esp_fondoidi',
1239    'field_accion_esp_capitalrie' => 'field_accion_esp_capitalrie',
1240    'field_accion_esp_infocentro' => 'field_accion_esp_infocentro',
1241    'field_accion_esp_fidetel' => 'field_accion_esp_fidetel',
1242  );
1243  if (is_array($fields) && count($fields)) {
1244    foreach($fields as $field_id => $field) {
1245      if (array_key_exists($field_id, $arreglo)) {
1246        $fields_financiamiento['otros'][] = $field_id;
1247        $valores[$field_id] = 0;
1248        $campos[] = $field_id;
1249        $titulos_campos[$field_id] = $field['widget']['label'];
1250      }
1251      elseif (variable_get('proyectos_operativos_ac_fo_' . $field_id, FALSE)) {
1252        $fields_financiamiento['otros'][] = $field_id;
1253        $valores[$field_id] = 0;
1254        $campos[] = $field_id;
1255        $titulos_campos[$field_id] = $field['widget']['label'];
1256      }
1257    }
1258  }
1259  $variables['fields_financiamiento'] = $fields_financiamiento;
1260  $variables['campos'] = $campos;
1261  $variables['titulos_campos'] = $titulos_campos;
1262  foreach($proyecto->field_proyecto_accion_esp as $accion) {
1263    if ($accion['nid']) {
1264      $accion_load = node_load($accion['nid']);
1265      if ($accion_load && $accion_load->type == 'accion_especifica') {
1266        foreach($campos as $field) {
1267          $valores[$field] += $accion_load->{$field}[0]['value'];
1268        }
1269        $titles[$accion_load->nid] = $accion_load->title;
1270        $acciones_especificas[$accion_load->nid] = $accion_load;
1271        $ejecucion += $accion_load->field_accion_esp_ponderacion[0]['value'];
1272        foreach($accion_load->field_accion_esp_programacion as $accion) {
1273          if ($accion['tid']) {
1274            $partidas[$accion['tid']] = $accion['tid'];
1275            for ($i = 0; $i < 12; $i++) {
1276              $valor = $i ? 'value_' . $i : 'value';
1277              if (!isset($arreglo_partida[$accion_load->nid][$accion['tid']])) {
1278                $arreglo_partida[$accion_load->nid][$accion['tid']] = 0;
1279              }
1280              if (!isset($arreglo_anual[$accion_load->nid][$valor])) {
1281                $arreglo_anual[$accion_load->nid][$valor] = 0;
1282              }
1283              $arreglo_partida[$accion_load->nid][$accion['tid']] += $accion[$valor];
1284              $arreglo_anual[$accion_load->nid][$valor] += $accion[$valor];
1285            }
1286          }
1287        }
1288      }
1289    }
1290  }
1291  $variables['valores'] = $valores;
1292  $variables['arreglo_anual'] = $arreglo_anual;
1293  $variables['arreglo_partida'] = $arreglo_partida;
1294  $variables['partidas'] = $partidas;
1295  $variables['titles'] = $titles;
1296  $ftypes = array(
1297    'value' => t('ENE'),
1298    'value_1' => t('FEB'),
1299    'value_2' => t('MAR'),
1300    'value_3' => t('ABR'),
1301    'value_4' => t('MAY'),
1302    'value_5' => t('JUN'),
1303    'value_6' => t('JUL'),
1304    'value_7' => t('AGO'),
1305    'value_8' => t('SEP'),
1306    'value_9' => t('OCT'),
1307    'value_10' => t('NOV'),
1308    'value_11' => t('DEC'),
1309  );
1310  $variables['ftypes'] = $ftypes;
1311
1312  $partidas_nombres = array();
1313  foreach($partidas as $valor) {
1314    $term = taxonomy_get_term($valor);
1315    // If this term's vocabulary supports localization.
1316    if (module_exists('i18ntaxonomy') && i18ntaxonomy_vocabulary($term->vid) == I18N_TAXONOMY_LOCALIZE) {
1317      $term->name = tt("taxonomy:term:$term->tid:name", $term->name);
1318    }
1319    $partidas_nombres[$valor] = $term->name;
1320  }
1321  $variables['partidas_nombres'] = $partidas_nombres;
1322}
1323
1324function _proyectos_reformulacion_reformula_list_pdf($node) {
1325  $pdf = _sipp_pdf_pdf_init();
1326  $html = theme('proyectos_reformulacion_reformula_obtiene_list_pdf', $node);
1327  if ($pdf) {
1328    $title = t('Reformulaciones Proyecto: @proyecto', array('@proyecto' => check_plain($node->title)));
1329    $pdf->SetTitle($title);
1330    $pdf->SetSubject($title);
1331    $pdf->writeHTML($html, true, false, true, false, '');
1332    $pdf->lastPage();
1333    header('Content-type: text/plain');
1334    $name = 'reformulaciones_' . $node->nid . '.pdf';
1335    header('Content-Disposition: attachment; filename="' . $name . '"');
1336    print $pdf->Output($name, 'I');
1337    exit();
1338  }
1339  else {
1340    return $html;
1341  }
1342}
1343
1344/*
1345 * Implementation of _proyectos_reformulacion_reformula_obtiene_list_page()
1346 */
1347function template_preprocess_proyectos_reformulacion_reformula_obtiene_list_pdf(&$variables) {
1348  global $user;
1349  $node = $variables['proyecto'];
1350  $ente_planificador = node_load($node->field_proyecto_ente[0]['nid']);
1351  $states = _proyectos_operativos_reformulacion_obtiene_estados();
1352
1353  $estado_naprobado = variable_get('proyectos_operativos_state_naprobado', NULL);
1354  $result = db_query('SELECT re.*, u.name, u.uid FROM {proyectos_reformular} re INNER JOIN {users} u ON u.uid = re.uid WHERE nid = %d AND estado <> %d ORDER BY id_ref DESC', $node->nid, $estado_naprobado);
1355  while($reformular = db_fetch_object($result)) {
1356    $reformulaciones[] = $reformular;
1357  }
1358  $variables['reformulaciones'] = $reformulaciones;
1359  $variables['states'] = $states;
1360  $variables['ente_planificador'] = $ente_planificador;
1361}
1362
1363function _sipp_pdf_reformulaview($node, $reformulacion_load = 0) {
1364  $pdf = _sipp_pdf_pdf_init();
1365  $id_ref = $reformulacion_load ? $reformulacion_load->id_ref : 0;
1366  $reformula = _proyectos_reformulacion_load($node, $id_ref);
1367  $variaciones = _proyectos_reformula_all_partidas_load($node, $id_ref);
1368  $html = theme('proyectos_reformulacion_reformula_tab_page_pdf', $node, $reformulacion_load, $id_ref, $reformula, $variaciones);
1369  if ($pdf) {
1370    $title = t('Reformulación Proyecto: @proyecto (@date)', array('@date' => format_date($reformulacion_load->date), '@proyecto' => check_plain($node->title)));
1371    $pdf->SetTitle($title);
1372    $pdf->SetSubject($title);
1373    $pdf->writeHTML($html, true, false, true, false, '');
1374    $pdf->lastPage();
1375    header('Content-type: text/plain');
1376    $name = 'reformulacion_' . $reformulacion_load->id_ref . '.pdf';
1377    header('Content-Disposition: attachment; filename="' . $name . '"');
1378    print $pdf->Output($name, 'I');
1379    exit();
1380  }
1381  else {
1382    return $html;
1383  }
1384}
1385
1386function template_preprocess_proyectos_reformulacion_reformula_tab_page_pdf(&$variables) {
1387  global $user;
1388  $node = $variables['proyecto'];
1389  $id_ref = $variables['id_ref'];
1390  $reformula = $variables['reformula'];
1391  $variaciones = $variables['variaciones'];
1392  $ente_planificador = node_load($node->field_proyecto_ente[0]['nid']);
1393  $variables['ente_planificador'] = $ente_planificador;
1394  $field = content_fields('field_accion_esp_unidadm', 'accion_especifica');
1395  $unidadesm = array();
1396  $tree = taxonomy_get_tree($field['vid']);
1397  if ($tree) {
1398    foreach ($tree as $term) {
1399      $unidadesm[$term->tid] = $term->name;
1400    }
1401  }
1402  $variables['unidadesm'] = $unidadesm;
1403  $grupos = array();
1404  if ($node->field_proyecto_accion_esp[0]['nid']) {
1405    foreach($node->field_proyecto_accion_esp as $ae) {
1406      $grupos[$ae['nid']] = node_load($ae['nid']);
1407    }
1408  }
1409  $variables['grupos'] = $grupos;
1410  //get first state
1411  $estados = array();
1412  if (module_exists('workflow')) {
1413    $estados = _proyectos_operativos_reformulacion_obtiene_estados();
1414  }
1415  $variables['estados'] = $estados;
1416  $ftypes = array(
1417    'value' => t('January'),
1418    'value_1' => t('February'),
1419    'value_2' => t('March'),
1420    'value_3' => t('April'),
1421    'value_4' => t('May'),
1422    'value_5' => t('June'),
1423    'value_6' => t('July'),
1424    'value_7' => t('August'),
1425    'value_8' => t('September'),
1426    'value_9' => t('Octuber'),
1427    'value_10' => t('November'),
1428    'value_11' => t('December'),
1429  );
1430  $variables['ftypes'] = $ftypes;
1431  $historys = array();
1432  if (module_exists('workflow')) {
1433    $result = db_query('SELECT re.*, u.name, u.uid FROM {proyectos_reformular_state} re INNER JOIN {users} u ON u.uid = re.uid WHERE nid = %d AND id_ref = %d ORDER BY date DESC', $node->nid, $id_ref);
1434    while($history = db_fetch_object($result)) {
1435      $historys[] = $history;
1436    }
1437  }
1438  $variables['historys'] = $historys;
1439}
1440
1441function _sipp_pdf_aeview($node, $reformulacion_load = 0, $ae = 0) {
1442  $pdf = _sipp_pdf_pdf_init();
1443  $id_ref = $reformulacion_load ? $reformulacion_load->id_ref : 0;
1444  $reformula = _proyectos_reformulacion_load($node, $id_ref);
1445  $variaciones = _proyectos_reformula_all_partidas_load($node, $id_ref);
1446  $html = theme('proyectos_reformulacion_reformula_tab_ae_page_pdf', $node, $reformulacion_load, $ae, $id_ref, $reformula, $variaciones);
1447  if ($pdf) {
1448    $pdf->SetTitle('AE ' . $ae->title);
1449    $pdf->SetSubject('AE: ' . $ae->title);
1450    $pdf->writeHTML($html, true, false, true, false, '');
1451    $pdf->lastPage();
1452    header('Content-type: text/plain');
1453    $name = 'accionespecifica_' . $ae->nid . '.pdf';
1454    header('Content-Disposition: attachment; filename="' . $name . '"');
1455    print $pdf->Output('accionespecifica_' . $ae->nid . '.pdf', 'I');
1456    exit();
1457  }
1458  else {
1459    return $html;
1460  }
1461}
1462
1463function template_preprocess_proyectos_reformulacion_reformula_tab_ae_page_pdf(&$variables) {
1464  $id_ref = $variables['id_ref'];
1465  $reformula = $variables['reformula'];
1466  $variaciones = $variables['variaciones'];
1467  $proyecto = $variables['proyecto'];
1468  $ente_planificador = node_load($proyecto->field_proyecto_ente[0]['nid']);
1469  $variables['ente_planificador'] = $ente_planificador;
1470  $ftypes = array(
1471    'value' => t('January'),
1472    'value_1' => t('February'),
1473    'value_2' => t('March'),
1474    'value_3' => t('April'),
1475    'value_4' => t('May'),
1476    'value_5' => t('June'),
1477    'value_6' => t('July'),
1478    'value_7' => t('August'),
1479    'value_8' => t('September'),
1480    'value_9' => t('Octuber'),
1481    'value_10' => t('November'),
1482    'value_11' => t('December'),
1483  );
1484  $variables['ftypes'] = $ftypes;
1485  $ae = $variables['ae'];
1486  $partidas_nodo = array();
1487  foreach ($ae->field_accion_esp_programacion as $partida) {
1488    if(!empty($partida['tid'])) {
1489      $partidas_nodo[$partida['tid']] = $partida;
1490    }
1491  }
1492  $variables['partidas_nodo'] = $partidas_nodo;
1493  $field = content_fields('field_accion_esp_programacion', 'accion_especifica');
1494  $tree = taxonomy_get_tree($field['vid']);
1495  $vtid = $field['vtid'];
1496  $partidas = array();
1497  if ($tree) {
1498    foreach ($tree as $term) {
1499      if (isset($vtid[$term->tid])) {
1500        $partidas[$term->tid] = $term->name;
1501      }
1502    }
1503  }
1504  $variables['partidas'] = $partidas;
1505  $arreglo = array();
1506  $titles = array(
1507    'ordinarios' => t('Recursos Ordinarios'),
1508    'propios' => t('Recursos Propios'),
1509    'transferencias' => t('Donaciones'),
1510    'otros' => t('Otros'),
1511  );
1512  $titles_field = array(
1513    'field_accion_esp_transferencias' => t('Recursos Ordinarios'),
1514    'field_accion_esp_creditosa' => t('Recursos Propios'),
1515    'transferencias' => t('Donaciones'),
1516    'otros' => t('Otros'),
1517  );
1518  $variables['titles_field'] = $titles_field;
1519
1520  $arreglo['ordinarios'] = array(
1521    'field_accion_esp_transferencias' => 'field_accion_esp_transferencias',
1522    'field_accion_esp_creditosa' => 'field_accion_esp_creditosa',
1523    'field_accion_esp_mcti' => 'field_accion_esp_mcti',
1524  );
1525  $arreglo['propios'] = array(
1526    'field_accion_esp_venta_act' => 'field_accion_esp_venta_act',
1527    'field_accion_esp_activos' => 'field_accion_esp_activos',
1528    'field_accion_esp_flujocaja' => 'field_accion_esp_flujocaja',
1529    'field_accion_esp_ventapro' => 'field_accion_esp_ventapro',
1530  );
1531  $arreglo['transferencias'] = array(
1532    'field_accion_esp_donaciones' => 'field_accion_esp_donaciones',
1533  );
1534  $arreglo['otros'] = array(
1535    'field_accion_esp_gobernacion' => 'field_accion_esp_gobernacion',
1536    'field_accion_esp_misionc' => 'field_accion_esp_misionc',
1537    'field_accion_esp_bid_fona' => 'field_accion_esp_bid_fona',
1538    'field_accion_esp_fonacit' => 'field_accion_esp_fonacit',
1539    'field_accion_esp_fonden' => 'field_accion_esp_fonden',
1540    'field_accion_esp_locti' => 'field_accion_esp_locti',
1541    'field_accion_esp_fondoidi' => 'field_accion_esp_fondoidi',
1542    'field_accion_esp_capitalrie' => 'field_accion_esp_capitalrie',
1543    'field_accion_esp_infocentro' => 'field_accion_esp_infocentro',
1544    'field_accion_esp_fidetel' => 'field_accion_esp_fidetel',
1545  );
1546  $variables['arreglo'] = $arreglo;
1547}
1548
1549
1550
1551
1552function _proyectos_reformulacion_reformula_tab_page_ver_ae_pdf($node, $reformulacion_load = 0, $ae = 0) {
1553  $planificado = t('planificado');
1554  $variacion = t('variación');
1555  $ftypes = array(
1556    'value' => t('January'),
1557    'value_1' => t('February'),
1558    'value_2' => t('March'),
1559    'value_3' => t('April'),
1560    'value_4' => t('May'),
1561    'value_5' => t('June'),
1562    'value_6' => t('July'),
1563    'value_7' => t('August'),
1564    'value_8' => t('September'),
1565    'value_9' => t('Octuber'),
1566    'value_10' => t('November'),
1567    'value_11' => t('December'),
1568  );
1569  $partidas_nodo = array();
1570  foreach ($ae->field_accion_esp_programacion as $partida) {
1571    if(!empty($partida['tid'])) {
1572      $partidas_nodo[$partida['tid']] = $partida;
1573    }
1574  }
1575
1576  $id_ref = $reformulacion_load ? $reformulacion_load->id_ref : 0;
1577  $reformula = _proyectos_reformulacion_load($node, $id_ref);
1578  $variaciones = _proyectos_reformula_all_partidas_load($node, $id_ref);
1579  $field = content_fields('field_accion_esp_programacion', 'accion_especifica');
1580  $tree = taxonomy_get_tree($field['vid']);
1581  $vtid = $field['vtid'];
1582  $partidas = array();
1583  if ($tree) {
1584    foreach ($tree as $term) {
1585      if (isset($vtid[$term->tid])) {
1586        $partidas[$term->tid] = $term->name;
1587      }
1588    }
1589  }
1590
1591  $arreglo = array();
1592  $titles = array(
1593    'ordinarios' => t('Recursos Ordinarios'),
1594    'propios' => t('Recursos Propios'),
1595    'transferencias' => t('Donaciones'),
1596    'otros' => t('Otros'),
1597  );
1598  $titles_field = array(
1599    'field_accion_esp_transferencias' => t('Recursos Ordinarios'),
1600    'field_accion_esp_creditosa' => t('Recursos Propios'),
1601    'transferencias' => t('Donaciones'),
1602    'otros' => t('Otros'),
1603  );
1604
1605
1606  $arreglo['ordinarios'] = array(
1607    'field_accion_esp_transferencias' => 'field_accion_esp_transferencias',
1608    'field_accion_esp_creditosa' => 'field_accion_esp_creditosa',
1609    'field_accion_esp_mcti' => 'field_accion_esp_mcti',
1610  );
1611  $arreglo['propios'] = array(
1612    'field_accion_esp_venta_act' => 'field_accion_esp_venta_act',
1613    'field_accion_esp_activos' => 'field_accion_esp_activos',
1614    'field_accion_esp_flujocaja' => 'field_accion_esp_flujocaja',
1615    'field_accion_esp_ventapro' => 'field_accion_esp_ventapro',
1616  );
1617  $arreglo['transferencias'] = array(
1618    'field_accion_esp_donaciones' => 'field_accion_esp_donaciones',
1619  );
1620  $arreglo['otros'] = array(
1621    'field_accion_esp_gobernacion' => 'field_accion_esp_gobernacion',
1622    'field_accion_esp_misionc' => 'field_accion_esp_misionc',
1623    'field_accion_esp_bid_fona' => 'field_accion_esp_bid_fona',
1624    'field_accion_esp_fonacit' => 'field_accion_esp_fonacit',
1625    'field_accion_esp_fonden' => 'field_accion_esp_fonden',
1626    'field_accion_esp_locti' => 'field_accion_esp_locti',
1627    'field_accion_esp_fondoidi' => 'field_accion_esp_fondoidi',
1628    'field_accion_esp_capitalrie' => 'field_accion_esp_capitalrie',
1629    'field_accion_esp_infocentro' => 'field_accion_esp_infocentro',
1630    'field_accion_esp_fidetel' => 'field_accion_esp_fidetel',
1631  );
1632  $output = '';
1633  $ente_planificador = node_load($node->field_proyecto_ente[0]['nid']);
1634  //$output .= '<fieldset><legend>' . t('Resumen del Proyecto') . '</legend>';
1635  $output .= '<div class="field"><div class="field-label">' . t('Código Único del Proyecto') . ':</div>' . $node->field_proyecto_codigo[0]['value'] . '</div>';
1636  $output .= '<div class="field"><div class="field-label">' . t('Nombre del Proyecto') . ':</div>' . $node->title . '</div>';
1637  $output .= '<div class="field"><div class="field-label">' . t('Organismo') . ':</div>' . $ente_planificador->title . '</div>';
1638  //$output .= '</fieldset>';
1639
1640
1641  //$output .= '<fieldset><legend>' . t('Resumen Financiero de las Acciones') . '</legend>';
1642  $output .= '<div class="field"><div class="field-label">' . t('Resumen Financiero de las Acciones') . ':</div>'. '</div>';
1643  $header = array();
1644  $header[] = array('data' => t('Partidas'), 'colspan' => 2);
1645  foreach($ftypes as $id_field => $texto) {
1646    $header[] = array('data' => $texto);
1647  }
1648  $header[] = array('data' => t('TOTAL'));
1649  $rows = array();
1650  $rowsF = array();
1651  $i = 0;
1652  $totales = array();
1653  $totalT = 0;
1654  $plant = array();
1655  $sumaplan = 0;
1656  $sumaplanm = array();
1657  foreach($partidas as $tid => $grupo) {
1658    $i++;
1659    $total = 0;
1660    $total1 = 0;
1661    $row = array();
1662    $row1 = array();
1663    $row[] = array('data' => $grupo, 'rowspan' => 2);
1664    $row[] = array('data' => $planificado, );
1665    $row1[] = array('data' => $variacion, );
1666    foreach($ftypes as $id_field => $texto) {
1667      $varia = isset($variaciones['field_accion_esp_programacion_' . $ae->nid][$tid][$id_field]) ? $variaciones['field_accion_esp_programacion_' . $ae->nid][$tid][$id_field] : 0;
1668      $min = $partidas_nodo[$tid][$id_field] + $varia;
1669      $valor = isset($reformula['field_accion_esp_programacion_' . $ae->nid][$tid][$id_field])? $reformula['field_accion_esp_programacion_' . $ae->nid][$tid][$id_field] : 0;
1670      $total1 += $valor;
1671      $totalT += $min + $valor;
1672      if (!isset($plant[$tid])) {
1673        $plant[$tid] = 0;
1674      }
1675      $plant[$tid] += $min;
1676      $sumaplan += $min;
1677      if (!isset($totales[$id_field])) {
1678        $totales[$id_field] = 0;
1679      }
1680      if (!isset($sumaplanm[$id_field])) {
1681        $sumaplanm[$id_field] = 0;
1682      }
1683      $sumaplanm[$id_field] += $min;
1684      $totales[$id_field] += $min + $valor;
1685      $idformu = $ae->nid . '_field_accion_esp_programacion_' . $tid . '_' . $id_field;
1686      $idformuj = str_replace('_', '-', $idformu);
1687      $row[] = array('data' => $min, );
1688      $row1[] = array('data' => $valor, );
1689    }
1690    $row[] = array('data' => $plant[$tid], );
1691    $row1[] = array('data' => $total1, );
1692    $rows[] = $row;
1693    $rows[] = $row1;
1694  }
1695  $row = array();
1696  $row[] = array('data' => '<b>' . t('TOTAL') . '</b>', 'colspan' => 2, 'align' => 'right');
1697  foreach($ftypes as $id_field => $texto) {
1698    $row[] = array('data' => $totales[$id_field], );
1699  }
1700  $row[] = array('data' => $totalT, );
1701  $rows[] = $row;
1702  $output .= theme('table', $header, $rows, array('border' => '1'));
1703 // $output .= '</fieldset>';
1704  $rows = array();
1705  $row = array();
1706  $row1 = array();
1707  $sumalT = 0;
1708  foreach($arreglo as $id => $arreglo1) {
1709    $sumal = 0;
1710    $output1 = '';
1711    foreach($arreglo1 as $id1) {
1712      $field = content_fields($id1, 'accion_especifica');
1713      $varia = isset($variaciones[$id1 . '_' . $ae->nid][0]['value']) ? $variaciones[$id1 . '_' . $ae->nid][0]['value'] : 0;
1714      $min = $ae->{$id1}[0]['value'] + $varia;
1715      if (!isset($sumafinm[$id])) {
1716        $sumafinm[$id] = 0;
1717      }
1718      $sumafinm[$id] += $min;
1719      $sumatotalf += $min;
1720      $field = content_fields($id1, 'accion_especifica');
1721      $valor = isset($reformula[$id1 . '_' . $ae->nid][0]['value'])? $reformula[$id1 . '_' . $ae->nid][0]['value'] : 0;
1722      $total1 += $valor;
1723      $total += $valor;
1724      $sumal += $min + $valor;
1725      $sumalT += $min + $valor;
1726      $idformuj = str_replace('_', '-', $id1);
1727      $output1 .= '<p><b>' . $field['widget']['label'] . ':</b>' . '<br><b>' . t('Planificado') . ':</b> ' . $min . '<br><b>' . t('Variación') . ':</b> ' . $valor .  '</p>';
1728    }
1729    $row[] = array('data' => $output1, );
1730    $row1[] = array('data' => $sumal, );
1731  }
1732  $rows[] = $row;
1733  $rows[] = $row1;
1734  $row = array();
1735  $row[] = array('data' => '<b>' . t('TOTAL') . ':</b>', 'colspan' => 3, 'align' => 'right');
1736  $row[] = array('data' => $sumalT, );
1737  $rows[] = $row;
1738  $output .= '<div class="field"><div class="field-label">' . t('Distribución por fuentes de Financiamiento (Bs.)') . ':</div>'. '</div>';
1739  $output .= theme('table', array(), $rows, array('border' => '1'));
1740  return $output;
1741}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.