<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
	$sql_descuento=$_POST["sql_descuento"];
?>

<?php 
/*! 
  @function num2letras () 
  @abstract Dado un n?mero lo devuelve escrito. 
  @param $num number - N?mero a convertir. 
  @param $fem bool - Forma femenina (true) o no (false). 
  @param $dec bool - Con decimales (true) o no (false). 
  @result string - Devuelve el n?mero escrito en letra. 

*/ 
function num2letras($num, $fem = true, $dec = true) { 
//if (strlen($num) > 14) die("El n?mero introducido es demasiado grande"); 
   $matuni[2]  = "dos"; 
   $matuni[3]  = "tres"; 
   $matuni[4]  = "cuatro"; 
   $matuni[5]  = "cinco"; 
   $matuni[6]  = "seis"; 
   $matuni[7]  = "siete"; 
   $matuni[8]  = "ocho"; 
   $matuni[9]  = "nueve"; 
   $matuni[10] = "diez"; 
   $matuni[11] = "once"; 
   $matuni[12] = "doce"; 
   $matuni[13] = "trece"; 
   $matuni[14] = "catorce"; 
   $matuni[15] = "quince"; 
   $matuni[16] = "dieciseis"; 
   $matuni[17] = "diecisiete"; 
   $matuni[18] = "dieciocho"; 
   $matuni[19] = "diecinueve"; 
   $matuni[20] = "veinte"; 
   $matunisub[2] = "dos"; 
   $matunisub[3] = "tres"; 
   $matunisub[4] = "cuatro"; 
   $matunisub[5] = "quin"; 
   $matunisub[6] = "seis"; 
   $matunisub[7] = "sete"; 
   $matunisub[8] = "ocho"; 
   $matunisub[9] = "nove"; 

   $matdec[2] = "veint"; 
   $matdec[3] = "treinta"; 
   $matdec[4] = "cuarenta"; 
   $matdec[5] = "cincuenta"; 
   $matdec[6] = "sesenta"; 
   $matdec[7] = "setenta"; 
   $matdec[8] = "ochenta"; 
   $matdec[9] = "noventa"; 
   $matsub[3]  = 'mill'; 
   $matsub[5]  = 'bill'; 
   $matsub[7]  = 'mill'; 
   $matsub[9]  = 'trill'; 
   $matsub[11] = 'mill'; 
   $matsub[13] = 'bill'; 
   $matsub[15] = 'mill'; 
   $matmil[4]  = 'millones'; 
   $matmil[6]  = 'billones'; 
   $matmil[7]  = 'de billones'; 
   $matmil[8]  = 'millones de billones'; 
   $matmil[10] = 'trillones'; 
   $matmil[11] = 'de trillones'; 
   $matmil[12] = 'millones de trillones'; 
   $matmil[13] = 'de trillones'; 
   $matmil[14] = 'billones de trillones'; 
   $matmil[15] = 'de billones de trillones'; 
   $matmil[16] = 'millones de billones de trillones'; 

   $num = trim((string)@$num); 
   if ($num[0] == '-') { 
      $neg = 'menos '; 
      $num = substr($num, 1); 
   }else 
      $neg = ''; 
   while ($num[0] == '0') $num = substr($num, 1); 
   if ($num[0] < '1' or $num[0] > 9) $num = '0' . $num; 
   $zeros = true; 
   $punt = false; 
   $ent = ''; 
   $fra = ''; 
   for ($c = 0; $c < strlen($num); $c++) { 
      $n = $num[$c]; 
      if (! (strpos(".,'''", $n) === false)) { 
         if ($punt) break; 
         else{ 
            $punt = true; 
            continue; 
         } 

      }elseif (! (strpos('0123456789', $n) === false)) { 
         if ($punt) { 
            if ($n != '0') $zeros = false; 
            $fra .= $n; 
         }else 

            $ent .= $n; 
      }else 

         break; 

   } 
   $ent = '     ' . $ent; 
   if ($dec and $fra and ! $zeros) { 
      $fin = ' coma'; 
      for ($n = 0; $n < strlen($fra); $n++) { 
         if (($s = $fra[$n]) == '0') 
            $fin .= ' cero'; 
         elseif ($s == '1') 
            $fin .= $fem ? ' una' : ' un'; 
         else 
            $fin .= ' ' . $matuni[$s]; 
      } 
   }else 
      $fin = ''; 
   if ((int)$ent === 0) return 'Cero ' . $fin; 
   $tex = ''; 
   $sub = 0; 
   $mils = 0; 
   $neutro = false; 
   while ( ($num = substr($ent, -3)) != '   ') { 
      $ent = substr($ent, 0, -3); 
      if (++$sub < 3 and $fem) { 
         $matuni[1] = 'una'; 
         $subcent = 'os'; 
      }else{ 
         $matuni[1] = $neutro ? 'un' : 'uno'; 
         $subcent = 'os'; 
      } 
      $t = ''; 
      $n2 = substr($num, 1); 
      if ($n2 == '00') { 
      }elseif ($n2 < 21) 
         $t = ' ' . $matuni[(int)$n2]; 
      elseif ($n2 < 30) { 
         $n3 = $num[2]; 
         if ($n3 != 0) $t = 'i' . $matuni[$n3]; 
         $n2 = $num[1]; 
         $t = ' ' . $matdec[$n2] . $t; 
      }else{ 
         $n3 = $num[2]; 
         if ($n3 != 0) $t = ' y ' . $matuni[$n3]; 
         $n2 = $num[1]; 
         $t = ' ' . $matdec[$n2] . $t; 
      } 
      $n = $num[0]; 
      if ($n == 1) { 
         $t = ' ciento' . $t; 
      }elseif ($n == 5){ 
         $t = ' ' . $matunisub[$n] . 'ient' . $subcent . $t; 
      }elseif ($n != 0){ 
         $t = ' ' . $matunisub[$n] . 'cient' . $subcent . $t; 
      } 
      if ($sub == 1) { 
      }elseif (! isset($matsub[$sub])) { 
         if ($num == 1) { 
            $t = ' mil'; 
         }elseif ($num > 1){ 
            $t .= ' mil'; 
         } 
      }elseif ($num == 1) { 
         $t .= ' ' . $matsub[$sub] . '?n'; 
      }elseif ($num > 1){ 
         $t .= ' ' . $matsub[$sub] . 'ones'; 
      }   
      if ($num == '000') $mils ++; 
      elseif ($mils != 0) { 
         if (isset($matmil[$sub])) $t .= ' ' . $matmil[$sub]; 
         $mils = 0; 
      } 
      $neutro = true; 
      $tex = $t . $tex; 
   } 
   $tex = $neg . substr($tex, 1) . $fin; 
   return ucfirst($tex); 
} 

