<?php
namespace App\Controller;
use App\Entity\Unidad;
use App\Entity\Usuario;
use App\Repository\EquipoRepository;
use App\Repository\ImpresoraRepository;
use App\Repository\OtroRepository;
use App\Repository\RedRepository;
use App\Repository\SolicitudRepository;
use App\Repository\UbicacionRepository;
use App\Service\DocumentoPDF;
use App\Service\SelloDigital;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
use phpDocumentor\Reflection\Types\False_;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/reporte')]
class ReporteController extends AbstractController
{
#[Route('/equipo-excel', name: 'app_reporte_equipo_excel', methods: ['POST'])]
public function equipoExcel(EquipoRepository $equipoRepository, Request $request): Response
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
# Obtenemos los datos del documento
$equipos = $equipoRepository->equipoUnidad($unidad);
# Definir el nombre temporal del archivo
$filePath = 'equipo.xlsx';
# Se definen las cabeceras del archivo
$cabecera = WriterEntityFactory::createRowFromArray([
'No.',
'Estatus',
'Marbete',
'Marca',
'Modelo',
'Serie',
'Procesador',
'CPU velocidad',
'Núcleos',
'SSD',
'HDD',
'RAM',
'MAC',
'IP',
'EMHV',
'Monitor marbete',
'Monitor marca',
'Monitor modelo',
'Monitor serie',
'Monitor tipo',
'Monitor pulgadas',
'Teclado marca',
'Teclado modelo',
'Teclado serie',
'Mouse marca',
'Mouse modelo',
'Mouse serie',
'Uso',
'Función',
'Unidad',
'Ubicación',
'Usuario'
]);
# Se crea el arreglo con los datos del cuerpo del documento
$data = [];
$n = 1;
foreach ($equipos as $equipo) {
$usuario = $equipo->getUsuario()->getNombre() . ' ' . $equipo->getUsuario()->getPapellido();
$ubicacion = $equipo->getUbicacion()->getArea();
$unidad = $equipo->getUnidad()->getNombre();
$ssd = "";
if ($equipo->getSsd() > 0 || $equipo->getSsd() != ""){
$ssd = $equipo->getSsd() . ' Gb';
}
$uso = match ($equipo->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$funcion = match ($equipo->getFuncion()) {
"1" => "Escritorio",
"2" => "Servidor",
default => ""
};
$estatus = match ($equipo->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$emhv = match ($equipo->isEmhv()) {
true => "Cumple",
false => "No cumple",
default => ""
};
$data[] = WriterEntityFactory::createRowFromArray([
$n,
$estatus,
$equipo->getMarbete(),
$equipo->getMarca(),
$equipo->getModelo(),
$equipo->getSerie(),
$equipo->getProcesador(),
$equipo->getCpuVelocidad(),
$equipo->getNucleos(),
$ssd,
$equipo->getHhd(),
$equipo->getRam(),
$equipo->getMac(),
$equipo->getIp(),
$emhv,
$equipo->getMonitorMarbete(),
$equipo->getMonitorMarca(),
$equipo->getMonitorModelo(),
$equipo->getMonitorSerie(),
$equipo->getMonitorTipo(),
$equipo->getMonitorPulgadas(),
$equipo->getTecladoMarca(),
$equipo->getTecladoModelo(),
$equipo->getTecladoSerie(),
$equipo->getMouseMarca(),
$equipo->getMouseModelo(),
$equipo->getMouseSerie(),
$uso,
$funcion,
$unidad,
$ubicacion,
$usuario
]);
$n++;
}
# Se crea el documento en formato CSV
$writer = WriterEntityFactory::createXLSXWriter();
$writer
->openToFile($filePath)
->addRow($cabecera)
->addRows($data)
->close()
;
$response = new BinaryFileResponse($filePath);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
'equipo' . '_' . date('Y-m-d') . '.xlsx'
);
$response->deleteFileAfterSend(true);
return $response;
}
#[Route('/equipo-pdf', name: 'app_reporte_equipo_pdf', methods: ['POST'])]
public function equipoPDF(EquipoRepository $equipoRepository, Request $request, SelloDigital $sello)
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
date_default_timezone_set('America/Mexico_City');
setlocale(LC_ALL, 'es_MX');
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
$fecha = date('d-m-Y H:i');
# Declaración de la instancia de TCPDF con el encabezado personalizado
$pdf = new DocumentoPDF();
if (empty($unidad)) {
$pdf->unidad = "Todas las Unidades administrativas";
} else {
$uni = $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
$pdf->unidad = $uni->getNombre();
}
$pdf->codigo = '15-528-PO-15-F18';
$pdf->revision = '02';
$pdf->faprobacion = '30/10/2022';
$pdf->fecha = $fecha;
$pdf->formato = 'FORMATO CE-1';
$pdf->nombre = 'CONTROL DE EQUIPO DE CÓMPUTO';
$pdf->setPrintFooter(false);
# Obtenemos los datos del documento
$equipos = $equipoRepository->equipoUnidad($unidad, 1);
$cadenaOriginal = $pdf->formato . '||';
$cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" : $pdf->unidad;
$cadenaOriginal .= '||' . $user->getNombre() . ' ' . $user->getPapellido() . '||' . $user->getCorreo() . '||' . $user->getRol()->getNombre();
$cadenaOriginal .= '||' . $fecha;
$cadena64 = $sello->generar($cadenaOriginal);
# Información del documento
$pdf->SetCreator('Conalep Estado de México');
$pdf->SetAuthor('SIGMEC');
$pdf->SetTitle('Reporte');
# Definimos los saltos de página como automáticos
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
#Nueva página con sus respectivas características
$pdf->AddPage('L', 'JIS_B4');
$pdf->SetY(50);
# Definimos la utilización de tipigrafías
$pdf->setFontSubsetting(true);
### Generamos el contenido a mostrar ###
ob_start();
$html = <<<EOD
<table width="100%" cellpadding="2" border="0.1">
<thead>
<tr style="text-align: center; background-color: #e4e4e4; font-size: 9px">
<td rowspan="2" style="width: 2%">#</td>
<td rowspan="2">Estatus</td>
<td colspan="9">CPU</td>
<td colspan="6">Monitor</td>
<td colspan="3">Teclado</td>
<td colspan="3">Mouse</td>
<td rowspan="2">Uso</td>
<td rowspan="2" style="font-size: 7.5px">Función</td>
<td rowspan="2" style="font-size: 7px">Ubicación</td>
<td rowspan="2" style="font-size: 7.5px">Usuario</td>
</tr>
<tr style="text-align: center; background-color: #e4e4e4; font-size: 7px">
<td>Marbete</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
<td style="font-size: 6px">Procesador</td>
<td>SSD</td>
<td>HDD</td>
<td>RAM</td>
<td>EMHV</td>
<td>Marbete</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
<td>Tipo</td>
<td>Pulgadas</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
</tr>
</thead>
<tbody>
EOD;
$pdf->setMargins(10,50);
$n = 1;
foreach ($equipos as $equipo) {
$usuario = $equipo->getUsuario()->getNombre() . ' ' . $equipo->getUsuario()->getPapellido();
$ubicacion = $equipo->getUbicacion()->getArea();
$uso = match ($equipo->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$funcion = match ($equipo->getFuncion()) {
"1" => "Escritorio",
"2" => "Servidor",
default => ""
};
$estatus = match ($equipo->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$emhv = match ($equipo->isEmhv()) {
true => "Si",
false => "No",
default => ""
};
$html .= <<<EOD
<tr style="font-size: 7px" nobr="true">
<td style="width: 2%">{$n}</td>
<td>{$estatus}</td>
<td>{$equipo->getMarbete()}</td>
<td>{$equipo->getMarca()}</td>
<td>{$equipo->getModelo()}</td>
<td>{$equipo->getSerie()}</td>
<td>{$equipo->getProcesador()}</td>
<td>{$equipo->getSsd()}</td>
<td>{$equipo->getHhd()}</td>
<td>{$equipo->getRam()}</td>
<td>{$emhv}</td>
<td>{$equipo->getMonitorMarbete()}</td>
<td>{$equipo->getMonitorMarca()}</td>
<td>{$equipo->getMonitorModelo()}</td>
<td>{$equipo->getMonitorSerie()}</td>
<td>{$equipo->getMonitorTipo()}</td>
<td>{$equipo->getMonitorPulgadas()}</td>
<td>{$equipo->getTecladoMarca()}</td>
<td>{$equipo->getTecladoModelo()}</td>
<td>{$equipo->getTecladoSerie()}</td>
<td>{$equipo->getMouseMarca()}</td>
<td>{$equipo->getMouseModelo()}</td>
<td>{$equipo->getMouseSerie()}</td>
<td>{$uso}</td>
<td style="font-size: 6px">{$funcion}</td>
<td style="font-size: 6px">{$ubicacion}</td>
<td style="font-size: 6px">{$usuario}</td>
</tr>
EOD;
$n++;
}
$html .= <<<EOD
</tbody>
</table>
EOD;
# Declaramos una nueva tipografía para el pie de página del contenido
$pdf->SetFont('freesans', '', 10, '', true);
# $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
$qr = new \TCPDF2DBarcode($cadenaOriginal, 'QRCODE,M');
$imgdata = $qr->getBarcodePngData(2.5, 2.5, array(0, 0, 0));
file_put_contents('img/sistema/qr.png', $imgdata);
$html .=
<<<EOD
<br>
<br>
<br>
<table width="100%" cellpadding="5" border="0">
<tbody>
<tr>
<td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
<td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
<td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
<td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
</tr>
<tr>
<td colspan="2" style="width: 75%">{$cadena64}</td>
<td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
</tr>
</tbody>
</table>
EOD;
# Imprimimos el contenido como HTML
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
ob_end_clean();
# ---------------------------------------------------------
# Mostramos el resultado en pantalla
$pdf->Output($pdf->formato . date('Ymd') . '.pdf', 'D');
}
#[Route('/impresora-excel', name: 'app_reporte_impresora_excel', methods: ['POST'])]
public function impresoraExcel(ImpresoraRepository $impresoraRepository, Request $request): Response
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
# Obtenemos los datos del documento
$impresoras = $impresoraRepository->impresoraUnidad($unidad);
# Definir el nombre temporal del archivo
$filePath = 'impresora.xlsx';
# Se definen las cabeceras del archivo
$cabecera = WriterEntityFactory::createRowFromArray([
'No.',
'Estatus',
'Marbete',
'Marca',
'Modelo',
'Serie',
'Tipo',
'Uso',
'MAC',
'IP',
'Unidad',
'Ubicación',
'Usuario'
]);
# Se crea el arreglo con los datos del cuerpo del documento
$data = [];
$n = 1;
foreach ($impresoras as $impresora) {
$usuario = $impresora->getUsuario()->getNombre() . ' ' . $impresora->getUsuario()->getPapellido();
$ubicacion = $impresora->getUbicacion()->getArea();
$unidad = $impresora->getUnidad()->getNombre();
$tipo = match ($impresora->getTipo()) {
"0" => "Laser",
"1" => "Matriz",
"2" => "Tinta",
default => ""
};
$uso = match ($impresora->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$estatus = match ($impresora->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$data[] = WriterEntityFactory::createRowFromArray([
$n,
$estatus,
$impresora->getMarbete(),
$impresora->getMarca(),
$impresora->getModelo(),
$impresora->getSerie(),
$tipo,
$uso,
$impresora->getMac(),
$impresora->getIp(),
$unidad,
$ubicacion,
$usuario
]);
$n++;
}
# Se crea el documento en formato CSV
$writer = WriterEntityFactory::createXLSXWriter();
$writer
->openToFile($filePath)
->addRow($cabecera)
->addRows($data)
->close()
;
$response = new BinaryFileResponse($filePath);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
'impresora' . '_' . date('Y-m-d') . '.xlsx'
);
$response->deleteFileAfterSend(true);
return $response;
}
#[Route('/impresora-pdf', name: 'app_reporte_impresora_pdf', methods: ['POST'])]
public function impresoraPDF(ImpresoraRepository $impresoraRepository, Request $request, SelloDigital $sello)
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
date_default_timezone_set('America/Mexico_City');
setlocale(LC_ALL, 'es_MX');
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
$fecha = date('d-m-Y H:i');
# Declaración de la instancia de TCPDF con el encabezado personalizado
$pdf = new DocumentoPDF();
if (empty($unidad)) {
$pdf->unidad = "Todas las Unidades administrativas";
} else {
$uni = $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
$pdf->unidad = $uni->getNombre();
}
$pdf->codigo = '15-528-PO-15-F18';
$pdf->revision = '02';
$pdf->faprobacion = '30/10/2022';
$pdf->fecha = $fecha;
$pdf->formato = 'FORMATO CE-2';
$pdf->nombre = 'CONTROL DE IMPRESORAS';
$pdf->setPrintFooter(false);
# Obtenemos los datos del documento
$impresoras = $impresoraRepository->impresoraUnidad($unidad, 1);
$cadenaOriginal = $pdf->formato . '||';
$cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" : $pdf->unidad;
$cadenaOriginal .= '||' . $user->getNombre() . ' ' . $user->getPapellido() . '||' . $user->getCorreo() . '||' . $user->getRol()->getNombre();
$cadenaOriginal .= '||' . $fecha;
$cadena64 = $sello->generar($cadenaOriginal);
# Información del documento
$pdf->SetCreator('Conalep Estado de México');
$pdf->SetAuthor('SIGMEC');
$pdf->SetTitle('Reporte');
# Definimos los saltos de página como automáticos
#$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
#Nueva página con sus respectivas características
$pdf->AddPage('L', 'LEGAL');
$pdf->SetY(50);
# Definimos la utilización de tipigrafías
$pdf->setFontSubsetting(true);
### Generamos el contenido a mostrar ###
ob_start();
$html = <<<EOD
<table cellpadding="2" border="0.1" width="100%">
<thead>
<tr style="text-align: center; background-color: #e4e4e4; font-size: 11px">
<td style="width: 5%">No.</td>
<td>Estatus</td>
<td>Marbete</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
<td>Tipo</td>
<td>Uso</td>
<td>Ubicación</td>
<td>Usuario</td>
</tr>
</thead>
<tbody>
EOD;
$pdf->setMargins(10,50);
$n = 1;
foreach ($impresoras as $impresora) {
$usuario = $impresora->getUsuario()->getNombre() . ' ' . $impresora->getUsuario()->getPapellido();
$ubicacion = $impresora->getUbicacion()->getArea();
$tipo = match ($impresora->getTipo()) {
'0' => '<span>Laser</span>',
'1' => '<span>Matriz</span>',
'2' => '<span>Tinta</span>',
default => ""
};
$uso = match ($impresora->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$estatus = match ($impresora->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$html .= <<<EOD
<tr style="font-size: 10px" nobr="true">
<td style="width: 5%">{$n}</td>
<td>{$estatus}</td>
<td>{$impresora->getMarbete()}</td>
<td>{$impresora->getMarca()}</td>
<td>{$impresora->getModelo()}</td>
<td>{$impresora->getSerie()}</td>
<td>{$tipo}</td>
<td>{$uso}</td>
<td>{$ubicacion}</td>
<td>{$usuario}</td>
</tr>
EOD;
$n++;
}
$html .= <<<EOD
</tbody>
</table>
EOD;
# Declaramos una nueva tipografía para el pie de página del contenido
$pdf->SetFont('freesans', '', 10, '', true);
# $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
$qr = new \TCPDF2DBarcode($cadenaOriginal, 'QRCODE,M');
$imgdata = $qr->getBarcodePngData(2.5, 2.5, array(0, 0, 0));
file_put_contents('img/sistema/qr.png', $imgdata);
$html .= <<<EOD
<br>
<br>
<br>
<table width="100%" cellpadding="5" border="0">
<tbody>
<tr>
<td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
<td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
<td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
<td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
</tr>
<tr>
<td colspan="2" style="width: 75%">{$cadena64}</td>
<td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
</tr>
</tbody>
</table>
EOD;
# Imprimimos el contenido como HTML
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
ob_end_clean();
# ---------------------------------------------------------
# Mostramos el resultado en pantalla
$pdf->Output($pdf->formato . date('Ymd') . '.pdf', 'D');
}
#[Route('/otro-excel', name: 'app_reporte_otro_excel', methods: ['POST'])]
public function otroExcel(OtroRepository $otroRepository, Request $request): Response
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
# Obtenemos los datos del documento
$otros = $otroRepository->otroUnidad($unidad);
# Definir el nombre temporal del archivo
$filePath = 'otro.xlsx';
# Se definen las cabeceras del archivo
$cabecera = WriterEntityFactory::createRowFromArray([
'No.',
'Estatus',
'Marbete',
'Descripción',
'Marca',
'Modelo',
'Serie',
'Uso',
'MAC',
'IP',
'Unidad',
'Ubicación',
'Usuario'
]);
# Se crea el arreglo con los datos del cuerpo del documento
$data = [];
$n = 1;
foreach ($otros as $otro) {
$usuario = $otro->getUsuario()->getNombre() . ' ' . $otro->getUsuario()->getPapellido();
$ubicacion = $otro->getUbicacion()->getArea();
$unidad = $otro->getUnidad()->getNombre();
$uso = match ($otro->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$estatus = match ($otro->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$data[] = WriterEntityFactory::createRowFromArray([
$n,
$estatus,
$otro->getMarbete(),
$otro->getDescripcion(),
$otro->getMarca(),
$otro->getModelo(),
$otro->getSerie(),
$uso,
$otro->getMac(),
$otro->getIp(),
$unidad,
$ubicacion,
$usuario
]);
$n++;
}
# Se crea el documento en formato CSV
$writer = WriterEntityFactory::createXLSXWriter();
$writer
->openToFile($filePath)
->addRow($cabecera)
->addRows($data)
->close()
;
$response = new BinaryFileResponse($filePath);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
'otro' . '_' . date('Y-m-d') . '.xlsx'
);
$response->deleteFileAfterSend(true);
return $response;
}
#[Route('/otro-pdf', name: 'app_reporte_otro_pdf', methods: ['POST'])]
public function otroPDF(OtroRepository $otroRepository, Request $request, SelloDigital $sello)
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
date_default_timezone_set('America/Mexico_City');
setlocale(LC_ALL, 'es_MX');
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
$fecha = date('d-m-Y H:i');
# Declaración de la instancia de TCPDF con el encabezado personalizado
$pdf = new DocumentoPDF();
if (empty($unidad)) {
$pdf->unidad = "Todas las Unidades administrativas";
} else {
$uni = $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
$pdf->unidad = $uni->getNombre();
}
$pdf->codigo = '15-528-PO-15-F18';
$pdf->revision = '02';
$pdf->faprobacion = '30/10/2022';
$pdf->fecha = $fecha;
$pdf->formato = 'FORMATO CE-3';
$pdf->nombre = 'CONTROL DE OTROS BIENES INFORMÁTICOS';
$pdf->setPrintFooter(false);
# Obtenemos los datos del documento
$otros = $otroRepository->otroUnidad($unidad, 1);
$cadenaOriginal = $pdf->formato . '||';
$cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" : $pdf->unidad;
$cadenaOriginal .= '||' . $user->getNombre() . ' ' . $user->getPapellido() . '||' . $user->getCorreo() . '||' . $user->getRol()->getNombre();
$cadenaOriginal .= '||' . $fecha;
$cadena64 = $sello->generar($cadenaOriginal);
# Información del documento
$pdf->SetCreator('Conalep Estado de México');
$pdf->SetAuthor('SIGMEC');
$pdf->SetTitle('Reporte');
# Definimos los saltos de página como automáticos
#$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
#Nueva página con sus respectivas características
$pdf->AddPage('L', 'LEGAL');
$pdf->SetY(50);
# Definimos la utilización de tipigrafías
$pdf->setFontSubsetting(true);
### Generamos el contenido a mostrar ###
ob_start();
$html = <<<EOD
<table cellpadding="2" border="0.1">
<thead>
<tr style="text-align: center; background-color: #e4e4e4; font-size: 11px">
<td style="width: 5%">No.</td>
<td>Estatus</td>
<td>Marbete</td>
<td>Descripción</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
<td>Uso</td>
<td>Ubicación</td>
<td>Usuario</td>
</tr>
</thead>
<tbody>
EOD;
$pdf->setMargins(10,50);
$n = 1;
foreach ($otros as $otro) {
$usuario = $otro->getUsuario()->getNombre() . ' ' . $otro->getUsuario()->getPapellido();
$ubicacion = $otro->getUbicacion()->getArea();
$uso = match ($otro->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$estatus = match ($otro->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$html .= <<<EOD
<tr style="font-size: 10px" nobr="true">
<td style="width: 5%">{$n}</td>
<td>{$estatus}</td>
<td>{$otro->getMarbete()}</td>
<td>{$otro->getDescripcion()}</td>
<td>{$otro->getMarca()}</td>
<td>{$otro->getModelo()}</td>
<td>{$otro->getSerie()}</td>
<td>{$uso}</td>
<td>{$ubicacion}</td>
<td>{$usuario}</td>
</tr>
EOD;
$n++;
}
$html .= <<<EOD
</tbody>
</table>
EOD;
# Declaramos una nueva tipografía para el pie de página del contenido
$pdf->SetFont('freesans', '', 10, '', true);
# $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
$qr = new \TCPDF2DBarcode($cadenaOriginal, 'QRCODE,M');
$imgdata = $qr->getBarcodePngData(2.5, 2.5, array(0, 0, 0));
file_put_contents('img/sistema/qr.png', $imgdata);
$html .= <<<EOD
<br>
<br>
<br>
<table width="100%" cellpadding="5" border="0">
<tbody>
<tr>
<td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
<td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
<td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
<td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
</tr>
<tr>
<td colspan="2" style="width: 75%">{$cadena64}</td>
<td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
</tr>
</tbody>
</table>
EOD;
# Imprimimos el contenido como HTML
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
ob_end_clean();
# ---------------------------------------------------------
# Mostramos el resultado en pantalla
$pdf->Output($pdf->formato . date('Ymd') . '.pdf', 'D');
}
#[Route('/red-excel', name: 'app_reporte_red_excel', methods: ['POST'])]
public function redExcel(RedRepository $redRepository, Request $request): Response
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
# Obtenemos los datos del documento
$redes = $redRepository->redUnidad($unidad);
# Definir el nombre temporal del archivo
$filePath = 'red.xlsx';
# Se definen las cabeceras del archivo
$cabecera = WriterEntityFactory::createRowFromArray([
'No.',
'Estatus',
'Marbete (opcional)',
'Descripción',
'Marca',
'Modelo',
'Serie',
'Velocidad',
'Puertos',
'Uso',
'MAC',
'IP',
'Unidad',
'Ubicación',
'Usuario'
]);
# Se crea el arreglo con los datos del cuerpo del documento
$data = [];
$n = 1;
foreach ($redes as $red) {
$usuario = $red->getUsuario()->getNombre() . ' ' . $red->getUsuario()->getPapellido();
$ubicacion = $red->getUbicacion()->getArea();
$unidad = $red->getUnidad()->getNombre();
$uso = match ($red->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$estatus = match ($red->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$data[] = WriterEntityFactory::createRowFromArray([
$n,
$estatus,
$red->getMarbete(),
$red->getDescripcion(),
$red->getMarca(),
$red->getModelo(),
$red->getSerie(),
$red->getVelocidad(),
$red->getPuertos(),
$uso,
$red->getMac(),
$red->getIp(),
$unidad,
$ubicacion,
$usuario
]);
$n++;
}
# Se crea el documento en formato CSV
$writer = WriterEntityFactory::createXLSXWriter();
$writer
->openToFile($filePath)
->addRow($cabecera)
->addRows($data)
->close()
;
$response = new BinaryFileResponse($filePath);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
'red' . '_' . date('Y-m-d') . '.xlsx'
);
$response->deleteFileAfterSend(true);
return $response;
}
#[Route('/red-pdf', name: 'app_reporte_red_pdf', methods: ['POST'])]
public function redPDF(RedRepository $redRepository, Request $request, SelloDigital $sello)
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
date_default_timezone_set('America/Mexico_City');
setlocale(LC_ALL, 'es_MX');
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
$fecha = date('d-m-Y H:i');
# Declaración de la instancia de TCPDF con el encabezado personalizado
$pdf = new DocumentoPDF();
if (empty($unidad)) {
$pdf->unidad = "Todas las Unidades administrativas";
} else {
$uni = $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
$pdf->unidad = $uni->getNombre();
}
$pdf->codigo = '15-528-PO-15-F18';
$pdf->revision = '02';
$pdf->faprobacion = '30/10/2022';
$pdf->fecha = $fecha;
$pdf->formato = 'FORMATO CE-4';
$pdf->nombre = 'CONTROL DE ACTIVOS DE COMUNICACIÓN';
$pdf->setPrintFooter(false);
# Obtenemos los datos del documento
$redes = $redRepository->redUnidad($unidad, 1);
$cadenaOriginal = $pdf->formato . '||';
$cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" : $pdf->unidad;
$cadenaOriginal .= '||' . $user->getNombre() . ' ' . $user->getPapellido() . '||' . $user->getCorreo() . '||' . $user->getRol()->getNombre();
$cadenaOriginal .= '||' . $fecha;
$cadena64 = $sello->generar($cadenaOriginal);
# Información del documento
$pdf->SetCreator('Conalep Estado de México');
$pdf->SetAuthor('SIGMEC');
$pdf->SetTitle('Reporte');
# Definimos los saltos de página como automáticos
#$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
#Nueva página con sus respectivas características
$pdf->AddPage('L', 'LEGAL');
$pdf->SetY(50);
# Definimos la utilización de tipigrafías
$pdf->setFontSubsetting(true);
### Generamos el contenido a mostrar ###
ob_start();
$html = <<<EOD
<table cellpadding="2" border="0.1">
<thead>
<tr style="text-align: center; background-color: #e4e4e4; font-size: 11px">
<td style="width: 5%">No.</td>
<td>Estatus</td>
<td>Marbete (opcional)</td>
<td>Descripción</td>
<td>Marca</td>
<td>Modelo</td>
<td>Serie</td>
<td>Velocidad</td>
<td>Puertos</td>
<td>Uso</td>
<td>Ubicación</td>
<td>Usuario</td>
</tr>
</thead>
<tbody>
EOD;
$pdf->setMargins(10,50);
$n = 1;
foreach ($redes as $red) {
$usuario = $red->getUsuario()->getNombre() . ' ' . $red->getUsuario()->getPapellido();
$ubicacion = $red->getUbicacion()->getArea();
$uso = match ($red->getUso()) {
"1" => "Educativo",
"2" => "Docente",
"3" => "Administrativo",
default => ""
};
$estatus = match ($red->getEstatus()) {
"1" => "En operación",
"2" => "Descompuesto",
"3" => "Sin instalar",
"4" => "En proceso de baja",
"5" => "Baja",
default => ""
};
$html .= <<<EOD
<tr style="font-size: 10px" nobr="true">
<td style="width: 5%">{$n}</td>
<td>{$estatus}</td>
<td>{$red->getMarbete()}</td>
<td>{$red->getDescripcion()}</td>
<td>{$red->getMarca()}</td>
<td>{$red->getModelo()}</td>
<td>{$red->getSerie()}</td>
<td>{$red->getVelocidad()}</td>
<td>{$red->getPuertos()}</td>
<td>{$uso}</td>
<td>{$ubicacion}</td>
<td>{$usuario}</td>
</tr>
EOD;
$n++;
}
$html .= <<<EOD
</tbody>
</table>
EOD;
# Declaramos una nueva tipografía para el pie de página del contenido
$pdf->SetFont('freesans', '', 10, '', true);
# $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
$qr = new \TCPDF2DBarcode($cadenaOriginal, 'QRCODE,M');
$imgdata = $qr->getBarcodePngData(2.5, 2.5, array(0, 0, 0));
file_put_contents('img/sistema/qr.png', $imgdata);
$html .= <<<EOD
<br>
<br>
<br>
<table width="100%" cellpadding="5" border="0">
<tbody>
<tr>
<td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
<td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
<td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
<td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
</tr>
<tr>
<td colspan="2" style="width: 75%">{$cadena64}</td>
<td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
</tr>
</tbody>
</table>
EOD;
# Imprimimos el contenido como HTML
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
ob_end_clean();
# ---------------------------------------------------------
# Mostramos el resultado en pantalla
$pdf->Output($pdf->formato . date('Ymd') . '.pdf', 'I');
}
#[Route('/pamp-excel', name: 'app_reporte_pamp_excel', methods: ['POST'])]
public function pampExcel(SolicitudRepository $solRep, Request $request): Response
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('pamp_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['pamp_filtro'])) ? $parameters['unidad'] : $user->getUnidad()->getIdUni();
$finicio = $parameters['anio'] . '-01-01';
$ffin = $parameters['anio'] . '-12-31';
# Obtenemos los datos del documento
$solicitudes = $solRep->registroTipoEquipoUsuario(null, 4, $unidad, $finicio, $ffin);
# Definir el nombre temporal del archivo
$filePath = 'pamp.xlsx';
# Se definen las cabeceras del archivo
$cabecera = WriterEntityFactory::createRowFromArray([
'No.',
'Solicitud',
'Periodo',
'Tipo equipo',
'Marbete',
'Marca',
'Modelo',
'Serie',
'Descripción',
'Unidad adminstrativa',
'Ubicación',
'Trabajo a realizar',
'Fecha registro',
'Fecha atención',
'Fecha de finalización',
'Servicio realizado',
'Refacciones',
'Resguardatario',
'Correo resguardatario',
'Gestor',
'Correo gestor',
'Estatus'
]);
# Se crea el arreglo con los datos del cuerpo del documento
$data = [];
$n = 1;
foreach ($solicitudes as $solicitud) {
if ($solicitud['tipo_mantenimiento'] == 'MP') {
$estatus = match ($solicitud['estatus']) {
"1" => "Pendiente",
"2" => "En Proceso",
"3" => "Atendido",
"4" => "Evaluado",
default => ""
};
$data[] = WriterEntityFactory::createRowFromArray([
$n,
$solicitud['id_sol'],
$solicitud['periodo'],
$solicitud['tipo_equipo'],
$solicitud['marbete'],
$solicitud['marca'],
$solicitud['modelo'],
$solicitud['serie'],
$solicitud['descripcion'],
$solicitud['nunidad'],
$solicitud['nubicacion'],
$solicitud['falla'],
$solicitud['fregistro'],
$solicitud['fatencion'],
$solicitud['ffin'],
$solicitud['srealizado'],
$solicitud['refacciones'],
$solicitud['unombre'] . ' ' . $solicitud['uapellido'],
$solicitud['ucorreo'],
$solicitud['gnombre'] . ' ' . $solicitud['gapellido'],
$solicitud['gcorreo'],
$estatus,
]);
$n++;
}
}
# Se crea el documento en formato CSV
$writer = WriterEntityFactory::createXLSXWriter();
$writer
->openToFile($filePath)
->addRow($cabecera)
->addRows($data)
->close()
;
$response = new BinaryFileResponse($filePath);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
'pamp' . '_' . date('Y-m-d') . '.xlsx'
);
$response->deleteFileAfterSend(true);
return $response;
}
#[Route('/pamp-pdf', name: 'app_reporte_pamp_pdf', methods: ['POST'])]
public function pampPDF(SolicitudRepository $solRep, Request $request, SelloDigital $sello)
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
date_default_timezone_set('America/Mexico_City');
setlocale(LC_ALL, 'es_MX');
# Se obtiene el nivel de acceso
$perfil = $request->getSession()->get('perfil');
$nivel = $perfil[9]["nivel"];
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('pamp_filtro');
if (empty($parameters)) {
$uni = "";
$year = date('Y');
} else {
$uni = (array_key_exists('unidad', $request->request->all()['pamp_filtro'])) ? $parameters['unidad'] : $user->getUnidad()->getIdUni();
$year = $parameters['anio'];
}
$periodo = date('d-m-Y H:i');
# Declaración de la instancia de TCPDF con el encabezado personalizado
$pdf = new DocumentoPDF();
if (empty($uni)) {
$pdf->unidad = "Todas las Unidades administrativas";
} else {
$unidad = $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $uni]);
$pdf->unidad = $unidad->getNombre();
}
$pdf->codigo = '15-528-PO-15-F18';
$pdf->revision = '02';
$pdf->faprobacion = '30/10/2022';
$pdf->fecha = $year; #$periodo
$pdf->formato = 'Diagrama de Gantt';
$pdf->nombre = 'Programa Anual de Mantenimiento Preventivo';
$pdf->setPrintFooter(false);
# Obtenemos los datos del documento
if ($nivel == 2) {
$solicitud = $solRep->findByAnioUnidad($year, $uni);
$conteo = $solRep->countByUnidad($uni);
} else {
$solicitud = $solRep->findByAnioUnidad($year, $user->getUnidad()->getIdUni());
$conteo = $solRep->countByUnidad($user->getUnidad()->getIdUni());
}
$cadenaOriginal = $pdf->formato . '||';
$cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" : $pdf->unidad;
$cadenaOriginal .= '||' . $user->getNombre() . ' ' . $user->getPapellido() . '||' . $user->getCorreo() . '||' . $user->getRol()->getNombre();
$cadenaOriginal .= '||' . $pdf->fecha;
$cadena64 = $sello->generar($cadenaOriginal);
# Información del documento
$pdf->SetCreator('Conalep Estado de México');
$pdf->SetAuthor('SIGMEC');
$pdf->SetTitle('Programa Anual de Mantenimiento Preventivo');
# Definimos los saltos de página como automáticos
#$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
#Nueva página con sus respectivas características
$pdf->AddPage('L', 'LEGAL');
$pdf->SetY(50);
# Definimos la utilización de tipigrafías
$pdf->setFontSubsetting(true);
# Obtiene datos de avance y equipos con mp
$n = 0;
$atendido = 0;
$avance = 0;
$marbetes = [];
foreach ($solicitud as $s) {
if ($s["estatus"] == "4") {
$atendido = $atendido + 1;
}
if ($s["tipo_equipo"] == "Cómputo") {
if (!in_array($s["marbete"], $marbetes)) {
$marbetes[] = $s["marbete"];
}
}
$n++;
}
if ($atendido > 0 and $n > 0) {
$avance = floor(($atendido / $n) * 100);
}
$ecmp = count($marbetes);
### Generamos el contenido a mostrar ###
ob_start();
$html = <<<EOD
<table cellpadding="2" border="0">
<tbody>
<tr>
<td colspan="8"><strong>Unidad administrativa</strong>: {$pdf->unidad}</td>
</tr>
<tr>
<td style="text-align: center">{$conteo["impresora"]}</td>
<td style="text-align: center">{$conteo["red"]}</td>
<td style="text-align: center">{$conteo["otro"]}</td>
<td style="text-align: center">{$conteo["equipo"]}</td>
<td style="text-align: center">{$conteo["emhv"]}</td>
<td style="text-align: center">{$ecmp}</td>
<td style="text-align: center">{$conteo["indice"]}%</td>
<td style="text-align: center">{$avance}%</td>
</tr>
<tr>
<td style="text-align: center"><strong>IMPRESORAS</strong></td>
<td style="text-align: center"><strong>RED</strong></td>
<td style="text-align: center"><strong>OTRO</strong></td>
<td style="text-align: center"><strong>CÓMPUTO</strong></td>
<td style="text-align: center"><strong>EMHV</strong></td>
<td style="text-align: center"><strong>EQ. COMPUTO/MP</strong></td>
<td style="text-align: center"><strong>ÍNDICE DE EMHV</strong></td>
<td style="text-align: center"><strong>AVANCE ATENCIÓN</strong></td>
</tr>
</tbody>
</table>
<br><br>
EOD;
$html .= <<<EOD
<table cellpadding="2" border="0.1">
<thead>
<tr style="text-align: center; background-color: #e4e4e4; font-size: 10px">
<th width="8.5mm">#</th>
<th width="27mm">Marbete</th>
<th width="45mm">Equipo</th>
<th width="125mm">Trabajo a realizar</th>
<th width="8mm"></th>
<th width="10mm">Ene</th>
<th width="10mm">Feb</th>
<th width="10mm">Mar</th>
<th width="10mm">Abr</th>
<th width="10mm">May</th>
<th width="10mm">Jun</th>
<th width="10mm">Jul</th>
<th width="10mm">Ago</th>
<th width="10mm">Sep</th>
<th width="10mm">Oct</th>
<th width="10mm">Nov</th>
<th width="10mm">Dic</th>
</tr>
</thead>
<tbody>
EOD;
$pdf->setMargins(10,50);
$n = 1;
foreach ($solicitud as $i) {
$mesP = date('m', strtotime($i['fatencion']));
$diaP = date('d', strtotime($i['fatencion']));
if (empty($i['ffin'])) {
$mesR = "00";
$diaR = "00";
} else {
$mesR = date('m', strtotime($i['ffin']));
$diaR = date('d', strtotime($i['ffin']));
}
if ($mesP == "01") { $mesP01 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP01 = $diaP; } else { $mesP01 = ''; $diaP01 = ''; }
if ($mesP == "02") { $mesP02 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP02 = $diaP; } else { $mesP02 = ''; $diaP02 = ''; }
if ($mesP == "03") { $mesP03 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP03 = $diaP; } else { $mesP03 = ''; $diaP03 = ''; }
if ($mesP == "04") { $mesP04 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP04 = $diaP; } else { $mesP04 = ''; $diaP04 = ''; }
if ($mesP == "05") { $mesP05 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP05 = $diaP; } else { $mesP05 = ''; $diaP05 = ''; }
if ($mesP == "06") { $mesP06 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP06 = $diaP; } else { $mesP06 = ''; $diaP06 = ''; }
if ($mesP == "07") { $mesP07 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP07 = $diaP; } else { $mesP07 = ''; $diaP07 = ''; }
if ($mesP == "08") { $mesP08 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP08 = $diaP; } else { $mesP08 = ''; $diaP08 = ''; }
if ($mesP == "09") { $mesP09 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP09 = $diaP; } else { $mesP09 = ''; $diaP09 = ''; }
if ($mesP == "10") { $mesP10 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP10 = $diaP; } else { $mesP10 = ''; $diaP10 = ''; }
if ($mesP == "11") { $mesP11 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP11 = $diaP; } else { $mesP11 = ''; $diaP11 = ''; }
if ($mesP == "12") { $mesP12 = 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'; $diaP12 = $diaP; } else { $mesP12 = ''; $diaP12 = ''; }
if ($mesR == "01") { $mesR01 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR01 = $diaR; } else { $mesR01 = ''; $diaR01 = ''; }
if ($mesR == "02") { $mesR02 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR02 = $diaR; } else { $mesR02 = ''; $diaR02 = ''; }
if ($mesR == "03") { $mesR03 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR03 = $diaR; } else { $mesR03 = ''; $diaR03 = ''; }
if ($mesR == "04") { $mesR04 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR04 = $diaR; } else { $mesR04 = ''; $diaR04 = ''; }
if ($mesR == "05") { $mesR05 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR05 = $diaR; } else { $mesR05 = ''; $diaR05 = ''; }
if ($mesR == "06") { $mesR06 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR06 = $diaR; } else { $mesR06 = ''; $diaR06 = ''; }
if ($mesR == "07") { $mesR07 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR07 = $diaR; } else { $mesR07 = ''; $diaR07 = ''; }
if ($mesR == "08") { $mesR08 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR08 = $diaR; } else { $mesR08 = ''; $diaR08 = ''; }
if ($mesR == "09") { $mesR09 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR09 = $diaR; } else { $mesR09 = ''; $diaR09 = ''; }
if ($mesR == "10") { $mesR10 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR10 = $diaR; } else { $mesR10 = ''; $diaR10 = ''; }
if ($mesR == "11") { $mesR11 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR11 = $diaR; } else { $mesR11 = ''; $diaR11 = ''; }
if ($mesR == "12") { $mesR12 = 'style="background-color: #dce79b; text-align: center; color: #333333;"'; $diaR12 = $diaR; } else { $mesR12 = ''; $diaR12 = ''; }
$html .= <<<EOD
<tr style="font-size: 9px">
<td width="8.5mm" rowspan="2" align="center">$n</td>
<td width="27mm" rowspan="2">{$i["marbete"]}</td>
<td width="45mm" rowspan="2">{$i["tipo_equipo"]}</td>
<td width="125mm" rowspan="2">{$i["falla"]}</td>
<td width="8mm">P</td>
<td width="10mm" {$mesP01}>{$diaP01}</td>
<td width="10mm" {$mesP02}>{$diaP02}</td>
<td width="10mm" {$mesP03}>{$diaP03}</td>
<td width="10mm" {$mesP04}>{$diaP04}</td>
<td width="10mm" {$mesP05}>{$diaP05}</td>
<td width="10mm" {$mesP06}>{$diaP06}</td>
<td width="10mm" {$mesP07}>{$diaP07}</td>
<td width="10mm" {$mesP08}>{$diaP08}</td>
<td width="10mm" {$mesP09}>{$diaP09}</td>
<td width="10mm" {$mesP10}>{$diaP10}</td>
<td width="10mm" {$mesP11}>{$diaP11}</td>
<td width="10mm" {$mesP12}>{$diaP12}</td>
</tr>
<tr style="font-size: 9px">
<td width="8mm">R</td>
<td width="10mm" {$mesR01}>{$diaR01}</td>
<td width="10mm" {$mesR02}>{$diaR02}</td>
<td width="10mm" {$mesR03}>{$diaR03}</td>
<td width="10mm" {$mesR04}>{$diaR04}</td>
<td width="10mm" {$mesR05}>{$diaR05}</td>
<td width="10mm" {$mesR06}>{$diaR06}</td>
<td width="10mm" {$mesR07}>{$diaR07}</td>
<td width="10mm" {$mesR08}>{$diaR08}</td>
<td width="10mm" {$mesR09}>{$diaR09}</td>
<td width="10mm" {$mesR10}>{$diaR10}</td>
<td width="10mm" {$mesR11}>{$diaR11}</td>
<td width="10mm" {$mesR12}>{$diaR12}</td>
</tr>
EOD;
$n++;
}
$html .= <<<EOD
</tbody>
</table>
EOD;
# Declaramos una nueva tipografía para el pie de página del contenido
$pdf->SetFont('freesans', '', 10, '', true);
# $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
$qr = new \TCPDF2DBarcode($cadenaOriginal, 'QRCODE,M');
$imgdata = $qr->getBarcodePngData(2.5, 2.5, array(0, 0, 0));
file_put_contents('img/sistema/qr.png', $imgdata);
$html .= <<<EOD
<br>
<br>
<br>
<table width="100%" cellpadding="5" border="0">
<tbody>
<tr>
<td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
<td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
<td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
<td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
</tr>
<tr>
<td colspan="2" style="width: 75%">{$cadena64}</td>
<td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
</tr>
</tbody>
</table>
EOD;
# Imprimimos el contenido como HTML
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
ob_end_clean();
# ---------------------------------------------------------
# Mostramos el resultado en pantalla
$pdf->Output($pdf->formato . date('Ymd') . '.pdf', 'D');
}
#[Route('/ubicacion-excel', name: 'app_reporte_ubicacion_excel', methods: ['POST'])]
public function ubicacionExcel(UbicacionRepository $ubicacionRepository, Request $request): Response
{
ini_set('memory_limit', '5120M');
ini_set('max_execution_time', 0);
ini_set('output_buffering', 0);
# Obtenemos los datos de la petición
/** @var Usuario $user */
$user = $this->getUser();
$parameters = $request->request->get('unidad_filtro');
$unidad = (array_key_exists('unidad', $request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
# Obtenemos los datos del documento
$ubicaciones = $ubicacionRepository->ubicaUnidad($unidad);
# Definir el nombre temporal del archivo
$filePath = 'otro.xlsx';
# Se definen las cabeceras del archivo
$cabecera = WriterEntityFactory::createRowFromArray([
'ID.',
'Ubicación',
'Unidad',
'Estatus'
]);
# Se crea el arreglo con los datos del cuerpo del documento
$data = [];
$n = 1;
foreach ($ubicaciones as $ubicacion) {
/*$usuario = $ubicacion->getUsuario()->getNombre() . ' ' . $ubicacion->getUsuario()->getPapellido();
$ubicacion1 = $ubicacion->getUbicacion()->getArea();*/
$unidad = $ubicacion->getUnidad()->getNombre();
/*$activo = match ($ubicacion->getActivo()) {
"1" => 'Activo',
"0" => 'Inactivo',
default => ""
};*/
if ($ubicacion->getActivo() == 1) {
$activo = "Activo";
} else {
$activo = "Inactivo";
}
$data[] = WriterEntityFactory::createRowFromArray([
$ubicacion->getIdUbi(),
$ubicacion->getArea(),
$unidad,
$activo
//$ubicacion->getActivo()
//$usuario,
]);
$n++;
}
# Se crea el documento en formato CSV
$writer = WriterEntityFactory::createXLSXWriter();
$writer
->openToFile($filePath)
->addRow($cabecera)
->addRows($data)
->close()
;
$response = new BinaryFileResponse($filePath);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
'Ubicaciónes- ' . '_' . date('Y-m-d') . '.xlsx'
);
$response->deleteFileAfterSend(true);
return $response;
}
}