src/Controller/ReporteController.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Unidad;
  4. use App\Entity\Usuario;
  5. use App\Repository\EquipoRepository;
  6. use App\Repository\ImpresoraRepository;
  7. use App\Repository\OtroRepository;
  8. use App\Repository\RedRepository;
  9. use App\Repository\SolicitudRepository;
  10. use App\Repository\UbicacionRepository;
  11. use App\Service\DocumentoPDF;
  12. use App\Service\SelloDigital;
  13. use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
  14. use phpDocumentor\Reflection\Types\False_;
  15. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  16. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Response;
  19. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. #[Route('/reporte')]
  22. class   ReporteController extends AbstractController
  23. {
  24.     #[Route('/equipo-excel'name'app_reporte_equipo_excel'methods: ['POST'])]
  25.     public function equipoExcel(EquipoRepository $equipoRepositoryRequest $request): Response
  26.     {
  27.         ini_set('memory_limit''5120M');
  28.         ini_set('max_execution_time'0);
  29.         ini_set('output_buffering'0);
  30.         # Obtenemos los datos de la petición
  31.         /** @var Usuario $user */
  32.         $user $this->getUser();
  33.         $parameters $request->request->get('unidad_filtro');
  34.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  35.         # Obtenemos los datos del documento
  36.         $equipos $equipoRepository->equipoUnidad($unidad);
  37.         # Definir el nombre temporal del archivo
  38.         $filePath 'equipo.xlsx';
  39.         # Se definen las cabeceras del archivo
  40.         $cabecera WriterEntityFactory::createRowFromArray([
  41.             'No.',
  42.             'Estatus',
  43.             'Marbete',
  44.             'Marca',
  45.             'Modelo',
  46.             'Serie',
  47.             'Procesador',
  48.             'CPU velocidad',
  49.             'Núcleos',
  50.             'SSD',
  51.             'HDD',
  52.             'RAM',
  53.             'MAC',
  54.             'IP',
  55.             'EMHV',
  56.             'Monitor marbete',
  57.             'Monitor marca',
  58.             'Monitor modelo',
  59.             'Monitor serie',
  60.             'Monitor tipo',
  61.             'Monitor pulgadas',
  62.             'Teclado marca',
  63.             'Teclado modelo',
  64.             'Teclado serie',
  65.             'Mouse marca',
  66.             'Mouse modelo',
  67.             'Mouse serie',
  68.             'Uso',
  69.             'Función',
  70.             'Unidad',
  71.             'Ubicación',
  72.             'Usuario'
  73.         ]);
  74.         # Se crea el arreglo con los datos del cuerpo del documento
  75.         $data = [];
  76.         $n 1;
  77.         foreach ($equipos as $equipo) {
  78.             $usuario $equipo->getUsuario()->getNombre() . ' ' $equipo->getUsuario()->getPapellido();
  79.             $ubicacion $equipo->getUbicacion()->getArea();
  80.             $unidad $equipo->getUnidad()->getNombre();
  81.             $ssd "";
  82.             if ($equipo->getSsd() > || $equipo->getSsd() != ""){
  83.                 $ssd $equipo->getSsd() . ' Gb';
  84.             }
  85.             $uso = match ($equipo->getUso()) {
  86.                 "1" => "Educativo",
  87.                 "2" => "Docente",
  88.                 "3" => "Administrativo",
  89.                 default => ""
  90.             };
  91.             $funcion = match ($equipo->getFuncion()) {
  92.                 "1" => "Escritorio",
  93.                 "2" => "Servidor",
  94.                 default => ""
  95.             };
  96.             $estatus = match ($equipo->getEstatus()) {
  97.                 "1" => "En operación",
  98.                 "2" => "Descompuesto",
  99.                 "3" => "Sin instalar",
  100.                 "4" => "En proceso de baja",
  101.                 "5" => "Baja",
  102.                 default => ""
  103.             };
  104.             $emhv = match ($equipo->isEmhv()) {
  105.                 true => "Cumple",
  106.                 false => "No cumple",
  107.                 default => ""
  108.             };
  109.             $data[] = WriterEntityFactory::createRowFromArray([
  110.                 $n,
  111.                 $estatus,
  112.                 $equipo->getMarbete(),
  113.                 $equipo->getMarca(),
  114.                 $equipo->getModelo(),
  115.                 $equipo->getSerie(),
  116.                 $equipo->getProcesador(),
  117.                 $equipo->getCpuVelocidad(),
  118.                 $equipo->getNucleos(),
  119.                 $ssd,
  120.                 $equipo->getHhd(),
  121.                 $equipo->getRam(),
  122.                 $equipo->getMac(),
  123.                 $equipo->getIp(),
  124.                 $emhv,
  125.                 $equipo->getMonitorMarbete(),
  126.                 $equipo->getMonitorMarca(),
  127.                 $equipo->getMonitorModelo(),
  128.                 $equipo->getMonitorSerie(),
  129.                 $equipo->getMonitorTipo(),
  130.                 $equipo->getMonitorPulgadas(),
  131.                 $equipo->getTecladoMarca(),
  132.                 $equipo->getTecladoModelo(),
  133.                 $equipo->getTecladoSerie(),
  134.                 $equipo->getMouseMarca(),
  135.                 $equipo->getMouseModelo(),
  136.                 $equipo->getMouseSerie(),
  137.                 $uso,
  138.                 $funcion,
  139.                 $unidad,
  140.                 $ubicacion,
  141.                 $usuario
  142.             ]);
  143.             $n++;
  144.         }
  145.         # Se crea el documento en formato CSV
  146.         $writer WriterEntityFactory::createXLSXWriter();
  147.         $writer
  148.             ->openToFile($filePath)
  149.             ->addRow($cabecera)
  150.             ->addRows($data)
  151.             ->close()
  152.         ;
  153.         $response = new BinaryFileResponse($filePath);
  154.         $response->setContentDisposition(
  155.             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  156.             'equipo' '_' date('Y-m-d') . '.xlsx'
  157.         );
  158.         $response->deleteFileAfterSend(true);
  159.         return $response;
  160.     }
  161.     #[Route('/equipo-pdf'name'app_reporte_equipo_pdf'methods: ['POST'])]
  162.     public function equipoPDF(EquipoRepository $equipoRepositoryRequest $requestSelloDigital $sello)
  163.     {
  164.         ini_set('memory_limit''5120M');
  165.         ini_set('max_execution_time'0);
  166.         ini_set('output_buffering'0);
  167.         date_default_timezone_set('America/Mexico_City');
  168.         setlocale(LC_ALL'es_MX');
  169.         # Obtenemos los datos de la petición
  170.         /** @var Usuario $user */
  171.         $user $this->getUser();
  172.         $parameters $request->request->get('unidad_filtro');
  173.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  174.         $fecha date('d-m-Y H:i');
  175.         # Declaración de la instancia de TCPDF con el encabezado personalizado
  176.         $pdf = new DocumentoPDF();
  177.         if (empty($unidad)) {
  178.             $pdf->unidad "Todas las Unidades administrativas";
  179.         } else {
  180.             $uni $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
  181.             $pdf->unidad $uni->getNombre();
  182.         }
  183.         $pdf->codigo '15-528-PO-15-F18';
  184.         $pdf->revision '02';
  185.         $pdf->faprobacion '30/10/2022';
  186.         $pdf->fecha $fecha;
  187.         $pdf->formato 'FORMATO CE-1';
  188.         $pdf->nombre 'CONTROL DE EQUIPO DE CÓMPUTO';
  189.         $pdf->setPrintFooter(false);
  190.         # Obtenemos los datos del documento
  191.         $equipos $equipoRepository->equipoUnidad($unidad1);
  192.         $cadenaOriginal $pdf->formato '||';
  193.         $cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" $pdf->unidad;
  194.         $cadenaOriginal .= '||' $user->getNombre() . ' ' $user->getPapellido() . '||' $user->getCorreo() . '||' $user->getRol()->getNombre();
  195.         $cadenaOriginal .= '||' $fecha;
  196.         $cadena64 $sello->generar($cadenaOriginal);
  197.         # Información del documento
  198.         $pdf->SetCreator('Conalep Estado de México');
  199.         $pdf->SetAuthor('SIGMEC');
  200.         $pdf->SetTitle('Reporte');
  201.         # Definimos los saltos de página como automáticos
  202.         $pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);
  203.         #Nueva página con sus respectivas características
  204.         $pdf->AddPage('L''JIS_B4');
  205.         $pdf->SetY(50);
  206.         # Definimos la utilización de tipigrafías
  207.         $pdf->setFontSubsetting(true);
  208.         ### Generamos el contenido a mostrar ###
  209.         ob_start();
  210.         $html = <<<EOD
  211.         <table width="100%" cellpadding="2" border="0.1">
  212.         <thead>
  213.             <tr style="text-align: center; background-color: #e4e4e4; font-size: 9px">
  214.                 <td rowspan="2" style="width: 2%">#</td>
  215.                 <td rowspan="2">Estatus</td>
  216.                 <td colspan="9">CPU</td>
  217.                 <td colspan="6">Monitor</td>
  218.                 <td colspan="3">Teclado</td>
  219.                 <td colspan="3">Mouse</td>
  220.                 <td rowspan="2">Uso</td>
  221.                 <td rowspan="2" style="font-size: 7.5px">Función</td>
  222.                 <td rowspan="2" style="font-size: 7px">Ubicación</td>
  223.                 <td rowspan="2" style="font-size: 7.5px">Usuario</td>
  224.             </tr>
  225.             <tr style="text-align: center; background-color: #e4e4e4; font-size: 7px">
  226.                 <td>Marbete</td>
  227.                 <td>Marca</td>
  228.                 <td>Modelo</td>
  229.                 <td>Serie</td>
  230.                 <td style="font-size: 6px">Procesador</td>
  231.                 <td>SSD</td>
  232.                 <td>HDD</td>
  233.                 <td>RAM</td>
  234.                 <td>EMHV</td>
  235.                 <td>Marbete</td>
  236.                 <td>Marca</td>
  237.                 <td>Modelo</td>
  238.                 <td>Serie</td>
  239.                 <td>Tipo</td>
  240.                 <td>Pulgadas</td>
  241.                 <td>Marca</td>
  242.                 <td>Modelo</td>
  243.                 <td>Serie</td>
  244.                 <td>Marca</td>
  245.                 <td>Modelo</td>
  246.                 <td>Serie</td>
  247.             </tr>
  248.         </thead>
  249.         <tbody>
  250.         EOD;
  251.         $pdf->setMargins(10,50);
  252.         $n 1;
  253.         foreach ($equipos as $equipo) {
  254.             $usuario $equipo->getUsuario()->getNombre() . ' ' $equipo->getUsuario()->getPapellido();
  255.             $ubicacion $equipo->getUbicacion()->getArea();
  256.             $uso = match ($equipo->getUso()) {
  257.                 "1" => "Educativo",
  258.                 "2" => "Docente",
  259.                 "3" => "Administrativo",
  260.                 default => ""
  261.             };
  262.             $funcion = match ($equipo->getFuncion()) {
  263.                 "1" => "Escritorio",
  264.                 "2" => "Servidor",
  265.                 default => ""
  266.             };
  267.             $estatus = match ($equipo->getEstatus()) {
  268.                 "1" => "En operación",
  269.                 "2" => "Descompuesto",
  270.                 "3" => "Sin instalar",
  271.                 "4" => "En proceso de baja",
  272.                 "5" => "Baja",
  273.                 default => ""
  274.             };
  275.             $emhv = match ($equipo->isEmhv()) {
  276.                 true => "Si",
  277.                 false => "No",
  278.                 default => ""
  279.             };
  280.             $html .= <<<EOD
  281.             <tr style="font-size: 7px" nobr="true">
  282.                 <td style="width: 2%">{$n}</td>
  283.                 <td>{$estatus}</td>
  284.                 <td>{$equipo->getMarbete()}</td>
  285.                 <td>{$equipo->getMarca()}</td>
  286.                 <td>{$equipo->getModelo()}</td>
  287.                 <td>{$equipo->getSerie()}</td>
  288.                 <td>{$equipo->getProcesador()}</td>
  289.                 <td>{$equipo->getSsd()}</td>
  290.                 <td>{$equipo->getHhd()}</td>
  291.                 <td>{$equipo->getRam()}</td>
  292.                 <td>{$emhv}</td>
  293.                 <td>{$equipo->getMonitorMarbete()}</td>
  294.                 <td>{$equipo->getMonitorMarca()}</td>
  295.                 <td>{$equipo->getMonitorModelo()}</td>
  296.                 <td>{$equipo->getMonitorSerie()}</td>
  297.                 <td>{$equipo->getMonitorTipo()}</td>
  298.                 <td>{$equipo->getMonitorPulgadas()}</td>
  299.                 <td>{$equipo->getTecladoMarca()}</td>
  300.                 <td>{$equipo->getTecladoModelo()}</td>
  301.                 <td>{$equipo->getTecladoSerie()}</td>
  302.                 <td>{$equipo->getMouseMarca()}</td>
  303.                 <td>{$equipo->getMouseModelo()}</td>
  304.                 <td>{$equipo->getMouseSerie()}</td>
  305.                 <td>{$uso}</td>
  306.                 <td style="font-size: 6px">{$funcion}</td>
  307.                 <td style="font-size: 6px">{$ubicacion}</td>
  308.                 <td style="font-size: 6px">{$usuario}</td>
  309.             </tr>
  310.             EOD;
  311.             $n++;
  312.         }
  313.         $html .= <<<EOD
  314.                 </tbody>  
  315.             </table>
  316.         EOD;
  317.         # Declaramos una nueva tipografía para el pie de página del contenido
  318.         $pdf->SetFont('freesans'''10''true);
  319.         # $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
  320.         $qr = new \TCPDF2DBarcode($cadenaOriginal'QRCODE,M');
  321.         $imgdata $qr->getBarcodePngData(2.52.5, array(000));
  322.         file_put_contents('img/sistema/qr.png'$imgdata);
  323.         $html .=
  324.             <<<EOD
  325. <br>
  326. <br>
  327. <br>
  328. <table width="100%" cellpadding="5" border="0">
  329.     <tbody>
  330.         <tr>
  331.             <td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
  332.             <td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
  333.             <td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
  334.             <td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
  335.         </tr>
  336.         <tr>
  337.             <td colspan="2" style="width: 75%">{$cadena64}</td>
  338.             <td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
  339.         </tr>
  340.     </tbody>
  341. </table>
  342. EOD;
  343.         # Imprimimos el contenido como HTML
  344.         $pdf->writeHTMLCell($w=0$h=0$x=''$y=''$html$border=0$ln=1$fill=0$reseth=true$align=''$autopadding=true);
  345.         ob_end_clean();
  346.         # ---------------------------------------------------------
  347.         # Mostramos el resultado en pantalla
  348.         $pdf->Output($pdf->formato date('Ymd') . '.pdf''D');
  349.     }
  350.     #[Route('/impresora-excel'name'app_reporte_impresora_excel'methods: ['POST'])]
  351.     public function impresoraExcel(ImpresoraRepository $impresoraRepositoryRequest $request): Response
  352.     {
  353.         ini_set('memory_limit''5120M');
  354.         ini_set('max_execution_time'0);
  355.         ini_set('output_buffering'0);
  356.         # Obtenemos los datos de la petición
  357.         /** @var Usuario $user */
  358.         $user $this->getUser();
  359.         $parameters $request->request->get('unidad_filtro');
  360.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  361.         # Obtenemos los datos del documento
  362.         $impresoras $impresoraRepository->impresoraUnidad($unidad);
  363.         # Definir el nombre temporal del archivo
  364.         $filePath 'impresora.xlsx';
  365.         # Se definen las cabeceras del archivo
  366.         $cabecera WriterEntityFactory::createRowFromArray([
  367.             'No.',
  368.             'Estatus',
  369.             'Marbete',
  370.             'Marca',
  371.             'Modelo',
  372.             'Serie',
  373.             'Tipo',
  374.             'Uso',
  375.             'MAC',
  376.             'IP',
  377.             'Unidad',
  378.             'Ubicación',
  379.             'Usuario'
  380.         ]);
  381.         # Se crea el arreglo con los datos del cuerpo del documento
  382.         $data = [];
  383.         $n 1;
  384.         foreach ($impresoras as $impresora) {
  385.             $usuario $impresora->getUsuario()->getNombre() . ' ' $impresora->getUsuario()->getPapellido();
  386.             $ubicacion $impresora->getUbicacion()->getArea();
  387.             $unidad $impresora->getUnidad()->getNombre();
  388.             $tipo = match ($impresora->getTipo()) {
  389.                 "0" => "Laser",
  390.                 "1" => "Matriz",
  391.                 "2" => "Tinta",
  392.                 default => ""
  393.             };
  394.             $uso = match ($impresora->getUso()) {
  395.                 "1" => "Educativo",
  396.                 "2" => "Docente",
  397.                 "3" => "Administrativo",
  398.                 default => ""
  399.             };
  400.             $estatus = match ($impresora->getEstatus()) {
  401.                 "1" => "En operación",
  402.                 "2" => "Descompuesto",
  403.                 "3" => "Sin instalar",
  404.                 "4" => "En proceso de baja",
  405.                 "5" => "Baja",
  406.                 default => ""
  407.             };
  408.             $data[] = WriterEntityFactory::createRowFromArray([
  409.                 $n,
  410.                 $estatus,
  411.                 $impresora->getMarbete(),
  412.                 $impresora->getMarca(),
  413.                 $impresora->getModelo(),
  414.                 $impresora->getSerie(),
  415.                 $tipo,
  416.                 $uso,
  417.                 $impresora->getMac(),
  418.                 $impresora->getIp(),
  419.                 $unidad,
  420.                 $ubicacion,
  421.                 $usuario
  422.             ]);
  423.             $n++;
  424.         }
  425.         # Se crea el documento en formato CSV
  426.         $writer WriterEntityFactory::createXLSXWriter();
  427.         $writer
  428.             ->openToFile($filePath)
  429.             ->addRow($cabecera)
  430.             ->addRows($data)
  431.             ->close()
  432.         ;
  433.         $response = new BinaryFileResponse($filePath);
  434.         $response->setContentDisposition(
  435.             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  436.             'impresora' '_' date('Y-m-d') . '.xlsx'
  437.         );
  438.         $response->deleteFileAfterSend(true);
  439.         return $response;
  440.     }
  441.     #[Route('/impresora-pdf'name'app_reporte_impresora_pdf'methods: ['POST'])]
  442.     public function impresoraPDF(ImpresoraRepository $impresoraRepositoryRequest $requestSelloDigital $sello)
  443.     {
  444.         ini_set('memory_limit''5120M');
  445.         ini_set('max_execution_time'0);
  446.         ini_set('output_buffering'0);
  447.         date_default_timezone_set('America/Mexico_City');
  448.         setlocale(LC_ALL'es_MX');
  449.         # Obtenemos los datos de la petición
  450.         /** @var Usuario $user */
  451.         $user $this->getUser();
  452.         $parameters $request->request->get('unidad_filtro');
  453.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  454.         $fecha date('d-m-Y H:i');
  455.         # Declaración de la instancia de TCPDF con el encabezado personalizado
  456.         $pdf = new DocumentoPDF();
  457.         if (empty($unidad)) {
  458.             $pdf->unidad "Todas las Unidades administrativas";
  459.         } else {
  460.             $uni $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
  461.             $pdf->unidad $uni->getNombre();
  462.         }
  463.         $pdf->codigo '15-528-PO-15-F18';
  464.         $pdf->revision '02';
  465.         $pdf->faprobacion '30/10/2022';
  466.         $pdf->fecha $fecha;
  467.         $pdf->formato 'FORMATO CE-2';
  468.         $pdf->nombre 'CONTROL DE IMPRESORAS';
  469.         $pdf->setPrintFooter(false);
  470.         # Obtenemos los datos del documento
  471.         $impresoras $impresoraRepository->impresoraUnidad($unidad1);
  472.         $cadenaOriginal $pdf->formato '||';
  473.         $cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" $pdf->unidad;
  474.         $cadenaOriginal .= '||' $user->getNombre() . ' ' $user->getPapellido() . '||' $user->getCorreo() . '||' $user->getRol()->getNombre();
  475.         $cadenaOriginal .= '||' $fecha;
  476.         $cadena64 $sello->generar($cadenaOriginal);
  477.         # Información del documento
  478.         $pdf->SetCreator('Conalep Estado de México');
  479.         $pdf->SetAuthor('SIGMEC');
  480.         $pdf->SetTitle('Reporte');
  481.         # Definimos los saltos de página como automáticos
  482.         #$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  483.         #Nueva página con sus respectivas características
  484.         $pdf->AddPage('L''LEGAL');
  485.         $pdf->SetY(50);
  486.         # Definimos la utilización de tipigrafías
  487.         $pdf->setFontSubsetting(true);
  488.         ### Generamos el contenido a mostrar ###
  489.         ob_start();
  490.         $html = <<<EOD
  491.         <table cellpadding="2" border="0.1" width="100%">
  492.         <thead>
  493.             <tr style="text-align: center; background-color: #e4e4e4; font-size: 11px">
  494.                 <td style="width: 5%">No.</td>
  495.                 <td>Estatus</td>
  496.                 <td>Marbete</td>
  497.                 <td>Marca</td>
  498.                 <td>Modelo</td>
  499.                 <td>Serie</td>
  500.                 <td>Tipo</td>
  501.                 <td>Uso</td>
  502.                 <td>Ubicación</td>
  503.                 <td>Usuario</td>
  504.             </tr>
  505.         </thead>
  506.         <tbody>
  507.         EOD;
  508.         $pdf->setMargins(10,50);
  509.         $n 1;
  510.         foreach ($impresoras as $impresora) {
  511.             $usuario $impresora->getUsuario()->getNombre() . ' ' $impresora->getUsuario()->getPapellido();
  512.             $ubicacion $impresora->getUbicacion()->getArea();
  513.             $tipo = match ($impresora->getTipo()) {
  514.                 '0' => '<span>Laser</span>',
  515.                 '1' => '<span>Matriz</span>',
  516.                 '2' => '<span>Tinta</span>',
  517.                 default => ""
  518.             };
  519.             $uso = match ($impresora->getUso()) {
  520.                 "1" => "Educativo",
  521.                 "2" => "Docente",
  522.                 "3" => "Administrativo",
  523.                 default => ""
  524.             };
  525.             $estatus = match ($impresora->getEstatus()) {
  526.                 "1" => "En operación",
  527.                 "2" => "Descompuesto",
  528.                 "3" => "Sin instalar",
  529.                 "4" => "En proceso de baja",
  530.                 "5" => "Baja",
  531.                 default => ""
  532.             };
  533.             $html .= <<<EOD
  534.             <tr style="font-size: 10px" nobr="true">
  535.                 <td style="width: 5%">{$n}</td>
  536.                 <td>{$estatus}</td>
  537.                 <td>{$impresora->getMarbete()}</td>
  538.                 <td>{$impresora->getMarca()}</td>
  539.                 <td>{$impresora->getModelo()}</td>
  540.                 <td>{$impresora->getSerie()}</td>
  541.                 <td>{$tipo}</td>
  542.                 <td>{$uso}</td>
  543.                 <td>{$ubicacion}</td>
  544.                 <td>{$usuario}</td>
  545.             </tr>
  546.             EOD;
  547.             $n++;
  548.         }
  549.         $html .= <<<EOD
  550.                 </tbody>  
  551.             </table>
  552.         EOD;
  553.         # Declaramos una nueva tipografía para el pie de página del contenido
  554.         $pdf->SetFont('freesans'''10''true);
  555.         # $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
  556.         $qr = new \TCPDF2DBarcode($cadenaOriginal'QRCODE,M');
  557.         $imgdata $qr->getBarcodePngData(2.52.5, array(000));
  558.         file_put_contents('img/sistema/qr.png'$imgdata);
  559.         $html .= <<<EOD
  560.             <br>
  561.             <br>
  562.             <br>
  563.             <table width="100%" cellpadding="5" border="0">
  564.                 <tbody>
  565.                     <tr>
  566.                         <td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
  567.                         <td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
  568.                         <td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
  569.                         <td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
  570.                     </tr>
  571.                     <tr>
  572.                         <td colspan="2" style="width: 75%">{$cadena64}</td>
  573.                         <td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
  574.                     </tr>
  575.                 </tbody>
  576.             </table>
  577.         EOD;
  578.         # Imprimimos el contenido como HTML
  579.         $pdf->writeHTMLCell($w=0$h=0$x=''$y=''$html$border=0$ln=1$fill=0$reseth=true$align=''$autopadding=true);
  580.         ob_end_clean();
  581.         # ---------------------------------------------------------
  582.         # Mostramos el resultado en pantalla
  583.         $pdf->Output($pdf->formato date('Ymd') . '.pdf''D');
  584.     }
  585.     #[Route('/otro-excel'name'app_reporte_otro_excel'methods: ['POST'])]
  586.     public function otroExcel(OtroRepository $otroRepositoryRequest $request): Response
  587.     {
  588.         ini_set('memory_limit''5120M');
  589.         ini_set('max_execution_time'0);
  590.         ini_set('output_buffering'0);
  591.         # Obtenemos los datos de la petición
  592.         /** @var Usuario $user */
  593.         $user $this->getUser();
  594.         $parameters $request->request->get('unidad_filtro');
  595.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  596.         # Obtenemos los datos del documento
  597.         $otros $otroRepository->otroUnidad($unidad);
  598.         # Definir el nombre temporal del archivo
  599.         $filePath 'otro.xlsx';
  600.         # Se definen las cabeceras del archivo
  601.         $cabecera WriterEntityFactory::createRowFromArray([
  602.             'No.',
  603.             'Estatus',
  604.             'Marbete',
  605.             'Descripción',
  606.             'Marca',
  607.             'Modelo',
  608.             'Serie',
  609.             'Uso',
  610.             'MAC',
  611.             'IP',
  612.             'Unidad',
  613.             'Ubicación',
  614.             'Usuario'
  615.         ]);
  616.         # Se crea el arreglo con los datos del cuerpo del documento
  617.         $data = [];
  618.         $n 1;
  619.         foreach ($otros as $otro) {
  620.             $usuario $otro->getUsuario()->getNombre() . ' ' $otro->getUsuario()->getPapellido();
  621.             $ubicacion $otro->getUbicacion()->getArea();
  622.             $unidad $otro->getUnidad()->getNombre();
  623.             $uso = match ($otro->getUso()) {
  624.                 "1" => "Educativo",
  625.                 "2" => "Docente",
  626.                 "3" => "Administrativo",
  627.                 default => ""
  628.             };
  629.             $estatus = match ($otro->getEstatus()) {
  630.                 "1" => "En operación",
  631.                 "2" => "Descompuesto",
  632.                 "3" => "Sin instalar",
  633.                 "4" => "En proceso de baja",
  634.                 "5" => "Baja",
  635.                 default => ""
  636.             };
  637.             $data[] = WriterEntityFactory::createRowFromArray([
  638.                 $n,
  639.                 $estatus,
  640.                 $otro->getMarbete(),
  641.                 $otro->getDescripcion(),
  642.                 $otro->getMarca(),
  643.                 $otro->getModelo(),
  644.                 $otro->getSerie(),
  645.                 $uso,
  646.                 $otro->getMac(),
  647.                 $otro->getIp(),
  648.                 $unidad,
  649.                 $ubicacion,
  650.                 $usuario
  651.             ]);
  652.             $n++;
  653.         }
  654.         # Se crea el documento en formato CSV
  655.         $writer WriterEntityFactory::createXLSXWriter();
  656.         $writer
  657.             ->openToFile($filePath)
  658.             ->addRow($cabecera)
  659.             ->addRows($data)
  660.             ->close()
  661.         ;
  662.         $response = new BinaryFileResponse($filePath);
  663.         $response->setContentDisposition(
  664.             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  665.             'otro' '_' date('Y-m-d') . '.xlsx'
  666.         );
  667.         $response->deleteFileAfterSend(true);
  668.         return $response;
  669.     }
  670.     #[Route('/otro-pdf'name'app_reporte_otro_pdf'methods: ['POST'])]
  671.     public function otroPDF(OtroRepository $otroRepositoryRequest $requestSelloDigital $sello)
  672.     {
  673.         ini_set('memory_limit''5120M');
  674.         ini_set('max_execution_time'0);
  675.         ini_set('output_buffering'0);
  676.         date_default_timezone_set('America/Mexico_City');
  677.         setlocale(LC_ALL'es_MX');
  678.         # Obtenemos los datos de la petición
  679.         /** @var Usuario $user */
  680.         $user $this->getUser();
  681.         $parameters $request->request->get('unidad_filtro');
  682.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  683.         $fecha date('d-m-Y H:i');
  684.         # Declaración de la instancia de TCPDF con el encabezado personalizado
  685.         $pdf = new DocumentoPDF();
  686.         if (empty($unidad)) {
  687.             $pdf->unidad "Todas las Unidades administrativas";
  688.         } else {
  689.             $uni $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
  690.             $pdf->unidad $uni->getNombre();
  691.         }
  692.         $pdf->codigo '15-528-PO-15-F18';
  693.         $pdf->revision '02';
  694.         $pdf->faprobacion '30/10/2022';
  695.         $pdf->fecha $fecha;
  696.         $pdf->formato 'FORMATO CE-3';
  697.         $pdf->nombre 'CONTROL DE OTROS BIENES INFORMÁTICOS';
  698.         $pdf->setPrintFooter(false);
  699.         # Obtenemos los datos del documento
  700.         $otros $otroRepository->otroUnidad($unidad1);
  701.         $cadenaOriginal $pdf->formato '||';
  702.         $cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" $pdf->unidad;
  703.         $cadenaOriginal .= '||' $user->getNombre() . ' ' $user->getPapellido() . '||' $user->getCorreo() . '||' $user->getRol()->getNombre();
  704.         $cadenaOriginal .= '||' $fecha;
  705.         $cadena64 $sello->generar($cadenaOriginal);
  706.         # Información del documento
  707.         $pdf->SetCreator('Conalep Estado de México');
  708.         $pdf->SetAuthor('SIGMEC');
  709.         $pdf->SetTitle('Reporte');
  710.         # Definimos los saltos de página como automáticos
  711.         #$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  712.         #Nueva página con sus respectivas características
  713.         $pdf->AddPage('L''LEGAL');
  714.         $pdf->SetY(50);
  715.         # Definimos la utilización de tipigrafías
  716.         $pdf->setFontSubsetting(true);
  717.         ### Generamos el contenido a mostrar ###
  718.         ob_start();
  719.         $html = <<<EOD
  720.         <table cellpadding="2" border="0.1">
  721.         <thead>
  722.             <tr style="text-align: center; background-color: #e4e4e4; font-size: 11px">
  723.                 <td style="width: 5%">No.</td>
  724.                 <td>Estatus</td>
  725.                 <td>Marbete</td>
  726.                 <td>Descripción</td>
  727.                 <td>Marca</td>
  728.                 <td>Modelo</td>
  729.                 <td>Serie</td>
  730.                 <td>Uso</td>
  731.                 <td>Ubicación</td>
  732.                 <td>Usuario</td>
  733.             </tr>
  734.         </thead>
  735.         <tbody>
  736.         EOD;
  737.         $pdf->setMargins(10,50);
  738.         $n 1;
  739.         foreach ($otros as $otro) {
  740.             $usuario $otro->getUsuario()->getNombre() . ' ' $otro->getUsuario()->getPapellido();
  741.             $ubicacion $otro->getUbicacion()->getArea();
  742.             $uso = match ($otro->getUso()) {
  743.                 "1" => "Educativo",
  744.                 "2" => "Docente",
  745.                 "3" => "Administrativo",
  746.                 default => ""
  747.             };
  748.             $estatus = match ($otro->getEstatus()) {
  749.                 "1" => "En operación",
  750.                 "2" => "Descompuesto",
  751.                 "3" => "Sin instalar",
  752.                 "4" => "En proceso de baja",
  753.                 "5" => "Baja",
  754.                 default => ""
  755.             };
  756.             $html .= <<<EOD
  757.             <tr style="font-size: 10px" nobr="true">
  758.                 <td style="width: 5%">{$n}</td>
  759.                 <td>{$estatus}</td>
  760.                 <td>{$otro->getMarbete()}</td>
  761.                 <td>{$otro->getDescripcion()}</td>
  762.                 <td>{$otro->getMarca()}</td>
  763.                 <td>{$otro->getModelo()}</td>
  764.                 <td>{$otro->getSerie()}</td>
  765.                 <td>{$uso}</td>
  766.                 <td>{$ubicacion}</td>
  767.                 <td>{$usuario}</td>
  768.             </tr>
  769.             EOD;
  770.             $n++;
  771.         }
  772.         $html .= <<<EOD
  773.                 </tbody>  
  774.             </table>
  775.         EOD;
  776.         # Declaramos una nueva tipografía para el pie de página del contenido
  777.         $pdf->SetFont('freesans'''10''true);
  778.         # $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
  779.         $qr = new \TCPDF2DBarcode($cadenaOriginal'QRCODE,M');
  780.         $imgdata $qr->getBarcodePngData(2.52.5, array(000));
  781.         file_put_contents('img/sistema/qr.png'$imgdata);
  782.         $html .= <<<EOD
  783.             <br>
  784.             <br>
  785.             <br>
  786.             <table width="100%" cellpadding="5" border="0">
  787.                 <tbody>
  788.                     <tr>
  789.                         <td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
  790.                         <td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
  791.                         <td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
  792.                         <td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
  793.                     </tr>
  794.                     <tr>
  795.                         <td colspan="2" style="width: 75%">{$cadena64}</td>
  796.                         <td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
  797.                     </tr>
  798.                 </tbody>
  799.             </table>
  800.         EOD;
  801.         # Imprimimos el contenido como HTML
  802.         $pdf->writeHTMLCell($w=0$h=0$x=''$y=''$html$border=0$ln=1$fill=0$reseth=true$align=''$autopadding=true);
  803.         ob_end_clean();
  804.         # ---------------------------------------------------------
  805.         # Mostramos el resultado en pantalla
  806.         $pdf->Output($pdf->formato date('Ymd') . '.pdf''D');
  807.     }
  808.     #[Route('/red-excel'name'app_reporte_red_excel'methods: ['POST'])]
  809.     public function redExcel(RedRepository $redRepositoryRequest $request): Response
  810.     {
  811.         ini_set('memory_limit''5120M');
  812.         ini_set('max_execution_time'0);
  813.         ini_set('output_buffering'0);
  814.         # Obtenemos los datos de la petición
  815.         /** @var Usuario $user */
  816.         $user $this->getUser();
  817.         $parameters $request->request->get('unidad_filtro');
  818.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  819.         # Obtenemos los datos del documento
  820.         $redes $redRepository->redUnidad($unidad);
  821.         # Definir el nombre temporal del archivo
  822.         $filePath 'red.xlsx';
  823.         # Se definen las cabeceras del archivo
  824.         $cabecera WriterEntityFactory::createRowFromArray([
  825.             'No.',
  826.             'Estatus',
  827.             'Marbete (opcional)',
  828.             'Descripción',
  829.             'Marca',
  830.             'Modelo',
  831.             'Serie',
  832.             'Velocidad',
  833.             'Puertos',
  834.             'Uso',
  835.             'MAC',
  836.             'IP',
  837.             'Unidad',
  838.             'Ubicación',
  839.             'Usuario'
  840.         ]);
  841.         # Se crea el arreglo con los datos del cuerpo del documento
  842.         $data = [];
  843.         $n 1;
  844.         foreach ($redes as $red) {
  845.             $usuario $red->getUsuario()->getNombre() . ' ' $red->getUsuario()->getPapellido();
  846.             $ubicacion $red->getUbicacion()->getArea();
  847.             $unidad $red->getUnidad()->getNombre();
  848.             $uso = match ($red->getUso()) {
  849.                 "1" => "Educativo",
  850.                 "2" => "Docente",
  851.                 "3" => "Administrativo",
  852.                 default => ""
  853.             };
  854.             $estatus = match ($red->getEstatus()) {
  855.                 "1" => "En operación",
  856.                 "2" => "Descompuesto",
  857.                 "3" => "Sin instalar",
  858.                 "4" => "En proceso de baja",
  859.                 "5" => "Baja",
  860.                 default => ""
  861.             };
  862.             $data[] = WriterEntityFactory::createRowFromArray([
  863.                 $n,
  864.                 $estatus,
  865.                 $red->getMarbete(),
  866.                 $red->getDescripcion(),
  867.                 $red->getMarca(),
  868.                 $red->getModelo(),
  869.                 $red->getSerie(),
  870.                 $red->getVelocidad(),
  871.                 $red->getPuertos(),
  872.                 $uso,
  873.                 $red->getMac(),
  874.                 $red->getIp(),
  875.                 $unidad,
  876.                 $ubicacion,
  877.                 $usuario
  878.             ]);
  879.             $n++;
  880.         }
  881.         # Se crea el documento en formato CSV
  882.         $writer WriterEntityFactory::createXLSXWriter();
  883.         $writer
  884.             ->openToFile($filePath)
  885.             ->addRow($cabecera)
  886.             ->addRows($data)
  887.             ->close()
  888.         ;
  889.         $response = new BinaryFileResponse($filePath);
  890.         $response->setContentDisposition(
  891.             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  892.             'red' '_' date('Y-m-d') . '.xlsx'
  893.         );
  894.         $response->deleteFileAfterSend(true);
  895.         return $response;
  896.     }
  897.     #[Route('/red-pdf'name'app_reporte_red_pdf'methods: ['POST'])]
  898.     public function redPDF(RedRepository $redRepositoryRequest $requestSelloDigital $sello)
  899.     {
  900.         ini_set('memory_limit''5120M');
  901.         ini_set('max_execution_time'0);
  902.         ini_set('output_buffering'0);
  903.         date_default_timezone_set('America/Mexico_City');
  904.         setlocale(LC_ALL'es_MX');
  905.         # Obtenemos los datos de la petición
  906.         /** @var Usuario $user */
  907.         $user $this->getUser();
  908.         $parameters $request->request->get('unidad_filtro');
  909.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  910.         $fecha date('d-m-Y H:i');
  911.         # Declaración de la instancia de TCPDF con el encabezado personalizado
  912.         $pdf = new DocumentoPDF();
  913.         if (empty($unidad)) {
  914.             $pdf->unidad "Todas las Unidades administrativas";
  915.         } else {
  916.             $uni $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $unidad]);
  917.             $pdf->unidad $uni->getNombre();
  918.         }
  919.         $pdf->codigo '15-528-PO-15-F18';
  920.         $pdf->revision '02';
  921.         $pdf->faprobacion '30/10/2022';
  922.         $pdf->fecha $fecha;
  923.         $pdf->formato 'FORMATO CE-4';
  924.         $pdf->nombre 'CONTROL DE ACTIVOS DE COMUNICACIÓN';
  925.         $pdf->setPrintFooter(false);
  926.         # Obtenemos los datos del documento
  927.         $redes $redRepository->redUnidad($unidad1);
  928.         $cadenaOriginal $pdf->formato '||';
  929.         $cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" $pdf->unidad;
  930.         $cadenaOriginal .= '||' $user->getNombre() . ' ' $user->getPapellido() . '||' $user->getCorreo() . '||' $user->getRol()->getNombre();
  931.         $cadenaOriginal .= '||' $fecha;
  932.         $cadena64 $sello->generar($cadenaOriginal);
  933.         # Información del documento
  934.         $pdf->SetCreator('Conalep Estado de México');
  935.         $pdf->SetAuthor('SIGMEC');
  936.         $pdf->SetTitle('Reporte');
  937.         # Definimos los saltos de página como automáticos
  938.         #$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  939.         #Nueva página con sus respectivas características
  940.         $pdf->AddPage('L''LEGAL');
  941.         $pdf->SetY(50);
  942.         # Definimos la utilización de tipigrafías
  943.         $pdf->setFontSubsetting(true);
  944.         ### Generamos el contenido a mostrar ###
  945.         ob_start();
  946.         $html = <<<EOD
  947.         <table cellpadding="2" border="0.1">
  948.         <thead>
  949.             <tr style="text-align: center; background-color: #e4e4e4; font-size: 11px">
  950.                 <td style="width: 5%">No.</td>
  951.                 <td>Estatus</td>
  952.                 <td>Marbete (opcional)</td>
  953.                 <td>Descripción</td>
  954.                 <td>Marca</td>
  955.                 <td>Modelo</td>
  956.                 <td>Serie</td>
  957.                 <td>Velocidad</td>
  958.                 <td>Puertos</td>
  959.                 <td>Uso</td>
  960.                 <td>Ubicación</td>
  961.                 <td>Usuario</td>
  962.             </tr>
  963.         </thead>
  964.         <tbody>
  965.         EOD;
  966.         $pdf->setMargins(10,50);
  967.         $n 1;
  968.         foreach ($redes as $red) {
  969.             $usuario $red->getUsuario()->getNombre() . ' ' $red->getUsuario()->getPapellido();
  970.             $ubicacion $red->getUbicacion()->getArea();
  971.             $uso = match ($red->getUso()) {
  972.                 "1" => "Educativo",
  973.                 "2" => "Docente",
  974.                 "3" => "Administrativo",
  975.                 default => ""
  976.             };
  977.             $estatus = match ($red->getEstatus()) {
  978.                 "1" => "En operación",
  979.                 "2" => "Descompuesto",
  980.                 "3" => "Sin instalar",
  981.                 "4" => "En proceso de baja",
  982.                 "5" => "Baja",
  983.                 default => ""
  984.             };
  985.             $html .= <<<EOD
  986.             <tr style="font-size: 10px" nobr="true">
  987.                 <td style="width: 5%">{$n}</td>
  988.                 <td>{$estatus}</td>
  989.                 <td>{$red->getMarbete()}</td>
  990.                 <td>{$red->getDescripcion()}</td>
  991.                 <td>{$red->getMarca()}</td>
  992.                 <td>{$red->getModelo()}</td>
  993.                 <td>{$red->getSerie()}</td>
  994.                 <td>{$red->getVelocidad()}</td>
  995.                 <td>{$red->getPuertos()}</td>
  996.                 <td>{$uso}</td>
  997.                 <td>{$ubicacion}</td>
  998.                 <td>{$usuario}</td>
  999.             </tr>
  1000.             EOD;
  1001.             $n++;
  1002.         }
  1003.         $html .= <<<EOD
  1004.                 </tbody>  
  1005.             </table>
  1006.         EOD;
  1007.         # Declaramos una nueva tipografía para el pie de página del contenido
  1008.         $pdf->SetFont('freesans'''10''true);
  1009.         # $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
  1010.         $qr = new \TCPDF2DBarcode($cadenaOriginal'QRCODE,M');
  1011.         $imgdata $qr->getBarcodePngData(2.52.5, array(000));
  1012.         file_put_contents('img/sistema/qr.png'$imgdata);
  1013.         $html .= <<<EOD
  1014.             <br>
  1015.             <br>
  1016.             <br>
  1017.             <table width="100%" cellpadding="5" border="0">
  1018.                 <tbody>
  1019.                     <tr>
  1020.                         <td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
  1021.                         <td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
  1022.                         <td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
  1023.                         <td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
  1024.                     </tr>
  1025.                     <tr>
  1026.                         <td colspan="2" style="width: 75%">{$cadena64}</td>
  1027.                         <td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
  1028.                     </tr>
  1029.                 </tbody>
  1030.             </table>
  1031.         EOD;
  1032.         # Imprimimos el contenido como HTML
  1033.         $pdf->writeHTMLCell($w=0$h=0$x=''$y=''$html$border=0$ln=1$fill=0$reseth=true$align=''$autopadding=true);
  1034.         ob_end_clean();
  1035.         # ---------------------------------------------------------
  1036.         # Mostramos el resultado en pantalla
  1037.         $pdf->Output($pdf->formato date('Ymd') . '.pdf''I');
  1038.     }
  1039.     #[Route('/pamp-excel'name'app_reporte_pamp_excel'methods: ['POST'])]
  1040.     public function pampExcel(SolicitudRepository $solRepRequest $request): Response
  1041.     {
  1042.         ini_set('memory_limit''5120M');
  1043.         ini_set('max_execution_time'0);
  1044.         ini_set('output_buffering'0);
  1045.         # Obtenemos los datos de la petición
  1046.         /** @var Usuario $user */
  1047.         $user $this->getUser();
  1048.         $parameters $request->request->get('pamp_filtro');
  1049.         $unidad = (array_key_exists('unidad'$request->request->all()['pamp_filtro'])) ? $parameters['unidad'] : $user->getUnidad()->getIdUni();
  1050.         $finicio $parameters['anio'] . '-01-01';
  1051.         $ffin $parameters['anio'] . '-12-31';
  1052.         # Obtenemos los datos del documento
  1053.         $solicitudes $solRep->registroTipoEquipoUsuario(null4$unidad$finicio$ffin);
  1054.         # Definir el nombre temporal del archivo
  1055.         $filePath 'pamp.xlsx';
  1056.         # Se definen las cabeceras del archivo
  1057.         $cabecera WriterEntityFactory::createRowFromArray([
  1058.             'No.',
  1059.             'Solicitud',
  1060.             'Periodo',
  1061.             'Tipo equipo',
  1062.             'Marbete',
  1063.             'Marca',
  1064.             'Modelo',
  1065.             'Serie',
  1066.             'Descripción',
  1067.             'Unidad adminstrativa',
  1068.             'Ubicación',
  1069.             'Trabajo a realizar',
  1070.             'Fecha registro',
  1071.             'Fecha atención',
  1072.             'Fecha de finalización',
  1073.             'Servicio realizado',
  1074.             'Refacciones',
  1075.             'Resguardatario',
  1076.             'Correo resguardatario',
  1077.             'Gestor',
  1078.             'Correo gestor',
  1079.             'Estatus'
  1080.         ]);
  1081.         # Se crea el arreglo con los datos del cuerpo del documento
  1082.         $data = [];
  1083.         $n 1;
  1084.         foreach ($solicitudes as $solicitud) {
  1085.             if ($solicitud['tipo_mantenimiento'] == 'MP') {
  1086.                 $estatus = match ($solicitud['estatus']) {
  1087.                     "1" => "Pendiente",
  1088.                     "2" => "En Proceso",
  1089.                     "3" => "Atendido",
  1090.                     "4" => "Evaluado",
  1091.                     default => ""
  1092.                 };
  1093.                 $data[] = WriterEntityFactory::createRowFromArray([
  1094.                     $n,
  1095.                     $solicitud['id_sol'],
  1096.                     $solicitud['periodo'],
  1097.                     $solicitud['tipo_equipo'],
  1098.                     $solicitud['marbete'],
  1099.                     $solicitud['marca'],
  1100.                     $solicitud['modelo'],
  1101.                     $solicitud['serie'],
  1102.                     $solicitud['descripcion'],
  1103.                     $solicitud['nunidad'],
  1104.                     $solicitud['nubicacion'],
  1105.                     $solicitud['falla'],
  1106.                     $solicitud['fregistro'],
  1107.                     $solicitud['fatencion'],
  1108.                     $solicitud['ffin'],
  1109.                     $solicitud['srealizado'],
  1110.                     $solicitud['refacciones'],
  1111.                     $solicitud['unombre'] . ' ' $solicitud['uapellido'],
  1112.                     $solicitud['ucorreo'],
  1113.                     $solicitud['gnombre'] . ' ' $solicitud['gapellido'],
  1114.                     $solicitud['gcorreo'],
  1115.                     $estatus,
  1116.                 ]);
  1117.                 $n++;
  1118.             }
  1119.         }
  1120.         # Se crea el documento en formato CSV
  1121.         $writer WriterEntityFactory::createXLSXWriter();
  1122.         $writer
  1123.             ->openToFile($filePath)
  1124.             ->addRow($cabecera)
  1125.             ->addRows($data)
  1126.             ->close()
  1127.         ;
  1128.         $response = new BinaryFileResponse($filePath);
  1129.         $response->setContentDisposition(
  1130.             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  1131.             'pamp' '_' date('Y-m-d') . '.xlsx'
  1132.         );
  1133.         $response->deleteFileAfterSend(true);
  1134.         return $response;
  1135.     }
  1136.     #[Route('/pamp-pdf'name'app_reporte_pamp_pdf'methods: ['POST'])]
  1137.     public function pampPDF(SolicitudRepository $solRepRequest $requestSelloDigital $sello)
  1138.     {
  1139.         ini_set('memory_limit''5120M');
  1140.         ini_set('max_execution_time'0);
  1141.         ini_set('output_buffering'0);
  1142.         date_default_timezone_set('America/Mexico_City');
  1143.         setlocale(LC_ALL'es_MX');
  1144.         # Se obtiene el nivel de acceso
  1145.         $perfil $request->getSession()->get('perfil');
  1146.         $nivel $perfil[9]["nivel"];
  1147.         # Obtenemos los datos de la petición
  1148.         /** @var Usuario $user */
  1149.         $user $this->getUser();
  1150.         $parameters $request->request->get('pamp_filtro');
  1151.         if (empty($parameters)) {
  1152.             $uni "";
  1153.             $year date('Y');
  1154.         } else {
  1155.             $uni = (array_key_exists('unidad'$request->request->all()['pamp_filtro'])) ? $parameters['unidad'] : $user->getUnidad()->getIdUni();
  1156.             $year $parameters['anio'];
  1157.         }
  1158.         $periodo date('d-m-Y H:i');
  1159.         # Declaración de la instancia de TCPDF con el encabezado personalizado
  1160.         $pdf = new DocumentoPDF();
  1161.         if (empty($uni)) {
  1162.             $pdf->unidad "Todas las Unidades administrativas";
  1163.         } else {
  1164.             $unidad $this->getDoctrine()->getRepository(Unidad::class)->findOneBy(['idUni' => $uni]);
  1165.             $pdf->unidad $unidad->getNombre();
  1166.         }
  1167.         $pdf->codigo '15-528-PO-15-F18';
  1168.         $pdf->revision '02';
  1169.         $pdf->faprobacion '30/10/2022';
  1170.         $pdf->fecha $year#$periodo
  1171.         $pdf->formato 'Diagrama de Gantt';
  1172.         $pdf->nombre 'Programa Anual de Mantenimiento Preventivo';
  1173.         $pdf->setPrintFooter(false);
  1174.         # Obtenemos los datos del documento
  1175.         if ($nivel == 2) {
  1176.             $solicitud $solRep->findByAnioUnidad($year$uni);
  1177.             $conteo $solRep->countByUnidad($uni);
  1178.         } else {
  1179.             $solicitud $solRep->findByAnioUnidad($year$user->getUnidad()->getIdUni());
  1180.             $conteo $solRep->countByUnidad($user->getUnidad()->getIdUni());
  1181.         }
  1182.         $cadenaOriginal $pdf->formato '||';
  1183.         $cadenaOriginal .= (empty($unidad)) ? "Todas las Unidades administrativas" $pdf->unidad;
  1184.         $cadenaOriginal .= '||' $user->getNombre() . ' ' $user->getPapellido() . '||' $user->getCorreo() . '||' $user->getRol()->getNombre();
  1185.         $cadenaOriginal .= '||' $pdf->fecha;
  1186.         $cadena64 $sello->generar($cadenaOriginal);
  1187.         # Información del documento
  1188.         $pdf->SetCreator('Conalep Estado de México');
  1189.         $pdf->SetAuthor('SIGMEC');
  1190.         $pdf->SetTitle('Programa Anual de Mantenimiento Preventivo');
  1191.         # Definimos los saltos de página como automáticos
  1192.         #$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  1193.         #Nueva página con sus respectivas características
  1194.         $pdf->AddPage('L''LEGAL');
  1195.         $pdf->SetY(50);
  1196.         # Definimos la utilización de tipigrafías
  1197.         $pdf->setFontSubsetting(true);
  1198.         # Obtiene datos de avance y equipos con mp
  1199.         $n 0;
  1200.         $atendido 0;
  1201.         $avance 0;
  1202.         $marbetes = [];
  1203.         foreach ($solicitud as $s) {
  1204.             if ($s["estatus"] == "4") {
  1205.                 $atendido $atendido 1;
  1206.             }
  1207.             if ($s["tipo_equipo"] == "Cómputo") {
  1208.                if (!in_array($s["marbete"], $marbetes)) {
  1209.                    $marbetes[] = $s["marbete"];
  1210.                }
  1211.             }
  1212.             $n++;
  1213.         }
  1214.         if ($atendido and $n 0) {
  1215.             $avance floor(($atendido $n) * 100);
  1216.         }
  1217.         $ecmp count($marbetes);
  1218.         ### Generamos el contenido a mostrar ###
  1219.         ob_start();
  1220.         $html = <<<EOD
  1221. <table cellpadding="2" border="0">
  1222.    <tbody>
  1223.    <tr>
  1224.        <td colspan="8"><strong>Unidad administrativa</strong>: {$pdf->unidad}</td>
  1225.    </tr>
  1226.    <tr>
  1227.        <td style="text-align: center">{$conteo["impresora"]}</td>
  1228.        <td style="text-align: center">{$conteo["red"]}</td>
  1229.        <td style="text-align: center">{$conteo["otro"]}</td>
  1230.        <td style="text-align: center">{$conteo["equipo"]}</td>
  1231.        <td style="text-align: center">{$conteo["emhv"]}</td>
  1232.        <td style="text-align: center">{$ecmp}</td>
  1233.        <td style="text-align: center">{$conteo["indice"]}%</td>
  1234.        <td style="text-align: center">{$avance}%</td>
  1235.    </tr>
  1236.    <tr>
  1237.        <td style="text-align: center"><strong>IMPRESORAS</strong></td>
  1238.        <td style="text-align: center"><strong>RED</strong></td>
  1239.        <td style="text-align: center"><strong>OTRO</strong></td>
  1240.        <td style="text-align: center"><strong>CÓMPUTO</strong></td>
  1241.        <td style="text-align: center"><strong>EMHV</strong></td>
  1242.        <td style="text-align: center"><strong>EQ. COMPUTO/MP</strong></td>
  1243.        <td style="text-align: center"><strong>ÍNDICE DE EMHV</strong></td>
  1244.        <td style="text-align: center"><strong>AVANCE ATENCIÓN</strong></td>
  1245.    </tr>
  1246.    </tbody>
  1247. </table>
  1248. <br><br>
  1249. EOD;
  1250.         $html .= <<<EOD
  1251.         <table cellpadding="2" border="0.1">
  1252.         <thead>
  1253.         <tr style="text-align: center; background-color: #e4e4e4; font-size: 10px">
  1254.             <th width="8.5mm">#</th>
  1255.             <th width="27mm">Marbete</th>
  1256.             <th width="45mm">Equipo</th>
  1257.             <th width="125mm">Trabajo a realizar</th>
  1258.             <th width="8mm"></th>
  1259.             <th width="10mm">Ene</th>
  1260.             <th width="10mm">Feb</th>
  1261.             <th width="10mm">Mar</th>
  1262.             <th width="10mm">Abr</th>
  1263.             <th width="10mm">May</th>
  1264.             <th width="10mm">Jun</th>
  1265.             <th width="10mm">Jul</th>
  1266.             <th width="10mm">Ago</th>
  1267.             <th width="10mm">Sep</th>
  1268.             <th width="10mm">Oct</th>
  1269.             <th width="10mm">Nov</th>
  1270.             <th width="10mm">Dic</th>
  1271.         </tr>
  1272.         </thead>
  1273.         <tbody>
  1274.         EOD;
  1275.         $pdf->setMargins(10,50);
  1276.         $n 1;
  1277.         foreach ($solicitud as $i) {
  1278.             $mesP date('m'strtotime($i['fatencion']));
  1279.             $diaP date('d'strtotime($i['fatencion']));
  1280.             if (empty($i['ffin'])) {
  1281.                 $mesR "00";
  1282.                 $diaR "00";
  1283.             } else {
  1284.                 $mesR date('m'strtotime($i['ffin']));
  1285.                 $diaR date('d'strtotime($i['ffin']));
  1286.             }
  1287.             if ($mesP == "01") { $mesP01 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP01 $diaP; } else { $mesP01 '';  $diaP01 ''; }
  1288.             if ($mesP == "02") { $mesP02 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP02 $diaP; } else { $mesP02 '';  $diaP02 ''; }
  1289.             if ($mesP == "03") { $mesP03 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP03 $diaP; } else { $mesP03 '';  $diaP03 ''; }
  1290.             if ($mesP == "04") { $mesP04 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP04 $diaP; } else { $mesP04 '';  $diaP04 ''; }
  1291.             if ($mesP == "05") { $mesP05 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP05 $diaP; } else { $mesP05 '';  $diaP05 ''; }
  1292.             if ($mesP == "06") { $mesP06 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP06 $diaP; } else { $mesP06 '';  $diaP06 ''; }
  1293.             if ($mesP == "07") { $mesP07 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP07 $diaP; } else { $mesP07 '';  $diaP07 ''; }
  1294.             if ($mesP == "08") { $mesP08 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP08 $diaP; } else { $mesP08 '';  $diaP08 ''; }
  1295.             if ($mesP == "09") { $mesP09 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP09 $diaP; } else { $mesP09 '';  $diaP09 ''; }
  1296.             if ($mesP == "10") { $mesP10 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP10 $diaP; } else { $mesP10 '';  $diaP10 ''; }
  1297.             if ($mesP == "11") { $mesP11 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP11 $diaP; } else { $mesP11 '';  $diaP11 ''; }
  1298.             if ($mesP == "12") { $mesP12 'style="background-color: #8b9cd0; text-align: center; color: #333333;"'$diaP12 $diaP; } else { $mesP12 '';  $diaP12 ''; }
  1299.             if ($mesR == "01") { $mesR01 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR01 $diaR; } else { $mesR01 '';  $diaR01 ''; }
  1300.             if ($mesR == "02") { $mesR02 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR02 $diaR; } else { $mesR02 '';  $diaR02 ''; }
  1301.             if ($mesR == "03") { $mesR03 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR03 $diaR; } else { $mesR03 '';  $diaR03 ''; }
  1302.             if ($mesR == "04") { $mesR04 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR04 $diaR; } else { $mesR04 '';  $diaR04 ''; }
  1303.             if ($mesR == "05") { $mesR05 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR05 $diaR; } else { $mesR05 '';  $diaR05 ''; }
  1304.             if ($mesR == "06") { $mesR06 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR06 $diaR; } else { $mesR06 '';  $diaR06 ''; }
  1305.             if ($mesR == "07") { $mesR07 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR07 $diaR; } else { $mesR07 '';  $diaR07 ''; }
  1306.             if ($mesR == "08") { $mesR08 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR08 $diaR; } else { $mesR08 '';  $diaR08 ''; }
  1307.             if ($mesR == "09") { $mesR09 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR09 $diaR; } else { $mesR09 '';  $diaR09 ''; }
  1308.             if ($mesR == "10") { $mesR10 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR10 $diaR; } else { $mesR10 '';  $diaR10 ''; }
  1309.             if ($mesR == "11") { $mesR11 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR11 $diaR; } else { $mesR11 '';  $diaR11 ''; }
  1310.             if ($mesR == "12") { $mesR12 'style="background-color: #dce79b; text-align: center; color: #333333;"'$diaR12 $diaR; } else { $mesR12 '';  $diaR12 ''; }
  1311.             $html .= <<<EOD
  1312.             <tr style="font-size: 9px">
  1313.                 <td width="8.5mm" rowspan="2" align="center">$n</td>
  1314.                 <td width="27mm" rowspan="2">{$i["marbete"]}</td>
  1315.                 <td width="45mm" rowspan="2">{$i["tipo_equipo"]}</td>
  1316.                 <td width="125mm" rowspan="2">{$i["falla"]}</td>
  1317.                 <td width="8mm">P</td>
  1318.                 <td width="10mm" {$mesP01}>{$diaP01}</td>
  1319.                 <td width="10mm" {$mesP02}>{$diaP02}</td>
  1320.                 <td width="10mm" {$mesP03}>{$diaP03}</td>
  1321.                 <td width="10mm" {$mesP04}>{$diaP04}</td>
  1322.                 <td width="10mm" {$mesP05}>{$diaP05}</td>
  1323.                 <td width="10mm" {$mesP06}>{$diaP06}</td>
  1324.                 <td width="10mm" {$mesP07}>{$diaP07}</td>
  1325.                 <td width="10mm" {$mesP08}>{$diaP08}</td>
  1326.                 <td width="10mm" {$mesP09}>{$diaP09}</td>
  1327.                 <td width="10mm" {$mesP10}>{$diaP10}</td>
  1328.                 <td width="10mm" {$mesP11}>{$diaP11}</td>
  1329.                 <td width="10mm" {$mesP12}>{$diaP12}</td>
  1330.             </tr>
  1331.             <tr style="font-size: 9px">
  1332.                 <td width="8mm">R</td>
  1333.                 <td width="10mm" {$mesR01}>{$diaR01}</td>
  1334.                 <td width="10mm" {$mesR02}>{$diaR02}</td>
  1335.                 <td width="10mm" {$mesR03}>{$diaR03}</td>
  1336.                 <td width="10mm" {$mesR04}>{$diaR04}</td>
  1337.                 <td width="10mm" {$mesR05}>{$diaR05}</td>
  1338.                 <td width="10mm" {$mesR06}>{$diaR06}</td>
  1339.                 <td width="10mm" {$mesR07}>{$diaR07}</td>
  1340.                 <td width="10mm" {$mesR08}>{$diaR08}</td>
  1341.                 <td width="10mm" {$mesR09}>{$diaR09}</td>
  1342.                 <td width="10mm" {$mesR10}>{$diaR10}</td>
  1343.                 <td width="10mm" {$mesR11}>{$diaR11}</td>
  1344.                 <td width="10mm" {$mesR12}>{$diaR12}</td>
  1345.             </tr>
  1346.             EOD;
  1347.             $n++;
  1348.         }
  1349.         $html .= <<<EOD
  1350.                 </tbody>  
  1351.             </table>
  1352.         EOD;
  1353.         # Declaramos una nueva tipografía para el pie de página del contenido
  1354.         $pdf->SetFont('freesans'''10''true);
  1355.         # $pdf->write2DBarcode($cadenaOriginal, 'QRCODE,H', false, false, 20, 20, $styleQR, 'N')
  1356.         $qr = new \TCPDF2DBarcode($cadenaOriginal'QRCODE,M');
  1357.         $imgdata $qr->getBarcodePngData(2.52.5, array(000));
  1358.         file_put_contents('img/sistema/qr.png'$imgdata);
  1359.         $html .= <<<EOD
  1360.             <br>
  1361.             <br>
  1362.             <br>
  1363.             <table width="100%" cellpadding="5" border="0">
  1364.                 <tbody>
  1365.                     <tr>
  1366.                         <td style="width: 30%; font-size: 11px"><strong>GENERÓ: </strong></td>
  1367.                         <td style="width: 30%"><strong>Usuario: </strong>{$user->getNombre()} {$user->getPapellido()}</td>
  1368.                         <td style="width: 30%"><strong>Correo: </strong>{$user->getCorreo()}</td>
  1369.                         <td style="width: 9%" rowspan="2"><img src="img/sistema/qr.png" alt="QRCODE" /></td>
  1370.                     </tr>
  1371.                     <tr>
  1372.                         <td colspan="2" style="width: 75%">{$cadena64}</td>
  1373.                         <td style="width: 13%"><img src="img/sistema/logo.png" alt="LOGO"></td>
  1374.                     </tr>
  1375.                 </tbody>
  1376.             </table>
  1377.         EOD;
  1378.         # Imprimimos el contenido como HTML
  1379.         $pdf->writeHTMLCell($w=0$h=0$x=''$y=''$html$border=0$ln=1$fill=0$reseth=true$align=''$autopadding=true);
  1380.         ob_end_clean();
  1381.         # ---------------------------------------------------------
  1382.         # Mostramos el resultado en pantalla
  1383.         $pdf->Output($pdf->formato date('Ymd') . '.pdf''D');
  1384.     }
  1385.     #[Route('/ubicacion-excel'name'app_reporte_ubicacion_excel'methods: ['POST'])]
  1386.     public function ubicacionExcel(UbicacionRepository $ubicacionRepositoryRequest $request): Response
  1387.     {
  1388.         ini_set('memory_limit''5120M');
  1389.         ini_set('max_execution_time'0);
  1390.         ini_set('output_buffering'0);
  1391.         # Obtenemos los datos de la petición
  1392.         /** @var Usuario $user */
  1393.         $user $this->getUser();
  1394.         $parameters $request->request->get('unidad_filtro');
  1395.         $unidad = (array_key_exists('unidad'$request->request->all()['unidad_filtro'])) ? $parameters['unidad'] : $user->getUnidad();
  1396.         # Obtenemos los datos del documento
  1397.         $ubicaciones $ubicacionRepository->ubicaUnidad($unidad);
  1398.         # Definir el nombre temporal del archivo
  1399.         $filePath 'otro.xlsx';
  1400.         # Se definen las cabeceras del archivo
  1401.         $cabecera WriterEntityFactory::createRowFromArray([
  1402.             'ID.',
  1403.             'Ubicación',
  1404.             'Unidad',
  1405.             'Estatus'
  1406.         ]);
  1407.         # Se crea el arreglo con los datos del cuerpo del documento
  1408.         $data = [];
  1409.         $n 1;
  1410.         foreach ($ubicaciones as $ubicacion) {
  1411.             /*$usuario = $ubicacion->getUsuario()->getNombre() . ' ' . $ubicacion->getUsuario()->getPapellido();
  1412.             $ubicacion1 = $ubicacion->getUbicacion()->getArea();*/
  1413.             $unidad $ubicacion->getUnidad()->getNombre();
  1414.             /*$activo = match ($ubicacion->getActivo()) {
  1415.                 "1" => 'Activo',
  1416.                 "0" => 'Inactivo',
  1417.                 default => ""
  1418.             };*/
  1419.             if ($ubicacion->getActivo() == 1) {
  1420.                 $activo "Activo";
  1421.             } else {
  1422.                 $activo "Inactivo";
  1423.             }
  1424.             $data[] = WriterEntityFactory::createRowFromArray([
  1425.                 $ubicacion->getIdUbi(),
  1426.                 $ubicacion->getArea(),
  1427.                 $unidad,
  1428.                 $activo
  1429.                 //$ubicacion->getActivo()
  1430.                 //$usuario,
  1431.             ]);
  1432.             $n++;
  1433.         }
  1434.         # Se crea el documento en formato CSV
  1435.         $writer WriterEntityFactory::createXLSXWriter();
  1436.         $writer
  1437.             ->openToFile($filePath)
  1438.             ->addRow($cabecera)
  1439.             ->addRows($data)
  1440.             ->close()
  1441.         ;
  1442.         $response = new BinaryFileResponse($filePath);
  1443.         $response->setContentDisposition(
  1444.             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  1445.             'Ubicaciónes- ' '_' date('Y-m-d') . '.xlsx'
  1446.         );
  1447.         $response->deleteFileAfterSend(true);
  1448.         return $response;
  1449.     }
  1450. }