?> 

<?

include("../../conex.php");
$dia = substr ($txtfecha, 0, 2);
$mes = substr ($txtfecha, 3, 2);
$aņo = substr ($txtfecha, 6, 4);
if ($mes=='01') $mes='Enero';
if ($mes=='02') $mes='Febrero';
if ($mes=='03') $mes='Marzo';
if ($mes=='04') $mes='Abril';
if ($mes=='05') $mes='Mayo';
if ($mes=='06') $mes='Junio';
if ($mes=='07') $mes='Julio';
if ($mes=='08') $mes='Agosto';
if ($mes=='09') $mes='Septiembre';
if ($mes=='10') $mes='Octubre';
if ($mes=='11') $mes='Noviembre';
if ($mes=='12') $mes='Diciembre';
/***************************************Selecciona comuna*****************************************************/
$sqlc = "SELECT * FROM comunas WHERE cod_comuna = $lstcom";
$resc = mysql_query($sqlc,$enlace);
$row=0;
while (mysql_fetch_object ($resc))
	{
	$comuna = mysql_result($resc, $row, "comuna");
	$row+=1;
	}
/***************************************coloca puntos*****************************************************/	
	$cnt=$_GET["cnt"];
	
	for ($i=1;$i<=$cnt;$i++)
		{
		$precio[$i] = "".number_format($precio[$i], 0, ',', '.');
		$total[$i] = "".number_format($total[$i], 0, ',', '.');
		}
	$sql_descuento = number_format($sql_descuento, 0, ',', '.');
	$ttotal = number_format($sql_total, 0, ',', '.');
	$neto = number_format($sql_neto, 0, ',', '.');
	$iva = number_format($sql_iva, 0, ',', '.');
