Pārlūkot izejas kodu

Se agrego PDF y excel de herramienta inventario

Jose Cienfuegos 7 mēneši atpakaļ
vecāks
revīzija
fb5287a865

+ 2 - 1
config/web.php

@@ -65,7 +65,8 @@ $config = [
   'params' => $params,
   'modules' => [
     'v1' => ['class' => 'v1\Module'],
-    'pdf' => ['class' => 'pdf\Module'],
+    'pdf' => ['class' => 'app\modules\pdf\Module'],
+    'excel' => ['class' => 'app\modules\excel\Module'],
   ]
 ];
 

+ 38 - 0
modules/excel/Module.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace app\modules\excel;
+
+use Yii;
+
+/**
+ * v1 module definition class
+ */
+class Module extends \yii\base\Module {
+
+  /**
+   * {@inheritdoc}
+   */
+  public $controllerNamespace = 'app\modules\excel\controllers';
+
+  /**
+   * {@inheritdoc}
+   */
+  public function init() {
+    parent::init();
+    $response = Yii::$app->getResponse();
+    $headers = $response->getHeaders();
+    
+    $headers->set('Access-Control-Allow-Methods', 'POST, GET, DELETE, PUT, OPTIONS');
+    $headers->set('Access-Control-Allow-Headers', 'Content-Type,Accept,Authorization');
+    $headers->set('Access-Control-Allow-Origin', '*');
+    $headers->set('Access-Control-Request-Method', 'POST, GET, DELETE, PUT, OPTIONS');
+    $headers->set('Access-Control-Allow-Credentials', 'true');
+    $headers->set('Access-Control-Max-Age', 86400);
+    if (Yii::$app->getRequest()->isOptions) {
+      Yii::$app->end();
+    } // */
+    Yii::$app->getUser()->enableSession = false;
+    Yii::$app->getUser()->identityClass = 'v1\models\Usuario';
+  }
+
+}

+ 150 - 0
modules/excel/controllers/HerramientaInventarioController.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace app\modules\excel\controllers;
+
+use v1\models\HerramientaInventario;
+use v1\models\Usuario;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Herramienta;
+use Yii;
+use yii\web\Controller;
+
+class HerramientaInventarioController extends Controller {
+
+  public function actionExcelHerramientaInventario() {
+    $request = Yii::$app->request;
+    $inicio = $request->get('inicio');
+    $fin = $request->get('fin');
+    $idHerramienta = $request->get('idHerramienta');
+
+    $inicioDate = $inicio ? DateTime::createFromFormat('Y-m-d', $inicio)->format('Y-m-d 00:00:00') : null;
+    $finDate = $fin ? DateTime::createFromFormat('Y-m-d', $fin)->format('Y-m-d 23:59:59') : null;
+
+
+    $query = HerramientaInventario::find()->where(['eliminado' => null]);
+    if ($inicioDate) {
+      $query->andWhere(['>=', 'creado', $inicioDate]);
+    }
+    if ($finDate) {
+      $query->andWhere(['<=', 'creado', $finDate]);
+    }
+
+    if ($idHerramienta) {
+      $query->andWhere(['idHerramienta' => $idHerramienta]);
+    }
+
+    $query->orderBy(['creado' => SORT_DESC]);
+
+
+    $spreadsheet = new Spreadsheet();
+    $sheet = $spreadsheet->getActiveSheet();
+    $sheet->setTitle('Inventario de Herramientas');
+
+    $BASEPATH = \Yii::getAlias('@app') . "/web";
+    $logo = $BASEPATH . '/img/edesarrollos-unicolor-azul.png';
+
+    $drawing = new Drawing();
+    $drawing->setName('Logotipo');
+    $drawing->setDescription('Logotipo de la empresa');
+    $drawing->setPath($logo);
+    $drawing->setHeight(70);
+    $drawing->setCoordinates('A1');
+    $drawing->setOffsetX(10);
+    $drawing->setOffsetY(10);
+    $drawing->setWorksheet($sheet);
+
+    $sheet->mergeCells('A5:J5');
+    $sheet->setCellValue('A5', 'Inventario de Herramientas');
+    $sheet->getStyle('A5')->getFont()->setBold(true);
+    $sheet->getStyle('A5')->getFont()->setSize(16);
+    $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+
+    $sheet->setCellValue('A6', 'Nombre');
+    $sheet->setCellValue('B6', 'Tipo');
+    $sheet->setCellValue('C6', 'Costo');
+    $sheet->setCellValue('D6', 'Serie');
+    $sheet->setCellValue('E6', 'Fecha de Compra');
+    $sheet->setCellValue('F6', 'Hora de Compra');
+    $sheet->setCellValue('G6', 'Estatus');
+    $sheet->setCellValue('H6', 'Descripción');
+    $sheet->setCellValue('I6', 'Cantidad');
+    $sheet->setCellValue('J6', 'Fecha de Ingreso');
+    $sheet->setCellValue('K6', 'Hora de Ingreso');
+
+    $headerStyle = [
+      'font' => ['bold' => true],
+      'alignment' => [
+        'horizontal' => Alignment::HORIZONTAL_CENTER,
+        'vertical' => Alignment::VERTICAL_CENTER,
+        'wrapText' => true
+      ],
+      'fill' => [
+        'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+        'startColor' => ['argb' => 'FFA0A0A0']
+      ]
+    ];
+    $sheet->getStyle('A6:K6')->applyFromArray($headerStyle);
+
+    $herramientas = Herramienta::find()
+      ->select(['nombre', 'id'])
+      ->indexBy('id')
+      ->column();
+
+      $row = 7;
+      foreach ($query->each() as $inventario) {
+          $herramientaInfo = 'N/A';
+          if (isset($herramientas[$inventario->idHerramienta])) {
+              $herramientaInfo = $herramientas[$inventario->idHerramienta];
+          }
+      
+          $fechaCompra = (new DateTime($inventario->herramienta->fechaCompra, new DateTimeZone('UTC')))
+              ->setTimezone(new DateTimeZone('America/Hermosillo'))
+              ->format('d/m/Y');
+          $horaCompra = (new DateTime($inventario->herramienta->fechaCompra, new DateTimeZone('UTC')))
+              ->setTimezone(new DateTimeZone('America/Hermosillo'))
+              ->format('H:i:s');
+
+         $fechaIngreso = (new DateTime($inventario->fechaIngreso, new DateTimeZone('UTC')))
+              ->setTimezone(new DateTimeZone('America/Hermosillo'))
+              ->format('d/m/Y');
+          $horaIngreso = (new DateTime($inventario->fechaIngreso, new DateTimeZone('UTC')))
+              ->setTimezone(new DateTimeZone('America/Hermosillo'))
+              ->format('H:i:s');
+      
+          $sheet->setCellValue('A' . $row, $inventario->herramienta->nombre);
+          $sheet->setCellValue('B' . $row, $inventario->herramienta->tipoHerramienta->tipo);
+          $sheet->setCellValue('C' . $row, $inventario->herramienta->costo);
+          $sheet->getStyle('C' . $row)->getNumberFormat()->setFormatCode('$#,##0.00');
+          $sheet->setCellValue('D' . $row, $inventario->herramienta->serie);
+          $sheet->setCellValue('E' . $row, $fechaCompra);
+          $sheet->setCellValue('F' . $row, $horaCompra);
+          $sheet->setCellValue('G' . $row, $inventario->herramienta->estatus);
+          $sheet->setCellValue('H' . $row, $inventario->herramienta->descripcion);
+          $sheet->setCellValue('I' . $row, $inventario->cantidad);
+          $sheet->setCellValue('J' . $row, $fechaIngreso);
+          $sheet->setCellValue('K' . $row, $horaIngreso);
+      
+          $row++;
+      }
+
+    foreach (range('A', 'K') as $columnID) {
+      $sheet->getColumnDimension($columnID)->setWidth(20);
+    }
+
+    $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+    try {
+      ob_start();
+      $writer->save("php://output");
+      $documento = ob_get_contents();
+      ob_clean();
+      Yii::$app->getResponse()->sendContentAsFile($documento, "Inventario_Herramientas.xlsx");
+    } catch (\Exception $exception) {
+      return null;
+    }
+  }
+}

