<?php
$docs_id=$_GET['docs_id'];
?>
<page backtop="1mm" backbottom="5mm" backleft="5mm" backright="5mm" style="font-size: 11pt; font-family: arial" >
    <table cellspacing="0" style="width: 100%;" >
        <tr>
            <td style="width: 48%; color: #444444;">
                <img style="width: 60%;" src="../../../img/<?php echo $empresa;?>.png" alt="Logo"><br>
            </td>
			<td style="width: 40%;font-size:12px;text-align:center;">
				<strong style="font-size:15px"><?php echo $emp_nombre;?></strong><br>
				<strong>Nit: <?php echo $emp_nit;?></strong> <br>
				<strong><?php echo $emp_direccion;?></strong><br>
				<strong><?php echo $emp_correo;?></strong><br>
				<strong>Tel: <?php echo $emp_cel;?> / <?php echo $emp_telefono;?></strong><br>
				<!--<strong>Responsable de IVA </strong><br> 
				<strong>Agente de retención en el impuesto sobre las ventas</strong>-->
			</td>
        </tr>
    </table>
  <div style="text-align: right;font-size:8px;padding-bottom:0px;">Autorización de numeración Dian No 18764035924072 desde DSE 1 hasta DSE 100000 con vigencia de 12 meses </div>
 	<table cellspacing="0" style="width: 100%;" >
        <tr>
             <td style="width: 70%;">
                <table cellspacing="0">
                    <tr>
                        <td style="background-color:#bdc3c7;padding:2px;text-align:center;"> 
                            <strong style="font-size:10px;color: #000" >DATOS DEL CLIENTE</strong>
                        </td>
                    </tr>
					<?php
					  	$can=mysqli_query($con,"SELECT * FROM proveedor where pro_id='$docs_proveedor'") or die(mysqli_error($con)); 
					    $dato1=mysqli_fetch_array($can);
					?>
					<tr>
						<td style="width: 100%;text-align:left;border:solid 1px #bdc3c7;font-size:10px ;padding-left: 15px"> 
							<p style="padding:-10px;"><strong>NOMBRE: </strong><?php echo $dato1['pro_nombre'];?></p>
							<p style="padding:-10px;"><strong>DOCUMENTO: </strong><?php echo $dato1['pro_nit'];?></p>
							<p style="padding:-10px;"><strong>DIRECCION: </strong><?php echo $dato1['pro_direccion'];?></p>
							<p style="padding:-10px;"><strong>TELEFONO: </strong><?php echo $dato1['pro_telefono'];?></p>
							<p style="padding:-10px;"><strong>FORMA DE PAGO: </strong><?php echo $dato['dosc_forma_pago'];?></p>
						</td>
					</tr>
			    </table>
            </td>
			<td style="width: 30%;">
				<table cellspacing="0" style="width: 100%; padding-left:5px">
			        <tr>
						<td style="width: 100%;color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
							<?php if ($docs_tipo_doc=='11') { ?>
							 	<strong style="font-size:10px;color: #000">DOCUMENTO SOPORTE N°</strong>
							<?php } else { ?>
							 	<strong style="font-size:10px;color: #000">NOTA DE AJUSTE A DOCUMENTO SOPORTE N°</strong>
							<?php }  ?>
						</td>
					</tr>
					<tr>
						<td style="width: 100%;padding:2px;text-align:center;border:solid 1px #bdc3c7;font-size:12px"> 
							<strong style="color: red"><?php echo $docs_prefijo;?><?php echo $docs_numero;?></strong>
						</td>
					</tr>
			    </table>
			    <table cellspacing="0" style="width: 100%;padding-left: 5px; padding-top: 5px;">
					<tr>
						<td style="width: 100%;text-align:left;border:solid 1px #bdc3c7;font-size:10px ;padding-left: 15px;"> 
							<p style="padding:-10px;"><strong>FECHA : </strong><?php echo $dato['docs_fecha'];?></p><br><br>	
						</td>
					</tr>
			    </table>
			</td>
		</tr>
    </table>



	<table cellspacing="0" style="width: 100%; padding-top: 5px;">
        <tr>
			<td style="width: 5%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">CANT</strong>
			</td>
			
			<td style="width: 50%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">DESCRIPCIÓN</strong>
			</td>
			<td style="width: 8%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">PRECIO U</strong>
			</td>
			<td style="width:9%; color:white;background-color:#bdc3c7;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">TOTAL</strong>
			</td>
		</tr>
