<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];		
?>
<?
include("../conex.php");

$comprobante=$_POST["idsalidaant"];

        $sql_cpc = "SELECT * FROM cabeza_pago_cliente, nombres WHERE  id=$comprobante AND cabeza_pago_cliente.rut=nombres.rut";
  		$res_cpc = mysql_query($sql_cpc,$enlace);
           $cont=0; 
			$id_numero = mysql_result($res_cpc, $cont, "id");
			$numero = mysql_result($res_cpc, $cont, "comprobante");
			$contado = mysql_result($res_cpc, $cont, "contado");	
			$tranferencia = mysql_result($res_cpc, $cont, "tranferencia");	
			$documento = mysql_result($res_cpc, $cont, "documento");
				$observacion = mysql_result($res_cpc, $cont, "observacion");
			$dcto = $documento;
			$total=$contado+$tranferencia+$documento;
			 $contado=number_format($contado,0,',','.');	
		  $tranferencia=number_format($tranferencia,0,',','.');	
		  $documento=number_format($documento,0,',','.');
		  
			$nombre = mysql_result($res_cpc, $cont, "razon_social");
            $fecha = mysql_result($res_cpc, $cont, "fecha");
 
                $dia = substr ($fecha, 8, 2);
				$ano = substr ($fecha, 0, 4);
				$mes = substr ($fecha, 5, 2);
				$fecha = "$dia-$mes-$ano";
				$fecha_pago = $fecha;
				
