|
@@ -1,257 +1,624 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
namespace app\modules\excel\controllers;
|
|
namespace app\modules\excel\controllers;
|
|
|
|
+
|
|
use v1\models\ObraEmpleado;
|
|
use v1\models\ObraEmpleado;
|
|
use v1\models\Usuario;
|
|
use v1\models\Usuario;
|
|
use DateTime;
|
|
use DateTime;
|
|
use DateTimeZone;
|
|
use DateTimeZone;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
|
|
+use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|
-use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
|
|
|
use v1\models\Obra;
|
|
use v1\models\Obra;
|
|
use v1\models\ObraHerramienta;
|
|
use v1\models\ObraHerramienta;
|
|
use Yii;
|
|
use Yii;
|
|
-use yii\web\Controller;
|
|
|
|
|
|
+use excel\web\Controller;
|
|
|
|
+use v1\models\Gasto;
|
|
|
|
+use v1\models\Nomina;
|
|
|
|
+use v1\models\ObraRubro;
|
|
|
|
+use v1\models\Pago;
|
|
|
|
+use yii\web\Response;
|
|
|
|
|
|
class ObraController extends Controller
|
|
class ObraController extends Controller
|
|
{
|
|
{
|
|
|
|
+ public static $estiloCeldaIzquierda12 = [
|
|
|
|
+ 'font' => [
|
|
|
|
+ 'bold' => true,
|
|
|
|
+ 'size' => 12,
|
|
|
|
+ 'color' => ['argb' => 'FF000000'],
|
|
|
|
+ ],
|
|
|
|
+ 'alignment' => [
|
|
|
|
+ 'horizontal' => Alignment::HORIZONTAL_LEFT,
|
|
|
|
+ 'vertical' => Alignment::VERTICAL_CENTER,
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public static $celdaVertical = [
|
|
|
|
+ 'font' => [
|
|
|
|
+ 'bold' => true,
|
|
|
|
+ 'size' => 14,
|
|
|
|
+ 'color' => ['argb' => 'FFFFFFFF'],
|
|
|
|
+ ],
|
|
|
|
+ 'alignment' => [
|
|
|
|
+ // 'textRotation' => 90,
|
|
|
|
+ 'horizontal' => Alignment::HORIZONTAL_CENTER,
|
|
|
|
+ 'vertical' => Alignment::VERTICAL_CENTER
|
|
|
|
+ ],
|
|
|
|
+ 'fill' => [
|
|
|
|
+ 'fillType' => Fill::FILL_SOLID,
|
|
|
|
+ 'startColor' => ['argb' => "FF625FF5"]
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public static $celdaHorizontal = [
|
|
|
|
+ 'font' => [
|
|
|
|
+ 'bold' => true,
|
|
|
|
+ 'size' => 14,
|
|
|
|
+ 'color' => ['argb' => 'FF000000'],
|
|
|
|
+ ],
|
|
|
|
+ 'alignment' => [
|
|
|
|
+ 'horizontal' => Alignment::HORIZONTAL_CENTER,
|
|
|
|
+ 'vertical' => Alignment::VERTICAL_CENTER
|
|
|
|
+ ],
|
|
|
|
+ 'fill' => [
|
|
|
|
+ 'fillType' => Fill::FILL_SOLID,
|
|
|
|
+ 'startColor' => ['argb' => "FFE7E7E7"]
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public static $celdaFuente12 = [
|
|
|
|
+ 'font' => [
|
|
|
|
+ 'bold' => true,
|
|
|
|
+ 'size' => 10,
|
|
|
|
+ 'color' => ['argb' => 'FF000000'],
|
|
|
|
+ ],
|
|
|
|
+ 'alignment' => [
|
|
|
|
+ 'horizontal' => Alignment::HORIZONTAL_LEFT,
|
|
|
|
+ 'vertical' => Alignment::VERTICAL_CENTER
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ public static $celdaVerticalF12 = [
|
|
|
|
+ 'font' => [
|
|
|
|
+ 'bold' => true,
|
|
|
|
+ 'size' => 10,
|
|
|
|
+ 'color' => ['argb' => 'FF000000'],
|
|
|
|
+ ],
|
|
|
|
+ 'alignment' => [
|
|
|
|
+ 'textRotation' => 90,
|
|
|
|
+ 'horizontal' => Alignment::HORIZONTAL_CENTER,
|
|
|
|
+ 'vertical' => Alignment::VERTICAL_CENTER
|
|
|
|
+ ],
|
|
|
|
+ 'fill' => [
|
|
|
|
+ 'fillType' => Fill::FILL_SOLID,
|
|
|
|
+ 'startColor' => ['argb' => "FFE7E7E7"]
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ public function encabezadoHoja($logo)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ $celdas = [
|
|
|
|
+ "A1" => [
|
|
|
|
+ "valor" => $logo,
|
|
|
|
+ "combinar" => "G4",
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ foreach ($celdas as $coordenada => $valor) {
|
|
|
|
+ $this->agregarCelda($coordenada, $valor);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->renglonActual = 6;
|
|
|
|
+
|
|
|
|
+ return $this;
|
|
|
|
+ }
|
|
|
|
|
|
public function actionExcelObra($idObra)
|
|
public function actionExcelObra($idObra)
|
|
{
|
|
{
|
|
|
|
+ $json = intval($this->req->get("json", ""));
|
|
$obra = Obra::findOne($idObra);
|
|
$obra = Obra::findOne($idObra);
|
|
$request = Yii::$app->request;
|
|
$request = Yii::$app->request;
|
|
-
|
|
|
|
- $spreadsheet = new Spreadsheet();
|
|
|
|
- $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
- $sheet->setTitle('Informacion General');
|
|
|
|
-
|
|
|
|
|
|
+ if ($json) {
|
|
|
|
+ \Yii::$app->getResponse()->format = Response::FORMAT_JSON;
|
|
|
|
+ return $json;
|
|
|
|
+ }
|
|
$BASEPATH = \Yii::getAlias('@app') . "/web";
|
|
$BASEPATH = \Yii::getAlias('@app') . "/web";
|
|
$logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
|
|
$logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
|
|
$fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
|
|
$fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
|
|
$fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
|
|
$fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
|
|
- $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:N5');
|
|
|
|
- $sheet->setCellValue('A5', 'Obra: ' . $obra->nombre);
|
|
|
|
- $sheet->mergeCells('A6:G6');
|
|
|
|
- $sheet->setCellValue('A6', 'Fecha Inicial: ' . $fechaInicio);
|
|
|
|
- $sheet->mergeCells('H6:N6');
|
|
|
|
- $sheet->setCellValue('H6', 'Fecha Final: ' . $fechaFin);
|
|
|
|
- $sheet->getStyle('A5')->getFont()->setBold(true);
|
|
|
|
- $sheet->getStyle('A5')->getFont()->setSize(16);
|
|
|
|
-
|
|
|
|
- $headerStyle = [
|
|
|
|
- 'font' => [
|
|
|
|
- 'bold' => true,
|
|
|
|
- 'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
|
|
|
|
- ],
|
|
|
|
- 'alignment' => [
|
|
|
|
- 'horizontal' => Alignment::HORIZONTAL_CENTER,
|
|
|
|
- 'vertical' => Alignment::VERTICAL_CENTER,
|
|
|
|
- 'wrapText' => true
|
|
|
|
- ],
|
|
|
|
- 'fill' => [
|
|
|
|
- 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
|
|
|
- 'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
|
|
|
|
- ],
|
|
|
|
- 'borders' => [
|
|
|
|
- 'allBorders' => [
|
|
|
|
- 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
|
|
|
- 'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
|
|
|
|
- ],
|
|
|
|
|
|
+ $this->encabezadoHoja($this->logo($logo, 'A1'));
|
|
|
|
+ $estiloEncabezado = array_merge(self::$celdaVertical, self::$bordes);
|
|
|
|
+ $encabezadoTabla = [
|
|
|
|
+ "A6" => [
|
|
|
|
+ "valor" => "Obra: $obra->nombre",
|
|
|
|
+ "combinar" => "D6",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "A7" => [
|
|
|
|
+ "valor" => "Fecha Inicial: $fechaInicio ",
|
|
|
|
+ "combinar" => "B7",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
],
|
|
],
|
|
|
|
+ "C7" => [
|
|
|
|
+ "valor" => "Fecha Final: $fechaFin",
|
|
|
|
+ "combinar" => "D7",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ]
|
|
];
|
|
];
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // Aplicar el borde a las celdas combinadas
|
|
|
|
- $sheet->getStyle('A5:N5')->applyFromArray($headerStyle);
|
|
|
|
- $sheet->getStyle('A6:G6')->applyFromArray($headerStyle);
|
|
|
|
- $sheet->getStyle('H6:N6')->applyFromArray($headerStyle);
|
|
|
|
-
|
|
|
|
- //Empleados
|
|
|
|
|
|
+ $this->agregarRenglones($encabezadoTabla);
|
|
$empleados = ObraEmpleado::find()
|
|
$empleados = ObraEmpleado::find()
|
|
->joinWith('empleado')
|
|
->joinWith('empleado')
|
|
->andWhere(['{{ObraEmpleado}}.[[eliminado]]' => null])->andWhere(['{{ObraEmpleado}}.[[idObra]]' => $idObra]);
|
|
->andWhere(['{{ObraEmpleado}}.[[eliminado]]' => null])->andWhere(['{{ObraEmpleado}}.[[idObra]]' => $idObra]);
|
|
$empleados->orderBy(['creado' => SORT_DESC]);
|
|
$empleados->orderBy(['creado' => SORT_DESC]);
|
|
|
|
|
|
- $sheet->mergeCells('A8:G8');
|
|
|
|
- $sheet->setCellValue('A8', 'Empleados');
|
|
|
|
- $sheet->getStyle('A8:G8')->applyFromArray($headerStyle);
|
|
|
|
- $sheet->mergeCells('A9:D9');
|
|
|
|
- $sheet->setCellValue('A9', 'Nombre');
|
|
|
|
- $sheet->getStyle('A9:D9')->applyFromArray($headerStyle);
|
|
|
|
- $sheet->mergeCells('E9:G9');
|
|
|
|
- $sheet->setCellValue('E9', 'Fecha Alta');
|
|
|
|
- $sheet->getStyle('E9:G9')->applyFromArray($headerStyle);
|
|
|
|
- $cellBorderStyle = [
|
|
|
|
- 'borders' => [
|
|
|
|
- 'allBorders' => [
|
|
|
|
- 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
|
|
|
- 'color' => ['argb' => 'FF000000'], // Color negro
|
|
|
|
- ],
|
|
|
|
|
|
+ $encabezadoTabla = [
|
|
|
|
+ "A9" => [
|
|
|
|
+ "valor" => "Empleados",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+ "combinar" => "B9",
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "A10" => [
|
|
|
|
+ "valor" => "Nombre",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "B10" => [
|
|
|
|
+ "valor" => "Fecha Alta",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
],
|
|
],
|
|
|
|
+ "C9" => [
|
|
|
|
+ "valor" => "Empleados",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+ "combinar" => "D9",
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "C10" => [
|
|
|
|
+ "valor" => "Nombre",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "D10" => [
|
|
|
|
+ "valor" => "Fecha Alta",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+
|
|
];
|
|
];
|
|
- $rowEmpleados = 10;
|
|
|
|
|
|
+
|
|
|
|
+ $rEmpleado = 11;
|
|
|
|
+ $this->agregarRenglones($encabezadoTabla);
|
|
|
|
+ $estiloCeldaIzquierda = array_merge(self::$bordes, self::$celdaFuente12);
|
|
|
|
+ $estiloCondicional = $this->estiloCondicional();
|
|
|
|
|
|
foreach ($empleados->each() as $obraEmpleado) {
|
|
foreach ($empleados->each() as $obraEmpleado) {
|
|
$empleado = $obraEmpleado->empleado;
|
|
$empleado = $obraEmpleado->empleado;
|
|
$fecha = (new DateTime($empleado->fechaAlta))->format('d-m-Y');
|
|
$fecha = (new DateTime($empleado->fechaAlta))->format('d-m-Y');
|
|
|
|
+ $renglones = [
|
|
|
|
+ "A{$rEmpleado}" => [
|
|
|
|
+ "valor" => $empleado->nombre,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
|
|
- $sheet->mergeCells('A' . $rowEmpleados . ':D' . $rowEmpleados);
|
|
|
|
- $sheet->setCellValue('A' . $rowEmpleados, $empleado->nombre);
|
|
|
|
- $sheet->getStyle('A' . $rowEmpleados . ':D' . $rowEmpleados)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
|
|
|
|
- $sheet->getStyle('A' . $rowEmpleados . ':D' . $rowEmpleados)->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
|
|
+ ],
|
|
|
|
+ "B{$rEmpleado}" => [
|
|
|
|
+ "valor" => $fecha,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
|
|
- $sheet->mergeCells('E' . $rowEmpleados . ':G' . $rowEmpleados);
|
|
|
|
- $sheet->setCellValue('E' . $rowEmpleados, $fecha);
|
|
|
|
- $sheet->getStyle('E' . $rowEmpleados . ':G' . $rowEmpleados)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
|
|
|
|
- $sheet->getStyle('E' . $rowEmpleados . ':G' . $rowEmpleados)->applyFromArray($cellBorderStyle);
|
|
|
|
- $rowEmpleados++;
|
|
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+ $rEmpleado += 1;
|
|
}
|
|
}
|
|
|
|
|
|
- //Herramientas
|
|
|
|
- $query = ObraHerramienta::find()
|
|
|
|
|
|
+ $herramienta = ObraHerramienta::find()
|
|
->joinWith('herramienta')
|
|
->joinWith('herramienta')
|
|
->andWhere(['{{ObraHerramienta}}.[[eliminado]]' => null])->andWhere(['{{ObraHerramienta}}.[[idObra]]' => $idObra]);
|
|
->andWhere(['{{ObraHerramienta}}.[[eliminado]]' => null])->andWhere(['{{ObraHerramienta}}.[[idObra]]' => $idObra]);
|
|
- $query->orderBy(['creado' => SORT_DESC]);
|
|
|
|
- $sheet->mergeCells('H8:N8');
|
|
|
|
- $sheet->setCellValue('H8', 'Herramientas');
|
|
|
|
- $sheet->getStyle('H8:N8')->applyFromArray($headerStyle);
|
|
|
|
- $sheet->mergeCells('H9:K9');
|
|
|
|
- $sheet->setCellValue('H9', 'Herramienta');
|
|
|
|
- $sheet->getStyle('H9:K9')->applyFromArray($headerStyle);
|
|
|
|
- $sheet->mergeCells('L9:N9');
|
|
|
|
- $sheet->setCellValue('L9', 'Cantidad');
|
|
|
|
- $sheet->getStyle('L9:N9')->applyFromArray($headerStyle);
|
|
|
|
- $rowHerramientas = 10;
|
|
|
|
-
|
|
|
|
- foreach ($query->each() as $obraHerramienta) {
|
|
|
|
|
|
+ $herramienta->orderBy(['creado' => SORT_DESC]);
|
|
|
|
+ $rHerramienta = 11;
|
|
|
|
+ foreach ($herramienta->each() as $obraHerramienta) {
|
|
$herramienta = $obraHerramienta->herramienta;
|
|
$herramienta = $obraHerramienta->herramienta;
|
|
- $sheet->mergeCells('H' . $rowHerramientas . ':K' . $rowHerramientas);
|
|
|
|
- $sheet->setCellValue('H' . $rowHerramientas, $herramienta->nombre); // Nombre del empleado
|
|
|
|
- $sheet->getStyle('H' . $rowHerramientas . ':K' . $rowHerramientas)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
|
|
|
|
- $sheet->getStyle('H' . $rowHerramientas . ':K' . $rowHerramientas)->applyFromArray($cellBorderStyle);
|
|
|
|
|
|
+ $renglones = [
|
|
|
|
+ "C{$rHerramienta}" => [
|
|
|
|
+ "valor" => $herramienta->nombre,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "D{$rHerramienta}" => [
|
|
|
|
+ "valor" => $obraHerramienta->cantidad,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+ $rHerramienta += 1;
|
|
|
|
+ }
|
|
|
|
+ $totalesController = new \v1\controllers\ObraController('totales', Yii::$app);
|
|
|
|
+
|
|
|
|
+ $totalGasto = $totalesController->actionTotalGasto($idObra);
|
|
|
|
+ $totalPago = $totalesController->actionTotalPago($idObra);
|
|
|
|
+ $totalNomina = $totalesController->actionTotalNomina($idObra);
|
|
|
|
+ $totalRubro = $totalesController->actionTotalRubro($idObra);
|
|
|
|
+ $saldo = $totalesController->actionSaldo($totalGasto, $totalNomina, $totalPago);
|
|
|
|
+ $ejercidoObra = $totalesController->actionEjercidoObra($totalGasto, $totalRubro);
|
|
|
|
+ $ejercer = $totalesController->actionEjercer($totalRubro, $totalPago);
|
|
|
|
+
|
|
|
|
+ $startRowTotales = max($rEmpleado, $rHerramienta) + 2;
|
|
|
|
+
|
|
|
|
+ $encabezadoTablaTotales = [
|
|
|
|
+ "A{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Gasto Total",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+
|
|
|
|
+ "B{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Pago Total",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+ ],
|
|
|
|
+ "C{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Nómina total",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "D{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Rubro de Obra",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "E{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Saldo total",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "F{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Ejercido obra",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "G{$startRowTotales}" => [
|
|
|
|
+ "valor" => "Por ejercer",
|
|
|
|
+ "estilo" => $estiloEncabezado,
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $this->agregarRenglones($encabezadoTablaTotales);
|
|
|
|
+ $datos = $startRowTotales + 1;
|
|
|
|
+ $renglones = [
|
|
|
|
+ "A{$datos}" => [
|
|
|
|
+ "valor" => $totalGasto,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "B{$datos}" => [
|
|
|
|
+ "valor" => $totalPago,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional,
|
|
|
|
+ ],
|
|
|
|
+ "C{$datos}" => [
|
|
|
|
+ "valor" => $totalNomina,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional,
|
|
|
|
+ ],
|
|
|
|
+ "D{$datos}" => [
|
|
|
|
+ "valor" => $totalRubro,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional,
|
|
|
|
+ ],
|
|
|
|
+ "E{$datos}" => [
|
|
|
|
+ "valor" => $saldo,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional,
|
|
|
|
+ ],
|
|
|
|
+ "F{$datos}" => [
|
|
|
|
+ "valor" => $ejercidoObra,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "#,##0.00%",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional,
|
|
|
|
+ ],
|
|
|
|
+ "G{$datos}" => [
|
|
|
|
+ "valor" => $ejercer,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional,
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+
|
|
|
|
+ $anchoColumnas = [
|
|
|
|
+ "A" => ["ancho" => 20],
|
|
|
|
+ "B" => ["ancho" => 20],
|
|
|
|
+ "C" => ["ancho" => 20],
|
|
|
|
+ "D" => ["ancho" => 20],
|
|
|
|
+ "E" => ["ancho" => 20],
|
|
|
|
+ "F" => ["ancho" => 20],
|
|
|
|
+ "G" => ["ancho" => 20],
|
|
|
|
+
|
|
|
|
+ ];
|
|
|
|
+ $this->anchoColumnas($anchoColumnas);
|
|
|
|
+
|
|
|
|
+ //Gastos
|
|
|
|
+ $this->nuevaHoja(1, 'Gasto');
|
|
|
|
+ $gasto = Gasto::find()
|
|
|
|
+ ->joinWith('conceptosObra')
|
|
|
|
+ ->andWhere(['{{Gasto}}.[[eliminado]]' => null])->andWhere(['{{Gasto}}.[[idObra]]' => $idObra]);
|
|
|
|
+ $gasto->orderBy(['fechaCompra' => SORT_DESC]);
|
|
|
|
+ $this->encabezadoHoja($this->logo($logo, 'A1'));
|
|
|
|
+
|
|
|
|
+ $encabezadoTabla = [
|
|
|
|
+ "A6" => [
|
|
|
|
+ "valor" => "Concepto Obra",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "B6" => [
|
|
|
|
+ "valor" => "Cantidad ",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "C6" => [
|
|
|
|
+ "valor" => "Fecha Compra",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "D6" => [
|
|
|
|
+ "valor" => "Descripción",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
|
|
- $sheet->mergeCells('L' . $rowHerramientas . ':N' . $rowHerramientas);
|
|
|
|
- $sheet->setCellValue('L' . $rowHerramientas, $obraHerramienta->cantidad); // Nombre del empleado
|
|
|
|
- $sheet->getStyle('L' . $rowHerramientas . ':N' . $rowHerramientas)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
|
|
|
|
- $sheet->getStyle('L' . $rowHerramientas . ':N' . $rowHerramientas)->applyFromArray($cellBorderStyle);
|
|
|
|
|
|
+ $r = 7;
|
|
|
|
+ $this->agregarRenglones($encabezadoTabla);
|
|
|
|
+ $estiloCeldaIzquierda = array_merge(self::$bordes, self::$celdaFuente12);
|
|
|
|
+ $estiloCondicional = $this->estiloCondicional();
|
|
|
|
|
|
- $rowHerramientas++;
|
|
|
|
|
|
+ foreach ($gasto->each() as $obraGasto) {
|
|
|
|
+ $fecha = (new DateTime($obraGasto->fechaCompra))->format('d-m-Y');
|
|
|
|
+ $gasto = $obraGasto->conceptosObra;
|
|
|
|
+
|
|
|
|
+ $renglones = [
|
|
|
|
+ "A{$r}" => [
|
|
|
|
+ "valor" => $gasto->concepto,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "B{$r}" => [
|
|
|
|
+ "valor" => $obraGasto->cantidad,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "C{$r}" => [
|
|
|
|
+ "valor" => $fecha,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "D{$r}" => [
|
|
|
|
+ "valor" => $obraGasto->descripcion,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+ $r += 1;
|
|
}
|
|
}
|
|
|
|
+ $anchoColumnas = [
|
|
|
|
+ "A" => ["ancho" => 20],
|
|
|
|
+ "B" => ["ancho" => 20],
|
|
|
|
+ "C" => ["ancho" => 20],
|
|
|
|
+ "D" => ["ancho" => 20],
|
|
|
|
+ ];
|
|
|
|
+ $this->anchoColumnas($anchoColumnas);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //Pagos
|
|
|
|
+ $this->nuevaHoja(2, 'Pago');
|
|
|
|
+ $pago = Pago::find()
|
|
|
|
+ ->joinWith('conceptosObra')
|
|
|
|
+ ->andWhere(['{{Pago}}.[[eliminado]]' => null])->andWhere(['{{Pago}}.[[idObra]]' => $idObra]);
|
|
|
|
+ $pago->orderBy(['fechaPago' => SORT_DESC]);
|
|
|
|
+ $this->encabezadoHoja($this->logo($logo, 'A1'));
|
|
|
|
+ $encabezadoTabla = [
|
|
|
|
+ "A6" => [
|
|
|
|
+ "valor" => "Concepto Obra",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "B6" => [
|
|
|
|
+ "valor" => "Cantidad ",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "C6" => [
|
|
|
|
+ "valor" => "Fecha Pago",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "D6" => [
|
|
|
|
+ "valor" => "Descripción",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $r = 7;
|
|
|
|
+ $this->agregarRenglones($encabezadoTabla);
|
|
|
|
+ $estiloCeldaIzquierda = array_merge(self::$bordes, self::$celdaFuente12);
|
|
|
|
+ $estiloCondicional = $this->estiloCondicional();
|
|
|
|
+
|
|
|
|
+ foreach ($pago->each() as $obraPago) {
|
|
|
|
+ $fecha = (new DateTime($obraPago->fechaPago))->format('d-m-Y');
|
|
|
|
+ $Pago = $obraPago->conceptosObra;
|
|
|
|
|
|
-//Totales
|
|
|
|
-$totalesController = new \v1\controllers\ObraController('totales', Yii::$app);
|
|
|
|
-
|
|
|
|
-$totalGasto = $totalesController->actionTotalGasto($idObra);
|
|
|
|
-$totalPago = $totalesController->actionTotalPago($idObra);
|
|
|
|
-$totalNomina = $totalesController->actionTotalNomina($idObra);
|
|
|
|
-$totalRubro = $totalesController->actionTotalRubro($idObra);
|
|
|
|
-$saldo = $totalesController->actionSaldo($totalGasto, $totalNomina, $totalPago);
|
|
|
|
-$ejercidoObra = $totalesController->actionEjercidoObra($totalGasto, $totalRubro);
|
|
|
|
-$ejercer = $totalesController->actionEjercer($totalRubro, $totalPago);
|
|
|
|
-
|
|
|
|
- $startRowTotales = max($rowEmpleados, $rowHerramientas) + 2;
|
|
|
|
-
|
|
|
|
-// Gasto total
|
|
|
|
-$sheet->mergeCells("A{$startRowTotales}:B{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("A{$startRowTotales}:B{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("A{$startRowTotales}", 'Gasto total');
|
|
|
|
-$sheet->mergeCells("A" . ($startRowTotales + 1) . ":B" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("A" . ($startRowTotales + 1), $totalGasto);
|
|
|
|
-$sheet->getStyle("A" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("A" . ($startRowTotales + 1). ":B" . ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-// Pago total
|
|
|
|
-$sheet->mergeCells("C{$startRowTotales}:D{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("C{$startRowTotales}:D{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("C{$startRowTotales}", 'Pago total');
|
|
|
|
-$sheet->mergeCells("C" . ($startRowTotales + 1) . ":D" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("C" . ($startRowTotales + 1), $totalPago);
|
|
|
|
-$sheet->getStyle("C" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("C" . ($startRowTotales + 1). ":D". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-// Nómina total
|
|
|
|
-$sheet->mergeCells("E{$startRowTotales}:F{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("E{$startRowTotales}:F{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("E{$startRowTotales}", 'Nómina total');
|
|
|
|
-$sheet->mergeCells("E" . ($startRowTotales + 1) . ":F" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("E" . ($startRowTotales + 1), $totalNomina);
|
|
|
|
-$sheet->getStyle("E" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("E" . ($startRowTotales + 1).":F". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-// Rubro de Obra total
|
|
|
|
-$sheet->mergeCells("G{$startRowTotales}:H{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("G{$startRowTotales}:H{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("G{$startRowTotales}", 'Rubro de Obra total');
|
|
|
|
-$sheet->mergeCells("G" . ($startRowTotales + 1) . ":H" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("G" . ($startRowTotales + 1), $totalRubro);
|
|
|
|
-$sheet->getStyle("G" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("G" . ($startRowTotales + 1). ":H". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-// Saldo total
|
|
|
|
-$sheet->mergeCells("I{$startRowTotales}:J{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("I{$startRowTotales}:J{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("I{$startRowTotales}", 'Saldo total');
|
|
|
|
-$sheet->mergeCells("I" . ($startRowTotales + 1) . ":J" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("I" . ($startRowTotales + 1), $saldo);
|
|
|
|
-$sheet->getStyle("I" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("I" . ($startRowTotales + 1). ":J" . ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-// Ejercido obra
|
|
|
|
-$sheet->mergeCells("K{$startRowTotales}:L{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("K{$startRowTotales}:L{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("K{$startRowTotales}", 'Ejercido obra');
|
|
|
|
-$sheet->mergeCells("K" . ($startRowTotales + 1) . ":L" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("K" . ($startRowTotales + 1), $ejercidoObra);
|
|
|
|
-$sheet->getStyle("K" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("K" . ($startRowTotales + 1). ":L". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-// Por ejercer
|
|
|
|
-$sheet->mergeCells("M{$startRowTotales}:N{$startRowTotales}");
|
|
|
|
-$sheet->getStyle("M{$startRowTotales}:N{$startRowTotales}")->applyFromArray($headerStyle);
|
|
|
|
-$sheet->setCellValue("M{$startRowTotales}", 'Por ejercer');
|
|
|
|
-$sheet->mergeCells("M" . ($startRowTotales + 1) . ":N" . ($startRowTotales + 1)); // Merge en la fila de resultados
|
|
|
|
-$sheet->setCellValue("M" . ($startRowTotales + 1), $ejercer);
|
|
|
|
-$sheet->getStyle("M" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
|
|
|
|
-$sheet->getStyle("M" . ($startRowTotales + 1). ":N" . ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
|
|
|
|
-
|
|
|
|
-$excelGasto= new \app\modules\excel\controllers\ObraGastoController('totales', Yii::$app);
|
|
|
|
-$sheetGasto = $excelGasto->actionExcelGasto($idObra);
|
|
|
|
-$spreadsheet->addSheet($sheetGasto);
|
|
|
|
-
|
|
|
|
-$excelPago= new \app\modules\excel\controllers\ObraPagoController('totales', Yii::$app);
|
|
|
|
-$sheetPago = $excelPago->actionExcelPago($idObra);
|
|
|
|
-$spreadsheet->addSheet($sheetPago);
|
|
|
|
-
|
|
|
|
-$excelNomina= new \app\modules\excel\controllers\ObraNominaController('totales', Yii::$app);
|
|
|
|
-$sheetNomina = $excelNomina->actionExcelNomina($idObra);
|
|
|
|
-$spreadsheet->addSheet($sheetNomina);
|
|
|
|
-
|
|
|
|
-$excelRubro= new \app\modules\excel\controllers\ObraRubroController('totales', Yii::$app);
|
|
|
|
-$sheetRubro = $excelRubro->actionExcelRubro($idObra);
|
|
|
|
-$spreadsheet->addSheet($sheetRubro);
|
|
|
|
- $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
|
|
|
- $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, "Obra.xlsx");
|
|
|
|
- } catch (\Exception $exception) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ $renglones = [
|
|
|
|
+ "A{$r}" => [
|
|
|
|
+ "valor" => $Pago->concepto,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "B{$r}" => [
|
|
|
|
+ "valor" => $obraPago->cantidad,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "C{$r}" => [
|
|
|
|
+ "valor" => $fecha,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "D{$r}" => [
|
|
|
|
+ "valor" => $obraPago->descripcion,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+ $r += 1;
|
|
}
|
|
}
|
|
|
|
+ $anchoColumnas = [
|
|
|
|
+ "A" => ["ancho" => 20],
|
|
|
|
+ "B" => ["ancho" => 20],
|
|
|
|
+ "C" => ["ancho" => 20],
|
|
|
|
+ "D" => ["ancho" => 20],
|
|
|
|
+ ];
|
|
|
|
+ $this->anchoColumnas($anchoColumnas);
|
|
|
|
+
|
|
|
|
+ $this->nuevaHoja(3, 'Nomina');
|
|
|
|
+ $nomina = Nomina::find()
|
|
|
|
+ ->joinWith('empleado')
|
|
|
|
+ ->andWhere(['{{Nomina}}.[[eliminado]]' => null])->andWhere(['{{Nomina}}.[[idObra]]' => $idObra]);
|
|
|
|
+ $nomina->orderBy(['fechaInicio' => SORT_DESC]);
|
|
|
|
+ $this->encabezadoHoja($this->logo($logo, 'A1'));
|
|
|
|
+ $encabezadoTabla = [
|
|
|
|
+ "A6" => [
|
|
|
|
+ "valor" => "Concepto Obra",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "B6" => [
|
|
|
|
+ "valor" => "Cantidad ",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "C6" => [
|
|
|
|
+ "valor" => "Fecha Inicio",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "D6" => [
|
|
|
|
+ "valor" => "Fecha Fin",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $r = 7;
|
|
|
|
+ $this->agregarRenglones($encabezadoTabla);
|
|
|
|
+ $estiloCeldaIzquierda = array_merge(self::$bordes, self::$celdaFuente12);
|
|
|
|
+ $estiloCondicional = $this->estiloCondicional();
|
|
|
|
+ foreach ($nomina->each() as $obraNomina) {
|
|
|
|
+ $fechaInicio = (new DateTime($obraNomina->fechaInicio))->format('d-m-Y');
|
|
|
|
+ $fechaFin = (new DateTime($obraNomina->fechaFin))->format('d-m-Y');
|
|
|
|
+ $empleado = $obraNomina->empleado;
|
|
|
|
+ $renglones = [
|
|
|
|
+ "A{$r}" => [
|
|
|
|
+ "valor" => $empleado->nombre,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "B{$r}" => [
|
|
|
|
+ "valor" => $obraNomina->montoPagado,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "C{$r}" => [
|
|
|
|
+ "valor" => $fechaInicio,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "D{$r}" => [
|
|
|
|
+ "valor" => $fechaFin,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+ $r += 1;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ $anchoColumnas = [
|
|
|
|
+ "A" => ["ancho" => 20],
|
|
|
|
+ "B" => ["ancho" => 20],
|
|
|
|
+ "C" => ["ancho" => 20],
|
|
|
|
+ "D" => ["ancho" => 20],
|
|
|
|
+ ];
|
|
|
|
+ $this->anchoColumnas($anchoColumnas);
|
|
|
|
+
|
|
|
|
+ $this->nuevaHoja(4, 'Rubro');
|
|
|
|
+ $rubro = ObraRubro::find()
|
|
|
|
+ ->joinWith('conceptoObra')
|
|
|
|
+ ->andWhere(['{{ObraRubro}}.[[eliminado]]' => null])->andWhere(['{{ObraRubro}}.[[idObra]]' => $idObra]);
|
|
|
|
+ $rubro->orderBy(['creado' => SORT_DESC]);
|
|
|
|
+ $this->encabezadoHoja($this->logo($logo, 'A1'));
|
|
|
|
+ $encabezadoTabla = [
|
|
|
|
+ "A6" => [
|
|
|
|
+ "valor" => "Concepto Obra",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "B6" => [
|
|
|
|
+ "valor" => "Cantidad ",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "C6" => [
|
|
|
|
+ "valor" => "Fecha Compra",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ],
|
|
|
|
+ "D6" => [
|
|
|
|
+ "valor" => "Descripción",
|
|
|
|
+ "estilo" => $estiloEncabezado
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $r = 7;
|
|
|
|
+ $this->agregarRenglones($encabezadoTabla);
|
|
|
|
+ $estiloCeldaIzquierda = array_merge(self::$bordes, self::$celdaFuente12);
|
|
|
|
+ $estiloCondicional = $this->estiloCondicional();
|
|
|
|
+ foreach ($rubro->each() as $obraRubro) {
|
|
|
|
+ $fecha = (new DateTime($obraRubro->fechaCompra))->format('d-m-Y');
|
|
|
|
+
|
|
|
|
+ $rubro = $obraRubro->conceptoObra;
|
|
|
|
+ $renglones = [
|
|
|
|
+ "A{$r}" => [
|
|
|
|
+ "valor" => $rubro->concepto,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "B{$r}" => [
|
|
|
|
+ "valor" => $obraRubro->cantidad,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda,
|
|
|
|
+ "formato" => "$#,##0.00",
|
|
|
|
+ "estiloCondicional" => $estiloCondicional
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ "C{$r}" => [
|
|
|
|
+ "valor" => $fecha,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ],
|
|
|
|
+ "D{$r}" => [
|
|
|
|
+ "valor" => $obraRubro->descripcion,
|
|
|
|
+ "estilo" => $estiloCeldaIzquierda
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $this->agregarRenglones($renglones);
|
|
|
|
+ $r += 1;
|
|
|
|
+ }
|
|
|
|
+ $anchoColumnas = [
|
|
|
|
+ "A" => ["ancho" => 20],
|
|
|
|
+ "B" => ["ancho" => 20],
|
|
|
|
+ "C" => ["ancho" => 20],
|
|
|
|
+ "D" => ["ancho" => 20],
|
|
|
|
+ ];
|
|
|
|
+ $this->anchoColumnas($anchoColumnas);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $documento = $this->obtenerHojaDeCalculo();
|
|
|
|
+ $this->crear($documento, "Obra_" . date("YmdHis"), self::TIPO_EXCEL);
|
|
|
|
+ \Yii::$app->end();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|