Index: 0.3-modules/reportes_sipes_views/reportes_sipes_views.module
===================================================================
--- 0.3-modules/reportes_sipes_views/reportes_sipes_views.module	(revision 9dbb666757921f977575326ebc9222c2a105f08d)
+++ 0.3-modules/reportes_sipes_views/reportes_sipes_views.module	(revision de509b8473c8313249042fb5bb28c83841c0615a)
@@ -65,61 +65,9 @@
  */
 function reporte_sipes_views_page() {
-  $view_id = 'reporte_poan_anual';
-  $view = views_get_view($view_id);
-  $display_id = 'block_1';
-  $view->set_display($display_id);
-  $view->override_path = $_GET['q'];
-  $view->pre_execute();
-  $view->execute();
-  // $output = $view->render();
-  $year = variable_get('proyectos_operativos_anho_creacion', 0);
-  $header = '<table border="1" cellpadding="4" style="text-align: justify">';
-  $header .= '<tr>';
-  $header .= '<th rowspan = "2" style="width: 5%; text-align: center">' . t('Cod.') . '</th>';
-  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('Nombre del Proyecto.') . '</th>';
-  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('Objetivo EspecÃ­fico del Proyecto') . '</th>';
-  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('Ejecutor') . '</th>';
-  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('LocalizaciÃ³n') . '</th>';
-  $header .= '<th colspan = "2" style="width: 20%; text-align: center">' . t('Resultado de las Acciones Especificas del Proyecto @year', array('@year' => $year)) . '</th>';
-  $header .= '<th colspan = "3" style="width: 35%; text-align: center">' . t('AsignaciÃ³n Presupuestaria @year (En Millones de Bolivares)', array('@year' => $year)) . '</th>';
-  $header .= '</tr>';
-  $header .= '<tr>';
-  $header .= '<th style="text-align: center">' . t('Bien o Servicio') . '</th>';
-  $header .= '<th style="text-align: center">' . t('Cantidad/Meta') . '</th>';
-  $header .= '<th style="text-align: center">' . t('Fuente') . '</th>';
-  $header .= '<th style="text-align: center">' . t('Monto') . '</th>';
-  $header .= '<th style="text-align: center">' . t('Total') . '</th>';
-  $header .= '</tr>';
-  $plan_nombre = t('Plan Operativo Anual: @anho', array('@anho' => $year));
-  $begin = '';
-  $output = '';
-  $nid = 0;
-  foreach ($view->result as $key => $values) {
-    if ($values->node_ente_planificador_hierarchical_nid != $nid) {
-      $output .= $begin . '<p></p><p>' . $plan_nombre . '<br>';
-      $output .= t('ORGANISMO RESPONSABLE: @ente', array('@ente' => $values->node_ente_planificador_hierarchical_title)) . '</p>';
-      $output .= $header;
-      $begin = '</table><br>';
-    }
-
-    $output .= '<tr>';
-    //field codigo
-    $output .= '<td>' . $values->node_title . '</td>';
-    $output .= '<td>' . $values->node_data_field_proyecto_poan_field_proyecto_titulo_value . '</td>';
-    $output .= '<td>' . $values->node_data_field_proyecto_poan_field_proyecto_og_value . '</td>';
-    $output .= '<td>' . $values->node_node_data_field_proyecto_ente_title . '</td>';
-    $output .= '<td>' . implode('<hr><br>', $values->views_php_6) . '</td>';
-    $output .= '<td>' . implode('<hr><br>', $values->views_php_7['bien']) . '</td>';
-    $output .= '<td>' . implode('<hr><br>', $values->views_php_7['unidades']) . '</td>';
-    $output .= '<td>' . implode('<hr><br>', $values->views_php_10['fuentes']) . '</td>';
-    $output .= '<td>' . implode('<hr><br>', $values->views_php_10['valores']) . '</td>';
-    $output .= '<td align="center">' . $values->views_php_10['total'] . '</td>';
-    $output .= '</tr>';
-  }
-  $output .= $begin;
+  if (!user_access('admin planificador')) return false;
+
   $author = variable_get('site_name', '');
   module_load_include('module', 'libraries', 'libraries');
   $path = libraries_get_path('tcpdf');
-
 
   if (($path) && (file_exists($path . '/config/lang/spa.php'))) {
@@ -168,11 +116,81 @@
   // add a page
   //$pdf->AddPage();
-  $pdf->AddPage('L', 'Legal');
+
   if ($pdf) {
     $title = t('Reporte Anual POAN @year', array('@year' => $year));
     $pdf->SetTitle($title);
     $pdf->SetSubject($title);
+  }
+
+  $view_id = 'reporte_poan_anual';
+  $view = views_get_view($view_id);
+  $display_id = 'block_1';
+
+  $view->set_display($display_id);
+  $view->override_path = $_GET['q'];
+  $view->pre_execute();
+  $view->execute();
+  $view->post_execute();
+  // $output = $view->render();
+
+
+
+  $year = variable_get('proyectos_operativos_anho_creacion', 0);
+  $header = '<table border="1" cellpadding="4" style="text-align: justify">';
+  $header .= '<tr>';
+  $header .= '<th rowspan = "2" style="width: 5%; text-align: center">' . t('Cod.') . '</th>';
+  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('Nombre del Proyecto.') . '</th>';
+  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('Objetivo EspecÃ­fico del Proyecto') . '</th>';
+  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('Ejecutor') . '</th>';
+  $header .= '<th rowspan = "2" style="width: 10%; text-align: center">' . t('LocalizaciÃ³n') . '</th>';
+  $header .= '<th colspan = "2" style="width: 20%; text-align: center">' . t('Resultados esperados del Proyecto @year', array('@year' => $year)) . '</th>';
+  $header .= '<th colspan = "3" style="width: 35%; text-align: center">' . t('AsignaciÃ³n Presupuestaria @year', array('@year' => $year)) . '</th>';
+  $header .= '</tr>';
+  $header .= '<tr>';
+  $header .= '<th style="text-align: center">' . t('Bien o Servicio') . '</th>';
+  $header .= '<th style="text-align: center">' . t('Cantidad/Meta') . '</th>';
+  $header .= '<th style="text-align: center">' . t('Fuente') . '</th>';
+  $header .= '<th style="text-align: center">' . t('Monto') . '</th>';
+  $header .= '<th style="text-align: center">' . t('Total') . '</th>';
+  $header .= '</tr>';
+  $plan_nombre = t('<strong>PLAN OPERATIVO ANUAL NACIONAL @anho (POAN @anho)</strong>', array('@anho' => $year));
+  $begin = '';
+  $nid = 0;
+  foreach ($view->result as $key => $values) {
+    $output = '';
+    if ($values->node_ente_planificador_hierarchical_nid != $nid) {
+      $objetivo = implode('<br>', $values->views_php_18[0]);
+      $output .= $begin . '<p></p><p>' . $plan_nombre . '<br>';
+      $output .= '<strong>' . t('OBJETIVO HISTORICO:') . '</strong><br>' . $objetivo . '<br>';
+      $output .= t('<strong>ORGANISMO RESPONSABLE</strong>: @ente', array('@ente' => $values->node_ente_planificador_hierarchical_title)) . '</p>';
+      $output .= $header;
+      $begin = '</table><br>';
+    }
+
+    $output .= '<tr>';
+    //field codigo
+    $output .= '<td>' . $values->node_title . '</td>';
+    $output .= '<td>' . $values->node_data_field_proyecto_poan_field_proyecto_titulo_value . '</td>';
+    $output .= '<td>' . $values->node_data_field_proyecto_poan_field_proyecto_og_value . '</td>';
+    $output .= '<td>' . $values->node_node_data_field_proyecto_ente_title . '</td>';
+    $output .= '<td>' . implode('<hr><br>', $values->views_php_6) . '</td>';
+    $output .= '<td>' . $values->node_data_field_proyecto_poan_field_proyecto_descripcion_bie . '</td>';
+
+    $term = taxonomy_get_term($values->node_data_field_proyecto_poan_field_proyecto_unidadm_value);
+    $output .= '<td>' . $values->views_php_17 . ' ' . $term->name . '</td>';
+
+    $output .= '<td>' . implode('<hr><br>', $values->views_php_10['fuentes']) . '</td>';
+    $output .= '<td>' . implode('<hr><br>', $values->views_php_10['valores']) . '</td>';
+    $output .= '<td align="center">' . $values->views_php_10['total'] . '</td>';
+    $output .= '</tr>';
+    $output .= $begin;
+
+    $pdf->AddPage('L', 'Legal');
     $pdf->writeHTML($output, true, false, true, false, '');
     $pdf->lastPage();
+
+  }
+
+  if ($pdf) {
     header('Content-type: text/plain');
     $name = 'reporte_anual_poan_' . $year . '.pdf';
@@ -188,4 +206,6 @@
  */
 function reporte_sipes_views_page_exel() {
+  if (!user_access('admin planificador')) return false;
+
   $content = '';
   $view_id = 'reporte_poan_anual';