<?php

$total_retencion=0;
$ret=mysqli_query($con,"SELECT SUM(ret_importe) as ret_importe FROM retencion_doc where retencion_ret_id='$docs_id'") or die(mysqli_error($con)); 
$rets=mysqli_fetch_array($ret);
$total_retencion=$rets['ret_importe'];

$sumador_total=0;
$can7=mysqli_query($con,"SELECT * FROM dian_documento_detalle where documento_id='$docs_id'") or die(mysqli_error($con));  
while($row=mysqli_fetch_array($can7))
{
    $sopd_nombre=$row['sopd_nombre'];
    $sopd_cantidad=$row['sopd_cantidad'];
    $sopd_precio=$row['sopd_precio'];
    $total=$sopd_precio*$sopd_cantidad;
    $sumador_total+= $total;
?>		
		<tr>
			
			<td style="width:10%;padding:2px;text-align:center;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $sopd_cantidad;?>
			</td>
			
			<td style="width: 60%;padding:2px;text-align:left;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo $sopd_nombre;?>
			</td>
			<td style="width:15%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo number_format($sopd_precio,0);?>
			</td>
			
			<td style="width: 15%;padding:2px;text-align:right;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7; border-bottom:solid 1px #bdc3c7;font-size:9px"> 
				<?php echo number_format($total,0);?>
			</td>
		</tr>
<?php } ?>		
    </table>


    <table cellspacing="0" style="width: 100%;padding-top: 5px;">
        <tr>
            <td style="width:69%;">
            	<table cellspacing="0" style="width: 100%;">
					<tr>
						<td>
							<table cellspacing="0" style="width: 100%;" >
								<tr>
									<td colspan="3" style="width: 100%;padding-bottom: 36px"></td>
								</tr>
								<tr>
									<td style="width: 45%;">_______________________________</td>
									<td style="width: 5%;"></td>
									<td style="width: 45%;">_____________________________</td>	
								</tr>
								<tr>
									<td style="width: 45%;font-size:8px;">ACEPTO QUE NO SOY RESPONSABLE DE IVA</td>
									<td style="width: 5%;"></td>
									<td style="width: 45%;font-size:8px;">ELABORADO POR</td>		
								</tr>
						    </table>
						</td>
					</tr>
			    </table>
            </td>
            <td style="width: 1%;"></td>
			<td style="width:30%;">
				<table cellspacing="0" style="width: 100%;">
			        <tr>
						<td colspan="2" style="width: 100%;color:white;background-color:#bdc3c7;text-align:center;padding:2px;"> 
							<strong style="font-size:10px;color: #000" >TOTALES</strong>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							SUBTOTAL
						</td>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($sumador_total,0); ?>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							RETENCIONES
						</td>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($total_retencion,0); ?>
						</td>
					</tr>
					<tr>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							TOTAL
						</td>
						<td style="width: 50%;padding:4px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;border-right:solid 1px #bdc3c7;font-size:10px;text-align:right;"> 
							<?php echo number_format($sumador_total-$total_retencion,0); ?>
						</td>
					</tr>
			    </table>
			</td>
		</tr>
    </table>
	<div style="font-size:8px;text-align: center;padding: 2px">Cufe: <?php echo $dato['dosc_cuds'];;?></div>
    <div style="font-size:10px; padding: 2px;text-align: center;">Documento soporte de costos y gastos en operaciones con no obligados a expedir factura o documento equivalente</div>
     <div style="font-size:8px; padding: 2px;text-align: center;"> Artículo 1.6.1.4.12 Decreto Único reglamentario en materia tributaria 1625 de 2016 - Susutituido por el Decreto 358 de 2020</div>
   
	<div style="width:100%; border-top:dashed 1px;margin-top:1mm;"></div>
	
</page>	  