source: sipes/0.3-modules/sipp_pdf/sipp_pdf.module

stable
Last change on this file was afd9afd, checked in by Miguel Angel Narvaez Montilva <miguelnarvaez31@…>, 6 años ago

se modifican modulos para imprimir en pdf y se agregan nuevos campos a la ficha de proyectos operativos

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