<?php
if(isset($_POST["bexp"])) {	
	$varFIni = ($_POST["eini"]=="") ? "NULL" : "'".FechaMySql($_POST["eini"])."'";
	$varFFin = ($_POST["efin"]=="") ? "NULL" : "'".FechaMySql($_POST["efin"])."'";
	$varClie = ($_POST["ccod"]=="") ? "NULL" : $_POST["ccod"];
	$varVend = ($_POST["vcod"]=="") ? "NULL" : $_POST["vcod"];
	
	$sql = "call spQuery_Cuentas_Cobrar($varClie, $varVend, $varFIni, $varFFin);";
	$_SESSION[expor_sql_1] =  $sql;
	$_SESSION[expor_sql_2] = NULL;
	$dir = "export.php?page=".$_POST[titu];
	header("location: $dir");
	}
require_once('../clases/xajax/xajax_core/xajax.inc.php');
$xajax = new xajax();
$xajax->setFlag('debug',true); 
$xajax->configure('javascript URI', '../clases/xajax/');

require "../clases/KoolAjax/koolajax.php";
$koolajax->scriptFolder = "clases/KoolAjax";
	
function seleccionaProducto($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Producto('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1]."[[sep]]".$Fila[2];
		else $retorna = "NO EXISTE";
		}
	return $retorna;
	}
	
function seleccionaCliente($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Cliente('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";
		}
	return $retorna;
	}	

function seleccionaVendedor($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Vendedor('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";
		}
	return $retorna;
	}
		
$xajax->processRequest();
$xajax->printJavascript("../clases/xajax");

$koolajax->enableFunction("seleccionaProducto");
$koolajax->enableFunction("seleccionaCliente");	
$koolajax->enableFunction("seleccionaVendedor");	
echo $koolajax->Render();
		
