<?php
session_start();
$ruta = '../../';
include($ruta."cxc/clases/covensol_cxc_c_cuentasxcobrar.php");
$propiedades['habilitar_json'] = 'no';
$objcxc = new covensol_cxc_cuentasxcobrar($propiedades);
$valido = $objcxc->cargar_seguridad("CXC","covensol_cxc_cmp_anticipo.php");
if($valido===false){exit();}

require_once($ruta.'shared/tcpdf/config/lang/ita.php');
require_once($ruta.'shared/tcpdf/tcpdf.php');  
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);


$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', true, 'UTF-8', false); 
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
$pdf->SetFooterMargin(10);
$pdf->SetAutoPageBreak(TRUE, 10);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setPrintHeader(false);
$pdf->setTextoFooter(utf8_encode('Ave. Panteón, Res. Antares, Piso 11, Apto 11-B, Caracas.'));
$pdf->SetFont('helvetica', '', 12);
$pdf->AddPage();



$margenes = $pdf->getMargins();

$fecha = date('m/d/Y');
$ano = date('Y');
$mes = date('m');
$dia = date('d');

$pdf->Image($ruta.'shared/imagebank/'.$_SESSION["ls_logo"],$margenes['left'],$margenes['top'], 30, 15); 

$prop['idant'] = $_GET['idant'];
			
$prop['criterio']='por_id';			
$filas = $objcxc->ConsultaAnticipo($prop);
$datos = $filas['fila'];
$datos = $objcxc->FormatDatosAntPresent($filas['fila']);	

$pdf->SetLineStyle(array('width' => 0.2, 'color' => $pdf->decodifica_color('#DDDDDD')));
$ancho[1] = 120;
$ancho[2] = 400;
$ancho_total = array_sum($ancho);
$ancho_firma=$ancho_total/3;

$pdf->SetY(30);
$DatosCaja="";
if($datos['codcaj']){
$DatosCaja='<tr>
			 <td width="'.$ancho[1].'" align="right"><b>Sucursal:</b></td>
			 <td width="'.$ancho[2].'" align="left"> '.$datos['nomsuc'].' </td>
		    </tr>
		    <tr>
			 <td width="'.$ancho[1].'" align="right"><b>Caja:</b></td>
			 <td width="'.$ancho[2].'" align="left"> '.$datos['nomcaj'].' </td>
		    </tr>	
			';
}

$encabezado ='<table width="'.$ancho_total.'" border="1" cellspacing="0" cellpadding="2" bordercolor="#CCCCCC">
               <tr bgcolor="#555555" color="#FFFFFF" >
				<td colspan="2" width="'.$ancho_total.'" ><p align="center"><strong>COMPROBANTE DE ANTICIPO (SALDO A FAVOR) </strong></p></td>				
			   </tr>
			   '.$DatosCaja.'			   
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Cliente:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['codcliente'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Razón Social:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['nombre_cliente'].' </td>
			   </tr>	
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>RIF:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['rif_completo'].' </td>
			   </tr>	
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Domicilio Fiscal:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['dircliente'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Fecha:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['fecant'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>N° Anticipo:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['nroant'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>N° Estatus:</b></td>
				<td width="'.$ancho[2].'" align="left"> '.$datos['denestant'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Concepto:</b></td>
				<td width="'.$ancho[2].'" align="justify"> '.$datos['conant'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Moneda:</b></td>
				<td width="'.$ancho[2].'" align="justify"> '.$datos['abrmon'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Tasa de Cambio:</b></td>
				<td width="'.$ancho[2].'" align="justify"> '.$datos['tascam'].' </td>
			   </tr>
			   <tr>
				<td width="'.$ancho[1].'" align="right"><b>Monto:</b></td>
				<td width="'.$ancho[2].'" align="justify"> '.$datos['monant'].' </td>
			   </tr>				 
			  </table>';

$pdf->writeHTML(utf8_encode($encabezado), true, false, false, false, '');

$FirmaSello = '<table cellspacing="0" cellpadding="3" border="1">
				  <tr bgcolor="#CCCCCC">					
					<td  align="center" width="'.$ancho_firma.'"><font size="8">ELABORADO</font></td>
					<td  align="center" width="'.$ancho_firma.'"><font size="8">VERIFICADO</font></td>
					<td align="center" width="'.$ancho_firma.'"><font size="8">AUTORIZADO</font></td>
				  </tr>
				  <tr>
					<td height="65" align="center">					   
					</td>
					<td>					
					</td>
					<td>					
					</td>
				  </tr>				 
				</table>';



$pdf->SetY(232);
$pdf->writeHTML(utf8_encode($FirmaSello), true, false, false, false, '');

$pdf->Output('Comprobante_Anticipo'.$datos['rif_completo'].'.pdf', 'I');


?>
