Informe tesoreria en excel
This commit is contained in:
34
app/src/Service/Informe.php
Normal file
34
app/src/Service/Informe.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Informe extends Ideal\Service
|
||||
{
|
||||
public function __construct(LoggerInterface $logger, protected string $folder)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
if (!file_exists($this->folder)) {
|
||||
mkdir($this->folder);
|
||||
}
|
||||
}
|
||||
|
||||
protected array $informes;
|
||||
|
||||
public function register(string $name, string $informeClass): Informe
|
||||
{
|
||||
$this->informes[$name] = $informeClass;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function build(string $type, string $filename, string $title, array $data): void
|
||||
{
|
||||
$informe = new $this->informes[$type]();
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [$this->folder, "{$filename}.xlsx"]);
|
||||
$informe->setFilename($filename);
|
||||
$informe->setTitle($title);
|
||||
$informe->addData($data);
|
||||
$informe->build();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user