<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
$COB_KOD=vbval(V($_GET['COB_KOD']));
$ES_CAJERO=0;
$ES_FACTURACION=0;
//+++++++++++++++++
if(USU_PER_GET_ES_CAJERO()){
	$ES_CAJERO=1;
}
if(USU_PER_GET_ES_FACTURACION()){
	$ES_FACTURACION=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=utf-8" />
<title>Pagos asignados</title>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<script>

</script>
<style type="text/css">
<!--
body {
	background-color: #666;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:900px;
	height:300px;
	position:absolute;
	left:50%;
	top:0px;
	background-color:#999999;
	margin:0 0 0 -450px;
}
#Layer2 {
	position:absolute;
	left:409px;
	top:205px;
	width:82px;
	height:24px;
	z-index:1;
}
.Estilo1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #FFFFFF;
}
.f2 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 12px; }
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.x4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body >
<form id="Frm" name="Frm" method="post" action="cobroz_pagos.php" onsubmit="return false;" autocomplete="off">
<input name="ES_CAJERO" id="ES_CAJERO" type="hidden" value="<?php echo $ES_CAJERO;?>" />
<input name="ES_FACTURACION" id="ES_FACTURACION" type="hidden" value="<?php echo $ES_FACTURACION;?>" />
<center> 
<div Id="DivFRM"  class="centrarFrm" >
<script>
function fpEliminar(id){
	var es_cajero=gv("ES_CAJERO");
	var es_facturacion=gv("ES_FACTURACION");
	if(jVal(es_cajero)==1 || jVal(es_facturacion)==1){
	}else{
		alert("Valido solo para usuarios de cargo cajero");
		return;
	}
	if(confirm("¿ Esta seguro que desea eliminar ?")){
		var r=AX("COB_VEN_ELIMINAR",id);
		var d=r.split("|");
		if(d[1]=="OK"){
			var td="TD_"+id;
			var cm="CM_"+id;
			var km="KM_"+id;
			document.getElementById(td).innerHTML="SI";
			document.getElementById(cm).style.display="none";
			document.getElementById(km).style.display="none";
			alert("Pago eliminado");
		}else{
			if(d[1]=="MS"){
				alert(d[2]);
			}else{
				alert("Error de conexion");
			}
		}
	}
}
function fpAnular(id,cob_id,ven_id){
	var es_cajero=gv("ES_CAJERO");
	var es_facturacion=gv("ES_FACTURACION");
	if(jVal(es_cajero)==1 || jVal(es_facturacion)==1){
	}else{
		alert("Valido solo para usuarios de cargo cajero");
		return;
	}
	if(confirm("¿ Esta seguro que desea anular ?")){
		var r=AX("COB_VEN_ANULAR",id,cob_id,ven_id);
		var d=r.split("|");
		if(d[1]=="OK"){
			var td="TD_"+id;
			var cm="CM_"+id;
			var km="KM_"+id;
			document.getElementById(td).innerHTML="SI";
			document.getElementById(cm).style.display="none";
			document.getElementById(km).style.display="none";
			alert("Pago anulado");
		}else{
			if(d[1]=="MS"){
				alert(d[2]);
			}else{
				alert("Error de conexion");
			}
		}
	}
}
</script>
<div id="layer3" style="position:absolute; left: 23px; top: 59px; width: 855px; height: 173px; overflow:auto">
<div align="left" class="f2">
<table width="841" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="120" bgcolor="#999999"><span class="x4">COMPROBANTE</span></td>
<td width="48" bgcolor="#999999"><span class="x4">SERIE</span></td>
<td width="79" bgcolor="#999999"><span class="x4">NUMERO</span></td>
<td width="65" bgcolor="#999999"><span class="x4">FECHA</span></td>
<td width="362" bgcolor="#999999"><span class="x4">CLIENTE</span></td>
<td width="68" bgcolor="#999999" align="right"><span class="x4">TOTAL</span></td>
<td width="24" bgcolor="#999999" align="center"><span class="x4">ANU</span></td>

<td width="57" bgcolor="#999999" align="center"><span class="x4">#</span></td>
<td width="57" bgcolor="#999999" align="center"><span class="x4">#</span></td>
</tr>
<?php		
$s="SELECT * FROM cobroz_ventas WHERE cv_id_cob=$COB_KOD ORDER BY id_cv  ";
$rs=grs($s);				
while($r=$rs->fetch_assoc()){	
	$TD="TD_".$r['id_cv'];				
	$CM="CM_".$r['id_cv'];		
	$KM="KM_".$r['id_cv'];
	//
	$AUX_VEN_ID=$r['cv_id_ven'];
	$AUX_VEN_COT=VEN_GET_COT_KOD($AUX_VEN_ID);
	$AUX_COB_COT=COB_GET_COT_KOD($COB_KOD);
	//
	$CSS="000";
	if($AUX_VEN_COT!=$AUX_COB_COT){
		$CSS="CC3300";
	}
?>
    <tr style="background-color:#FFF; color:#<?php echo $CSS;?>">
    <td ><?php echo $r['cv_com'];?></td>
    <td ><?php echo $r['cv_ser'];?></td>
    <td ><?php echo $r['cv_num'];?></td>
    <td ><?php echo $r['cv_fecha'];?></td>
    <td ><?php echo $r['cv_cliente'];?></td>
    <td align="right" ><?php echo NF2($r['cv_total'],1);?></td>
    <td align="center" id="<?php echo $TD;?>" ><?php echo $r['cv_cob_anu'];?></td>
    <td >
    <?php
	if($r['cv_cob_anu']=="NO"){
	?>
    <input name="<?php echo $CM;?>" type="button" id="<?php echo $CM;?>"  
    value="Anular"
    onclick="fpAnular('<?php echo $r['id_cv'];?>','<?php echo $r['cv_id_cob'];?>','<?php echo $r['cv_id_ven'];?>')" />
    <?php
	}
	?>
    <td>
    <?php
	if($r['cv_cob_anu']=="NO"){
	?>
    <input name="<?php echo $KM;?>" type="button" id="<?php echo $KM;?>"  
    value="Eliminar" disabled="disabled"
    onclick="fpEliminar('<?php echo $r['id_cv'];?>')" />
    <?php
	}
	?>
    </td>
    </td>
    </tr>
<?php
}
?>		            
</table>
</div>
</div>
<div id="layer" style="position:absolute; left: 116px; top: 21px; width: 412px; height: 24px;">
<div align="left" class="Estilo1">PAGOS ASIGNADOS</div>
</div>

<div id="LblTit" style="position:absolute; left: 57px; top: 2px; width: 64px;">
<div align="left" class="Estilo1"><img src="img/unidades.png" width="48" height="48" /></div>
</div>
</div>
</center>	
</form>
</body>
</html>