+ 523 - 0
modules/excel/web/Controller.php

@@ -0,0 +1,523 @@
+<?php
+
+namespace excel\web;
+
+use common\rest\JsonController;
+use yii\web\Controller as WebController;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\Border;
+use PhpOffice\PhpSpreadsheet\Style\Fill;
+use yii\filters\auth\CompositeAuth;
+use yii\filters\auth\QueryParamAuth;
+use yii\web\Response;
+use Yii;
+
+class Controller extends WebController {
+
+  public $app = null;
+  public $req = null;
+  public $res = null;
+
+  const MIMETYPE_EXCEL = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+
+  const TIPO_EXCEL = "excel";
+  const TIPO_PDF = "pdf";
+
+  const COLOR_NEGRO = "FF000000";
+  const COLOR_AZUL = "FF1A95E8";
+  const COLOR_GRIS = "FF959595";
+
+  public $renglonActual = 1;
+  public $renglonPrevio = 0;
+  protected $spreadsheet;
+  protected $activeSheet;
+
+  public static $estiloCeldaNormal = [
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_LEFT,
+    ],
+  ];
+
+  public static $estiloCeldaCentrada = [
+    'font' => [
+      'bold' => true,
+      'size' => 16,
+      'color' => ['argb' => 'FF000000'],
+    ],
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+      'vertical' => Alignment::VERTICAL_CENTER,
+    ],
+  ];
+
+  public static $estiloCeldaIzquierda = [
+    'font' => [
+      'bold' => true,
+      'size' => 16,
+      'color' => ['argb' => 'FF000000'],
+    ],
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_LEFT,
+      'vertical' => Alignment::VERTICAL_CENTER,
+    ],
+  ];
+
+  public static $bordes = [
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF000000'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF000000'],
+      ],
+      'top' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF000000'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF000000'],
+      ]
+    ],
+  ];
+
+  public static $bordesPrimario = [
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF750d44'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF750d44'],
+      ],
+      'top' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF750d44'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FF750d44'],
+      ]
+    ],
+  ];
+
+  public static $bordesWhite = [
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'top' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ]
+    ],
+  ];
+
+  public static $bordesGray = [
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFE2E2E2'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFE2E2E2'],
+      ],
+      'top' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFE2E2E2'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_THIN,
+        'color' => ['argb' => 'FFE2E2E2'],
+      ]
+    ],
+  ];
+
+  public static $estiloEncabezado = [
+    'font' => [
+      'bold' => true,
+      'size' => 9
+    ],
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+      'vertical' => Alignment::VERTICAL_CENTER,
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => self::COLOR_GRIS]
+    ],
+    'font' => [
+      'bold'  => true,
+      'color' => ['argb' => "AAFFFFFF"],
+    ],
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ]
+    ],
+  ];
+
+  public static $estiloTitulo = [
+    'font' => [
+      'bold' => true,
+      'size' => 13,
+      'color' => ['argb' => self::COLOR_AZUL],
+    ],
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+      'vertical' => Alignment::VERTICAL_CENTER,
+    ],
+  ];
+
+  public static $CELDA_VERDE = [
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FFD8E4BD']
+    ],
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_DASHED,
+      ],
+    ],
+  ];
+
+  public static $CELDA_AMARILLA = [
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FFFFE597']
+    ],
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_DASHED,
+      ],
+    ],
+  ];
+
+  public static $CELDA_ROJA = [
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FFE6B8B7']
+    ],
+    'borders' => [
+      'left' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'right' => [
+        'borderStyle' => Border::BORDER_THICK,
+        'color' => ['argb' => 'FFFFFFFF'],
+      ],
+      'bottom' => [
+        'borderStyle' => Border::BORDER_DASHED,
+      ],
+    ],
+  ];
+
+  public static $CELDA_PRIMARIA = [
+    'font' => [
+      'bold' => true,
+      'size' => 16,
+      'color' => ['argb' => 'FFFFFFFF'],
+    ],
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FF660034']
+    ],
+  ];
+
+  public static $CELDA_SECUNDARIA = [
+    'font' => [
+      'bold' => true,
+      'size' => 16,
+      'color' => ['argb' => 'FFFFFFFF'],
+    ],
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_CENTER,
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FF990033']
+    ],
+  ];
+
+  public static $TITULO_01 = [
+    'font' => [
+      'bold' => true,
+      'size' => 14,
+      'color' => ['argb' => 'FFFFFFFF'],
+    ],
+  ];
+
+  public static $TITULO_02 = [
+    'font' => [
+      'bold' => true,
+      'size' => 14,
+      'color' => ['argb' => 'FF000000'],
+    ],
+  ];
+
+  public static $DESCR_01 = [
+    'alignment' => [
+      'horizontal' => Alignment::HORIZONTAL_LEFT,
+    ],
+    'font' => [
+      'bold' => false,
+      'size' => 12,
+      'color' => ['argb' => 'FF000000'],
+    ],
+  ];
+
+  public static $CELDA_GRIS_01 = [
+    'font' => [
+      'bold' => true,
+      'size' => 14,
+      'color' => ['argb' => 'FFFFFFFF'],
+    ],
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FF808080']
+    ],
+  ];
+
+  public static $CELDA_GRIS_02 = [
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FFA6A6A6']
+    ],
+  ];
+
+  public static $CELDA_GRIS_03 = [
+    'fill' => [
+      'fillType' => Fill::FILL_SOLID,
+      'startColor' => ['argb' => 'FFD9D9D9']
+    ],
+  ];
+
+  /* public function behaviors() {
+    $behavior = parent::behaviors();
+    $behavior["authenticator"] = [
+      "class" => CompositeAuth::className(),
+      "authMethods" => [
+        QueryParamAuth::className(),
+      ]
+    ];
+    return $behavior;
+  } */
+
+  public function beforeAction($action) {
+
+    parent::beforeAction($action);
+    $this->app = Yii::$app;
+    $this->req = $this->app->getRequest();
+    $this->res = $this->app->getResponse();
+
+    $this->spreadsheet = new Spreadsheet();
+    $this->activeSheet = $this->spreadsheet->getActiveSheet();
+    return true;
+  }
+
+  public function obtenerHojaDeCalculo() {
+    return $this->spreadsheet;
+  }
+
+  public function nuevaHoja($indice = null, $titulo = null) {
+    $this->activeSheet = $this->spreadsheet->createSheet($indice);
+    if ($titulo !== null) {
+      $this->activeSheet->setTitle($titulo);
+    }
+  }
+
+  public function logo($logo, $coordenada = "I1", $nombre = 'Logo', $descripcion = 'Logo', $x = 27, $y = 8, $heigth = 75) {
+    $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
+    $drawing->setName($nombre);
+    $drawing->setDescription($descripcion);
+    $drawing->setPath($logo);
+    $drawing->setCoordinates($coordenada);
+    $drawing->setOffsetX($x);
+    $drawing->setOffsetY($y);
+    $drawing->setHeight($heigth);
+    $drawing->setWorksheet($this->activeSheet);
+  }
+
+  public function titulo($inicio = 1, $titulo, $columnaInicio = "A", $columnaFinal = "E") {
+    if ($inicio < $this->renglonActual) {
+      $inicio = $this->renglonActual + 1;
+    }
+    $renglones = [
+      "{$columnaInicio}{$inicio}" => [
+        "valor" => "{$titulo}",
+        "combinar" => "{$columnaFinal}{$inicio}",
+        "estilo" => [
+          'alignment' => [
+            'horizontal' => Alignment::HORIZONTAL_CENTER,
+          ],
+          'font' => [
+            'bold'  => true,
+            'color' => ['argb' => self::COLOR_AZUL],
+            // 'size'  => 15,
+            // 'name'  => 'Verdana'
+          ]
+        ]
+      ]
+    ];
+
+    foreach ($renglones as $coordenada => $valor) {
+      $this->agregarCelda($coordenada, $valor);
+    }
+
+    $this->renglonActual = $inicio + 1;
+    return $this;
+  }
+
+  public function agregarRenglones($renglones) {
+    foreach ($renglones as $coordenada => $valor) {
+      $this->agregarCelda($coordenada, $valor);
+    }
+    return $this;
+  }
+
+  public function agregarEncabezado($titulos) {
+    if (count($titulos) <= 0) {
+      return $this;
+    }
+
+    foreach ($titulos as $k => $v) {
+      $this->agregarCelda($k, [
+        "valor" => "$v",
+        "estilo" => self::$estiloEncabezado
+      ]);
+    }
+
+    return $this;
+  }
+
+  public function agregarCelda($coordenada, $valor) {
+    if (isset($valor["valor"])) {
+      $this->activeSheet
+        ->setCellValue($coordenada, $valor["valor"]);
+      if (isset($valor["combinar"])) {
+        $coordenada = "{$coordenada}:{$valor["combinar"]}";
+        $this->activeSheet
+          ->mergeCells($coordenada);
+      }
+    }
+    if (isset($valor["estilo"])) {
+      $this->activeSheet
+        ->getStyle($coordenada)
+        ->applyFromArray($valor["estilo"]);
+    }
+    if (isset($valor["formato"])) {
+      $this->activeSheet
+        ->getStyle($coordenada)
+        ->getNumberFormat()
+        ->setFormatCode($valor["formato"]);
+    }
+    if (isset($valor["wrap"])) {
+      $this->activeSheet
+        ->getStyle($coordenada)
+        ->getAlignment()
+        ->setWrapText($valor["wrap"] || false);
+    }
+  }
+
+  # Después de agregar toda la información elegir el ancho de las columnas
+  public function anchoColumnas($columnas) {
+    foreach ($columnas as $columna => $c) {
+      if (isset($c["auto"]) && $c["auto"]) {
+        $this->activeSheet
+          ->getColumnDimension($columna)
+          ->setAutoSize(true);
+      } elseif (isset($c["ancho"]) && $c["ancho"] > 0) {
+        $this->activeSheet->getColumnDimension($columna)->setWidth($c["ancho"]);
+      }
+    }
+    return $this;
+  }
+
+  # Generar el archivo excel
+  public function generar($filename = null) {
+    $writer = IOFactory::createWriter($this->spreadsheet, 'Xlsx');
+    try {
+      ob_start();
+      $writer->save("php://output");
+      $documento = ob_get_contents();
+      ob_clean();
+      return $documento;
+    } catch (\Exception $exception) {
+      return null;
+    }
+  }
+
+  # Descarga el archivo en formato excel o pdf
+  public function crear($hojaCalculo, $archivo = null, $tipo = self::TIPO_EXCEL) {
+    if (!$tipo) {
+      $tipo = \Yii::$app->getRequest()->get("tipo", "excel");
+    }
+    $tipo_writer = 'Xlsx';
+    $extension = '.xlsx';
+    if ($tipo === self::TIPO_PDF) {
+      $tipo_writer = 'Mpdf';
+      $extension = '.pdf';
+    }
+    $writer = IOFactory::createWriter($hojaCalculo, $tipo_writer);
+    $archivo .= $extension;
+    try {
+      ob_start();
+      $writer->save("php://output");
+      $content = ob_get_contents();
+      ob_clean();
+      \Yii::$app->getResponse()->sendContentAsFile($content, $archivo);
+    } catch (\Exception $e) {
+      echo $e->getMessage();
+    }
+  }
+}

