source: sipes/0.3-modules/sipp_pdf/sipp_pdf.module @ 92213c1

stableversion-3.0
Last change on this file since 92213c1 was 4334672, checked in by lhernandez <lhernandez@…>, 8 años ago

se agrego el border de las tablas

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