Merge branch 'develop'
This commit is contained in:
@ -4,6 +4,8 @@ namespace App\Service\Informe\Contabilidad;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
|
use App\Service\Informe\Informe;
|
||||||
use Incoviba\old\Proyecto\Proyecto;
|
use Incoviba\old\Proyecto\Proyecto;
|
||||||
use Incoviba\old\Venta\Venta;
|
use Incoviba\old\Venta\Venta;
|
||||||
use Incoviba\old\Venta\Pago;
|
use Incoviba\old\Venta\Pago;
|
||||||
@ -137,7 +139,7 @@ class Resumen
|
|||||||
$haber -= $pago->valor;
|
$haber -= $pago->valor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output []= implode($this->separator, ['', $haber, $debe]);
|
$output []= implode($this->separator, ['', '', $haber, $debe]);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +152,12 @@ class Resumen
|
|||||||
$output = array_merge($output, $this->buildLibro($venta, $up_to), [''], ['']);
|
$output = array_merge($output, $this->buildLibro($venta, $up_to), [''], ['']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = "Contabilidad - Resumen - {$ventas[0]->proyecto()->descripcion} - {$up_to->format('Y-m-d')}.csv";
|
$filename = "Contabilidad - Resumen - {$ventas[0]->proyecto()->descripcion} - {$up_to->format('Y-m-d')}.xlsx";
|
||||||
|
$informe = new Informe();
|
||||||
|
$informe->createSpreadsheet()
|
||||||
|
->addArray($output)
|
||||||
|
->send($filename);
|
||||||
|
return;
|
||||||
|
|
||||||
header("Content-Type: text/csv; charset=utf-8");
|
header("Content-Type: text/csv; charset=utf-8");
|
||||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||||
|
29
app/Service/Informe/Informe.php
Normal file
29
app/Service/Informe/Informe.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Service\Informe;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
|
||||||
|
class Informe
|
||||||
|
{
|
||||||
|
protected $spreadsheet;
|
||||||
|
public function createSpreadsheet()
|
||||||
|
{
|
||||||
|
$this->spreadsheet = new Spreadsheet();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function addArray(array $data, string $start = 'A1')
|
||||||
|
{
|
||||||
|
$this->spreadsheet->getActiveSheet()->fromArray($data, null, $start);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function send(string $filename)
|
||||||
|
{
|
||||||
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
|
header("Content-Disposition: attachment;filename='{$filename}'");
|
||||||
|
header('Cache-Control: max-age=0');
|
||||||
|
|
||||||
|
$writer = IOFactory::createWriter($this->spreadsheet, 'Xlsx');
|
||||||
|
$writer->save('php://output');
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user