                                                                                                                                                                                                                        
<html>
<head>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
</head>
<script language="javascript">

function pon_prefijo(dsccli,cedcli,cliexe,cdgcli,limcre,salact) {
	parent.document.formulario.cdgclifac.value=cdgcli;
	parent.document.formulario.dsccli.value=dsccli;
	parent.document.formulario.cedcli.value=cedcli;
	parent.document.formulario.limcre.value=limcre;
	parent.document.formulario.salact.value=salact;
	parent.document.formulario.cliexe.value=cliexe;
	parent.document.formulario_lineas.cliexe2.value=cliexe;
	parent.document.formulario_lineas.cdgclifac2.value=cdgcli;
	parent.document.formulario_lineas.cdgart.value="";
	parent.document.formulario_lineas.dscart.value="";
	parent.document.formulario_lineas.preivi.value="";
	parent.document.formulario_lineas.importe.value="";
	parent.document.formulario_lineas.descuento.value="";
	parent.document.combotipoventa.disabled=false;
}

function limpiar() {
	parent.document.formulario_lineas.cdgclifac2.value="";
	parent.document.formulario.cdgclifac.value="";
	parent.document.formulario.dsccli.value="";
	parent.document.formulario.cedcli.value="";
	parent.document.formulario.cdgcli.value="";
	parent.document.formulario.cdgcli.focus();
	parent.document.formulario.cliexe.value="";
	parent.document.formulario.limcre.value="";
	parent.document.formulario.salact.value="";
	parent.document.formulario_lineas.cdgart.value="";
	parent.document.formulario_lineas.dscart.value="";
	parent.document.formulario_lineas.preivi.value="";
	parent.document.formulario_lineas.cantidad.value="";
	parent.document.formulario_lineas.importe.value="";
	parent.document.formulario_lineas.descuento.value="";
	parent.document.formulario_lineas.cliexe.value="";
}


</script>
<? include ("../conectar.php"); ?>
<body>
<?

	
	$cdgcli=$_GET["cdgcli"];
	$dsccli=$_GET["dsccli"];
	
	if ($cdgcli==9999){
	
	$sel_Saldo="SELECT  Sum(salact) AS totalfac FROM web_2101 WHERE cdgcli = $cdgcli";
	$rs_facturas=mysql_query($sel_Saldo);
	$salact=mysql_result($rs_facturas,0,"totalfac");
	
	$consulta="SELECT * FROM web_0301 WHERE cdgcli=$cdgcli ";
	$rs_tabla = mysql_query($consulta);
	$estcli=mysql_result($rs_tabla,0,estcli);
	
	if (mysql_num_rows($rs_tabla)>0) {
	
		
		?>
		<script languaje="javascript">
		pon_prefijo("<? echo $dsccli ?>","<? echo mysql_result($rs_tabla,0,cedcli) ?>","<? echo mysql_result($rs_tabla,0,cliexe) ?>","<? echo $cdgcli ?>" ,"<? echo mysql_result($rs_tabla,0,limcre) ?>","<? echo $salact ?>");
		</script>
		<? 
	} 
	

		} else {
		
		
		
	$sel_Saldo="SELECT  Sum(salact) AS totalfac FROM web_2101 WHERE cdgcli = $cdgcli";
	$rs_facturas=mysql_query($sel_Saldo);
	$salact=mysql_result($rs_facturas,0,"totalfac");
	
	$consulta="SELECT * FROM web_0301 WHERE cdgcli=$cdgcli ";
	$rs_tabla = mysql_query($consulta);
	$estcli=mysql_result($rs_tabla,0,estcli);
	
	if (mysql_num_rows($rs_tabla)>0) {
	
	if ($estcli=="ACTIVO") {
		
		?>
		<script languaje="javascript">
		pon_prefijo("<? echo mysql_result($rs_tabla,0,dsccli) ?>","<? echo mysql_result($rs_tabla,0,cedcli) ?>","<? echo mysql_result($rs_tabla,0,cliexe) ?>","<? echo $cdgcli ?>" ,"<? echo mysql_result($rs_tabla,0,limcre) ?>","<? echo $salact ?>");
		</script>
		<? 
	} else { ?>
	<script>
	alert ("Cliente Inactivo favor consulte con el Administrador");
	limpiar();
	</script>
	<? }
	
	} else {
	?>
		<script>
	alert ("No existe ningun cliente con ese codigo");
	limpiar();
	</script>
	<?
	}
	}
	
?>
</div>
</body>
</html>