function MyTable($obj, $Titulo, $Opcion, $Valor) {
$Link = $_SERVER['PHP_SELF'];
$MyTabla = "_sv_venta";
$myID = "id_venta";
?>
<script language="javascript">
function CalcularItem(i) {
	var varCantidad = 0;
	var varUnitario = 0;
	var varVenta 	= 0;
	var varIgv		= 0;
	var varTotal	= 0;
	
	var vuni = document.getElementById('iuni['+i+']');
	var vcan = document.getElementById('ican['+i+']');
	
	var vven = document.getElementById('iven['+i+']');
	var vigv = document.getElementById('iigv['+i+']');
	var vtot = document.getElementById('itot['+i+']');
	
	if (vuni.value=="") varUnitario = "0";
	else	varUnitario = vuni.value;
	
	if (vcan.value=="") varCantidad="0";
	else	varCantidad = vcan.value;

	
	vven.value = parseFloat(varUnitario)*parseFloat(varCantidad);
	vigv.value = redondear(parseFloat(vven.value)*0.19,2);
	vtot.value = redondear(parseFloat(vven.value)*1.19,2);
	/*
	if (vuni.value != "" && vcan.value != "") {
		if (vper.value=="") vper.value="0";
		vven.value = parseFloat(vuni.value)*parseFloat(vcan.value);
		vigv.value = redondear(parseFloat(vven.value)*0.19,2);
		vpre.value = redondear(parseFloat(vuni.value)*parseFloat(vcan.value)*1.19,2);
		vvper.value = redondear(parseFloat(vpre.value)*parseFloat(vper.value)/100,2);
		vtot.value = redondear(parseFloat(vpre.value),2) + redondear(parseFloat(vpre.value)*parseFloat(vper.value)/100,2);
		}
	else {
		vven.value = "";
		vigv.value = "";
		vpre.value = "";
		vtot.value = "";
		}
	*/
	CalculaRTotal();
	}
	
function CalculaRTotal() {
	var form = document.getElementById('formulario');
	var sto = 0;
	var igv = 0;
	var tot = 0;
	var per = 0;
	for (i=0;i<form.elements.length;i++) {	
		var Campo = form.elements[i].name;		
		if(Campo.indexOf("iven")==0) {
			if (form.elements[i].value!="")
				sto = sto + parseFloat(form.elements[i].value);		
			}
		else if(Campo.indexOf("iigv")==0) {
			if (form.elements[i].value!="")
				igv = igv + parseFloat(form.elements[i].value);		
			}
		else if(Campo.indexOf("itot")==0) {
			if (form.elements[i].value!="")
				tot = tot + parseFloat(form.elements[i].value);		
			}
		else if(Campo.indexOf("vper")==0) {
			if (form.elements[i].value!="")
				per = per + parseFloat(form.elements[i].value);		
			}
		}
	form.stot.value = redondear(sto,2);
	form.igv.value = redondear(igv,2);
	form.tot.value = redondear(tot,2);
	form.per.value = redondear(per,2);
	}
	
function restar() {
    var miTabla = document.getElementById("cuerpoTabla");
    var i = 0;
    do
        if (miTabla.rows[i].getElementsByTagName("input")[0].checked == true)
            miTabla.deleteRow(i);
        else
            i ++;
    while (miTabla.rows.length != i)
}

function suma()  {
	var vnum = document.getElementById('num');
	var num = parseInt(vnum.value)+1;
	var miTabla = document.getElementById("cuerpoTabla");
	var fila = document.createElement("tr");
	var celda1 = document.createElement("td");
	var celda2 = document.createElement("td");
	var celda3 = document.createElement("td");
	var celda4 = document.createElement("td");
	var celda5 = document.createElement("td");
	var celda6 = document.createElement("td");
	var celda7 = document.createElement("td");
	var celda8 = document.createElement("td");
	celda1.innerHTML = "<input id='icod["+num+"]' name='icod["+num+"]' type='text' style='text-align:center; width:80px' ondblclick=\"cargarProducto('icod["+num+"]', 'inom["+num+"]')\"  onblur=\"select_producto('"+num+"')\" onkeypress=\"return SoloNumeros(event)\"/>";	
	celda2.innerHTML = "<input id='inom["+num+"]' name='inom["+num+"]' type='text' onkeypress=\"return SoloNumeros(event)\" readonly style='width:250px' />";	
	celda3.innerHTML = "<input id='iuni["+num+"]' name='iuni["+num+"]' type='text' onkeypress=\"return SoloNumeros(event)\" onkeyup=\"CalcularItem('"+num+"')\" style='text-align:right;width:50px'/>";
	celda4.innerHTML = "<input id='ican["+num+"]' name='ican["+num+"]' type='text' onkeypress=\"return SoloNumeros(event)\" onkeyup=\"CalcularItem('"+num+"')\" style='text-align:right;width:50px'/>";
	celda5.innerHTML = "<input id='iven["+num+"]' name='iven["+num+"]' type='text' onkeypress=\"return SoloNumeros(event)\" readonly style='text-align:right;width:50px'/>";
	celda6.innerHTML = "<input id='iigv["+num+"]' name='iigv["+num+"]' type='text' onkeypress=\"return SoloNumeros(event)\" readonly style='text-align:right;width:50px'/>";
	celda7.innerHTML = "<input id='itot["+num+"]' name='itot["+num+"]' type='text' onkeypress=\"return SoloNumeros(event)\" readonly style='text-align:right;width:50px'/>";		
	celda8.innerHTML = "<a hre='#' onClick='DeleteRow(this)'> <img src='images/b_drop.png' border='0'></a>";
	fila.appendChild(celda1);
	fila.appendChild(celda2);
	fila.appendChild(celda3);
	fila.appendChild(celda4);
	fila.appendChild(celda5);
	fila.appendChild(celda6);
	fila.appendChild(celda7);
	fila.appendChild(celda8);
	miTabla.appendChild(fila);
	vnum.value=num;
	}

function DeleteRow(x) {
	while (x.tagName.toLowerCase() !='tr') {
		if(x.parentElement)
			x=x.parentElement;
		else if(x.parentNode)
			x=x.parentNode;
		else
		return;
		}
	var rowNum=x.rowIndex;
	while (x.tagName.toLowerCase() !='table') {
		if(x.parentElement)
			x=x.parentElement;
		else if(x.parentNode)
			x=x.parentNode;
		else
			return;
		}
	x.deleteRow(rowNum);
	CalculaTotal();
	}
	
function valida(e){
	tecla=(document.all) ? e.keyCode : e.which;
	if(tecla == 13)
	document.form.cond.focus();
	}
	
function pulsar(e, a) {
	tecla=(document.all) ? e.keyCode : e.which;
	var Campo = a.name;		
		
	if(tecla==13) {
		if(Campo == "ccod") {
			cargar("U","C",a.value,document.form.emp.value);
			document.form.cond.focus();
			}
		if(Campo.indexOf("acod")==0) {
			msj_articulo = "NO PRESIONES ENTER\n";
			}
		}
	return(tecla!=13);
//	document.form.cond.focus();
	}

function cargarProducto(ccod, cnom) {
	var Ruta = 'lista_producto.php?ccod='+ccod+'&cnom='+cnom;
	testwindow= window.open (Ruta, "mywindow",
    "location=1,status=1,scrollbars=1,width=600,height=600");
	}
function cargarCliente(ccod, cnom) {
	var Ruta = 'lista_cliente.php?ccod='+ccod+'&cnom='+cnom;
	testwindow= window.open (Ruta, "mywindow", "location=1,status=1,scrollbars=1,width=600,height=550");
	}
function cargarVendedor(vcod, vnom) {
		var Ruta = 'lista_vendedor.php?vcod='+vcod+'&vnom='+vnom;
		testwindow= window.open (Ruta, "mywindow", "location=1,status=1,scrollbars=1,width=600,height=550");
		}
		
function select_producto(ide) {	
	var ccod1 = document.getElementById('icod['+ide+']');
	var cnom1 = document.getElementById('inom['+ide+']');
	var cuni  = document.getElementById('iuni['+ide+']');	
	
	var existe="NO";
	var form = document.getElementById('formulario');	
	if(ccod1.value=="") {
		ccod1.value = "";
		cnom1.value = "";
		}
	else {		
		var dato = koolajax.callback(seleccionaProducto(ccod1.value));		
		if(dato=="NO EXISTE") {
			alert("PRODUCTO ESCRITO NO EXISTE...");
			ccod1.value = "";
			cnom1.value = dato;
			cuni.value = "";
			ccod1.focus();
			}
		else {
			var myArray = dato.split('[[sep]]'); 			
			for (i=0;i<form.elements.length;i++) {
				var Campo = form.elements[i].name;		
				if(Campo.indexOf("icod")==0 && form.elements[i].value==ccod1.value && Campo != ccod1.name) {
					existe="SI";	
					}	
				}				
			if (existe=="SI") {
				ccod1.value = "";
				cnom1.value = "";
				cuni.value = "";
				alert("EL producto : " + ccod1.value + "\n" + myArray[0] + "\nYA ESTA AGREGADO, SELECCIONE OTRO POR FAVOR");
				ccod1.focus();
				}
			else {
				
				cnom1.value = myArray[0];
				cuni.value 	= myArray[1];
				}
			}
		}
	}
	
function select_Vendedor(vcod, vnom) {		
		var vcod1 = document.getElementById(vcod);
		var vnom1 = document.getElementById(vnom);
		if(vcod1.value=="") {
			vcod1.value = "";
			vnom1.value = "";
			}
		else {			
			var dato = koolajax.callback(seleccionaVendedor(vcod1.value));
			if(dato=="NO EXISTE") {
	//			alert("CLIENTE NO EXISTE");
				vcod1.value = "";
				vnom1.value = dato;
				vcod1.focus();
				}
			else {
				vnom1.value = dato;
				}
			}
		}
		
function select_Cliente(ccod, cnom) {
			
	var ccod1 = document.getElementById(ccod);
	var cnom1 = document.getElementById(cnom);
	
	if(ccod1.value=="") {
		ccod1.value = "";
		cnom1.value = "";
		}
	else {			
		var dato = koolajax.callback(seleccionaCliente(ccod1.value));
		if(dato=="NO EXISTE") {
//			alert("CLIENTE NO EXISTE");
			ccod1.value = "";
			cnom1.value = dato;
			ccod1.focus();
			}
		else {
			cnom1.value = dato;
			}
		}
	}
	
function AgregarPago(varUrl, varCod) {		
	var Ruta = varUrl+'?opt=PAG&valor='+varCod;
	window.location.href = Ruta;
	}
	
</script>
<?php
if(!isset($Opcion)) {
	$varCCOD = (isset($_POST["ccod"]))?$_POST["ccod"]:NULL;
	$varCNOM = (isset($_POST["cnom"]))?$_POST["cnom"]:NULL;
	
	$varTabla=array("id"=>"tabla", "name"=>"table", "tamano"=>"420", "clase"=>"Formtitulo", "titulo"=>$Titulo." - BUSQUEDA",
					"formu"=>array("id"=>"form", "name"=>"form", "metodo"=>"POST"),						
					"ocult"=>array(array("tipo"=>"oculto", "id"=>"titu", "name"=>"titu", "valor"=>$Titulo),
								   array("tipo"=>"oculto", "id"=>"opt", "name"=>"opt", "valor"=>$Opcion)
								  ),
					"conte"=>array(array("titulo"=>"Cliente :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"text", "id"=>"ccod", "name"=>"ccod", "valor"=>$_POST[ccod], "ancho"=>"50", 
																				 "alinear"=>"center", "blur"=>"select_Cliente('ccod', 'cnom')", 
																				 "dclick"=>"cargarCliente('ccod', 'cnom')"),
																		   array("tipo"=>"text", "id"=>"cnom", "name"=>"cnom", "valor"=>$_POST[cnom], "ancho"=>"200")
																		   )
													 )
										 ),
								   array("titulo"=>"Vendedor :", "clase1"=>"FormCampo1", "clase2"=>"interior",
										 "campo"=>array("tipo"=>"varios",
														"contenido"=>array(array("tipo"=>"text", "id"=>"vcod", "name"=>"vcod", "valor"=>$_POST[vcod], "ancho"=>"50", 
																				 "alinear"=>"center", "blur"=>"select_Vendedor('vcod', 'vnom')", 
																				 "dclick"=>"cargarVendedor('vcod', 'vnom')"),
																		   array("tipo"=>"text", "id"=>"vnom", "name"=>"vnom", "valor"=>$_POST[vnom], "ancho"=>"200")
																		   )
													 )
										 ),									  
								   array("titulo"=>"Fecha Incial :", "clase1"=>"FormCampo1", "clase2"=>"interior", 
										 "campo"=>array("tipo"=>"fecha", "id"=>"eini", "name"=>"eini", "alinear"=>"center", "valor"=>$_POST[eini]) ),
								   array("titulo"=>"Fecha Final :", "clase1"=>"FormCampo1", "clase2"=>"interior", 
										 "campo"=>array("tipo"=>"fecha", "id"=>"efin", "name"=>"efin", "alinear"=>"center", "valor"=>$_POST[efin]) )									   
								   ),
					"boton"=>array(array("tipo"=>"submit", "id"=>"bcon", "name"=>"bcon", "ancho"=>"80", "alto"=>"22", "texto"=>"Consultar"),			  
								   array("tipo"=>"submit", "id"=>"bexp", "name"=>"bexp", "ancho"=>"80", "alto"=>"22", "texto"=>"Exportar")
								   )
					);
	echo $obj->setTablaForm($varTabla);		
	if(isset($_POST["bcon"])) {
		$varFIni = ($_POST["eini"]=="") ? "NULL" : "'".FechaMySql($_POST["eini"])."'";
		$varFFin = ($_POST["efin"]=="") ? "NULL" : "'".FechaMySql($_POST["efin"])."'";
		$varClie = ($_POST["ccod"]=="") ? "NULL" : $_POST["ccod"];
		$varVend = ($_POST["vcod"]=="") ? "NULL" : $_POST["vcod"];
		
		$sql = "call spQuery_Cuentas_Cobrar($varClie, $varVend, $varFIni, $varFFin);";
		$varTabla=array("id"=>"theTable", "name"=>"theTable", "tamano"=>"98%", "sql_cab"=>$sql,	"pages"=>20,
							"conte"=>array(array("tamano"=>20, "titulo"=>"IDE", "alinear"=>"center", "oculto"=>"SI"),
										   array("tamano"=>50, "titulo"=>"EMISION", "alinear"=>"center"),
										   array("tamano"=>90, "titulo"=>"PEDIDO", "alinear"=>"center"),
										   array("tamano"=>40, "titulo"=>"DOCUMENTO"),
										   array("tamano"=>10, "titulo"=>"CCLI", "alinear"=>"center"),
										   array("tamano"=>250,"titulo"=>"CLIENTE"),
										   array("tamano"=>10, "titulo"=>"CVEN", "alinear"=>"center"),
										   array("tamano"=>250,"titulo"=>"VENDEDOR"),
										   array("tamano"=>60, "titulo"=>"TOTAL", "alinear"=>"right"),
										   array("tamano"=>60, "titulo"=>"PAGOS", "alinear"=>"right"),
										   array("tamano"=>60, "titulo"=>"SALDO", "alinear"=>"right")
										   ),
							"boton"=>array(array("tipo"=>"img", "id"=>"bbpag", "name"=>"bpag", "img"=>"../images/b_money_add.png", 
										   		 "toltip"=>array(array("valor"=>"HAGA CLICK PARA <b>REALIZAR UN PAGO</b> DE LA VENTA<br><b>Fecha Emisión : </b>"),
																 array("valor"=>1, "tipo"=>"INDEX"),
																 array("valor"=>"<br><b>Nro. Pedido : </b>"),
																 array("valor"=>2, "tipo"=>"INDEX"),
																 array("valor"=>"<br><b>Documento : </b>"),
																 array("valor"=>3, "tipo"=>"INDEX")
												   				),
												 "click"=>array("funcion"=>"AgregarPago",
																"param"=>array(array("valor"=>$Link, "tipo"=>"TEXTO"),
																			   array("valor"=>0, "tipo"=>"INDEX")																   
																			   )
																)
												 ),											
										)
							);
			echo $obj->SetGridTabla($varTabla);	
		}
	}