/***************************************Saca Seriado*****************************************************/	
$gchassis = $seriado[1];
$bsql = "SELECT * FROM seriado WHERE chassis = '$gchassis'";
$resultado =mysql_query($bsql,$enlace);
$cont=0;
while (mysql_fetch_object ($resultado))
	{
	$bsql_marca=mysql_result($resultado, $cont, "marca");
	$bsql_modelo=mysql_result($resultado, $cont, "modelo");
	$bsql_motor=mysql_result($resultado, $cont, "motor");
	$bsql_chassis=mysql_result($resultado, $cont, "chassis");
	$bsql_color=mysql_result($resultado, $cont, "color");
	$bsql_ano=mysql_result($resultado, $cont, "ano");
	$bsql_peso_bruto=mysql_result($resultado, $cont, "peso_bruto");
	$bsql_combustible=mysql_result($resultado, $cont, "combustible");
	$bsql_descripcion=mysql_result($resultado, $cont, "descripcion");
	$cont+=1;
}
/*******************************************total en letras**************************************************************/
$letotal = num2letras($sql_total); 
$atxt = split(' ',$letotal); 
strlen($atxt[0]);
$letot1 = strlen($atxt[0]);
$cont=0;
for ($i=0;$i<100;$i++)
	{
	$cont+=strlen($atxt[$i]);
	$cont+=1;
	if ($cont>=70)
		{
		$cont-=strlen($atxt[$i]);
		$cont-=1;
		$i=100;
		}
	}
$letot1 = substr ($letotal, 0, $cont);
$letot2 = substr ($letotal, $cont, strlen($letotal));
$letot1=strtoupper($letot1);
$letot2=strtoupper($letot2);
/*******************************************total obs**************************************************************/

$observaciones=$_POST["txtobs"];

$atxt2 = split(' ',$observaciones); 
strlen($atxt2[0]);
$obs1 = strlen($atxt2[0]);
$cont2=0;
for ($i2=0;$i2<100;$i2++)
	{
	$cont2+=strlen($atxt2[$i2]);
	$cont2+=1;
	if ($cont2>=60)
		{
		$cont2-=strlen($atxt2[$i2]);
		$cont2-=1;
		$i2=100;
		}
	}
$obs1 = substr ($observaciones, 0, $cont2);
$obs2 = substr ($observaciones, $cont2, strlen($observaciones));




if ($letot2!='')$letot2.=" pesos";
else $letot1.=" pesos";
$sql_bv = "SELECT * FROM vendedor WHERE Id = $lstvendedor";
$res_bv = mysql_query($sql_bv,$enlace);
	$row=0;
	while (mysql_fetch_object ($res_bv))
		{
		$vendedor = mysql_result($res_bv, $row, "nombres");
		$row=$row+1;
		}

?>
<!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:"Courier New", Courier, monospace; font-size: 14px; }
.Estilo19 {font-family:"Courier New", Courier, monospace; font-size: 14px; }
.saltopagina {
page-break-after: always;
}
-->
</style>
<body onLoad="fun_mail();">

<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr height="24px">
	<td width="390px" align="left">&nbsp;</td>
	<td width="34px" align="center">&nbsp;<?=$dia?>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td width="17px">&nbsp;</td>
	<td width="153px" align="center">&nbsp;<?=$mes?></td>
	<td width="17px">&nbsp;</td>
	<td width="89px" align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$aņo?></td>
  </tr>
</table>
<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr height="8px" style="font-size:8px"><td width="100%" style="font-size:8px">&nbsp;</td></tr>
    <tr height="8px" style="font-size:8px"><td width="100%" style="font-size:8px">&nbsp;</td></tr>

</table>
<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr height="17px">
		<td width="60px" align="left" class="Estilo19">&nbsp;</td>
		<td width="424px" align="left" class="Estilo19">&nbsp;&nbsp;<?=$txtrsoc;?></td>
		<td width="40px" class="Estilo19">&nbsp;</td>
		<td width="176px" align="left" class="Estilo19">&nbsp;&nbsp;&nbsp;<?=$txtrut;?></td>
		</tr>
	<tr height="17px">
		<td align="left" class="Estilo19">&nbsp;</td>
		<td align="left" class="Estilo19">&nbsp;&nbsp;<?=$txtdireccion;?></td>
		<td class="Estilo19">&nbsp;</td>
		<td align="left" class="Estilo19">&nbsp;&nbsp;&nbsp;<?=$txtciudad;?></td>
		</tr>
	<tr height="17px">
		<td class="Estilo19">&nbsp;</td>
		<td class="Estilo19" align="left">&nbsp;&nbsp;<?=$txtactividad;?></td>
		<td class="Estilo19">&nbsp;</td>
		<td class="Estilo19" align="left">&nbsp;&nbsp;&nbsp;<?=$comuna;?></td>
	</tr>
	<tr height="17px">
		<td class="Estilo19">&nbsp;</td>
		<td class="Estilo19" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$radiobutton2;?></td>
		<td class="Estilo19">&nbsp;</td>
		<td class="Estilo19" align="left">&nbsp;&nbsp;&nbsp;<?=$fechaven;?></td>
	</tr>
