<?php
$total_global=0;
$query=mysqli_query($con, "SELECT * FROM dian_documento_soporte where docs_fecha BETWEEN '$desde' AND '$hasta' and empresa='$empresa' order by docs_fecha desc");

?>
<page backtop="1mm" backbottom="5mm" backleft="5mm" backright="5mm" style="font-size: 11pt; font-family: arial" >
	<table cellspacing="0" style="width: 100%; padding-top: 5px;">
		
		<tr style="">
			<td colspan="6" style="width: 100%; color:white;background-color:#FF330C;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">REPORTE DOCUMENTO SOPORTE VICPOS</strong>
			</td>
		</tr>

		<?php
		while ($roww=mysqli_fetch_array($query))
		{
			 $docs_id=$roww['docs_id'];
		?>

		<tr>
			<td style="width: 10%;color:white;background-color:#CACDCD;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">N°</strong>
			</td>
			<td style="width: 40%; color:white;background-color:#CACDCD;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">PROVEEDOR</strong>
			</td>
			<td style="width: 20%; color:white;background-color:#CACDCD;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">DOCUMENTO</strong>
			</td>
			<td style="width: 20%; color:white;background-color:#CACDCD;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000">FECHA</strong>
			</td>
		</tr>
		
		
    	<tr style="">
			<td style="width: 10%;color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo $roww['docs_prefijo'];?> <?php echo $roww['docs_numero'];?> </strong>
			</td>
			<td style="width: 40%; color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">
					<?php 
					$docs_proveedor=$roww['docs_proveedor'];
					$can=mysqli_query($con,"SELECT * FROM proveedor where pro_id=$docs_proveedor") or die(mysqli_error($con));
	                $dato1=mysqli_fetch_array($can);

					echo $dato1['pro_nombre'];?>
				</strong>
			</td>
			<td style="width: 20%; color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo $dato1['pro_nit']?> - <?php echo $dato1['pro_dv']?></strong>
			</td>
			<td style="width: 20%; color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo $roww['docs_fecha'];?></strong>
			</td>
			
		</tr>
		<tr style="">


			<td style="width: 10%;color:white;background-color:#CACDCD;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">CANT.</strong>
			</td>
			<td style="width: 40%; color:white;background-color:#CACDCD;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">DESCRIPCIÓN</strong>
			</td>
			<td style="width: 20%; color:white;background-color:#CACDCD;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">PRECIO U.</strong>
			</td>
			<td style="width: 20%; color:white;background-color:#CACDCD;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">TOTAL</strong>
			</td>
			
		</tr>
		<?php

$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 style="">
			<td style="width: 10%;color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo $sopd_cantidad;?></strong>
			</td>
			<td style="width: 40%; color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo $sopd_nombre;?></strong>
			</td>
			<td style="width: 20%; color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo number_format($sopd_precio);?></strong>
			</td>
			<td style="width: 20%; color:white;background-color:#fff;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo number_format($total,0);?></strong>
			</td>
		</tr>

		    
   		

	<?php } ?>
		<tr>
			<td colspan="3" style="width: 20%; color:white;background-color:#FFF894;padding:2px;text-align:right;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">TOTAL</strong>
			</td>
			<td colspan="2"  style="width: 10%; color:white;background-color:#FFF894;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo number_format($sumador_total,0);?></strong>
			</td>
		</tr>

		<tr>
			<td colspan="6" style="width: 10%;color:white;background-color:#FFFFFF;padding:2px;text-align:center"> 
				<strong style="font-size:10px;color: #000"> </strong>
			</td>
		</tr>
	<?php 
 $total_global+= $sumador_total;
} ?>
	<tr>
		<td colspan="3" style="width: 20%; color:white;background-color:#A0EEFF;padding:2px;text-align:right;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000">TOTAL</strong>
		</td>
		<td colspan="2" style="width: 10%; color:white;background-color:#A0EEFF;padding:2px;text-align:center;border-bottom:solid 1px #bdc3c7;border-left:solid 1px #bdc3c7;"> 
				<strong style="font-size:10px;color: #000"><?php echo number_format($total_global,0);?></strong>
		</td>
	</tr>

	</table>
</page>	  