+ 30 - 0
modules/pdf/controllers/HerramientaInventarioController.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace app\modules\pdf\controllers; 
+
+use pdf\web\Controller;
+use v1\models\HerramientaInventario;
+
+
+class HerramientaInventarioController extends Controller {
+  public function actionIndex() {
+    $tipoReporte = $this->req->get('solicitud', '');
+
+  }
+
+  public function actionInventario() {
+    $id = $this->req->get('i', '');
+
+    $modelo = HerramientaInventario::findOne(['id'=>$id]);
+
+    $contenido = $this->renderPartial('/herramienta-inventario/index', [
+      'modelo' => $modelo
+    ]);
+
+    $folio = rand(0, 45);
+
+    $this->nombreArchivo = "Herramienta Inventario $folio";
+
+    $this->exportarPdf($contenido);
+  }
+}

+ 91 - 0
modules/pdf/views/herramienta-inventario/index.php

@@ -0,0 +1,91 @@
+<?php
+
+/**
+ * @var $modelo \v1\models\HerramientaInventario
+ */
+
+use app\models\Herramienta;
+use app\models\HerramientaInventario;
+use app\models\TipoHerramienta;
+use Luecano\NumeroALetras\NumeroALetras;
+use pdf\web\Controller;
+
+setlocale(LC_ALL, 'es_ES');
+$basePath = \Yii::getAlias('@app') . "/web/";
+
+$inventarios = HerramientaInventario::find()->with('herramienta')->all();
+
+?>
+<div class="contentpanel">
+  <table style="width:1200px; border-collapse:collapse; border: 1px solid  #000000; margin-right:auto; margin-left:auto; ">
+    <tr>
+      <td style="width:20% !important; background-color:#000000; text-align:center;">
+        <img src="<?= $basePath ?>/img/edesarrollos-unicolor-blanco.png" style="width:30%">
+      </td>
+    </tr>
+    <tr>
+      <td style="font-size:40px; background-color:#000000; color:#ffffff; text-align:center; height:60px">
+        Inventario de Herramienta
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <table width="100%">
+          <tr>
+            <th rowspan="2" style="width:50%">FECHA</th>
+            <th style="width:50%">DIA/MES/AÑO</th>
+          </tr>
+        </table>
+      </td>
+    </tr>
+  </table>
+  <table border="1" style="border-collapse:collapse; width:1100px; margin-top:20px; text-align: left;">
+    <tr style="background-color:#000000; color:#ffffff">
+      <th style="height:30px; color:#ffffff; width:200px">
+        Nombre Herramienta
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Tipo
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Serie
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Costo
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Descripción
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Estatus
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Cantidad
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Fecha Compra
+      </th>
+      <th style="height:30px; color:#ffffff; width:200px; text-align: left;">
+        Fecha de Ingreso
+      </th>
+    </tr>
+    <?php
+    $totalGeneral = 0;
+      foreach ($inventarios as $inventario) :
+
+    ?>
+      <tr style="height:100px">
+        <td  style="width:20px"><?= $inventario->herramienta->nombre ?></td>
+        <td><?= $inventario->herramienta->tipoHerramienta->tipo ?></td>
+        <td style="height:25px"><?= $inventario->herramienta->serie ?></td>
+        <td style="text-align:left">$<?= number_format($inventario->herramienta->costo, 2, '.', ',') ?></td>
+        <td style="height:25px"><?= $inventario->herramienta->descripcion ?></td>
+        <td style="height:25px"><?= $inventario->herramienta->estatus ?></td>
+        <td style="height:25px"><?= $inventario->cantidad ?></td>
+        <td style="height:25px"><?= $inventario->herramienta->fechaCompra ?></td>
+        <td style="height:25px"><?= $inventario->fechaIngreso ?></td>
+      </tr>
+    <?php endforeach; ?>
+
+  </table>
+</div>

