[e5efb650-13c2-4ea4-9d5f-3b3b1e1b3deb](2025-07-16 11:02:32) - Proceso finalizado exitosamente, URL: https://aptuslegal.app/imagenesAptusLegal/arochi/LogosArochi/MAR-130885.png 

[b2c3a0fe-5315-4912-9df2-e8f34be8a296](2025-07-16 11:15:18) - Proceso de subida de imagen iniciado, data: {"source":"webhook","RefAL":"MAR-130876","MarcaId":"4597192000272553001","user":"bmeza@arochilindner.com"}
[b2c3a0fe-5315-4912-9df2-e8f34be8a296](2025-07-16 11:15:25) - Tokens generados: 1000.ce3f7e0a48cdbc690e7275891dbb1ba6.5063f1819edfa831d73a44e8622d956a
[b2c3a0fe-5315-4912-9df2-e8f34be8a296](2025-07-16 11:15:25) - Intento 0 para obtener imagen de marca de CRM, respuesta: 200
[b2c3a0fe-5315-4912-9df2-e8f34be8a296](2025-07-16 11:15:25) - Imagen guardada localmente de manera exitosa
[b2c3a0fe-5315-4912-9df2-e8f34be8a296](2025-07-16 11:15:27) - Intento 0 para actualizar CRM con datos de url de marca: {
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2025-07-16T12:15:26-04:00",
                "Modified_By": {
                    "name": "Aptus Legal Administrator",
                    "id": "4597192000000287001"
                },
                "Created_Time": "2025-07-15T10:17:50-04:00",
                "id": "4597192000272553001",
                "Created_By": {
                    "name": "Catalina Lozada Brown",
                    "id": "4597192000011167112"
                }
            },
            "message": "record updated",
            "status": "success"
        }
    ]
}
[b2c3a0fe-5315-4912-9df2-e8f34be8a296](2025-07-16 11:15:27) - Proceso finalizado exitosamente, URL: https://aptuslegal.app/imagenesAptusLegal/arochi/LogosArochi/MAR-130876.png 