</table>

<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr height="17px">
		<td width="70px" align="left" class="Estilo19">&nbsp;</td>
		<td width="234px" class="Estilo19">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$vendedor?></td>
		<td width="40px" align="left" class="Estilo19">&nbsp;&nbsp;</td>
		<td width="356px" align="left" class="Estilo19">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
</table>

<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr height="24px">
		<td width="70px" align="left" class="Estilo19">&nbsp;</td>
		<td width="204px" class="Estilo19">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td width="40px" align="left" class="Estilo19">&nbsp;&nbsp;</td>
		<td width="386px" align="left" class="Estilo19">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
</table>

<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr height="42px">
		<td width="70px" align="left" class="Estilo19">&nbsp;</td>
		<td width="204px" class="Estilo19">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td width="40px" align="left" class="Estilo19">&nbsp;&nbsp;</td>
		<td width="386px" align="left" class="Estilo19">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
</table>

<?
$totalunidades=0;
$totalkilos=0;
$cntcal=1;
while ($cntcal<=23)
	{
	if ($codigo[$cntcal]!='')
		{
		$totalunidades+=$cantidad[$cntcal];
		$sqlbkg="SELECT * FROM productos WHERE codigo = $codigo[$cntcal]";
		$resbkg = mysql_query($sqlbkg,$enlace);
		$row=0;
		while (mysql_fetch_object ($resbkg))
			{
			$kilos = mysql_result($resbkg, 0, "peso");
			$row=$row+1;
			}
		$totalkilos+=$kilos*$cantidad[$cntcal];
		}
	$cntcal+=1;
	}