+ 245 - 54
modules/pdf/web/Controller.php

@@ -1,14 +1,19 @@
 <?php
 
-namespace app\modules\pdf\web;
+namespace pdf\web;
 
+use PhpOffice\PhpSpreadsheet\Helper\Html;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\Fill;
 use yii\filters\auth\CompositeAuth;
 use yii\filters\auth\QueryParamAuth;
 use yii\filters\Cors;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use yii\web\Controller as WebController;
 
-class Controller extends \yii\web\Controller {
+class Controller extends WebController {
 
   /**
    * Si es verdadero imprime el contenido en el web
@@ -30,7 +35,7 @@ class Controller extends \yii\web\Controller {
   public $configuracion = [
     "format" => "letter",
     "default_font" => "Roboto",
-  ];  
+  ];
 
   /**
    * Texto para la marca de agua
@@ -149,17 +154,16 @@ class Controller extends \yii\web\Controller {
     \Yii::$app->end();
   }
 
-  public function afterAction($action, $result)
-  {
+  public function afterAction($action, $result) {
     if (!$this->html) {
       $result = str_replace('disabled="disabled"', '', $result);
       return $this->exportarPdf($result);
     }
     $this->marcaDeAgua = intval($this->req->get("wm", 1)) === 1;
-    $watermark = "background-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' ".
-      "height='100px' width='100px'><text transform='translate(20, 100) rotate(-45)' fill='rgb(210,210,210)' ".
+    $watermark = "background-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' " .
+      "height='100px' width='100px'><text transform='translate(20, 100) rotate(-45)' fill='rgb(210,210,210)' " .
       "font-size='18'>{$this->marcaDeAguaTexto}</text></svg>\");";
-    if(!$this->marcaDeAgua) {
+    if (!$this->marcaDeAgua) {
       $watermark = "";
     }
     $fondo = ".fondo-privado { background-color: rgb(141,216,169,0.7) !important; }";
@@ -171,11 +175,19 @@ class Controller extends \yii\web\Controller {
   /**
    * funcion para generar cualquier Excel
    */
-  public static function Excel($titulo = "Reporte", $pestania = "Reporte", $nombre = "Reporte", $etiquetas = [], $campos = [], $datos, $usarApuntador = true, $isArray = false, $respaldo = false) {
+  public static function Excel(
+    $titulo = "Reporte",
+    $pestania = "Reporte",
+    $nombre = "Reporte",
+    $etiquetas = [],
+    $campos = [],
+    $datos,
+    $usarApuntador = true, $isArray = false, $respaldo = false) {
     // Create new Spreadsheet object
     $basePath = \Yii::getAlias("@app");
 
     $spreadsheet = new Spreadsheet();
+
     $spreadsheet->setActiveSheetIndex(0);
     $spreadsheet->getSecurity()->setLockWindows(false);
     $spreadsheet->getSecurity()->setLockStructure(false);
@@ -185,7 +197,9 @@ class Controller extends \yii\web\Controller {
     $spreadsheet->getActiveSheet()->getProtection()->setFormatCells(false);
 
     // Set document properties
-    $spreadsheet->getProperties()->setCreator('pbr')->setLastModifiedBy('pbr')->setTitle($titulo)
+    $spreadsheet->getProperties()->setCreator('eDesarrollos')
+      ->setLastModifiedBy('eDesarrollos')
+      ->setTitle($titulo)
       ->setDescription($titulo);
 
     $spreadsheet->getActiveSheet()->setTitle($pestania);
@@ -198,7 +212,6 @@ class Controller extends \yii\web\Controller {
         'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
       ]
     ];
-    
     $style_titulo_etiquestas = [
       'font' => [
         'bold' => true,
@@ -220,6 +233,184 @@ class Controller extends \yii\web\Controller {
     $spreadsheet->setActiveSheetIndex(0);
     $i = $respaldo ? 1 : 7;
     $ltrs = [];
+    $ltr = 65;
+    $ltr2 = 64;
+
+    foreach ($etiquetas as $v) {
+      if ($ltr2 >= 65) {
+        //if(!in_array(chr($ltr2), ["[","]","\\","^","_","`"]))
+        $letra = chr($ltr2) . chr($ltr);
+      } else {
+        $letra = chr($ltr);
+      }
+      $ltrs[] = $letra;
+      $spreadsheet->getActiveSheet()->setCellValue($letra . $i, $v);
+      if ($ltr >= 90) {
+        $ltr2++;
+        $ltr = 65;
+      } else {
+        $ltr++;
+      }
+    }
+
+    // Add some data
+    $i++; //Es el renglón inicial
+    if ($usarApuntador) {
+      /* @var $datos ActiveQuery */
+      if (!$isArray) {
+        foreach ($datos->each() as $v) {
+          $l = 0;
+          foreach ($campos as $k => $a) {
+            $spreadsheet
+              ->getActiveSheet()
+              ->setCellValue($ltrs[$l] . $i, isset($v[$a]) ? $v[$a] : "")
+              ->getColumnDimension($ltrs[$l])
+              ->setAutoSize(true);
+            $l++;
+          }
+          $i++;
+        }
+      } else {
+        foreach ($datos as $v) {
+          $l = 0;
+          foreach ($campos as $k => $a) {
+            $spreadsheet
+              ->getActiveSheet()
+              ->setCellValue($ltrs[$l] . $i, isset($v[$a]) ? $v[$a] . "-" : "---")
+              ->getColumnDimension($ltrs[$l])
+              ->setAutoSize(true);
+            $l++;
+          }
+          $i++;
+        }
+      }
+
+    } else {
+      foreach ($datos as $v) {
+        $l = 0;
+        foreach ($campos as $k => $a) {
+
+          if (gettype($v[$a]) === 'array') {
+            if (isset($v[$a][1]) && $v[$a][1] === "html") {
+
+              $html = new Html();
+              $spreadsheet
+                ->getActiveSheet()
+                ->setCellValue($ltrs[$l] . $i, isset($v[$a][0]) ? $html->toRichTextObject($v[$a][0]) : "")
+                ->getColumnDimension($ltrs[$l])
+                ->setAutoSize(true);
+            } else {
+              $spreadsheet
+                ->getActiveSheet()
+                ->setCellValue($ltrs[$l] . $i, isset($v[$a][0]) ? $v[$a][0] : "")
+                ->getColumnDimension($ltrs[$l])
+                ->setAutoSize(true);
+
+              $spreadsheet
+                ->getActiveSheet()
+                ->getStyle($ltrs[$l] . $i)
+                ->getNumberFormat()
+                ->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD);
+            }
+          } else {
+            $spreadsheet
+              ->getActiveSheet()
+              ->setCellValue($ltrs[$l] . $i, isset($v[$a]) ? $v[$a] : "")
+              ->getColumnDimension($ltrs[$l])
+              ->setAutoSize(true);
+
+          }
+
+          $l++;
+        }
+        $i++;
+      }
+
+    }
+    // Rename worksheet
+//    $spreadsheet->getStyle('A1:A3')->getNumberFormat()->setFormatCode('#,##0.00');
+    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
+    $spreadsheet->setActiveSheetIndex(0);
+
+    $ultima_letra = array_pop($ltrs);
+
+    if (!$respaldo) {
+      $spreadsheet->getActiveSheet()->mergeCells('A3:' . $ultima_letra . "3");
+      $spreadsheet->getActiveSheet()->getStyle("A3:" . $ultima_letra . "3")->applyFromArray($style_titulo);
+      $spreadsheet->getActiveSheet()->setCellValue('A3', $titulo);
+      //$spreadsheet->getActiveSheet()->setCellValue('A2', '=HIPERVINCULO("http://www.google.com/","Google")');
+
+      $objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
+      $objDrawing->setName('Logo');
+      $objDrawing->setDescription('Logo');
+      $objDrawing->setPath($basePath . '/web/img/logo-salud.png');
+      $objDrawing->setWidth(300);
+      $objDrawing->setCoordinates('A1');
+      $objDrawing->setWorksheet($spreadsheet->getActiveSheet());
+
+      $spreadsheet->getActiveSheet()->getStyle("A7:" . $ultima_letra . "7")->applyFromArray($style_titulo_etiquestas);
+    } else
+      $spreadsheet->getActiveSheet()->getStyle("A1:" . $ultima_letra . "1")->applyFromArray($style_titulo_etiquestas);
+
+    // Redirect output to a client's web browser (Xlsx)
+    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+    header('Content-Disposition: attachment;filename="' . $nombre . '"');
+    header('Cache-Control: max-age=0');
+
+    $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
+    $writer->save('php://output');
+    exit;
+  }
+
+  public static function Excelp($titulo = "Reporte", $pestania = "Reporte", $nombre = "Reporte", $etiquetas = [], $campos = [], $datos, $usarApuntador = true, $isArray = false, $respaldo = false) {
+    // Create new Spreadsheet object
+    $basePath = \Yii::getAlias("@app");
+
+    $spreadsheet = new Spreadsheet();
+    $spreadsheet->setActiveSheetIndex(0);
+    $spreadsheet->getSecurity()->setLockWindows(false);
+    $spreadsheet->getSecurity()->setLockStructure(false);
+    $spreadsheet->getActiveSheet()->getProtection()->setSheet(false);
+    $spreadsheet->getActiveSheet()->getProtection()->setSort(false);
+    $spreadsheet->getActiveSheet()->getProtection()->setInsertRows(false);
+    $spreadsheet->getActiveSheet()->getProtection()->setFormatCells(false);
+
+    // Set document properties
+    $spreadsheet->getProperties()->setCreator('pbr')->setLastModifiedBy('pbr')->setTitle($titulo)
+      ->setDescription($titulo);
+
+    $spreadsheet->getActiveSheet()->setTitle($pestania);
+    $style_titulo = [
+      'font' => [
+        'bold' => true,
+        'size' => 13,
+      ],
+      'alignment' => [
+        'horizontal' => Alignment::HORIZONTAL_CENTER,
+      ]
+    ];
+
+    $style_titulo_etiquestas = [
+      'font' => [
+        'bold' => true,
+        'size' => 11,
+        'color' => ['rgb' => '000000'],
+        'background' => ['rgb' => '4c5966'],
+      ],
+      'alignment' => [
+        'horizontal' => Alignment::HORIZONTAL_CENTER_CONTINUOUS,
+      ],
+      'fill' => [
+        'type' => Fill::FILL_GRADIENT_LINEAR,
+        'rotation' => 90,
+        'startcolor' => ['argb' => '000000',],
+        'endcolor' => ['argb' => '000000',],
+      ],
+    ];
+
+    $spreadsheet->setActiveSheetIndex(0);
+    $i = $respaldo ? 1 : 7;
+    $ltrs = [];
     $ltr2 = 65;
     $ltr = 65;
     foreach ($etiquetas as $v) {
@@ -317,9 +508,8 @@ class Controller extends \yii\web\Controller {
 
       //$spreadsheet->getActiveSheet()->getStyle("A7:" . $ultima_letra . "7")->applyFromArray($style_titulo_etiquestas);
     }
-      
 
-    
+
     // Redirect output to a client's web browser (Xlsx)
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="' . $nombre . '"');
@@ -330,7 +520,7 @@ class Controller extends \yii\web\Controller {
     exit;
   }
 
-  public  function excelMir($datos = []) {
+  public function excelMir($datos = []) {
     // Create new Spreadsheet object
     $nombre = "excels.xlsx";
     $titulo = "Matriz de Indicadores para Resultados (2022)";
@@ -374,8 +564,8 @@ class Controller extends \yii\web\Controller {
     $spreadsheet->getActiveSheet()->getStyle('F4:K4')->applyFromArray($style_titulo);
     $spreadsheet->getActiveSheet()->setCellValue('F4', $titulo);
     $losbenificiarios = "";
-    if(count($datos["benificiarios"])>0){
-      foreach($datos["benificiarios"] as $ben){
+    if (count($datos["benificiarios"]) > 0) {
+      foreach ($datos["benificiarios"] as $ben) {
         $losbenificiarios .= "{$ben->beneficiario->nombre}, ";
       }
     }
@@ -392,7 +582,7 @@ class Controller extends \yii\web\Controller {
     $spreadsheet->getActiveSheet()->mergeCells('B14:B15');
     $spreadsheet->getActiveSheet()->setCellValue("C14", "Indicadores");
     $spreadsheet->getActiveSheet()->mergeCells('C14:E14');
-    
+
     $spreadsheet->getActiveSheet()->setCellValue("F14", "Programación");
     $spreadsheet->getActiveSheet()->mergeCells('F14:J14');
     $spreadsheet->getActiveSheet()->setCellValue("K14", "Meta % de Anua");
@@ -421,15 +611,15 @@ class Controller extends \yii\web\Controller {
     $spreadsheet->getActiveSheet()->setCellValue("I15", "IV");
     $spreadsheet->getActiveSheet()->setCellValue("J15", "Avance\nAcumulado");
 
-    $objDrawing = $this->cargarImagen($spreadsheet,'/web/img/logo-salud.png',300,"A1");
-    $objDrawing = $this->cargarImagen($spreadsheet,'/web/img/sa.png',150,"Q5");
+    $objDrawing = $this->cargarImagen($spreadsheet, '/web/img/logo-salud.png', 300, "A1");
+    $objDrawing = $this->cargarImagen($spreadsheet, '/web/img/sa.png', 150, "Q5");
     $spreadsheet->getActiveSheet()->setCellValue('R3', " ");
 
     $i = 16;
-    if($datos["mir"] != null){
+    if ($datos["mir"] != null) {
       $nuevoNiveles = [];
-      foreach($datos["niveles"] as $nivel) {
-        if(!isset($nuevoNiveles[$nivel->nivel])) {
+      foreach ($datos["niveles"] as $nivel) {
+        if (!isset($nuevoNiveles[$nivel->nivel])) {
           $nuevoNiveles[$nivel->nivel] = [];
         }
         $nuevoNiveles[$nivel->nivel][] = $nivel;
@@ -442,37 +632,37 @@ class Controller extends \yii\web\Controller {
         "ACTIVIDAD"
       ];
 
-      foreach($ordenNivel as $k=>$v){
+      foreach ($ordenNivel as $k => $v) {
         $inicio = $i;
-        $spreadsheet->getActiveSheet()->setCellValue("A".$i, $v);
+        $spreadsheet->getActiveSheet()->setCellValue("A" . $i, $v);
         $fin = 0;
-        foreach($nuevoNiveles[$v] as $nivel){
-          $spreadsheet->getActiveSheet()->setCellValue("B".$i, $nivel->resumen);
-          foreach($nivel->matrizMIRIndicadores as $indicador){
-            $spreadsheet->getActiveSheet()->setCellValue("C".$i, $indicador->nombre);
-            $spreadsheet->getActiveSheet()->setCellValue("D".$i, $indicador->unidadMedida->nombre);
-            $spreadsheet->getActiveSheet()->setCellValue("E".$i, $indicador->numerador);
-            $spreadsheet->getActiveSheet()->setCellValue("E".($i+1), $indicador->denominador);
-            $spreadsheet->getActiveSheet()->setCellValue("F".$i, $indicador->numeradorT1);
-            $spreadsheet->getActiveSheet()->setCellValue("G".$i, $indicador->numeradorT2);
-            $spreadsheet->getActiveSheet()->setCellValue("H".$i, $indicador->numeradorT3);
-            $spreadsheet->getActiveSheet()->setCellValue("I".$i, $indicador->numeradorT4);
-
-            $spreadsheet->getActiveSheet()->setCellValue("F".($i+1), $indicador->denominadorT1);
-            $spreadsheet->getActiveSheet()->setCellValue("G".($i+1), $indicador->denominadorT2);
-            $spreadsheet->getActiveSheet()->setCellValue("H".($i+1), $indicador->denominadorT3);
-            $spreadsheet->getActiveSheet()->setCellValue("I".($i+1), $indicador->denominadorT4);
-
-            $spreadsheet->getActiveSheet()->setCellValue("J".$i, $indicador->avanceAcumulado);
-            $spreadsheet->getActiveSheet()->setCellValue("K".$i, $indicador->metaAnual);
-            $spreadsheet->getActiveSheet()->setCellValue("L".$i, $indicador->porcentajeAvance);
-            $spreadsheet->getActiveSheet()->setCellValue("M".$i, $indicador->lineaBase);
-            $spreadsheet->getActiveSheet()->setCellValue("N".$i, $indicador->sentido->valor);
-            $spreadsheet->getActiveSheet()->setCellValue("O".$i, $indicador->frecuencia->nombre);
-            $spreadsheet->getActiveSheet()->setCellValue("P".$i, $indicador->metodoVerificacion);
-            $spreadsheet->getActiveSheet()->setCellValue("Q".$i, $indicador->supuestos);
-            $spreadsheet->getActiveSheet()->setCellValue("R".$i, " ");
-            $i+=2;
+        foreach ($nuevoNiveles[$v] as $nivel) {
+          $spreadsheet->getActiveSheet()->setCellValue("B" . $i, $nivel->resumen);
+          foreach ($nivel->matrizMIRIndicadores as $indicador) {
+            $spreadsheet->getActiveSheet()->setCellValue("C" . $i, $indicador->nombre);
+            $spreadsheet->getActiveSheet()->setCellValue("D" . $i, $indicador->unidadMedida->nombre);
+            $spreadsheet->getActiveSheet()->setCellValue("E" . $i, $indicador->numerador);
+            $spreadsheet->getActiveSheet()->setCellValue("E" . ($i + 1), $indicador->denominador);
+            $spreadsheet->getActiveSheet()->setCellValue("F" . $i, $indicador->numeradorT1);
+            $spreadsheet->getActiveSheet()->setCellValue("G" . $i, $indicador->numeradorT2);
+            $spreadsheet->getActiveSheet()->setCellValue("H" . $i, $indicador->numeradorT3);
+            $spreadsheet->getActiveSheet()->setCellValue("I" . $i, $indicador->numeradorT4);
+
+            $spreadsheet->getActiveSheet()->setCellValue("F" . ($i + 1), $indicador->denominadorT1);
+            $spreadsheet->getActiveSheet()->setCellValue("G" . ($i + 1), $indicador->denominadorT2);
+            $spreadsheet->getActiveSheet()->setCellValue("H" . ($i + 1), $indicador->denominadorT3);
+            $spreadsheet->getActiveSheet()->setCellValue("I" . ($i + 1), $indicador->denominadorT4);
+
+            $spreadsheet->getActiveSheet()->setCellValue("J" . $i, $indicador->avanceAcumulado);
+            $spreadsheet->getActiveSheet()->setCellValue("K" . $i, $indicador->metaAnual);
+            $spreadsheet->getActiveSheet()->setCellValue("L" . $i, $indicador->porcentajeAvance);
+            $spreadsheet->getActiveSheet()->setCellValue("M" . $i, $indicador->lineaBase);
+            $spreadsheet->getActiveSheet()->setCellValue("N" . $i, $indicador->sentido->valor);
+            $spreadsheet->getActiveSheet()->setCellValue("O" . $i, $indicador->frecuencia->nombre);
+            $spreadsheet->getActiveSheet()->setCellValue("P" . $i, $indicador->metodoVerificacion);
+            $spreadsheet->getActiveSheet()->setCellValue("Q" . $i, $indicador->supuestos);
+            $spreadsheet->getActiveSheet()->setCellValue("R" . $i, " ");
+            $i += 2;
           }
           //$spreadsheet->getActiveSheet()->mergeCells("B{$inicio}:B{$f}");
         }
@@ -489,7 +679,7 @@ class Controller extends \yii\web\Controller {
     exit;
   }
 
-  function cargarImagen($spreadsheet, $imagen = "/web/img/logo-salud.png", $width = 300, $ubicacion = "A1"){
+  function cargarImagen($spreadsheet, $imagen = "/web/img/logo-salud.png", $width = 300, $ubicacion = "A1") {
     $basePath = \Yii::getAlias("@app");
     $objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
     $objDrawing->setName('Logo');
@@ -499,4 +689,5 @@ class Controller extends \yii\web\Controller {
     $objDrawing->setCoordinates($ubicacion);
     $objDrawing->setWorksheet($spreadsheet->getActiveSheet());
   }
+
 }

BIN
web/img/edesarrollos-unicolor-azul.png