<?
session_start();                                        //  ******* MCC   30/09/09  ********
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
$id_empresa =$_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<form id="form1" name="form1" method="post" action="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="../css/cal.js" type="text/JavaScript"></script>
<title>Documentos Girados a Proveedores</title>
<?
include("../conex.php");

$cliente=$_GET["id"];
$f3sql="SELECT razon_social AS nombre FROM nombres WHERE rut='$cliente'";
$f3cons = mysql_query($f3sql,$enlace);	
$nombre=mysql_result($f3cons, 0, "nombre");
?>



<style type="text/css">
<!--
.Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;}
.Estilo2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color:#FF0000}
-->
</style>
</head>
<body LINK="#000000" VLINK="#000000" ALINK="#000000">  <br>
<div align="center" class="titulos2">DOCUMENTOS GIRADOS <?=$nombre?>, Rut <?=$cliente?>   </div>
<div align="center">

    <table width="78%" border="0">
      <tr bgcolor="#CCCCCC">
	  	
        <th width="9%" scope="col"><div align="center">RUT</div></th>
        <th width="25%" scope="col"><div align="center">NOMBRE</div></th>
        <th width="11%" scope="col"><div align="center">BANCO</div></th>
        <th width="11%" scope="col"><div align="center">CUENTA</div></th>
       <th width="10%" scope="col"><div align="center">NUMERO</div></th>
     <th width="12%" scope="col"><div align="center">VENCE</div></th>
		<th width="13%" scope="col"><div align="center">MONTO</div></th>
       
       
<?		
		$total_neto=0;
		$total=0;
	

$sqlfs = "select Id, rut, id_banco, ctacte, cheque, fecha_ven, monto, cobrado FROM documentos_proveedores WHERE cobrado='N' AND rut='$cliente' ORDER BY fecha_ven ASC";


		
		  	$resfs = mysql_query($sqlfs,$enlace);	

			$cont=0;
			while (mysql_fetch_object ($resfs))
 				{
									
				$rut = mysql_result($resfs, $cont, "rut");			
				$id_banco= mysql_result($resfs, $cont, "id_banco");
				$id_documentos_clientes = mysql_result($resfs, $cont, "Id");
				
				$ctacte= mysql_result($resfs, $cont, "ctacte");
				$cheque= mysql_result($resfs, $cont, "cheque");
				$fec= mysql_result($resfs, $cont, "fecha_ven");
				$dia = substr ($fec, 8, 2);
                $mes = substr ($fec, 5, 2);
                $aņo = substr ($fec, 0, 4);
                $vence1= $dia.'/'.$mes.'/'.$aņo;
				$vence[$cont] =  $vence1;
				$monto= mysql_result($resfs, $cont, "monto");
				$dep= mysql_result($resfs, $cont, "cobrado");
				$total+=$monto;			
				$monto=number_format($monto,0,',','.');
				
				$con=0;
				$sql_banco = "select * FROM banco WHERE  Id=$id_banco";
				$res_banco = mysql_query($sql_banco,$enlace);	
				while (mysql_fetch_object ($res_banco))
 				{
				$banco= mysql_result($res_banco, 0, "descripcion");
				$con+=1;
				}
				
	           $conc=0;
				$sql_cliente = "select * FROM nombres WHERE  rut='$rut'";
				$res_cliente = mysql_query($sql_cliente,$enlace);	
				while (mysql_fetch_object ($res_cliente))
 				{
				$nombre= mysql_result($res_cliente, 0, "razon_social");
				$conc+=1;
				}
			?>	
				 
			<tr>
		        <td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>
		          <?=$rut?>    
	          </strong></span></div></td>
              <td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>
		          <?=$nombre?>    
	          </strong></span></div></td>
               <td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong><?=$banco?></strong></span></div></td>
               
				<td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong><?=$ctacte?></strong></span></div></td>
				
                <td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="right"><span class="Estilo1"><strong><?=$cheque?></strong></span></div></td>
                 <td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="right"><span class="Estilo1"><strong><?=$vence[$cont];?></strong></span></div></td>
        
              <td style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="right"><span class="Estilo1"><strong><?=$monto?></strong></span></div></td>
                
				
                
	        </tr>	
			<?
			$cont+=1;
			}
			$total=number_format($total,0,',','.');
			
			?>
			<tr>
		        <td 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 style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo1"><strong>
	            
			  </strong></span><strong>Total </strong></div></td>
				
				<td 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 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 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 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 style="border-color:#CCCCCC; border:solid; border-width:2px; border-right-width:1px"><div align="right"><span class="Estilo1"><strong>
	            
				</strong></span><span class="Estilo1"><strong>
				<?=$total?>
				</strong></span></div></td>
                
	        </tr>
    </table>
<form name="form1" method="post" action="">

	<table width="150" border="0" align="center">
	<tr>
		<td width="30%" align="rigth">
			<input type="submit" name="salir" value="Salir" onClick="fun_salir();"/>
		</td>
		<td width="70%" align="right">
			<input type="button" name="imprimir" id="imprimir" value="Imprimir" onClick="fun_imprimir();">
		</td>
	</tr>
</table>
      <input name="txt_nv" id="txt_nv" type="text" style="visibility:hidden" size="1">
      <input name="txtvence" id="txtvence" type="text" style="visibility:hidden" size="1">
      <input name="lstcliente" id="lstcliente" type="text" value="<?=$cliente;?>" style="visibility:hidden" size="1">
      <input name="lstvendedor" id="lstvendedor" type="text" value="<?=$vende;?>" style="visibility:hidden" size="1">
      <input name="txtfecha" id="txtfecha" type="text" value="<?=$txtfecha;?>" style="visibility:hidden" size="1"> 
      <input name="txtfecha1" id="txtfecha1" type="text" value="<?=$txtfecha1;?>" style="visibility:hidden" size="1"> 
       
  </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_imprimir()
	{
	document.getElementById('imprimir').style.display = "none";
	window.print();
	document.getElementById('imprimir').style.display = "block";
	};

function fun_deposito(cual, verifica)
	{

	if (verifica=="N") 	
	{
	document.form1.txt_nv.value=cual;
	document.form1.action= "depositar.php";
	document.form1.target="_blank";
	document.form1.submit();
	document.form1.action = "muestra.php";
	document.form1.target="_self";
	document.form1.submit();
	}
	else 	
	{
	document.form1.txt_nv.value=cual;
	document.form1.action= "volver.php";
	document.form1.target="_blank";
	document.form1.submit();
	document.form1.action = "muestra.php";
	document.form1.target="_self";
	document.form1.submit();
	}
	}
	
function fun_vence(cual, verifica, donde)
	{
	if (verifica=="N") 	
	  {
	document.form1.txt_nv.value=cual;
	document.form1.txtvence.value = document.getElementById("vence["+donde+"]").value;
	document.form1.action= "cambia_vence.php";
	document.form1.target="_blank";
	document.form1.submit();
	document.form1.action = "muestra.php";
	document.form1.target="_self";
	document.form1.submit();
	   }
	
	}
	

	

</script>