$pdf->Cell(1.8, 0.30, number_format($ArrayDescuento[$i],2), 0, 1,'R', 0); $pdf->SetXY($X+12.8,$Y); $pdf->Cell(1.0, 0.30, utf8_decode($ArrayObjImpu[$i]), 0, 1,'C', 0); if($lTipImp == 1) { $pdf->SetXY($X+13.75,$Y); $pdf->Cell(1.8, 0.30, number_format($ArrayTrasladoBase[$i],2), 0, 1,'R', 0); $pdf->SetXY($X+15.6,$Y); $pdf->Cell(1.0, 0.30, $ArrayTrasladoImpu[$i], 0, 1,'L', 0); $pdf->SetXY($X+16.4,$Y); $pdf->Cell(1.0, 0.30, $ArrayTrasladoTipo[$i], 0, 1,'L', 0); $pdf->SetXY($X+16.8,$Y); $pdf->Cell(1.8, 0.30, number_format($ArrayTrasladoTasa[$i],6), 0, 1,'R', 0); $pdf->SetXY($X+18.5,$Y); $pdf->Cell(1.8, 0.30, number_format($ArrayTrasladoImpo[$i],2), 0, 1,'R', 0); } if($lTipImp == 2) { $pdf->SetXY($X+13.75,$Y); $pdf->Cell(1.8, 0.30, number_format($ArrayRetencionBase[$i],2), 0, 1,'R', 0); $pdf->SetXY($X+15.6,$Y); $pdf->Cell(1.0, 0.30, $ArrayRetencionImpu[$i], 0, 1,'L', 0); $pdf->SetXY($X+16.4,$Y); $pdf->Cell(1.0, 0.30, $ArrayRetencionTipo[$i], 0, 1,'L', 0); $pdf->SetXY($X+16.8,$Y); $pdf->Cell(1.8, 0.30, number_format($ArrayRetencionTasa[$i],6), 0, 1,'R', 0); $pdf->SetXY($X+18.5,$Y); $pdf->Cell(1.8, 0.30, number_format($ArrayRetencionImpo[$i],2), 0, 1,'R', 0); } $pdf->line($X+1, $Y-0.1, $X+20.4, $Y-0.1); $Y = $Y + 0.35; $pdf->SetFont('arial','B',8); $pdf->SetTextColor(0,0,0); $pdf->SetXY($X+1.0,$Y); $pdf->Cell(1.0, 0.30, utf8_decode("Descripción:"), 0, 1,'L', 0); $pdf->SetFont('arial','',8); $pdf->SetTextColor(0,0,0); $pdf->SetXY($X+2.8,$Y); $pdf->MultiCell(17.3, 0.30, utf8_decode($ArrayArtSer[$i]), 0, 'J', 0); //$pdf->Write(0.4,''); $YY = $pdf->GetY()+0.18; $Puntero = $pdf->GetY(); $Y = $YY; $Regs++; if ($Puntero>23.5) { if ($TotRegs>$Regs) { $pdf->AddPage(); Titulos($pdf, 1.5); $Y = 2.4; } else { $pdf->AddPage(); $Y = 1.4; } } } #============================================================================================================ #== 4.4 IMPRESIÓN DE LOS SUBTOTALES. #============================================================================================================ if ($Puntero<=23.5) { $Y = 18.00; SubTotales($pdf, $Y, $subTotal, $descuento, $ImporteTotalIVA, $ImporteTotalIEPS, $total, $formaDePago, $metodoDePago, $NumCtaPago, $Puntero, $moneda, $tipoCambio, $ImporteTotalISR, $ImporteTotalIVAR); } if ($Puntero>23.5 && $TotRegs==$Regs) { SubTotales($pdf, $Y, $subTotal, $descuento, $ImporteTotalIVA, $ImporteTotalIEPS, $total, $formaDePago, $metodoDePago, $NumCtaPago, $Puntero, $moneda, $tipoCambio, $ImporteTotalISR, $ImporteTotalIVAR); } #============================================================================================================ #== 4.5 IMPRESIÓN DE LOS DATOS INFERIORES. #============================================================================================================ if ($Puntero<18.5) { if ($filename != "") { DatosInf($pdf, $filename, 0, $selloCFD, $selloSAT, $CadOri, $PaginaWeb); } } if ($Puntero>=18.5 && $Puntero<23.5) { $pdf->AddPage(); //$pdf->image("archs_graf/FondoTenue.jpg",1, 5 , 19.5, 18); if ($filename != "") { DatosInf($pdf, $filename, -20.5, $selloCFD, $selloSAT, $CadOri, $PaginaWeb); } } if ($Puntero>=23.5) { if ($filename != "") { DatosInf($pdf, $filename, $Puntero -41, $selloCFD, $selloSAT, $CadOri, $PaginaWeb); } } #============================================================================================================ #== 4.6 SE GRABA EL DOCUMENTO .PDF EN EL DISCO DURO #============================================================================================================ $pdf->Output($SendaArchsCFDI.$NomArchPDF, 'F'); #============================================================================================================ #== 4.7 DESCOMENTAR SI ESTÁ UTILIZANDO EL SISTEMA OPERATIVO LINUX. #============================================================================================================ chmod ($SendaArchsCFDI.$NomArchPDF,0777); #============================================================================================================ #== 4.8 SE MUESTRA EL DOCUMENTO .PDF EN EL NAVEGADOR. #============================================================================================================ $pdf->Output($SendaArchsCFDI.$NomArchPDF, 'I'); #============================================================================================================ #== FUNCIONES GENERALES #============================================================================================================ function Titulos($pdf, $Y){ $Y = $Y + 0.24; $pdf->SetTextColor(0,0,0); $pdf->SetFont('arial','B',8); $pdf->SetXY(0.75,$Y); $pdf->Cell(1.5, 0.30, "Cant.", 0, 1,'C', 0); $pdf->SetXY(1.95,$Y); $pdf->Cell(1.8, 0.30, "Unidad", 0, 1,'L', 0); $pdf->SetXY(4.5,$Y); $pdf->Cell(3.3, 0.30, "Clave", 0, 1,'L', 0); $pdf->SetXY(6.2,$Y); $pdf->Cell(1.7, 0.30, utf8_decode("V. Unitario"), 0, 1,'R', 0); $pdf->SetXY(8.0,$Y); $pdf->Cell(1.8, 0.30, utf8_decode("Importe"), 0, 1,'R', 0); $pdf->SetXY(10.6,$Y); $pdf->Cell(1.8, 0.30, utf8_decode("Descuento"), 0, 1,'R', 0); $pdf->SetXY(12.8,$Y); $pdf->Cell(1.0, 0.30, utf8_decode("Objeto"), 0, 1,'L', 0); $pdf->SetXY(13.75,$Y); $pdf->Cell(1.7, 0.30, utf8_decode("Base"), 0, 1,'R', 0); $pdf->SetXY(15.5,$Y); $pdf->Cell(1.0, 0.30, utf8_decode("Impto"), 0, 1,'L', 0); $pdf->SetXY(16.4,$Y); $pdf->Cell(1.0, 0.30, utf8_decode("Tipo"), 0, 1,'L', 0); $pdf->SetXY(16.8,$Y); $pdf->Cell(1.7, 0.30, utf8_decode("Tasa"), 0, 1,'R', 0); $pdf->SetXY(18.5,$Y); $pdf->Cell(1.8, 0.30, utf8_decode("Importe"), 0, 1,'R', 0); } function SubTotales($pdf, $Y, $subTotal, $descuento, $ImporteTotalIVA, $ImporteTotalIEPS, $total, $formaDePago, $metodoDePago, $NumCtaPago, $Puntero, $moneda, $tipoCambio, $ImporteTotalISR, $ImporteTotalIVAR){ $X = 0; $Y = $Y - 0.00; //== Subtotales ============================================================ $pdf->SetTextColor(0,0,0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+16.27,$Y+0.35); $pdf->Cell(1.7, 0.30, "Subtotal:", 0, 1,'R', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+16.16+2.5,$Y+0.35); $pdf->Cell(1.7, 0.30, number_format($subTotal,2), 0, 1,'R', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+16.27,$Y+0.35+0.5); $pdf->Cell(1.7, 0.30, "Descuento:", 0, 0,'R', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+16.16+2.5,$Y+0.35+0.5); $pdf->Cell(1.7, 0.30, number_format($descuento,2), 0, 1,'R', 0); if ($ImporteTotalIVAR > 0) { $pdf->SetFont('arial','B',9); $pdf->SetXY($X+16.27,$Y+0.35+(0.5*2)); $pdf->Cell(1.7, 0.30, "IVA RETENIDO:", 0, 0,'R', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+16.16+2.5,$Y+0.35+(0.5*2)); $pdf->Cell(1.7, 0.30, number_format($ImporteTotalIVAR,2), 0, 1,'R', 0); } if ($ImporteTotalISR > 0) { $pdf->SetFont('arial','B',9); $pdf->SetXY($X+16.27,$Y+0.35+(0.5*2)); $pdf->Cell(1.7, 0.30, "IMPUESTOS RETENIDOS:", 0, 0,'R', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+16.16+2.5,$Y+0.35+(0.5*2)); $pdf->Cell(1.7, 0.30, number_format($ImporteTotalISR,2), 0, 1,'R', 0); } //== $pdf->SetFont('arial','B',9); //== $pdf->SetXY($X+16.27,$Y+0.35+(0.5*2)); //== $pdf->Cell(1.7, 0.30, "IMPUESTOS RETENIDOS:", 0, 0,'R', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+16.27,$Y+0.35+(0.5*3)); $pdf->Cell(1.7, 0.30, "IVA:", 0, 0,'R', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+16.16+2.5,$Y+0.35+(0.5*3)); $pdf->Cell(1.7, 0.30, number_format($ImporteTotalIVA,2), 0, 1,'R', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+16.27,$Y+0.37+(0.5*4)); $pdf->Cell(1.7, 0.30, "Total:", 0, 1,'R', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+16.16+2.5,$Y+0.37+(0.5*4)); $pdf->Cell(1.7, 0.30, number_format($total,2), 0, 1,'R', 0); //================================================================ $pdf->SetFont('arial','B',9); $pdf->SetXY($X+1,$Y+0.35); $pdf->Cell(1.7, 0.30, "Total con letra: ", 0, 1,'L', 0); $pdf->SetFont('arial','',8); $pdf->SetXY($X+1,$Y+0.35+0.40); //$pdf->Cell(1.7, 0.30, NumLet($total,$moneda), 0, 1,'L', 0); $pdf->Cell(1.7, 0.30, convertirNumeroLetra($total,$moneda), 0, 1,'L', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+1,$Y+0.35+0.40+0.8); $pdf->Cell(1.7, 0.30, "Forma de pago:", 0, 1,'L', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+3.6,$Y+0.35+0.40+0.8); $pdf->Cell(1.7, 0.30, utf8_decode($formaDePago), 0, 1,'L', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+9.15,$Y+0.35+0.40+0.8); $pdf->Cell(1.7, 0.30, "Moneda:", 0, 1,'L', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+10.7,$Y+0.35+0.40+0.8); $pdf->Cell(1.7, 0.30, utf8_decode($moneda), 0, 1,'L', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+1,$Y+0.35+0.40+1.3); $pdf->Cell(1.7, 0.30, utf8_decode("Método de pago:"), 0, 1,'L', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+3.76,$Y+0.35+0.40+1.3); $pdf->Cell(1.7, 0.30, utf8_decode($metodoDePago), 0, 1,'L', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY($X+8,$Y+0.35+0.40+1.3); $pdf->Cell(1.7, 0.30, utf8_decode("Tipo de Cambio:"), 0, 1,'L', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+10.7,$Y+0.35+0.40+1.3); $pdf->Cell(1.7, 0.30, number_format($tipoCambio,4), 0, 1,'L', 0); $pdf->SetDrawColor(128,0,0); $pdf->SetLineWidth(0.05); $pdf->RoundedRect($X+1, $Y+0.15, 19.4, 2.60, 0.2, ''); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(0.02); if (strlen($NumCtaPago)>0){ $pdf->SetFont('arial','B',9); $pdf->SetXY($X+1,$Y+0.35+0.40+1.8); $pdf->Cell(1.7, 0.30, utf8_decode("Número de cuenta:"), 0, 1,'L', 0); $pdf->SetFont('arial','',9); $pdf->SetXY($X+3.76+0.3,$Y+0.35+0.40+1.8); $pdf->Cell(1.7, 0.30, $NumCtaPago, 0, 1,'L', 0); } } function DatosInf($pdf, $filename, $Y, $selloCFD, $selloSAT, $CadOri, $PaginaWeb){ $pdf->SetFont('arial','B',9); $pdf->SetXY(1.2,22.9+$Y-0.2 -0.7); $pdf->Cell(1.7,0.30, "Sello digital del CFDI:", 0, 1,'L', 0); $pdf->SetFont('arial','',7); $pdf->SetXY(1.2,+22.9+0.35+$Y-0.2 -0.7); $pdf->MultiCell(19.4, 0.25, $selloCFD, 0, 'L', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY(4.2,21.9+2+$Y -0.7); $pdf->Cell(1.7, 0.30, "Sello del SAT:", 0, 1,'L', 0); $pdf->SetFont('arial','',7); $pdf->SetXY(4.2,21.9+0.35+2+$Y -0.7); $pdf->MultiCell(16.1, 0.25, $selloSAT, 0, 'L', 0); $pdf->SetFont('arial','B',9); $pdf->SetXY(4.2,25+0.5+$Y -0.7); $pdf->Cell(1.7, 0.30, utf8_decode("Cadena original del complemento de certificación digital del SAT:"), 0, 1,'L', 0); $pdf->SetFont('arial','',7); $pdf->SetXY(4.2,25.1+0.5+0.25+$Y -0.7); $pdf->MultiCell(16.1, 0.25, $CadOri, 0, 'L', 0); if ($filename != "") { $pdf->Image($filename,1.2,23.8+$Y -0.7,3,3,'PNG'); } } function ProcesImpTot($ImpTot){ $ImpTot = number_format($ImpTot, 4); $ArrayImpTot = explode(".", $ImpTot); $NumEnt = $ArrayImpTot[0]; $NumDec = ProcesDecFac($ArrayImpTot[1]); return $NumEnt.".".$NumDec; } function ProcesDecFac($Num){ $FolDec = ""; if ($Num < 10){$FolDec = "00000".$Num;} if ($Num > 9 and $Num < 100){$FolDec = $Num."0000";} if ($Num > 99 and $Num < 1000){$FolDec = $Num."000";} if ($Num > 999 and $Num < 10000){$FolDec = $Num."00";} if ($Num > 9999 and $Num < 100000){$FolDec = $Num."0";} return $FolDec; } function VerifStatusCFDI($pdf, $StatusCFDI){ if ($StatusCFDI=="CANCELADO"){ $pdf->SetLineWidth(0.1); $pdf->SetDrawColor(200,0,0); $pdf->SetTextColor(200,0,0); $pdf->SetFont('verdana','',53); $pdf->RoundedRect(4.4, 7.4-2.5, 12.6, 2.05, 0.4, ''); $pdf->SetXY(1,8.4-2.5); $pdf->Cell(19.4, 0.30, "CANCELADO", 0, 1,'C', 0); $pdf->SetLineWidth(0.02); $pdf->SetDrawColor(0,0,0); $pdf->SetTextColor(0,0,0); } }