<?php
 
if(session_id()=="") 
	session_start();
$com="AS";	
require_once("DMMYSQLG.php");
$tipRequest=$_REQUEST['typeRequest'];

/*Si Tipo de respuesta es distinta de AutoCompletar Se imprime Ventana de Busqueda*/
//if(trim($tipRequest)=="" || !isset($tipRequest)){
	require_once("DFJQUERY.inc");
	
	$textBus=$_REQUEST['textBus'];
	$textBus=trim($textBus);

	if(!isset($_POST['idBusCli']))
		$idCli= trim($_POST['idCli']);
	else
		$idCli= trim($_POST['idBusCli']);
	$dt_catcli=mysqli_fetch_array(mysqli_query($con ,"SELECT cod_cli as idCatCli, CONCAT(ap_pat_cli,' ',ap_mat_cli,' ',nom_cli) as nomCli FROM dgcatcli WHERE cod_cli='$idCli'"));
?>
	<html>
	<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
	<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
	
	<style type="text/css">
	<!--
	.Estilo2 {
		font-size: 12px;
		font-weight: bold;
		
	}
	body {
		margin-left: 0px;
		margin-top: 0px;
		margin-right: 0px;
		margin-bottom: 0px;
	}
	.Estilo9 {font-family: Arial, Helvetica, sans-serif}
	.styTabEspA {font-family: Arial, Helvetica, sans-serif; background:#9DCEFF;}
	.styTabEspB {font-family: Arial, Helvetica, sans-serif; background:#FCFCFC;}
.style3 {
	color: #FFFFFF;
	font-size: 14px;
}
	-->
	</style>
	<body id="bodyVENTESP">
	 <form name="formbascps" id="formbascps" method="post" action="">
	   <img src="logos/mover.gif" width="30" height="30" /><img src="logos/cerrar.gif" alt="cerrar" width="30" height="30" onClick="<? echo "cloLayAndCpy({idLayer:'".$_POST['layerToLoad']."'},{})";?>"/>
	  <input type="hidden" value="<? echo $idCli;?>" name="idBusCli" id="idBusCli">
	
	<table  border="0" align="center">
		  <tr> 
			<td style="#FF9900"><div align="center" class="Estilo2 Estilo9 style3" id="titleTableEsp">ANTICIPO CLIENTES </div></td>
		  </tr>
	   </table>
		
		<table align = "center">
		  <tr>
		    <td colspan="5" nowrap style="#CCCCCC"><div align="center"><? echo $dt_catcli['nomCli'];?></div></td>
	      </tr>
		  <tr>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Num. Anticipo </div></td>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Valor Total</div></td>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Saldo Aplicado</div></td>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Saldo Actual</div></td>
		  </tr>
		  <?php

		  	$arrStyles=array("styTabEspA","styTabEspB");
			$sq_ger_cajerosj=mysqli_query($con ,"SELECT
										dgger_cajerosj.n_rec as numAnt,									
										CONCAT(dgcatcli.ap_pat_cli,' ',dgcatcli.ap_mat_cli,' ',dgcatcli.nom_cli) as nomCli,
										dgcatcli.cod_cli as idCli,
										dgger_cajerosj.importe as totAnt,
										
										(dgger_cajerosj.importe-dgger_cajerosj.sal_apl) as salAnt									
									FROM 
										dgger_cajerosj 
									INNER JOIN dgcatcli ON(dgger_cajerosj.num_cli=dgcatcli.cod_cli)
									WHERE 
										dgger_cajerosj.num_cli='$idCli' AND dgger_cajerosj.tip_mov='3' AND (dgger_cajerosj.importe-dgger_cajerosj.sal_apl)>0");
			while($dt_ger_cajerosj=mysqli_fetch_array($sq_ger_cajerosj)){
				echo "<tr class=\"".$arrStyles[($i%2)]."\">";
				echo "<td><div align=\"left\">".$dt_ger_cajerosj['numAnt']."</div></td>";
				echo "<td><div align=\"left\">".number_format($dt_ger_cajerosj['totAnt'],2,'.',',')."</div></td>";
				//echo "<td><div align=\"left\">".number_format($dt_ger_cajerosj['salAplAnt'],2,'.',',')."</div></td>";
				echo "<td><div align=\"left\">".number_format($dt_ger_cajerosj['salAnt'],2,'.',',')."</div></td>";
				echo "</tr>";
			}
		  ?>
		</table>
	 </form>
	</body>
	</html>