<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
$id_bodega = $_POST["lstbodega"];	
$id_zona = $_POST["lstzona"];	
$id_vendedor = $_POST["lstvendedor"];	
$sql_num_bol=$_POST["txtnumbol"];
$id_tipo_pago=$_POST["lstpago"];
include("../../conex.php");
?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Contado</title>
	</head>
	<style type="text/css">
	<!--
	.Estilo18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; }
	.Estilo19 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
	-->
	</style>
	<?
	
		
	$cant = 1;
	$flag=0;
	/******************************  Descuento en pesos *********************************************************************/
		$sql_descuento=$_POST["sql_descuento"];
		$sql_subtotal=$_POST["sql_subtotal"];
		$cal_descuento=$sql_descuento;
		$por_des=($cal_descuento*100)/$sql_subtotal;
	/******************************  Total de productos *********************************************************************/
		
		$cant = "1";
	$ctot_prod=0;
	while ($cant<=$cnt)
		{
		if ($total[$cant]>0)
			{
			$ctot_prod+=1;
			}
		$cant=$cant+1;
		}
		/************************************************** sacar valor de iva ***********************************************/	
		$sql_neto=$_POST["sql_neto"];
		$sql_iva=$_POST["sql_iva"];
		$sql_total=$_POST["sql_total"];
	
	
		/************************************************** insertar salida ***********************************************/	
		$fecha=$_POST["txtfecha"];
		$dia = substr ($fecha, 0, 2);
		$mes = substr ($fecha, 3, 2);
		$ano2 = substr ($fecha, 8, 2);
		$aņo = substr ($fecha, 6, 4); 
		$fecha_em = "$aņo-$mes-$dia";
		$fecha=$_POST["fechaven"];
		$dia = substr ($fecha, 0, 2);
		$mes = substr ($fecha, 3, 2);
		$aņo = substr ($fecha, 6, 4); 
		$fecha_ve = "$aņo-$mes-$dia";
		
	?>
	<body onLoad="fun_mail();">
	
	<table width="400px" align="center" border="0" cellpadding="0" cellspacing="0">
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
		<tr height="11px">
			<td width="100%">&nbsp;</td>
		</tr>
	</table>
	<table width="400px" align="center" border="0" cellpadding="0" cellspacing="0">
		<tr height="27px">
			<td width="280px">&nbsp;</td>
			<td width="40px" align="center"><?=$dia;?></td>
			<td width="40px" align="center"><?=$mes;?></td>
			<td width="40px" align="center"><?=$ano2;?></td>
		</tr>
	</table>
	<table width="400px" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr height="11px"> 
			<td width="47px"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">&nbsp;</font></strong></div></td>
			<td width="39px"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">&nbsp;</font></strong></div></td>
			<td width="235px"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">&nbsp;</font></strong></div></td>
			<td width="79px"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">&nbsp;</font></strong></div></td>
		</tr>
	<? 
	$cant = 1;
	$cnt_tot_prod=0;
	$total_while=0;
	while ($cant<=$cnt)
		{
		if ($total[$cant]>0)
			{
			$cnt_tot_prod+=1;
			if($cnt_tot_prod<$ctot_prod){
				$porcentaje_valor=100-$por_des;
				$totalw=(int)($total[$cant]*$porcentaje_valor/100);
				$total_while+=$totalw;
				$desporprod[$cant]=$total[$cant]-$totalw;
				}
			else{
				$totalw=$txttotal-$total_while;
				$desporprod[$cant]=$total[$cant]-$totalw;
				}
			}
		$cant=$cant+1;
		}
		for ($i=1;$i<=$cnt;$i++)
			{ 	
			for ($j=1;$j<$cnt;$j++)
				{
					$auxa = $j+1;
				if ($codigo[$j]=='')
					{
					$aux=$codigo[$j];
					$codigo[$j]=$codigo[$auxa];
					$codigo[$auxa]=$aux;
					
					$aux=$cantidad[$j];
					$cantidad[$j]=$cantidad[$auxa];
					$cantidad[$auxa]=$aux;
					
					$aux=$precio[$j];
					$precio[$j]=$precio[$auxa];
					$precio[$auxa]=$aux;
					
					$aux=$detalle[$j];
					$detalle[$j]=$detalle[$auxa];
					$detalle[$auxa]=$aux;
					}
				}
			}
		
		
		
		?>
		<tr height="11px"> 
			<td><div align="left" style=""><span class="Estilo19">
				&nbsp;<? echo "$codigo[1]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[1]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[1]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[1]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[2]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[2]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[2]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[2]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[3]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[3]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[3]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[3]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[4]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[4]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[4]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[4]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[5]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[5]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[5]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[5]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[6]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[6]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[6]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[6]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[7]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[7]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[7]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[7]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[8]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[8]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[8]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[8]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[9]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[8]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[9]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[9]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[10]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[10]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[10]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[10]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[11]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[11]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[11]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[11]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[12]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[12]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[12]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[12]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[13]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[13]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[13]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[13]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;<? echo "$codigo[14]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$cantidad[14]";?>&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? echo "$detalle[14]";?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? echo "$precio[14]";?>&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				&nbsp;
			</span></div></td>
		</tr>	
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				&nbsp;
			</span></div></td>
		</tr>
		<tr height="11px"> 
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				&nbsp;
			</span></div></td>
			<td><div align="left"><span class="Estilo19">
				<? if ($cal_descuento!=0) { ?> Descuento: <? }?>&nbsp;
			</span></div></td>
			<td><div align="right"><span class="Estilo19">
				<? if ($cal_descuento!=0) { echo $cal_descuento; }?>&nbsp;
			</span></div></td>
		</tr>	
		
	</table>
	
	<table width="400px" align="center" border="0" cellpadding="0" cellspacing="0">
		<tr height="27px">
			<td width="47px">&nbsp;</td>
			<td width="39px" align="center">&nbsp;</td>
			<td width="235px" align="right">&nbsp;</td>
			<td width="79px" align="right"><?=$sql_total?></td>
		</tr>
	</table>
	</body>
	</html>
<script>
function fun_mail()
	{
	window.print();
	window.top.open('','_parent','');window.top.close();
	}
</script>



