function getFecha($date) { $anio = substr($date, 0, 4); $mes = substr($date, 5, 2); $dia = substr($date, 8, 2); $nDia = substr($date, 11, 1); $nombreDia = nombreDia($nDia); $nombreMes = nombreMes($mes); return nombreDia($nDia) . ", {$dia} {$nombreMes} de {$anio}"; }
// se setea el valor de celda que sigue despues del encabezado $fech = 0; foreach ($resultado as $key => $fila) { for ($i = 0; $i <= $cont; $i = $i + 4) { if (isset($fila['TOTALPROC_X' . $i])) { //mes $objPHPExcel->setActiveSheetIndex(0)->mergeCells('A' . $cell . ':B' . $cell)->mergeCells('A' . ($cell + 1) . ':B' . ($cell + 1))->mergeCells('A' . ($cell + 2) . ':B' . ($cell + 2)); $objPHPExcel->getActiveSheet()->getStyle('A' . $cell . ':B' . $cell)->applyFromArray($estiloCabecera); $objPHPExcel->getActiveSheet()->getStyle('A' . ($cell + 1) . ':B' . ($cell + 1))->applyFromArray($estiloCabecera); $objPHPExcel->getActiveSheet()->getStyle('A' . ($cell + 2) . ':B' . ($cell + 2))->applyFromArray($estiloCabecera); //busco el nombre del mes list($mes, $aa) = dameMes($arrayFechas[$fech]['Inicio']); $objPHPExcel->getActiveSheet()->getStyle('B' . ($cell + 1) . ':H' . ($cell + 1))->applyFromArray($estiloInfo); $objPHPExcel->getActiveSheet()->getStyle('I' . ($cell + 1) . ':J' . ($cell + 1))->applyFromArray($estiloCabecera); //nombre del mes $mmm = nombreMes($mes); $objPHPExcel->getActiveSheet()->getCell('A' . ($cell + 1))->setValue($mmm . " - " . $aa); //PROC $objPHPExcel->getActiveSheet()->getCell('C' . ($cell + 1))->setValue($fila['TOTALPROC_X' . $i]); //NO PROC $objPHPExcel->getActiveSheet()->getCell('E' . ($cell + 1))->setValue($fila['TOTALNOPROC_X' . $i]); //NO PROC $objPHPExcel->getActiveSheet()->getCell('G' . ($cell + 1))->setValue($fila['CERRADOS_X' . $i]); //total $objPHPExcel->getActiveSheet()->getCell('I' . ($cell + 1))->setValue($fila['TOTAL_X' . $i]); //color para el total dinamico $objPHPExcel->getActiveSheet()->getStyle('I' . $cell . ':I' . ($cell + 1))->applyFromArray($estiloCabecera); $objPHPExcel->getActiveSheet()->getStyle('J' . $cell . ':J' . ($cell + 1))->applyFromArray($estiloCabecera); $objPHPExcel->getActiveSheet()->getStyle('I' . $cell . ':I' . ($cell + 2))->applyFromArray($estiloCabecera); $objPHPExcel->getActiveSheet()->getStyle('J' . $cell . ':J' . ($cell + 2))->applyFromArray($estiloCabecera); $cell = $cell + 3;
$x = 0; foreach ($FacturasEmitidas as $Factura) { $color = $x % 2 == 0 ? '#d4d2c2' : '#ebeae3'; $FacturasTabla .= '<tr style="background:' . $color . '; color:black; height: 30px;"><td><center>' . $Factura['folio'] . '</center></td>' . '<td><center>' . $Factura['cliente'] . '</center></td>' . '<td><center>$' . number_format((double) $Factura['subtotal'], 2, '.', '') . '</center></td>' . '<td><center>$' . number_format((double) $Factura['subtotal'] * (intval($Fiscal_IVA) / 100), 2, '.', '') . '</center></td>' . '<td><center>$' . number_format((double) $Factura['subtotal'] * number_format((double) (intval($Fiscal_IVA) / 100) + 1.0, 2, '.', ''), 2, '.', '') . '</center></td></tr>'; $TotalIVA += number_format((double) $Factura['subtotal'] * (intval($Fiscal_IVA) / 100), 2, '.', ''); $TotalGeneral += number_format((double) $Factura['subtotal'] * number_format((double) (intval($Fiscal_IVA) / 100) + 1.0, 2, '.', ''), 2, '.', ''); $x++; } $html = '<html><body>' . '<p style="text-align:center; font-size: 40px; height:55px; color: white; background: black;">Reporte de Facturas Emitidas</p>' . '<p style="font-size: 20px; text-align:center; height:20px;"> Para el periodo del 1ro al ' . intval(cal_days_in_month(CAL_GREGORIAN, date(intval($_GET['month'])), date("Y"))) . ' de ' . nombreMes($_GET['month']) . '</p>' . '<br>' . '<table style="width:70%;" align="center"> <thead> <tr style="font-weight:bold; text-align:center; font-size: 20px;"> <td>Folio</td> <td>Cliente</td> <td>Subtotal</td> <td>IVA ' . $Fiscal_IVA . '%</td> <td>Total</td> </tr> </thead> <tbody> <tr><td colspan="5"></td></tr>'; $html .= $FacturasTabla; $html .= '</tbody>' . '</table>'; $html .= '<br>'; $html .= '<p style="height: 20px; text-align: right; width: 70%;">Total Facturas Emitidas - <strong>' . $x . '</strong></p>' . '<p style="height: 20px; text-align: right; width: 70%;">Total IVA - <strong>$' . $TotalIVA . '</strong></p>' . '<p style="height: 20px; text-align: right; width: 70%;">Gran Total - <strong>$' . $TotalGeneral . '</strong></p>'; $html .= '<p style="text-align:center; font-size: 20px; height:25px; color: white; background: black;">Reporte generado el ' . date('d/m/Y h:i:s a', time()) . '</p>'; $html .= '</body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $dompdf->stream("Facturas_" . nombreMes($_GET['month']) . "_2013.pdf"); }
</tr> <tr> <td colspan="2" style="width:100%; height: 25px; "> </td> </tr> <tr> <td colspan="2" style="width:100%; height: 1px; background:#418bca;"> </td> </tr> <tr> <td colspan="2" style="width:100%; height: 25px; "> </td> </tr> <tr> <td style="width:100%; padding-right:20px;" colspan="2" align="right"> ' . $Expedido_Ciudad . ', ' . $Expedido_Estado . ', ' . $FechaEmision_Explode[0] . ' de ' . nombreMes(intval($FechaEmision_Explode[1])) . ' de ' . $FechaEmision_Explode[2] . ' </td> </tr> <tr> <td style="width:100%;" colspan="2"> <center><h1>FACTURA</h1></center> </td> </tr> <tr> <td style="width:50%; padding-left: 30px;"> <b>' . $Cliente_Nombre . '</b><br> ' . $Cliente_RFC . '<br> <br> ' . $Cliente_Calle . '<br> ' . $Cliente_Ciudad . ', ' . $Cliente_Estado . ' ' . $Cliente_CP . '<br> ' . $Cliente_Telefono . '<br>
echo number_format((double) $Factura['subtotal'] * number_format((double) (intval($Fiscal_IVA) / 100) + 1.0, 2, '.', ''), 2, '.', ''); ?> </center></td> </tr> <?php } ?> </tbody> </table> <center><a href='functions/doReportInvoices.php?month=<?php echo intval($_GET['month']); ?> ' target="_blank" style="text-decoration:none;">Descargar en PDF</a></center> <br> </div> <div class="col-lg-2"> </div> </div> <?php } else { if (intval($_GET['month']) > 12) { echo "<center>Ese mes no existe en el Calendario Gregoriano. ¿Cómo mides tus meses?</center><br>"; } else { if (intval($_GET['month']) > date("m")) { echo "<center>Para ese mes, aun no tengo información. Apenas estamos en " . nombreMes(intval(date("m"))) . ".</center><br>"; } } } } else { echo "No existe una sesión válida para acceder a éste recurso. <a href='index.php?action=logout'> Haga click aqui para corregirlo</a>"; }
echo $Fiscal_RFC; ?> </address> </div> </div> </p> <!-- List group --> <ul class="list-group list-group-flush"> <li class="list-group-item"> Hoy es <?php echo intval(date("d")); ?> de <?php echo nombreMes(date("m")); ?> . Faltan <?php echo intval(cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y"))) - intval(date("d")); ?> dias para cerrar el mes. <div class="progress progress-striped"> <div class="progress-bar progress-bar-info" style="width: <?php echo intval(intval(date("d")) * 100 / intval(cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y")))); ?> %;"></div> </div> Haz capturado <?php echo $TotalFacturasEsteMes['total']; ?> facturas de las cuales has emitido correctamente <?php