?>
<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr>
	<td width="66px%" align="left" class="Estilo18">&nbsp;<?=$codigo[1]?></td>
	<td width="66px" align="left" class="Estilo18">&nbsp;<?=$cantidad[1]?></td>
	<td width="365px" align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[1]?></td>
	<td width="88px" align="right" class="Estilo18"><?=$precio[1]?>&nbsp;</td>
	<td width="115px" align="right" class="Estilo18">&nbsp;<?=$total[1]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[2]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[2]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[2]?></td>
	<td align="right" class="Estilo18"><?=$precio[2]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[2]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[3]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[3]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[3]?></td>
	<td align="right" class="Estilo18"><?=$precio[3]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[3]?>&nbsp;</td>

  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[4]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[4]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[4]?></td>
	<td align="right" class="Estilo18"><?=$precio[4]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[4]?>&nbsp;</td>

  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[5]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[5]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[5]?></td>
	<td align="right" class="Estilo18"><?=$precio[5]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[5]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[6]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[6]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[6]?></td>
	<td align="right" class="Estilo18"><?=$precio[6]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[6]?>&nbsp;</td>

  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[7]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[7]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[7]?></td>
	<td align="right" class="Estilo18"><?=$precio[7]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[7]?>&nbsp;</td>

  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[8]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[8]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[8]?></td>
	<td align="right" class="Estilo18"><?=$precio[8]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[8]?>&nbsp;</td>

  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[9]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[9]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[9]?></td>
	<td align="right" class="Estilo18"><?=$precio[9]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[9]?>&nbsp;</td>

  </tr>
  <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[10]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[10]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[10]?></td>
	<td align="right" class="Estilo18"><?=$precio[10]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[10]?>&nbsp;</td>
  </tr>
  <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[11]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[11]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[11]?></td>
	<td align="right" class="Estilo18"><?=$precio[11]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[11]?>&nbsp;</td>
  </tr>
  <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[12]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[12]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[12]?></td>
	<td align="right" class="Estilo18"><?=$precio[12]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[12]?>&nbsp;</td>
  </tr>
  <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[13]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[13]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[13]?></td>
	<td align="right" class="Estilo18"><?=$precio[13];?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[13]?>&nbsp;</td>
  </tr>
  <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[14]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[14]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[14]?></td>
	<td align="right" class="Estilo18"><?=$precio[14];?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[14]?>&nbsp;</td>
  </tr>
  <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[15]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[15]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[15]?></td>
	<td align="right" class="Estilo18"><?=$precio[15]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[15]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[16]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[16]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[16]?></td>
	<td align="right" class="Estilo18"><?=$precio[16]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[16]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[17]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[17]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[17]?></td>
	<td align="right" class="Estilo18"><?=$precio[17]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[17]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[18]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[18]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[18]?></td>
	<td align="right" class="Estilo18"><?=$precio[18]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[18]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[19]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[19]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[19]?></td>
	<td align="right" class="Estilo18"><?=$precio[19]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[19]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[20]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[20]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[20]?></td>
	<td align="right" class="Estilo18"><?=$precio[20]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[20]?>&nbsp;</td>
  </tr>
    <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[21]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[21]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[21]?></td>
	<td align="right" class="Estilo18"><?=$precio[21]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[21]?>&nbsp;</td>
  </tr>
      <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[22]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[22]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[22]?></td>
	<td align="right" class="Estilo18"><?=$precio[22]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[22]?>&nbsp;</td>
  </tr>
      <tr>
	<td align="left" class="Estilo18">&nbsp;<?=$codigo[23]?></td>
	<td align="left" class="Estilo18">&nbsp;<?=$cantidad[23]?></td>
	<td align="left" class="Estilo18">&nbsp;&nbsp;&nbsp;<?=$detalle[23]?></td>
	<td align="right" class="Estilo18"><?=$precio[23]?>&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?=$total[23]?>&nbsp;</td>
  </tr>
  <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
	<td align="left" class="Estilo18">&nbsp;<? if ($sql_descuento!=0){ ?>&nbsp;&nbsp;Descuento<? } ?></td>
	<td align="right" class="Estilo18">&nbsp;</td>
	<td align="right" class="Estilo18">&nbsp;<?  if ($sql_descuento!=0){ echo "$ ".$sql_descuento; }?>&nbsp;&nbsp;&nbsp;</td>
  </tr>
</table>
<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr>
	<td width="63px" class="Estilo18">&nbsp;</td>
	<td width="440px" class="Estilo18">SON:&nbsp;<?=$letot1?></td>
	<td width="72px" align="right" class="Estilo18">NETO: </td>
	<td width="125px" align="right" class="Estilo18">$&nbsp;<?=$neto?>&nbsp;&nbsp;&nbsp;</td>
  </tr>
  <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;<?=$letot2?></td>
	<td align="right" class="Estilo18">IVA: </td>
	<td align="right" class="Estilo18">$&nbsp;<?=$iva?>&nbsp;&nbsp;&nbsp;</td>
  </tr>
  <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;<? if ($txtnumoc!='') { echo "Segun orden: ".$txtnumoc; }?></td>
	<td align="right" class="Estilo18">TOTAL: </td>
	<td align="right" class="Estilo18">$&nbsp;<?=$ttotal?>&nbsp;&nbsp;&nbsp;</td>
  </tr>
</table>
<table width="700px" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr>
	<td width="66px%" align="center" class="Estilo18">&nbsp;</td>
	<td width="66px" align="center" class="Estilo18">&nbsp;</td>
	<td width="365px" align="left" class="Estilo18">&nbsp;</td>
	<td width="88px" align="right" class="Estilo18">&nbsp;</td>
	<td width="115px" align="right" class="Estilo18">&nbsp;</td>
  </tr>

  <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;&nbsp;&nbsp;TOTAL UNIDADES: <?=$totalunidades;?></td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
  </tr>
    <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;&nbsp;&nbsp;TOTAL KILOS: <?=$totalkilos;?></td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
  </tr>
  <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;<?=$obs1;?></td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
  </tr>
  <tr>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;<?=$obs2;?></td>
	<td class="Estilo18">&nbsp;</td>
	<td class="Estilo18">&nbsp;</td>
  </tr>
</table>

</body>
</html>

<script>
function fun_mail()
	{
	window.print();
	window.top.open('','_parent','');window.top.close();
	}
</script>