elseif($Opcion=="PAG") {
	$sql = "call spQuery_Registro_Ventas_Detalle($Valor);";
	$varTipo = (isset($_POST["tipo"]))?$_POST["tipo"]:NULL;
	$obj->AbrirConexion();
	$rs = $obj->Query($sql);
	$obj->CerrarConexion();
	$fila = $obj->FetchArray($rs);
	
	echo "<form name=\"formulario\" id=\"formulario\" method=\"post\" onSubmit=\"return validaRegistroPago(this)\">";
	echo "<table style=\"padding:0;margin-top:0px;border-collapse:collapse;\" ";
	echo "width=450 align=center cellpadding=0 cellspacing=0>";
	echo "<tr>";
	echo "<td height=25 colspan=2 valign=top align=\"center\" class=\"FormTitulo\">";
	echo "<input name=\"txtven\" type=\"hidden\" id=\"txtven\" value=\"$Valor\" />";
	echo "<input name=\"txtcli\" type=\"hidden\" id=\"txtcli\" value=\"$fila[CCLI]\" />";
	echo "<input name=\"txtsal\" type=\"hidden\" id=\"txtsal\" value=\"$fila[SALDO]\" />";
	echo "$Titulo - REALIZAR PAGO";	
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\" width=100>Fecha Emisión :</td>";
	echo "<td class=\"interior\" width=300>$fila[EMISION]</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Tipo Documento :</td>";
	echo "<td class=\"interior\">$fila[CTIP]</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Nro. Doc. :</td>";
	echo "<td class=\"interior\">$fila[NDOC]</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Cliente :</td>";
	echo "<td class=\"interior\">$fila[CCLI] - $fila[CLIENTE]</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Vendedor :</td>";
	echo "<td class=\"interior\">$fila[CVEN] - $fila[VENDEDOR]</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Cond. Venta :</td>";
	echo "<td class=\"interior\">$fila[CONDICION]</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Monto :</td>";
	echo "<td class=\"interior\">".number_format($fila["TOTAL"],"2",".",",")."</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Pagos Efectuados :</td>";
	echo "<td class=\"interior\">".number_format($fila["PAGOS"],"2",".",",")."</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Saldo Actual:</td>";
	echo "<td class=\"interior\">".number_format($fila["SALDO"],"2",".",",")."</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\" width=100>Tipo Pago :</td>";
	echo "<td class=\"interior\" width=300>";
	$sql = "select id_forma_pago, nombre from _sys_tipo_pago";
	echo $obj->SetCombo("tipo", $sql, $varTipo, "200", NULL, NULL,NULL,"NO");
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Nro. Documento :</td>";
	echo "<td class=\"interior\">";
	echo "<input id=\"num\" name=\"num\" type=\"text\" style=\"width:120px;text-align:center\" autocomplete='off'>";
	echo "</td>";
	echo "</tr>";	
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Fecha Pago :</td>";
	echo "<td class=\"interior\">";
	echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	echo "<tr>";
	echo "<td width=\"90\" height=\"22\" valign=\"middle\">";
	echo "<input name=femi type=text class=inputNormal id=femi ";
	echo "style=\"width:100px; height:18px; font-family:tahoma; font-size:11px; text-align:center\" value=\"".date( "d/m/Y",time())."\">";
	echo "</td>";
	echo "<td width=\"40\" valign=\"middle\">";
	echo "<a href=\"javascript:void(0)\" ";
	echo "onClick=\"if(self.gfPop)gfPop.fPopCalendar(document.formulario.femi);return false;\" >";
	echo "<img class=PopcalTrigger src=\"HelloWorld/calbtn.gif\" width=34 height=22 border=0></a>";
	echo "</td>";
	echo "<td width=\"300\" valign=\"middle\">";
	echo "Ejm. ",date( "d/m/Y",time()); 
	echo "</td>";
	echo "</tr>";
	echo "</table>";	
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Monto a Pagar :</td>";
	echo "<td class=\"interior\">";
	echo "<input id=\"txtpago\" name=\"txtpago\" type=\"text\" style=\"width:100px;text-align:center\" onkeypress=\"return SoloNumeros(event)\" >";
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td class=\"FormCampo1\">Observacion :</td>";
	echo "<td class=\"interior\">";
	echo "<textarea name=\"txtobs\" rows=\"5\" id=\"txtobs\" style=\"width:300px;\"></textarea>";
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td height=25 colspan=10 valign=top aling=\"center\" class=\"FormTitulo\">";		
	echo "<input id=\"save\" name=\"save\" type=\"submit\" style=\"width:100px;height:22px;\" value=\"Registrar Pago\" ";
	echo "onClick=\"return confirm('¿DESEA GUARDAR ESTE PAGO?')\" >&nbsp;&nbsp;";
	echo "<input name=\"regresar\" type=\"button\" id=\"regresar\" style=\"width:100px; height:22px;\" ";
	echo "onClick=\"location='".$Link."'\" value=\"Regresar\">";
	echo "</td>";
	echo "</tr>";
	echo "</table>";	
	echo "</form>";		
	}
if(isset($_POST["save"])) {
	$Usr = (isset($_SESSION["_CUSE"]))  ? $_SESSION["_CUSE"] : "1";
	$varFecha = FechaMySql($_POST[femi]);	
	$sql = "CALL spMante_Pago($_POST[txtcli], $_POST[txtven],  '$_POST[tipo]', '$_POST[num]', '$varFecha', $_POST[txtsal], $_POST[txtpago],  '$_POST[txtobs]', $Usr);";
	$obj->AbrirConexion();
	$rs = $obj->Query($sql);
	$obj->CerrarConexion();
	echo "<script language='Javascript'>";
	echo "window.location='$Link'";
	echo "</script>\n";
	}
} 
?>