/********************************** Datos Empresa *********************************************************************/
$sql_empresa = "SELECT * FROM empresa, comunas WHERE comunas.cod_comuna = empresa.comuna AND id=$id_empresa";
	$res_empresa = mysql_query($sql_empresa,$enlace);
	$row=0;
	while (mysql_fetch_object ($res_empresa))
		{
		$empresa_rut=mysql_result($res_empresa, $row, "rut_empresa");
		$empresa_nombre=mysql_result($res_empresa, $row, "nombre");
		$empresa_direccion=mysql_result($res_empresa, $row, "direccion");
		$empresa_ciudad=mysql_result($res_empresa, $row, "ciudad");
		$empresa_comuna=mysql_result($res_empresa, $row, "comunas.comuna");
		$empresa_actividad=mysql_result($res_empresa, $row, "actividad");
		$empresa_rut_representante=mysql_result($res_empresa, $row, "rut_representante");
		$empresa_nombre_representante=mysql_result($res_empresa, $row, "nombre_representante");
		$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>Comprobante de Pago</title>
<style type="text/css">
<!--
.Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
body {
	background-color: #CCCCCC;
	margin-left: 0px;
	margin-top: 3px;
	margin-right: 0px;
	margin-bottom: 0px;
}
select {
	clear: right;
	float: left;
	height: auto;
	width: 267px;
}
-->
</style></head>

</head>

<body alink="CCCCCC" link="CCCCCC" vlink="CCCCCC">
<div align="center">
 <form id="form1" name="form1" method="post" action="" target="leftFrame">
<table width="640" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td width="60px"><div align="center"><img src="../Images/logo.gif" width="60px" height="60px"></div></td>
		<td width="160px"><div align="left"><font size="1">
		<?=$empresa_nombre?><br>
		<?=$empresa_direccion?><br>
		<?=$empresa_ciudad;?>

		</font></div>
		</td>
		<td width="420px"><div align="left"><font size="3">
		COMPROBANTE DE PAGO <?=$numero;?>
		</font></div>
		</td>
	</tr>
</table>
<table width="640" border="0" align="center">
	<tr>
		<td width="5%">&nbsp;</td>
		<td width="54%"><div align="justify">
		Con fecha <?=$fecha_pago?> se reciben del Sr(a) <?=$nombre;?><br> la cantidad de <strong><font size="+1">$<?=number_format($total,0,',','.');?></font></strong> por pago de:
		</div></td>
		
	</tr>
    <?
     $sql_cpc = "SELECT * FROM pago_cliente WHERE  id_cpc=$comprobante";
  		$res_cpc = mysql_query($sql_cpc,$enlace);
          $cont=0;
			while (mysql_fetch_object ($res_cpc))
			{
			$descripcion = mysql_result($res_cpc, $cont, "descripcion");
			$valor = mysql_result($res_cpc, $cont, "valor");				
		    $valor=number_format($valor,0,',','.');	
		 
?>
<tr>
<td width="5%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong></strong></span></div></td>
<td width="54%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong><?=$descripcion?>		$<?=$valor?></strong></span></div></td>

</tr>			
<?
			
	$cont+=1;
	}
		   
 ?> 
 

 <tr>
 <td width="5%" ><strong></strong></td>
<td width="54%" ><div align="left"><span class="Estilo1"><strong>Contado: $<?=$contado?></strong></span></div></td>
</tr>
 <tr>
 <td width="5%" ><div align="left"><span class="Estilo1"><strong></strong></span></div></td>
<td width="54%" ><div align="left"><span class="Estilo1"><strong>Transferencia:$<?=$tranferencia?></strong></span></div></td>
</tr>
 <tr>
 <td width="5%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong></strong></span></div></td>
<td width="54%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>Documentos:	$<?=$documento?></strong></span></div></td>
</tr>
   

<?

 $sql_cpc = "SELECT * FROM documentos_clientes WHERE  id_cpc=$comprobante";
  		$res_cpc = mysql_query($sql_cpc,$enlace);
          $cont=0;
			while (mysql_fetch_object ($res_cpc))
			{
			$cheque = mysql_result($res_cpc, $cont, "cheque");
			$monto =  mysql_result($res_cpc, $cont, "monto");
			$cobrado = mysql_result($res_cpc, $cont, "cobrado");
			$fecha =  mysql_result($res_cpc, $cont, "fecha_ven");
			   $dia = substr ($fecha, 8, 2);
				$ano = substr ($fecha, 0, 4);
				$mes = substr ($fecha, 5, 2);
				$vence = "$dia-$mes-$ano";			
		$monto=number_format($monto,0,',','.');	
		 
?>
<tr>
<td width="5%"><div align="left"><span class="Estilo1"><strong></strong></span></div></td>
<td width="54%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong><?=$cheque?> / <?=$monto?>/<?=$vence?>/Pagado: <?=$cobrado?></strong></span></div></td>

</tr>			
<?
         $cont+=1;
		 }
?>
<td width="5%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong></strong></span></div></td>
<td width="54%" style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>Obs: <?=$observacion?></strong></span></div></td>

</table>			
  <table width="100%" border="0">
 <tr>
  
 <td width="20%"><input name="idsalidaant" type="text" id="idsalidaant" value="<?=$id_numero;?>" style="visibility:hidden" size="1"></td>
 <td width="22%" align="right"><input type="button" name="imprimir" id="imprimir" value="Imprimir" onClick="fun_imprimir();" /></td>
 <td width="6%" align="right"><input type="button" name="Anular" id="Anular" value="Anular" onClick="fun_anular();" /></td>
   <td width="32%" align="left"><input type="button" name="volver" id="volver" value="Salir" onClick="cerrar();"/></td>
   <td width="20%">&nbsp;</td>
      </tr>
   </table>
  
  </form>
</div>  
</body>
</html>
<script language="javascript" type="text/javascript">
function cerrar()
{
window.top.open('','_parent','');
window.top.close();
}

function fun_salir()
	{
	window.top.open('','_parent','');window.top.close();
	}
function fun_anular()
	{
	document.form1.action = "anular.php";
	document.form1.target = "_self";
	document.form1.submit();
	}
function fun_imprimir()
	{
	document.getElementById('imprimir').style.display = "none";
	document.getElementById('volver').style.display = "none"
	document.getElementById('Anular').style.display = "none"
	window.print();
	document.getElementById('imprimir').style.display = "block";
	document.getElementById('volver').style.display = "block"
	document.getElementById('Anular').style.display = "block"
	}
</script>