[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:27) - Proceso de subida de imagen iniciado, data: {"source":"webhook","RefAL":"MAR-130886","MarcaId":"4597192000272876113","user":"clozada@arochilindner.com"}
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:35) - Tokens generados: 1000.75e7091152a0572c660e3b45bbfe6805.06d4fa373c986bb655d322a507055510
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:35) - Intento 0 el registro no contiene foto asociada
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:35) - ERROR al obtener imagen, intento: 1 , respuesta: null
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:37) - Intento 1 el registro no contiene foto asociada
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:37) - ERROR al obtener imagen, intento: 2 , respuesta: null
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:40) - Intento 2 el registro no contiene foto asociada
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:40) - ERROR al obtener imagen, intento: 3 , respuesta: null
[229bdc2b-99c1-441f-b22f-4a640d19ef47](2025-07-16 11:58:42) - No se pudo encontrar una imagen asociada a registro de CRM \n
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:24:57) - Proceso de subida de imagen iniciado, data: {"source":"webhook","RefAL":"MAR-130887","MarcaId":"4597192000272864059","user":"gsanchez@arochilindner.com"}
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:05) - Tokens generados: 1000.b8e7a4afce90a537744383907366c509.20ab40fb4c38baefcf4750a90e3b128a
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:05) - Intento 0 el registro no contiene foto asociada
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:05) - ERROR al obtener imagen, intento: 1 , respuesta: null
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:07) - Intento 1 el registro no contiene foto asociada
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:07) - ERROR al obtener imagen, intento: 2 , respuesta: null
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:10) - Intento 2 el registro no contiene foto asociada
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:10) - ERROR al obtener imagen, intento: 3 , respuesta: null
[6db17ede-a621-4f4e-8f61-32f2b4289bc7](2025-07-16 13:25:12) - No se pudo encontrar una imagen asociada a registro de CRM \n
[2e83ec30-4ccb-439c-855b-m:remoteref) refs/heads/master refs/remotes/master [5ms]
2025-07-16 10:33:26.627 [info] > git rev-parse --show-toplevel [1ms]
2025-07-16 10:33:26.628 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.650 [info] > git status -z -uall [15ms]
2025-07-16 10:33:26.651 [info] > git rev-parse --show-toplevel [20ms]
2025-07-16 10:33:26.651 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.655 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [15ms]
2025-07-16 10:33:26.680 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [6ms]
2025-07-16 10:33:26.683 [info] > git rev-parse --show-toplevel [28ms]
2025-07-16 10:33:26.683 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.687 [info] > git config --get commit.template [8ms]
2025-07-16 10:33:26.687 [info] > git config --get --local branch.master.vscode-merge-base [4ms]
2025-07-16 10:33:26.688 [warning] [Git][config] git config failed: Failed to execute git
2025-07-16 10:33:26.697 [info] > git rev-parse --show-toplevel [10ms]
2025-07-16 10:33:26.697 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.705 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [9ms]
2025-07-16 10:33:26.705 [info] > git reflog master --grep-reflog=branch: Created from *. [13ms]
2025-07-16 10:33:26.709 [info] > git rev-parse --show-toplevel [5ms]
2025-07-16 10:33:26.709 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.709 [info] > git symbolic-ref --short refs/remotes/origin/HEAD [1ms]
2025-07-16 10:33:26.709 [info] fatal: ref refs/remotes/origin/HEAD is not a symbolic ref
2025-07-16 10:33:26.709 [warning] [Repository][getDefaultBranch] Failed to get default branch details: Failed to execute git.
2025-07-16 10:33:26.724 [info] > git status -z -uall [4ms]
2025-07-16 10:33:26.724 [info] > git merge-base refs/heads/master refs/remotes/origin/master [10ms]
2025-07-16 10:33:26.728 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [4ms]
2025-07-16 10:33:26.734 [info] > git rev-parse --show-toplevel [16ms]
2025-07-16 10:33:26.735 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.739 [info] > git merge-base refs/heads/master refs/remotes/origin/master [5ms]
2025-07-16 10:33:26.742 [info] > git diff --name-status -z --diff-filter=ADMR 260de950da7ddffb8befd39e63975ce4be79558f...refs/remotes/origin/master [15ms]
2025-07-16 10:33:26.743 [info] > git diff --name-status -z --diff-filter=ADMR 260de950da7ddffb8befd39e63975ce4be79558f...refs/remotes/origin/master [1ms]
2025-07-16 10:33:26.743 [info] > git rev-parse --show-toplevel [5ms]
2025-07-16 10:33:26.743 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.747 [info] > git rev-parse --show-toplevel [1ms]
2025-07-16 10:33:26.747 [info] fatal: not a git repository (or any of the parent directories): .git
2025-07-16 10:33:26.750 [info] [Model][doInitialScan] Initial repository scan completed - repositories (1), closed repositories (0), parent repositories (0), unsafe repositories (0)
2025-07-16 10:37:13.550 [info] > git config --get commit.template [4ms]
2025-07-16 10:37:13.550 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2025-07-16 10:37:13.559 [info] > git status -z -uall [4ms]
2025-07-16 10:37:13.560 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [2ms]
2025-07-16 10:37:18.573 [info] > gi<?php
	header('Content-Type: text/html; charset=UTF-8');
	require("fpdf/fpdf.php");
	include("qrlib/qrlib.php");
	include ("funciones.php");
	
	#============================================================================================================
	#== 1. CREAMOS LA CLASE Y OBTENEMOS LOS DATOS BASICOS DEL REPORTE 
	#============================================================================================================
	class PDF extends FPDF
	{
		/*
		function Header()
		{
			if($this->PageNo() > 1){
				
				//$this->image("archs_graf/aptuslegalsystems.jpg",1, 0.5);
				
				$this->SetTextColor(0,0,0);
				$this->SetFont('arial','B',10);
				$this->SetXY(15, 0.75);
				$this->Cell(2.5, 0.25, "FOLIO:", 0, 1,'R', 0);
				
				$this->SetTextColor(171,17,17);
				$this->SetFont('arial','B',14);
				$this->SetXY(17.5, 0.75);
				$this->Cell(1, 0.25, $this->numFact, 0, 1,'L', 0);

				$this->SetFont('arial','I',11); 
				$this->SetTextColor(128,0,0);
				$this->SetXY(5.0, 0.75);
				$this->Cell(10, 0.30, utf8_decode("www.rgr.com.mx"), 0, 1,'C', 0); 
			}
		}
		*/
		
		function Footer()
		{
			$this->SetFont('arial','B',10); 
			$this->SetTextColor(128,0,0);
			$this->SetXY(2.2,26.7);
			$this->Cell(15.6, 0.30, utf8_decode("ESTE DOCUMENTO ES UNA REPRESENTACIÓN IMPRESA DE UN CFDI"), 0, 1,'C', 0);    
			
			$this->SetTextColor(0,0,0);
			$this->SetFont('arial','',10);
			$this->SetXY(19.4,26.7);
			$this->Cell(0.8, 0.25, $this->PageNo().'/{nb}', 0, 1,'L', 0);
		}
	}
	
	$SendaArchsCFDI 	= "archs_cfdi/";
	$SendaArchsGraf 	= "archs_graf/";
	
	$NomArchXML 		= $_GET["NomArchXML"];
	$NomArchPDF 		= $_GET["NomArchPDF"];
	
	$FechaHoraEmision 	= date("Y-m-d")."T".date("H:i:s"); 
	$Obs 				= "";
	$StatusCFDI 		= "ACTIVO";
	$PaginaWeb 			= "www.rgr.com.mx";
	
	$SumaImportes 		= 0;
	$TotImpuestos 		= 0;
	
	$UUID          	  	= "";
	$Fact_Fecha    	  	= "";
	$selloCFD      	  	= "";
	$noCertificado 	  	= "";
	$noCertificadoSAT 	= "";
	$fechaTim 		  	= "";
	$selloSAT 		 	= "";
	$versionTim			= "";
	$rfcPAC 			= "";
	
	$xml = file_get_contents($SendaArchsCFDI.$NomArchXML);
	
	#============================================================================================================
	#== 2. OBTENIENDO DATOS DEL ARCHIVO .XML 
	#============================================================================================================
	
	$DOM = new DOMDocument('1.0', 'utf-8');
	$DOM->preserveWhiteSpace = FALSE;
	$DOM->loadXML($xml);
	
	$params = $DOM->getElementsByTagName('TimbreFiscalDigital');
	foreach ($params as $param) {
		$UUID     			= $param->getAttribute('UUID');
		$noCertificadoSAT 	= $param->getAttribute('NoCertificadoSAT');
		$selloCFD 		 	= $param->getAttribute('SelloCFD');
		$selloSAT 		 	= $param->getAttribute('SelloSAT');
		$rfcPAC		 	 	= $param->getAttribute('RfcProvCertif');
		$fechaTim 		 	= $param->getAttribute('FechaTimbrado');
		$versionTim 	    = $param->getAttribute('Version');
	}      
	
	$params = $DOM->getElementsByTagName('Emisor');
	foreach ($params as $param) {
		$Emisor_Nom 	= $param->getAttribute('Nombre');
		$Emisor_RFC 	= $param->getAttribute('Rfc');
		$Emisor_Regimen = $param->getAttribute('RegimenFiscal');
	}    
	
	$params = $DOM->getElementsByTagName('Receptor');
	foreach ($params as $param) {
		$Receptor_Nom 		= $param->getAttribute('Nombre');
		$Receptor_RFC 		= $param->getAttribute('Rfc');
		$Receptor_UsoCFDI = $param->getAttribute('UsoCFDI');
		$Receptor_DomFis  = $param->getAttribute('DomicilioFiscalReceptor');
		$Receptor_RegFis  = $param->getAttribute('RegimenFiscalReceptor');
		$Receptor_Direccion = $param->getAttribute('Direccion');
		
		$Direccion = '';
		$CIF = '';

		if (preg_match('/^(.*)CIF:\s*([A-Z0-9]+),(.*)$/i', $Receptor_Direccion, $matches)) {
			$Direccion = trim($matches[1]) . ',' . trim($matches[3]);
			$CIF = trim($matches[2]);
		} else {
			$Direccion = $Receptor_Direccion;
		}
	}    
	
	
	$params = $DOM->getElementsByTagName('Comprobante');
	foreach ($params as $param) {
		$Fact_Fecha    		= $param->getAttribute('Fecha');
		$Fact_Serie    		= $param->getAttribute('Serie');
		$Fact_Folio    		= $param->getAttribute('Folio');
		$Fact_NoFact   		= $Fact_Serie.' - '.str_pad($Fact_Folio, 6, "0", STR_PAD_LEFT);
		$descuento     		= $param->getAttribute('Descuento');
		$subTotal      		= $param->getAttribute('SubTotal');
		$total         		= $param->getAttribute('Total');
		$version       		= $param->getAttribute('Version');
		$noCertificado 		= $param->getAttribute('NoCertificado');
		$formaDePago   		= $param->getAttribute('FormaPago');
		$metodoDePago  		= $param->getAttribute('MetodoPago');
		$moneda		  		   = $param->getAttribute('Moneda');
		$tipoCambio	  		   = $param->getAttribute('TipoCambio');
		$NumCtaPago    		= "";
		$LugarExpedicion 	   = $param->getAttribute('LugarExpedicion');
		$FechaHoraEmision 	= $param->getAttribute('Fecha');
	}
	
	if (strlen($Fact_NoFact) == 0){
		$Fact_NoFact = "S/N";
	}
	
	// Adicionado por FFR en MArzo 30, 2019
	// Para el manejo de los CFDI Relacionados  
	$Tipo_Relacion = "";
	$params = $DOM->getElementsByTagName('CfdiRelacionados');
	foreach ($params as $param) {
		$Tipo_Relacion 		= $param->getAttribute('TipoRelacion');
	}
	$i		= 0; 
	$paramx = $DOM->getElementsByTagName('cfdiRelacionado');
	foreach ($paramx as $param) {
		$ArrayUUID[$i]      = $param->getAttribute('UUID');
		$i++;
	}


	$i		= 0; 
   $k    = 0;
	$ImpTot = 0;
	$ImporteTotalIVA 		= 0;
	$ImporteTotalIEPS 	= 0;
	$ImporteTotalISR  	= 0;
	$ImporteTotalIVAR  	= 0;

	$params = $DOM->getElementsByTagName('Concepto');
	foreach ($params as $param) 
	{
		$ArrayCant[$i]      = $param->getAttribute('Cantidad');
		$ArrayCvePro[$i]    = $param->getAttribute('ClaveProdServ');
		$ArrayUniMed[$i]    = $param->getAttribute('Unidad');
		$ArrayClaArtSer[$i] = $param->getAttribute('ClaveUnidad'); 
		$ArrayArtSer[$i]    = $param->getAttribute('Descripcion');
		$ArrayPreUni[$i]    = $param->getAttribute('ValorUnitario');
		$ArrayDescuento[$i] = $param->getAttribute('Descuento');
		$ArrayImporte[$i]   = $param->getAttribute('Importe');
		
		// Added by facc's on Feb 28, 2022 for CFDI 4.0
		$ArrayObjImpu[$i]   = $param->getAttribute('ObjetoImp');
		$lTipImp = 0;
		$traslados = $param->getElementsByTagName('Traslado');
		foreach ($traslados as $traslado) {
			$lTipImp = 1;
			$ArrayTrasladoImpo[$i]  = $traslado->getAttribute('Importe');
			$ArrayTrasladoTasa[$i]  = $traslado->getAttribute('TasaOCuota');
			$ArrayTrasladoTipo[$i]  = $traslado->getAttribute('TipoFactor');
			$ArrayTrasladoImpu[$i]  = $traslado->getAttribute('Impuesto');
			$ArrayTrasladoBase[$i]  = $traslado->getAttribute('Base');

			$TotImpuestos =  $TotImpuestos + $traslado->getAttribute('Importe');
		
			if ($traslado->getAttribute('Impuesto') == "002")
			{ // IVA
				$ImporteTotalIVA = $ImporteTotalIVA + $traslado->getAttribute('Importe');    
			}
			
			if ($traslado->getAttribute('Impuesto') == "003")
			{ // IEPS
				$ImporteTotalIEPS = $ImporteTotalIEPS + $traslado->getAttribute('Importe');    
			}

		}

		$retenciones = $param->getElementsByTagName('Retencion');
		foreach ($retenciones as $retencion) {
			$lTipImp = 2;
			$ArrayRetencionImpo[$i]  = $retencion->getAttribute('Importe');
			$ArrayRetencionTasa[$i]  = $retencion->getAttribute('TasaOCuota');
			$ArrayRetencionTipo[$i]  = $retencion->getAttribute('TipoFactor');
			$ArrayRetencionImpu[$i]  = $retencion->getAttribute('Impuesto');
			$ArrayRetencionBase[$i]  = $retencion->getAttribute('Base');

			if ($retencion->getAttribute('Impuesto')=="001")
			{ // ISR
				$ImporteTotalISR = $ImporteTotalISR + $retencion->getAttribute('Importe');    
			}
			if ($retencion->getAttribute('Impuesto')=="002")
			{ // ISR
				$ImporteTotalIVAR = $ImporteTotalIVAR + $retencion->getAttribute('Importe');    
			}
		}

		$SumaImportes 		  = $SumaImportes + $ArrayImporte[$i];
		$i++;
	}       

	// $ImporteTotalIVA 		= 0;
	// $ImporteTotalIEPS 	= 0;
	// $ImporteTotalISR  	= 0;
	// $ImporteTotalIVAR  	= 0;
	
	// $params = $DOM->getElementsByTagName('Retencion');
	// foreach ($params as $param) {
	// 	if($param->getAttribute('Base') == "")
	// 	{
	// 		if ($param->getAttribute('Impuesto')=="001")
	// 		{ // ISR
	// 			$ImporteTotalISR = $ImporteTotalISR + $param->getAttribute('Importe');    
	// 		}
	// 		if ($param->getAttribute('Impuesto')=="002")
	// 		{ // ISR
	// 			$ImporteTotalIVAR = $ImporteTotalIVAR + $param->getAttribute('Importe');    
	// 		}
	// 	}
	// }
	
	// $params = $DOM->getElementsByTagName('Traslado');
	// foreach ($params as $param) {
	// 	if($param->getAttribute('Base') == "")
	// 	{
	// 		$TotImpuestos =  $TotImpuestos + $param->getAttribute('Importe');
		
	// 		if ($param->getAttribute('Impuesto')=="002")
	// 		{ // IVA
	// 			$ImporteTotalIVA = $ImporteTotalIVA + $param->getAttribute('Importe');    
	// 		}
			
	// 		if ($param->getAttribute('Impuesto')=="003")
	// 		{ // IEPS
	// 			$ImporteTotalIEPS = $ImporteTotalIEPS + $param->getAttribute('Importe');    
	// 		}
	// 	}
	// }
	
			
    if ($fechaTim != "")
	{
		$CadOri = "||".$versionTim."|".$UUID."|".$fechaTim."|".$rfcPAC."|".$selloCFD."|".$noCertificadoSAT."||";
	}
	else
	{
		$CadOri = "||".$versionTim."|".$UUID."|".$Fact_Fecha."|".$rfcPAC."|".$selloCFD."|".$noCertificadoSAT."||";
	}	
	
	#============================================================================================================
	#== 3. Crear archivo .PNG con codigo bidimensional 
	#============================================================================================================

	$filename = "";

	if ($UUID != "")
	{
		$filename 	= $SendaArchsGraf."/Img_".$UUID.".png";
		$CadImpTot 	= ProcesImpTot($total);
		$CadImpTot  = str_replace ( ",", '', $CadImpTot);
		$CadSello  	= substr($selloCFD,-8);
		$Cadena 	= "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=".$UUID."&re=".$Emisor_RFC."&rr=".$Receptor_RFC."&tt=".$CadImpTot."&fe=".$CadSello;
		QRcode::png($Cadena, $filename, 'H', 3, 2);    
		chmod($filename, 0777);  
	}

	#============================================================================================================
	#== 4. CONSTRUYENDO EL DOCUMENTOS CON LA LIBRERÍA FPDF 
	#============================================================================================================
	
	$pdf=new PDF('P','cm','Letter');
	$pdf->AliasNbPages();
	$pdf->AddPage();
	$pdf->AddFont('IDAutomationHC39M','','IDAutomationHC39M.php');
	$pdf->AddFont('verdana','','verdana.php');
	$pdf->SetAutoPageBreak(true);
	$pdf->SetMargins(0, 0, 0);
	$pdf->SetLineWidth(0.02);
	$pdf->SetFillColor(0,0,0);
	
	#============================================================================================================
	#== 4.1 ENCABEZADO DE LA FACTURA 
	#============================================================================================================
	
	$X = 0;
	$Y = 0;
	

	$pdf->image("archs_graf/Membrete_Fact_RZ.jpg",$X+1, $Y+1 , 9, 2.3);
	$pdf->image("archs_graf/LogoSAT.jpg",$X+16.6, $Y+3.4 , 0, 0);
	
	$pdf->SetTextColor(128,0,0);
	$pdf->SetFont('arial','B',13);
	$pdf->SetXY($X+11.7,$Y+1.20+0.1);
	$pdf->Cell(1.5, 0.25, "COMPROBANTE FISCAL DIGITAL", 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+15.5,$Y+1.96);
	$pdf->Cell(2.5, 0.25, "FOLIO:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(171,17,17);
	$pdf->SetFont('arial','B',14);
	$pdf->SetXY($X+17,$Y+1.95);
	$pdf->Cell(1, 0.25, $Fact_NoFact, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+2.05);
	$pdf->Cell(2, 0.25, "FOLIO FISCAL:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','B',11);
	$pdf->SetXY($X+10.5+0.5,$Y+2.6);
	$pdf->Cell(2, 0.25, $UUID, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+2.5+0.6);
	$pdf->Cell(2, 0.25, "CERTIFICADO SAT:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+10.5+0.5,$Y+2.5+0.6+0.4);
	$pdf->Cell(2, 0.25, $noCertificadoSAT, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+4.06);
	$pdf->Cell(2, 0.25, "CERTIFICADO DEL EMISOR:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+10.5+0.5,$Y+4.06+0.4);
	$pdf->Cell(2, 0.25, $noCertificado, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+4.46+0.5);
	$pdf->Cell(2, 0.25, utf8_decode("FECHA HORA DE EMISIÓN:"), 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',9);
	$pdf->SetXY($X+10.5+0.5,$Y+4.46+0.5+0.34);
	$pdf->MultiCell(9.4, 0.35, str_replace("T"," ",utf8_decode($FechaHoraEmision)), 0, 'L');
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+6);
	$pdf->Cell(2, 0.25, utf8_decode("FECHA HORA DE CERTIFICACIÓN:"), 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',9);
	$pdf->SetXY($X+10.5+5.5,$Y+6);
	$pdf->Cell(2, 0.25, str_replace("T"," ",$fechaTim), 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+6.6);
	$pdf->Cell(2, 0.25, utf8_decode("TIPO DE COMPROBANTE:"), 0, 1,'L', 0);
	
	$pdf->SetFont('arial','',9);
	$pdf->SetTextColor(17,71,121);
	$pdf->SetXY($X+14.7,$Y+6.6);
	$pdf->Cell(1, 0.25, utf8_decode("I - INGRESO"), 0, 1,'L', 0);

	$pdf->SetFont('arial','B',14);
	$pdf->SetTextColor(17,71,121);
	$pdf->SetXY($X+19.0,$Y+6.6);
	$pdf->Cell(1, 0.25, utf8_decode("v4.0"), 0, 1,'L', 0);
	$pdf->SetFont('arial','',9);

	$pdf->SetDrawColor(128,0,0);
	$pdf->SetLineWidth(0.05);
	$pdf->RoundedRect($X+10.4, $Y+1, 10, 6.14, 0.2, '');
	
	#============================================================================================================
	#== 4.2 DATOS DEL EMISOR
	#============================================================================================================
	
	#==$pdf->SetFillColor(84,141,212);
	$pdf->SetFillColor(223,234,247);
	$pdf->RoundedRect($X+1, $Y+3.5, 9, 3.64, 0.2, 'F');
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',11);
	$pdf->SetXY($X+1.05,$Y+3.7);
	$pdf->Cell(1, 0.25, "EMISOR:", 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',12);
	$pdf->SetXY($X+1.4,$Y+4.0+0.2);
	$pdf->MultiCell(8.6, 0.45, utf8_decode($Emisor_Nom), 0, 'C');
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.05,$Y+3.7+0.45+1.25);
	$pdf->Cell(1, 0.25, "RFC:", 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+2.05,$Y+3.7+0.45+1.25);
	$pdf->Cell(1, 0.25, utf8_decode($Emisor_RFC), 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+1.05,$Y+3.7+0.45+1.8);
	$pdf->Cell(1, 0.25, utf8_decode("LUGAR DE EXPEDICIÓN:"), 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+1.05+4,$Y+3.7+0.45+1.8);
	$pdf->Cell(1, 0.25, $LugarExpedicion, 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+1.05,$Y+4.2+0.45+1.8);
	$pdf->Cell(1, 0.25, utf8_decode("RÉGIMEN FISCAL:"), 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+0.05+4,$Y+4.2+0.45+1.8);
	$pdf->Cell(1, 0.25, $Emisor_Regimen, 0, 1,'L', 0);
	$Y = $Y -1;
	
	#============================================================================================================
	#== 4.3 DATOS DEL RECEPTOR
	#============================================================================================================
	
	#==$pdf->SetFillColor(191,191,191);
	$pdf->SetFillColor(222,222,222);
	#==$pdf->SetFillColor(223,234,247);
	$pdf->RoundedRect($X+1, $Y+8.4, 19.4, 2.0, 0.2, 'F');
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',11);
	$pdf->SetXY($X+1.05,$Y+8.6);
	$pdf->Cell(1, 0.25, "RECEPTOR:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.5,$Y+8.4+0.60);
	$pdf->Cell(1, 0.25, utf8_decode($Receptor_Nom), 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.05,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, "RFC:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+1.05+0.9,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_RFC, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+6,$Y+9.5+0.1);
	$pdf->Cell(2, 0.25, utf8_decode("USO CFDI:"), 0, 1,'L', 0);    
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+6+2,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_UsoCFDI, 0, 1,'L', 0);

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+10,$Y+9.5+0.1);
	$pdf->Cell(2, 0.25, utf8_decode("RÉGIMEN FISCAL:"), 0, 1,'L', 0);    
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+10+3.3,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_RegFis, 0, 1,'L', 0);

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+15.5,$Y+9.5+0.1);
	$pdf->Cell(2, 0.25, utf8_decode("CÓDIGO POSTAL:"), 0, 1,'L', 0);    
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+15.5+3.3,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_DomFis, 0, 1,'L', 0);   

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.05, $Y+10.0);
	$pdf->Cell(2, 0.25, utf8_decode("DIRECCIÓN:"), 0, 1,'L', 0);   

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+1.05+3.3, $Y+10.0);
	$pdf->Cell(1, 0.25, utf8_decode($Direccion), 0, 1,'L', 0);

	if ($CIF != '') {
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('arial','B',10);
		$pdf->SetXY($X+1.05, $Y+11.0);
		$pdf->Cell(2, 0.25, utf8_decode("CIF:"), 0, 1,'L', 0);   

		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('arial','',11);
		$pdf->SetXY($X+1.05+3.3, $Y+11.0);
		$pdf->Cell(1, 0.25, utf8_decode($CIF), 0, 1,'L', 0);
	}

	$pdf->SetDrawColor(0,0,0);
	$pdf->SetLineWidth(0.02);    
	
	VerifStatusCFDI($pdf, $StatusCFDI);
	
	$Puntero	= 0;
	$a 			= 9.58;
	$b 			= 0;
	$c 			= 0;
	$Y 			= $Y + 1;
	
	#============================================================================================================
	#== 4.3 REGISTROS DE CFDI RELACIONADOS
	#============================================================================================================

	if($Tipo_Relacion <> "")
	{
		$Y = $pdf->GetY()+0.50;

		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('arial','B',11);
		$pdf->SetXY($X+1.05,$Y);
		$pdf->Cell(1, 0.25, "CFDI RELACIONADOS", 0, 1,'L', 0);


		$pdf->SetFont('arial','',9);
		$pdf->SetXY($X+6.0,$Y);
		$pdf->Cell(1, 0.25, utf8_decode("Tipo de Relación: ").$Tipo_Relacion, 0, 1,'L', 0);

		$Y = $pdf->GetY()+0.20;

		$TotRegs = count($ArrayUUID);

		for ($i=0; $i<$TotRegs; $i++)
		{
			$YY = $pdf->GetY()+0.20;
			$Y = $YY;

			$pdf->SetFont('arial','',8);
			$pdf->SetTextColor(0,0,0);
			
			$pdf->SetXY($X+1.05,$Y);
			$pdf->Cell(1.5, 0.30, $ArrayUUID[$i], 0, 1,'L', 0);
		}
	}
	
	#============================================================================================================ 
	#== 4.3 REGISTROS DE ARTÍCULOS 
	#============================================================================================================
	
	$Y = $pdf->GetY()+0.20;
	
	if (strlen($Obs)==0)
	{
		$Y = $Y + 1.1;
	}
	else
	{
		$Y = $Y + 0.8;
	}
	
	$Regs 			= 0;
	$RefAgregPag 	= 0;
	
	Titulos($pdf, $Y-0.8);    
	
	$TotRegs = count($ArrayCant);
	
	for ($i=0; $i<$TotRegs; $i++)
	{
		$pdf->SetFont('arial','',8);
		$pdf->SetTextColor(0,0,0);
		
		$pdf->SetXY($X+0.75,$Y);
		$pdf->Cell(1.5, 0.30, $ArrayCant[$i], 0, 1,'C', 0);
		
		$pdf->SetXY($X+1.975,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode($ArrayClaArtSer[$i]), 0, 1,'L', 0);
		
		$pdf->SetXY($X+2.6,$Y);
		$pdf->MultiCell(2.0, 0.30, utf8_decode($ArrayUniMed[$i]), 0, 'L', 0);
		
		$pdf->SetXY($X+4.5,$Y);
		$pdf->Cell(2.0, 0.30, utf8_decode($ArrayCvePro[$i]), 0, 1,'L', 0);

		$pdf->SetXY($X+6.2,$Y);
		$pdf->Cell(1.7, 0.30, number_format($ArrayPreUni[$i],2), 0, 1,'R', 0);
		
		$pdf->SetXY($X+8.0,$Y);
		$pdf->Cell(1.8, 0.30, number_format($ArrayImporte[$i],2), 0, 1,'R', 0);

		$pdf->SetXY($X+10.6,$Y);
		$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);
		}
	}       
	
	
		