<?php
    session_start();   
	//////////////////////////////////////////////         SEGURIDAD               /////////////////////////////////////////////
	if(!array_key_exists("la_logusr",$_SESSION))
	{
		print "<script language=JavaScript>";
		print "location.href='../sigesp_inicio_sesion.php'";
		print "</script>";		
	}
	$ls_logusr=$_SESSION["la_logusr"];
	require_once("class_folder/class_funciones_cxp.php");
	$io_fun_cxp=new class_funciones_cxp();
	$io_fun_cxp->uf_load_seguridad("CXP","sigesp_cxp_p_recepcioncontable.php",$ls_permisos,$la_seguridad,$la_permisos);
	$ls_reporte=$io_fun_cxp->uf_select_config("CXP","REPORTE","FORMATO_RECEPCION","sigesp_cxp_rfs_recepciones.php","C");
	$ls_clactacon=$_SESSION["la_empresa"]["clactacon"];	
	$ls_valclacon=$_SESSION["la_empresa"]["valclacon"];	
	$ls_codigocuentarepcajchi=$_SESSION["la_empresa"]["repcajchi"];	
	//////////////////////////////////////////////         SEGURIDAD               /////////////////////////////////////////////

   //--------------------------------------------------------------
   function uf_limpiarvariables()
   {
		//////////////////////////////////////////////////////////////////////////////
		//	     Function: uf_limpiarvariables
		//		   Access: private
		//	  Description: Función que limpia todas las variables necesarias en la página
		//	   Creado Por: Ing. Yesenia Moreno/ Ing. Luis Lang
		// Fecha Creación: 17/03/2007								Fecha Última Modificación : 
		//////////////////////////////////////////////////////////////////////////////
   		global $ls_estatus,$ld_fecregdoc,$ls_tipodestino,$ls_codprovben,$ls_nomprovben,$ls_codtipdoc,$io_fun_cxp;
		global $ls_operacion,$ls_existe,$ls_codcla,$ls_dencondoc,$ld_fecvendoc,$ld_fecemidoc,$ls_numref,$ls_numrecdoc,$ls_conanurd;
		global $ls_codigocuenta,$ls_codigocuentarepcajchi,$ls_estatuscontable,$ls_estatuspresupuesto,$ls_codtipdoc,$li_totrowspg,$ls_procede;
		global $ls_tipocontribuyente,$li_totrowscg,$ls_estimpmun,$ls_estlibcom,$ls_estliqimp,$ls_estliqant,$ls_parametros,$ls_estmodiva,$li_estaprord,$ls_repcajchi;
		global $ls_codfuefin,$ls_denfuefin,$ls_codrecdoc,$ls_coduniadm,$ls_denuniadm,$ls_codestpro1,$ls_codestpro2;
		global $ls_codestpro3,$ls_codestpro4,$ls_codestpro5,$ls_estcla,$ls_estact,$ls_disabled,$ls_rifpro,$ls_numordpagmin,$ls_codtipfon,$ls_denproalt,$ls_codproalt;
		global $ls_benefalt;
		global $cuenta_desc_anticipo,$est_desc_anticipo,$nro_desc_anticipo,$nrofiladescant,$mondescant,$porcantdesc,$nrodesc;
		
		global $anticipo,$nroanticipo,$nrocontanticipo;
		$ls_estatus="REGISTRO";
		$ld_fecregdoc=date("d/m/Y");
		$ls_codprovben="";
		$ls_nomprovben="";
		$ls_codtipdoc="";	
		$ls_tipodestino="";
		$ls_operacion=$io_fun_cxp->uf_obteneroperacion();
		$ls_existe=$io_fun_cxp->uf_obtenerexiste();
		$ls_codcla="--";
		$ls_dencondoc="";
		$ls_conanurd="";
		$ld_fecvendoc=date("d/m/Y");
		$ld_fecemidoc=date("d/m/Y");
		$ls_numref="";
		$ls_numrecdoc="";		
		$ls_codigocuenta="";
		//$ls_codigocuentarepcajchi="";
		$ls_estatuscontable="";
		$ls_estatuspresupuesto="";
		$ls_codtipdoc="";
		$li_totrowspg="";
		$li_totrowscg="";
		$li_estaprord="0";
		$ls_procede="CXPRCD";
		$ls_tipocontribuyente="";
		$ls_estimpmun="1";
		$ls_estlibcom="1";
		$ls_estliqimp="0";
		$ls_estliqant="0";
		$ls_repcajchi="0";
		$ls_estmodiva=$_SESSION["la_empresa"]["estmodiva"];
		$ls_parametros="";
		$ls_codfuefin="";
		$ls_denfuefin="";
		$ls_codrecdoc="";
		$ls_coduniadm="";
		$ls_denuniadm="";
		$ls_codestpro1="";
		$ls_codestpro2="";
		$ls_codestpro3="";
		$ls_codestpro4="";
		$ls_codestpro5="";
		$ls_estcla="";
		$ls_estact="0";
		$ls_numordpagmin="";
		$ls_codtipfon="";
		$ls_disabled = $ls_rifpro = "";
		$ls_codproalt="";
		$ls_denproalt="";
		$ls_benefalt="";
		$anticipo="";
		$nroanticipo="";
		$nrocontanticipo="";
		
		$cuenta_desc_anticipo="";
		$est_desc_anticipo="";
		$nro_desc_anticipo="";
		$nrofiladescant="";
		$mondescant="";
		$porcantdesc="";
		$nrodesc="";
		
   }
   //--------------------------------------------------------------

   //--------------------------------------------------------------
   function uf_load_variables()
   {
		//////////////////////////////////////////////////////////////////////////////
		//	     Function: uf_load_variables
		//		   Access: private
		//	  Description: Función que carga todas las variables necesarias en la página
		//	   Creado Por: Ing. Yesenia Moreno/ Ing. Luis Lang
		// Fecha Creación: 29/04/2007								Fecha Última Modificación : 
		//////////////////////////////////////////////////////////////////////////////
   		global $ld_fecregdoc,$ls_tipodestino,$ls_codprovben,$ls_nomprovben,$ls_codtipdoc,$io_fun_cxp;
		global $ls_operacion,$ls_existe,$ls_codcla,$ls_dencondoc,$ld_fecvendoc,$ld_fecemidoc,$ls_numref,$ls_numrecdoc,$ls_conanurd;
		global $ls_codigocuenta,$ls_codigocuentarepcajchi,$ls_estatuscontable,$ls_estatuspresupuesto,$ls_codtipdoc,$li_totrowspg,$ls_procede;
		global $ls_tipocontribuyente,$li_totrowscg,$ls_estimpmun,$ls_estliqimp,$ls_estliqant,$ls_estlibcom,$ls_repcajchi;
		global $li_subtotal,$li_cargos,$li_total,$li_deducciones,$li_totalgeneral,$lb_valido;
		global $ls_codfuefin,$ls_denfuefin,$ls_codrecdoc,$ls_coduniadm,$ls_codestpro1,$ls_codestpro2,$ls_codestpro3;
		global $ls_codestpro4,$ls_codestpro5,$ls_estcla,$ls_estact,$ls_disabled,$ls_rifpro,$ls_numordpagmin,$ls_codtipfon,$ls_codproalt;
	    global $ls_benefalt;
		global $anticipo,$nroanticipo,$nrocontanticipo;
		global $cuenta_desc_anticipo,$est_desc_anticipo,$nro_desc_anticipo,$nrofiladescant,$mondescant,$porcantdesc,$nrodesc;
		
		$ld_fecregdoc=$io_fun_cxp->uf_obtenervalor("txtfecregdoc",$_POST["fecregdoc"]);
		$ld_fecvendoc=$io_fun_cxp->uf_obtenervalor("txtfecvendoc",$_POST["fecvendoc"]);
		$ld_fecemidoc=$io_fun_cxp->uf_obtenervalor("txtfecemidoc",$_POST["fecemidoc"]);
		$ls_codtipdoc=$io_fun_cxp->uf_obtenervalor("cmbcodtipdoc",$_POST["codtipdoc"]);
		$ls_codcla=$io_fun_cxp->uf_obtenervalor("cmbcodcla",$_POST["codcla"]);
		$ls_tipodestino=$io_fun_cxp->uf_obtenervalor("cmbtipdes",$_POST["tipdes"]);
		$ls_estimpmun=$io_fun_cxp->uf_obtenervalor("chkestimpmun","0");
		$ls_estliqimp=$io_fun_cxp->uf_obtenervalor("chkestliqimp","0");
		$ls_estliqant=$io_fun_cxp->uf_obtenervalor("chkestliqant","0");
		$ls_estlibcom=$io_fun_cxp->uf_obtenervalor("chkestlibcom","0");
		$ls_repcajchi=$io_fun_cxp->uf_obtenervalor("chkrepcajchi","0");
		$ls_codprovben=trim($_POST["txtcodigo"]);
		$ls_codrecdoc=$_POST["txtcodrecdoc"];
		$ls_nomprovben=$_POST["txtnombre"];
		$ls_dencondoc=$_POST["txtdencondoc"];
		$ls_conanurd=$_POST["txtconanurd"];
		$ls_numref=$_POST["txtnumref"];
		$ls_numrecdoc=trim($_POST["txtnumrecdoc"]);
		$ls_codigocuenta=$_POST["codigocuenta"];
		//MODIFICADO POR OFIMATICA DE VENEZUELA EL 13-06-2011, se quito el comentario ya que al tener tildado el campo de reposicion de caja chica colocaba en los
		//objetos ocultos de codigocuenta y codigocuentarepcajchi el mismo valor, dando errores al momento de guardar.
		$ls_codigocuentarepcajchi=$_POST["codigocuentarepcajchi"];
		// FIN Modificacion OFIMATICA DE VENEZUELA
		$ls_estatuscontable=$_POST["estatuscontable"];
		$ls_estatuspresupuesto=$_POST["estatuspresupuesto"];
		$li_totrowspg=$_POST["totrowspg"];
		$li_totrowscg=$_POST["totrowscg"];
		$li_estaprord=$_POST["estaprord"];
		$ls_procede=$_POST["procede"];
		$ls_codfuefin=str_pad($_POST["txtcodfuefin"],2,"-",0);
		$ls_denfuefin=$_POST["txtdenfuefin"];
		$ls_tipocontribuyente=$_POST["tipocontribuyente"];
		$ls_coduniadm=$_POST["txtcodunieje"];
		$ls_codestpro1=$_POST["txtcodestpro1"];
		$ls_codestpro2=$_POST["txtcodestpro2"];
		$ls_codestpro3=$_POST["txtcodestpro3"];
		$ls_codestpro4=$_POST["txtcodestpro4"];
		$ls_codestpro5=$_POST["txtcodestpro5"];
		$ls_numordpagmin=$_POST["txtnumordpagmin"];
		$ls_codtipfon=$_POST["txtcodtipfon"];
		$ls_estcla=$_POST["hidestcla"];
		$ls_codproalt=$_POST["txtcodproalt"];
		$ls_estact=$io_fun_cxp->uf_obtenervalor("hidestact","0");
		$li_subtotal=str_replace(".","",$_POST["txtsubtotal"]);
		$li_subtotal=str_replace(",",".",$li_subtotal);
		$li_cargos=str_replace(".","",$_POST["txtcargos"]);
		$li_cargos=str_replace(",",".",$li_cargos);
		$li_total=str_replace(".","",$_POST["txttotal"]);
		$li_total=str_replace(",",".",$li_total);
		$li_deducciones=str_replace(".","",$_POST["txtdeducciones"]);
		$li_deducciones=str_replace(",",".",$li_deducciones);
		$li_totalgeneral=str_replace(".","",$_POST["txttotalgener"]);
		$li_totalgeneral=str_replace(",",".",$li_totalgeneral);
		$lb_valido=true;
		$ls_operacion=$io_fun_cxp->uf_obteneroperacion();
		$ls_existe=$io_fun_cxp->uf_obtenerexiste();
		$ls_benefalt=$_POST["txtbenefalt"];
		$anticipo=$_POST["chkanticipo"]?1:0;
		$nroanticipo=$_POST["txtnroanticipo"];
		$nrocontanticipo=$_POST["txtnrocontrato"];
		$cuenta_desc_anticipo=$_POST["hcuenta_anticipo"];
		$est_desc_anticipo=$_POST["hestanticipo"];
		$nro_desc_anticipo=$_POST["hnroantact"];
		$nrofiladescant=$_POST["hnrofilaant"];
		$mondescant=$_POST["hmontotanticipo"];
		$porcantdesc=$_POST["hporcantdesc"];
		$nrodesc=$_POST["hnrodesc"];
		//hcuenta_anticipo,hestanticipo,hnroantact,hnrofilaant,hmontotanticipo,hporcantdesc
        //global $cuenta_desc_anticipo,$est_desc_anticipo,$nro_desc_anticipo,$nrofiladescant,$mondescant,$porcantdesc;

		
		if($ls_existe=="TRUE")
		{
			$ls_disabled="disabled";
		}
		$ls_rifpro = $_POST["txtrifpro"];
   }
   //--------------------------------------------------------------
   
   //--------------------------------------------------------------
   function uf_load_data(&$as_parametros)
   {
		//////////////////////////////////////////////////////////////////////////////
		//	     Function: uf_load_variables
		//		   Access: private
		//	  Description: Función que carga todas las variables necesarias en la página
		//	   Creado Por: Ing. Yesenia Moreno/ Ing. Luis Lang
		// Fecha Creación: 29/04/2007								Fecha Última Modificación : 
		//////////////////////////////////////////////////////////////////////////////
		global $li_subtotal,$li_cargos,$li_total,$li_deducciones,$li_totalgeneral,$li_totrowspg,$ls_numrecdoc,$ls_codigocuenta;
		global $ls_estatuscontable,$ls_estatuspresupuesto, $li_totrowscg;
			
		for($li_fila=1;($li_fila<$li_totrowspg);$li_fila++)
		{
			$ls_nrocomp=$_POST["txtspgnrocomp".$li_fila];
			$ls_codpro=$_POST["txtcodpro".$li_fila];
			$ls_estcla=$_POST["txtestcla".$li_fila];
			$ls_cuenta=$_POST["txtspgcuenta".$li_fila];
			$ls_sccuenta=$_POST["txtspgsccuenta".$li_fila];
			$ls_cargo=$_POST["txtcargo".$li_fila];
			$li_moncue=$_POST["txtspgmonto".$li_fila];
			$li_original=$_POST["txtoriginal".$li_fila];
			$li_compromiso=$_POST["txtcompromiso".$li_fila];
			$ls_procede=$_POST["txtspgprocededoc".$li_fila];
			$ls_codfuefin=$_POST["txtcodfuefin".$li_fila];

			$as_parametros=$as_parametros."&txtspgnrocomp".$li_fila."=".$ls_nrocomp."&txtcodpro".$li_fila."=".$ls_codpro."&txtestcla".$li_fila."=".$ls_estcla."".
					   					  "&txtspgcuenta".$li_fila."=".$ls_cuenta."&txtspgsccuenta".$li_fila."=".$ls_sccuenta."".
										  "&txtcargo".$li_fila."=".$ls_cargo."&txtspgmonto".$li_fila."=".$li_moncue."".
										  "&txtoriginal".$li_fila."=".$li_original."&txtspgprocededoc".$li_fila."=".$ls_procede.
										  "&txtcodfuefin".$li_fila."=".$ls_codfuefin.
										  "&txtcompromiso".$li_fila."=".$li_compromiso;
		}
		for($li_fila=1;($li_fila<$li_totrowscg);$li_fila++)
		{
			$ls_nrocomp=$_POST["txtscgnrocomp".$li_fila];
			$ls_cuenta=$_POST["txtscgcuenta".$li_fila];
			$li_mondeb=$_POST["txtmondeb".$li_fila];
			$li_monhab=$_POST["txtmonhab".$li_fila];
			$ls_debhab=$_POST["txtdebhab".$li_fila];
			$ls_estatus=$_POST["txtestatus".$li_fila];
			$ls_procede=$_POST["txtscgprocededoc".$li_fila];
			$as_parametros=$as_parametros."&txtscgnrocomp".$li_fila."=".$ls_nrocomp."&txtscgcuenta".$li_fila."=".$ls_cuenta."".
					   					  "&txtmondeb".$li_fila."=".$li_mondeb."&txtmonhab".$li_fila."=".$li_monhab."".
										  "&txtdebhab".$li_fila."=".$ls_debhab."&txtestatus".$li_fila."=".$ls_estatus."".
										  "&txtscgprocededoc".$li_fila."=".$ls_procede;
		}
		$as_parametros=$as_parametros."&sccuentaprov=".$ls_codigocuenta."&generarcontable=0"."&totrowscg=".$li_totrowscg;
		$as_parametros=$as_parametros."&numrecdoc=".$ls_numrecdoc."&totrowspg=".$li_totrowspg."&estcontable=".$ls_estatuscontable."&estpresupuestario=".$ls_estatuspresupuesto;
		$as_parametros=$as_parametros."&subtotal=".$li_subtotal."&cargos=".$li_cargos."&deducciones=".$li_deducciones."&total=".$li_total."&totgeneral=".$li_totalgeneral;
   }
   //--------------------------------------------------------------
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Recepci&oacute;n de Documentos</title>
<meta http-equiv="" content="text/html; charset=iso-8859-1">
<meta http-equiv="" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="JavaScript1.2" src="js/stm31.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="js/funcion_cxp.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/valida_tecla.js"></script>
<script type="text/javascript" language="javascript" src="../shared/js/number_format.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/disabled_keys.js"></script>
<meta http-equiv="" content="text/html; charset=iso-8859-1"><meta http-equiv="" content="text/html; charset=iso-8859-1">
<link href="../shared/css/cabecera.css" rel="stylesheet" type="text/css">
<link href="../shared/css/general.css" rel="stylesheet" type="text/css">
<link href="../shared/css/tablas.css" rel="stylesheet" type="text/css">
<link href="../shared/css/ventanas.css" rel="stylesheet" type="text/css">

<script src="../base/librerias/js/jquery/jquery.js" type="text/javascript"></script>
<script src="../base/librerias/js/jquery/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="../base/librerias/js/jquery/jquery.alerts.js" type="text/javascript"></script>
<link href="../base/librerias/js/jquery/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />
<link href="../shared/js/css_intra/datepickercontrol.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/librerias_comunes_covensol.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/number_format.js"></script>
<script language="JavaScript" type="text/JavaScript" src="../shared/js/js_ajax.js"></script>
<script language="JavaScript" src="../shared/js/sigesp_js.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset="><style type="text/css">
<!--
a:link {
	color: #006699;
}
a:visited {
	color: #006699;
}
a:hover {
	color: #006699;
}
a:active {
	color: #006699;
}
-->
</style>
<link href="../shared/js/css_intra/datepickercontrol.css" rel="stylesheet" type="text/css">
<link href="css/cxp.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style></head>
<body>
<?php
	require_once("class_folder/sigesp_cxp_c_recepcion.php");
	$io_cxp=new sigesp_cxp_c_recepcion("../");
	uf_limpiarvariables();
	switch ($ls_operacion) 
	{
		case "NUEVO":
			unset($_SESSION["cargos"]);
			unset($_SESSION["amortizacion"]);
			unset($_SESSION["deducciones"]);
			unset($_SESSION["ls_ajuste"]);
			require_once("../shared/class_folder/sigesp_c_generar_consecutivo.php");
			$io_keygen= new sigesp_c_generar_consecutivo();
			$ls_codrecdoc=$io_keygen->uf_generar_numero_nuevo("CXP","cxp_rd","codrecdoc","CXPRCD",15,"","","");
			unset($io_keygen);
			break;

		case "GUARDAR":
			uf_load_variables();
			$io_cxp->benefalt=$ls_benefalt;
			$io_cxp->anticipo=$anticipo;
			$io_cxp->nroanticipo=$nroanticipo;
			$io_cxp->nrocontanticipo=$nrocontanticipo;						
			$io_cxp->DescAnticipo=$est_desc_anticipo;
			$io_cxp->NroDescAnticipo=$nro_desc_anticipo;
			$io_cxp->sc_cuenta_desc=$cuenta_desc_anticipo;
			$io_cxp->montodesc=$mondescant;
			$io_cxp->nrodesc=$nrodesc;
			$io_cxp->estliqimp=$ls_estliqimp;
			$io_cxp->estliqant=$ls_estliqant;
			$lb_valido=$io_cxp->uf_guardar($ls_existe,$ls_numrecdoc,$ls_tipodestino,$ls_codprovben,$ls_codtipdoc,$ld_fecregdoc,
										   $ld_fecvendoc,$ld_fecemidoc,$ls_codcla,$ls_dencondoc,$ls_procede,$li_cargos,$li_deducciones,
										   $li_totalgeneral,$ls_numref,$ls_estimpmun,$ls_estlibcom,$li_totrowspg,$li_totrowscg,
										   $ls_codfuefin,$ls_codrecdoc,$ls_coduniadm,$ls_codestpro1,$ls_codestpro2,$ls_codestpro3,
										   $ls_codestpro4,$ls_codestpro5,$ls_estcla,$ls_estact,$ls_numordpagmin,$ls_codtipfon,$ls_repcajchi,$ls_codproalt,$la_seguridad);
			uf_load_data($ls_parametros);
			if($lb_valido)
			{
				$ls_existe="TRUE";
				$ls_disabled="disabled";
			}
			break;
			
		case "ELIMINAR":
			uf_load_variables();
			$io_cxp->benefalt=$ls_benefalt;
			$io_cxp->anticipo=$anticipo;
			$io_cxp->nroanticipo=$nroanticipo;
			$io_cxp->nrocontanticipo=$nrocontanticipo;						
			$io_cxp->DescAnticipo=$est_desc_anticipo;
			$io_cxp->NroDescAnticipo=$nro_desc_anticipo;
			$io_cxp->sc_cuenta_desc=$cuenta_desc_anticipo;
			$io_cxp->montodesc=$mondescant;
			$io_cxp->nrodesc=$nrodesc;
			$lb_valido=$io_cxp->uf_delete(trim($ls_numrecdoc),$ls_tipodestino,trim($ls_codprovben),$ls_codtipdoc,$la_seguridad);
			if($lb_valido==false)
			{
				uf_load_data($ls_parametros);
				$ls_existe="TRUE";
			}
			else
			{
				uf_limpiarvariables();
				$ls_existe="FALSE";
				unset($_SESSION["cargos"]);
				unset($_SESSION["deducciones"]);
				unset($_SESSION["ls_ajuste"]);
			}
			break;
	}
?>
<table width="762" border="0" align="center" cellpadding="0" cellspacing="0" class="contorno">
  <tr>
    <td width="780" height="30" colspan="11" class="cd-logo"><img src="../shared/imagebank/header.jpg" width="817" height="40"></td>
  </tr>
  <tr>
    <td width="432" height="20" colspan="11" bgcolor="#E7E7E7"><table width="792" border="0" align="center" cellpadding="0" cellspacing="0">
        <td width="432" height="20" bgcolor="#E7E7E7" class="descripcion_sistema">Cuentas por Pagar </td>
            <td width="346" bgcolor="#E7E7E7"><div align="right"><span class="letras-pequenas"><b><?PHP print date("j/n/Y")." - ".date("h:i a");?></b></span></div></td>
        <tr>
          <td height="20" bgcolor="#E7E7E7" class="descripcion_sistema">&nbsp;</td>
          <td bgcolor="#E7E7E7"><div align="right" class="letras-pequenas"><b><?php print $_SESSION["la_nomusu"]." ".$_SESSION["la_apeusu"];?></b></div></td>
        </table></td>
  </tr>
  <tr>
    <td height="20" colspan="11" bgcolor="#E7E7E7" class="cd-menu"><script type="text/javascript" language="JavaScript1.2" src="js/menu.js"></script></td>
  </tr>
  <tr>
    <td width="780" height="13" colspan="11" class="toolbar"></td>
  </tr>
  <tr>
    <td height="20" width="25" class="toolbar"><div align="center"><a href="javascript: ue_nuevo();"><img src="../shared/imagebank/tools20/nuevo.gif" alt="Nuevo" width="20" height="20" border="0" title="Nuevo"></a></div></td>
    <td class="toolbar" width="25"><div align="center"><a href="javascript: ue_guardar();"><img src="../shared/imagebank/tools20/grabar.gif" alt="Grabar" width="20" height="20" border="0" title="Guardar"></a></div></td>
    <td class="toolbar" width="25"><div align="center"><a href="javascript: ue_buscar();"><img src="../shared/imagebank/tools20/buscar.gif" alt="Buscar" width="20" height="20" border="0" title="Buscar"></a></div></td>
    <td class="toolbar" width="25"><div align="center"><a href="javascript: ue_eliminar();"><img src="../shared/imagebank/tools20/eliminar.gif" alt="Eliminar" width="20" height="20" border="0" title="Eliminar"></a></div></td>
    <td class="toolbar" width="25"><a href="javascript: ue_imprimir();"><img src="../shared/imagebank/tools20/imprimir.gif" alt="Imprimir" width="20" height="20" border="0" title="Imprimir"></a></td>
    <td class="toolbar" width="25"><div align="center"><a href="javascript: ue_cerrar();"><img src="../shared/imagebank/tools20/salir.gif" alt="Salir" width="20" height="20" border="0" title="Salir"></a></div></td>
    <td class="toolbar" width="25"><div align="center"><a href="javascript: ue_ayuda();"><img src="../shared/imagebank/tools20/ayuda.gif" alt="Ayuda" width="20" height="20" border="0" title="Ayuda"></a></div></td>
    <td class="toolbar" width="25"><div align="center"></div></td>
    <td class="toolbar" width="25"><div align="center"></div></td>
    <td class="toolbar" width="25"><div align="center"></div></td>
    <td class="toolbar" width="530">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
  <form name="formulario" method="post" action="" id="formulario">
<?php
//////////////////////////////////////////////         SEGURIDAD               /////////////////////////////////////////////
	$io_fun_cxp->uf_print_permisos($ls_permisos,$la_permisos,$ls_logusr,"location.href='sigespwindow_blank.php'");
	unset($io_fun_cxp);
//////////////////////////////////////////////         SEGURIDAD               /////////////////////////////////////////////
?>

    <table width="866" border="0" align="center" cellpadding="0" cellspacing="0" class="formato-blanco">
      <tr>
        <td width="864"  height="136">
            <table width="852" border="0" align="center" cellpadding="0" cellspacing="0" class="formato-blanco">
              <tr>
                <td colspan="4" class="titulo-ventana">Registro de Recepci&oacute;n de Documentos </td>
              </tr>
              <tr style="visibility:hidden">
                <td height="22">Reporte en
                  <select name="cmbbsf" id="cmbbsf">
                    <option value="0" selected>Bs.</option>
                    <option value="1">Bs.F.</option>
                  </select></td>
                <td height="22">&nbsp;</td>
                <td height="22">&nbsp;</td>
                <td height="22">&nbsp;</td>
              </tr>
              <tr>
                <td width="200" height="22"><div align="right">Estatus</div></td>
                <td width="472" height="22"><input name="txtestatus" type="text" class="sin-borde2" id="txtestatus" value="<?php print $ls_estatus; ?>" size="20" readonly>                </td>
                <td width="131" height="22"><div align="right">Fecha de Registro </div></td>
                <td width="92" height="22"><input name="txtfecregdoc" type="text" id="txtfecregdoc" onKeyDown="javascript:ue_formato_fecha(this,'/',patron,true,event);" onBlur="javascript: ue_validar_formatofecha(this);" value="<?php  print $ld_fecregdoc;?>" size="17"  style="text-align:center" datepicker="true"></td>
              </tr>
              <tr>
                <td height="22"><div align="right">Tipo de Documento </div></td>
                <td height="22" colspan="3"><?php $io_cxp->uf_load_tipodocumento($ls_codtipdoc,"C");?></td>
              </tr>
              <tr>
                <td height="22" align="right">
                  <select name="cmbtipdes" id="cmbtipdes" onChange="javascript: ue_cambiardestino(); " >
                    <option value="-" selected>-- Seleccione Uno --</option>
                    <option value="P" <?php if($ls_tipodestino=="P"){ print "selected";} ?>>PROVEEDOR</option>
                    <option value="B" <?php if($ls_tipodestino=="B"){ print "selected";} ?>>BENEFICIARIO</option>
                  </select>                </td>
                <td height="22" align="left"><div align="left">
                  <input name="txtcodigo" type="text" id="txtcodigo" value="<?php print $ls_codprovben;?>" size="15" maxlength="10" readonly style="text-align:center">
                  <input name="txtnombre" type="text" class="sin-borde" id="txtnombre" value="<?php print $ls_nomprovben;?>" size="45" maxlength="30" readonly>                
                </div></td>
                <td height="22" align="right"><strong>RIF:</strong></td>
                <td height="22"><input name="txtrifpro" type="text" class="sin-borde" id="txtrifpro" value="<?php echo $ls_rifpro ?>" size="15" readonly></td>
              </tr>
              <tr>
                <td height="22" colspan="4" class="titulo-celdanew">Informaci&oacute;n del Documento </td>
              </tr>
              <tr>
                <td height="22" colspan="4">
				<table width="842" border="0" cellpadding="0" cellspacing="1" class="celdas-blancas">
                <tr>
				    <td height="22" class="bordeazul"><div align="right">Anticipo: </div></td>
				    <td height="22" colspan="3" class="bordeazul"><input name="chkanticipo" type="checkbox" class="sin-borde" id="chkanticipo" value="1" onClick="javascript: ValidarAnticipo();" <?php if($anticipo){echo 'checked';};?> disabled >
&nbsp;&nbsp;&nbsp;&nbsp;				      &nbsp;
				      N&deg; Anticipo 
				        
				        <input type="text" style="text-align:center" name="txtnroanticipo" id="txtnroanticipo"  value="<?php print $nroanticipo;?>" disabled readonly>
			          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;N&deg; Contrato 
			          <input   style="text-align:center" name="txtnrocontrato" type="text" id="txtnrocontrato" value="<?php print $nrocontanticipo;?>" size="30" disabled >		            </td>
			      </tr>
                  <tr>
                    <td width="196" height="22"><div align="right">N&uacute;mero de Documento </div></td>
                    <td width="272" height="22"><div align="left">
                      <input name="txtnumrecdoc" type="text" id="txtnumrecdoc"  onKeyPress="return keyRestrict(event,'1234567890'+'abcdefghijklmnopqrstuvwxyz')" onBlur="javascript: ue_verificar_rd();" value="<?php print $ls_numrecdoc;?>" size="20" maxlength="45" style="text-align:center" >
                    </div></td>
                    <td width="184" height="22"><div align="right">N&uacute;mero de Control </div></td>
                    <td width="185" height="22"><div align="left">
                      <input name="txtnumref" type="text" id="txtnumref"  onKeyPress="return keyRestrict(event,'1234567890'+'abcdefghijklmnopqrstuvwxyz-')" value="<?php print $ls_numref;?>" size="20" maxlength="15" style="text-align:center"  onBlur="javascript: ue_verificar_numref();" >
                    </div></td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">Fecha de Emisi&oacute;n </div></td>
                    <td width="272" height="22"><div align="left">
                      <input name="txtfecemidoc" type="text" id="txtfecemidoc" style="text-align:center" value="<?php print $ld_fecemidoc;?>" size="17"  onKeyDown="javascript:ue_formato_fecha(this,'/',patron,true,event);" onBlur="javascript: ue_validar_formatofecha(this);" datepicker="true">
                    </div></td>
                    <td height="22"><div align="right">Fecha de Vencimiento </div></td>
                    <td height="22"><div align="left">
                      <input name="txtfecvendoc" type="text" id="txtfecvendoc" style="text-align:center" value="<?php print $ld_fecvendoc;?>" size="17"  onKeyDown="javascript:ue_formato_fecha(this,'/',patron,true,event);" onBlur="javascript: ue_validar_formatofecha(this);" datepicker="true">
                    </div></td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">N&uacute;mero de Control Interno </div></td>
                    <td height="22"><div align="left">
                      <input type="text" name="txtcodrecdoc" id="txtcodrecdoc" value="<?php print $ls_codrecdoc;?>" style="text-align:center" readonly>
                    </div></td>
                    <td height="22">&nbsp;</td>
                    <td height="22">&nbsp;</td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">Fuente de Financiamiento</div></td>
                    <td height="22" colspan="3"><div align="left">
                      <input name="txtcodfuefin" type="text" id="txtcodfuefin" style="text-align:center" value="<?php print $ls_codfuefin;?>" size="5" maxlength="2" readonly>
                      <a href="javascript: ue_fuentefinanciamiento();"><img src="../shared/imagebank/tools15/buscar.gif" alt="Buscar" width="15" height="15" border="0"></a>
                      <input name="txtdenfuefin" type="text" class="sin-borde" id="txtdenfuefin" value="<?php print $ls_denfuefin;?>" size="50" readonly>
                    </div></td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">Unidad Ejecutora </div></td>
                    <td height="22" colspan="3"><div align="left">
                      <input name="txtcodunieje" type="text" id="txtcodunieje" style="text-align:center" value="<?php print $ls_coduniadm;?>" size="15" maxlength="10" readonly>
                      <a href="javascript: ue_unidadejecutora();"><img src="../shared/imagebank/tools15/buscar.gif" alt="Buscar" width="15" height="15" border="0"></a>
                      <input name="txtdenunieje" type="text" class="sin-borde" id="txtdenunieje" value="<?php print $ls_denuniadm;?>" size="80" readonly>
                    </div></td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">Clasificaci&oacute;n del Concepto </div></td>
                    <td height="22" colspan="3"><?php $io_cxp->uf_load_clasificacionconcepto($ls_codcla);?></td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">Beneficiario Alterno</div></td>
                    <td height="22" colspan="3"><input name="txtbenefalt" type="text" id="txtbenefalt" value="<?php print $ls_benefalt; ?>" size="80" style="text-align:left" onKeyPress="return keyRestrict(event,'1234567890'+'abcdefghijklmnñopqrstuvwxyzáéíóú ()@#!%/[]*-+_,.$¿?¡');" ></td>
                  </tr>
                  <tr>
                    <td height="22"><div align="right">Concepto</div></td>
                    <td colspan="3" rowspan="2"><textarea name="txtdencondoc" cols="100" rows="3" id="txtdencondoc"  onKeyPress="return keyRestrict(event,'1234567890'+'abcdefghijklmnñopqrstuvwxyzáéíóú ()@#!%/[]*-+_,.$¿?¡');"><?php print $ls_dencondoc;?></textarea></td>
                  </tr>
                  <tr>
                    <td height="22">&nbsp;</td>
                  </tr>
				  <tr>
                    <td height="22"><div align="right">Concepto Anulaci&oacute;n</div></td>
                    <td colspan="3" rowspan="2"><textarea name="txtconanurd" cols="100" rows="2" id="txtconanurd" onKeyUp="ue_validarcomillas(this);" disabled><?php print $ls_conanurd;?></textarea></td>
                  </tr>
                  <tr>
                    <td height="22">&nbsp;</td>
                  </tr>
				  <tr>
				    <td height="22"><div align="right">No. Orden de Pago Ministerio </div></td>
				    <td height="22"><input name="txtnumordpagmin" type="text" id="txtnumordpagmin" value="<?php print $ls_numordpagmin; ?>" size="19" maxlength="19" style="text-align:center" readonly>
			        <a href="javascript: ue_ordenpagoministerio();"><img src="../shared/imagebank/tools15/buscar.gif" alt="Buscar" width="15" height="15" border="0"></a></td>
				    <td height="22">&nbsp;</td>
				    <td height="22">&nbsp;</td>
			      </tr>
				  <tr>
				    <td height="22"></td>
				    <td height="22"><div align="right">
				      <input name="hidestact" type="hidden" id="hidestact" value="<?php print $ls_estact; ?>">
				      Compra de Activos Fijos
		              <input name="chkactivos" type="checkbox" class="sin-borde" id="chkactivos" value="1" onClick="javascript: ue_activos();" <?php if($ls_estact!="0"){print "checked";} print $ls_disabled; ?> >
				    </div></td>
				    
					<input name="hidrepcajchi" type="hidden" id="hidrepcajchi" value="<?php print $ls_repcajchi; ?>">
					<td height="22"><div align="right">                  Reposiciones
                      <input name="chkrepcajchi" type="checkbox" class="sin-borde" id="chkrepcajchi" value="1" onClick="javascript: ue_cambioctarepcajchi();" <?php if($ls_repcajchi!="0"){print "checked";}?>></td>
			      </tr>
				  <tr>
                    <td height="22"></td>
                    <td width="272" height="22"><div align="left">
                      <div align="right">Asociado al Libro de Compras
                        <input name="chkestlibcom" type="checkbox" class="sin-borde" id="chkestlibcom" value="1" <?php if($ls_estlibcom!=""){print "checked";}?>>
                      </div>
                    </div>
                    <div align="right"></div></td>
                    <td width="184" height="22"><div align="right">Impuesto Municipal
                        <input name="chkestimpmun" type="checkbox" class="sin-borde" id="chkestimpmun" value="1" <?php if($ls_estimpmun!=""){print "checked";}?>>
                    </div></td>
                    <td height="22">&nbsp;</td>
                  </tr>
				  <tr>
				    <td height="22"></td>
				    <td width="272" height="22"><div align="left">
                        <div align="right">Liquidaci&oacute;n de Importaci&oacute;n
							<input name="chkestliqimp" type="checkbox" class="sin-borde" id="chkestliqimp" value="1" <?php if($ls_estliqimp){print "checked";}?>>
                        </div>
				      </div>
				        <div align="right"></div></td>
				    <td width="184" height="22"><div align="left">
                        <div align="right">Liquidaci&oacute;n de Anticipo
                          <input name="chkestliqant" type="checkbox" class="sin-borde" id="chkestliqant" value="1" onClick="ObjForm.ValidarLiquidacion();" <?php if($ls_estliqant){print "checked";}?>>
                        </div>
				      </div>
				        <div align="right"></div></td>
				    <td height="22">&nbsp;</td>
			      </tr>
				  <tr>
				    <td height="22"><div align="right">Proveedor Alterno para  el Comprobante de Retenci&oacute;n del IVA</div></td>
				    <td height="22" colspan="3"><input name="txtcodproalt" type="text" id="txtcodproalt" style="text-align:center" value="<?php print $ls_codproalt; ?>" size="15" maxlength="10" readonly>
                      <a href="javascript: ue_proveedoralterno();"><img src="../shared/imagebank/tools15/buscar.gif" alt="Buscar" width="15" height="15" border="0"></a>
                      <input name="txtdenproalt" type="text" class="sin-borde" id="txtdenproalt" value="<?php print $ls_denproalt; ?>" size="50" readonly></td>
			      </tr>
				  <tr>
				    <td height="22">&nbsp;</td>
				    <td height="22" colspan="3">&nbsp;</td>
			      </tr>
				  
				  <tr>
				    <td height="22" colspan="4"><div id="resultados" align="center"></div></td>
			      </tr>
                </table>				</td>
		<table width="791" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td align="center"><div id="cuentas"></div></td>
              </tr>
          </table>
				  </tr>
                </table>				</td>
      </tr>
          </table>
<p> 
          <input name="operacion" type="hidden" id="operacion" value="<?php print $ls_operacion;?>">
          <input name="existe" type="hidden" id="existe" value="<?php print $ls_existe;?>">
          <input name="codtipdoc" type="hidden" id="codtipdoc" value="<?php print $ls_codtipdoc;?>">
          <input name="tipdes" type="hidden" id="tipdes" value="<?php print $ls_tipodestino;?>">
          <input name="fecregdoc" type="hidden" id="fecregdoc" value="<?php print $ld_fecregdoc;?>">
          <input name="fecvendoc" type="hidden" id="fecvendoc" value="<?php print $ld_fecvendoc;?>">
          <input name="fecemidoc" type="hidden" id="fecemidoc" value="<?php print $ld_fecemidoc;?>">
          <input name="codcla" type="hidden" id="codcla" value="<?php print $ls_codcla;?>">
          <input name="estatuspresupuesto" type="hidden" id="estatuspresupuesto" value="<?php print $ls_estatuspresupuesto;?>">
          <input name="estatuscontable" type="hidden" id="estatuscontable" value="<?php print $ls_estatuscontable;?>">
          <input name="codigocuenta" type="hidden" id="codigocuenta" value="<?php print $ls_codigocuenta;?>">
		  <input name="codigocuentarepcajchi" type="hidden" id="codigocuentarepcajchi" value="<?php print $ls_codigocuentarepcajchi;?>">
          <input name="totrowspg" type="hidden" id="totrowspg" value="<?php print $li_totrowspg;?>">
          <input name="totrowscg" type="hidden" id="totrowscg" value="<?php print $li_totrowscg;?>">
          <input name="estaprord" type="hidden" id="estaprord" value="<?php print $li_estaprord;?>">
          <input name="procede" type="hidden" id="procede" value="<?php print $ls_procede;?>">
<input name="tipocontribuyente" type="hidden" id="tipocontribuyente" value="<?php print $ls_tipocontribuyente;?>">
          <input name="generarcontable" type="hidden" id="generarcontable" value="0">
          <input name="estmodiva" type="hidden" id="estmodiva" value="<?php print $ls_estmodiva;?>">
          <input name="causadoparcial" type="hidden" id="causadoparcial"    value="0">
          <input name="parametros"     type="hidden" id="parametros"    value="<?php print $ls_parametros;?>">
          <input name="formato"    type="hidden" id="formato"    value="<?php print $ls_reporte; ?>">
          <input name="cerrarasiento" type="hidden" id="cerrarasiento" value="0">
          <input name="recepcionexiste" type="hidden" id="recepcionexiste" value="false">
          <input name="clactacont" type="hidden" id="clactacont" value="<?php print $ls_clactacon; ?>">
          <input name="valclacon" type="hidden" id="valclacon" value="<?php print $ls_valclacon; ?>">
          <input name="hidestcla"     type="hidden" id="hidestcla" value="<?php echo $ls_estcla; ?>">
          <input name="txtcodestpro1" type="hidden" id="txtcodestpro1" value="<?php print $ls_codestpro1;?>">
          <input name="txtcodestpro2" type="hidden" id="txtcodestpro2" value="<?php print $ls_codestpro2;?>">
          <input name="txtcodestpro3" type="hidden" id="txtcodestpro3" value="<?php print $ls_codestpro3;?>">
          <input name="txtcodestpro4" type="hidden" id="txtcodestpro4" value="<?php print $ls_codestpro4;?>">
          <input name="txtcodestpro5" type="hidden" id="txtcodestpro5" value="<?php print $ls_codestpro5;?>">
          <input name="hidestint" type="hidden" id="hidestint" value="<?php print $ls_estint;?>">
          <input name="hidcuentaint" type="hidden" id="hidcuentaint" value="<?php print $ls_cuentaint;?>">
          <input name="txtcodtipfon" type="hidden" id="txtcodtipfon" value="<?php print $ls_codtipfon;?>">
		  <input name="confiva" type="hidden" id="confiva" value="<?php print ($_SESSION["la_empresa"]["confiva"]);?>">
          <input name="capiva" type="hidden" id="capiva" value="<?php print $_SESSION["la_empresa"]["capiva"]; ?>">
          <input name="ageviapro" type="hidden" id="ageviapro" value="<?php print $ls_ageviapro; ?>">           
          <input name="hcuenta_anticipo" type="hidden" id="hcuenta_anticipo" value="<?php print $cuenta_desc_anticipo; ?>">
          <input name="hestanticipo" type="hidden" id="hestanticipo" value="<?php print $est_desc_anticipo; ?>">
          <input name="hnroantact" type="hidden" id="hnroantact" value="<?php print $nro_desc_anticipo; ?>">
          <input name="hnrofilaant" type="hidden" id="hnrofilaant" value="<?php print $nrofiladescant; ?>">
          <input name="hmontotanticipo" type="hidden" id="hmontotanticipo" value="<?php print $mondescant; ?>">
          <input name="hporcantdesc" type="hidden" id="hporcantdesc" value="<?php print $porcantdesc; ?>">
          <input name="hnrodesc" type="hidden" id="hnrodesc" value="<?php print $nrodesc; ?>">
          
        </p></td>
      </tr>
    </table>
</form>
</body>
<script language="javascript">
var patron = new Array(2,2,4);
var patron2 = new Array(1,3,3,3,3);
window.NoPreguntar=0;
function ue_nuevo()
{
	f=document.formulario;
	li_incluir=f.incluir.value;
	if(li_incluir==1)
	{	
		f.operacion.value="NUEVO";
		f.existe.value="FALSE";		
		f.action="sigesp_cxp_p_recepcioncontable.php";
		f.submit();
   	}
	else
   	{
 		alert("No tiene permiso para realizar esta operacion");
   	}
}

function ue_verificar_rd()
{
	f=document.formulario;
	if(f.existe.value=="FALSE")
	{
		ls_proceso="VERIFICAR_RD";
		parametros="";
		tipodocumento=ue_validarvacio(f.cmbcodtipdoc.value);
		codtipdoc=tipodocumento.substr(0,5);
		tipdes=ue_validarvacio(f.cmbtipdes.value);
		codigo=ue_validarvacio(f.txtcodigo.value);
		numrecdoc=ue_validarvacio(f.txtnumrecdoc.value);
		parametros="&codtipdoc="+codtipdoc+"&numrecdoc="+numrecdoc+"&tipdes="+tipdes+"&codigo="+codigo;
		if(parametros!="")
		{
			ajax=objetoAjax();
			divgrid = document.getElementById('cuentas');
			// Pagina donde están los métodos para buscar y pintar los resultados
			ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					texto=ajax.responseText;
					//divgrid.innerHTML = ajax.responseText;
					if(texto.indexOf("ERROR->")!=-1)
					{
						posicion=texto.indexOf("ERROR->");
						lontitud=texto.length-posicion;
						f.txtnumrecdoc.value="";
						//f.txtnumrecdoc.focus();
						alert(texto.substr(posicion,lontitud));
						f.recepcionexiste.value="false";
					}
					else
					{
						f.recepcionexiste.value="true";
					}
				}
			}
			ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			// Enviar todos los campos a la pagina para que haga el procesamiento
			ajax.send("proceso="+ls_proceso+parametros);
		}
	}
}

function ue_verificar_numref()
{
	f=document.formulario;
	numref=f.txtnumref.value;
	caracter=numref.substr(2,1);
	if(caracter!="-")
	{
		alert("El numero de referencia no cumple con la Providencia 0257 del SENIAT. Formato valido: 00-000000 ");
		f.txtnumref.value="";
	}
}

function ue_guardar()
{
	f=document.formulario;
	li_incluir=f.incluir.value;
	li_cambiar=f.cambiar.value;
	lb_existe=f.existe.value;
	if(((lb_existe=="TRUE")&&(li_cambiar==1))||(lb_existe=="FALSE")&&(li_incluir==1))
	{
		estaprord=f.estaprord.value;
		if(estaprord=="1")
		{
			alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
		}
		else
		{
			valido=true;
			resp = ObjForm.ValidarTipoLiquidacion();
			if(!resp){return;}
			codtipdoc=ue_validarvacio(f.cmbcodtipdoc.value);
			codigo=ue_validarvacio(f.txtcodigo.value);
			numrecdoc=ue_validarvacio(f.txtnumrecdoc.value);
			dencondoc=ue_validarvacio(f.txtdencondoc.value);
			fecregdoc=ue_validarvacio(f.txtfecregdoc.value);
			fecemidoc=ue_validarvacio(f.txtfecemidoc.value);
			fecvendoc=ue_validarvacio(f.txtfecvendoc.value);
			subtotal=ue_validarvacio(f.txtsubtotal.value);
			cargos=ue_validarvacio(f.txtcargos.value);
			totaldebe=ue_validarvacio(f.txttotaldebe.value);
			totalhaber=ue_validarvacio(f.txttotalhaber.value);
			totalgeneral=ue_formato_calculo(ue_validarvacio(f.txttotalgener.value));
			codigocuenta=trim(ue_validarvacio(f.codigocuenta.value));
			cerrarasiento=f.cerrarasiento.value;
			totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
			f.totrowspg.value=totrowspg;
			totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
			f.totrowscg.value=totrowscg;
			contable=codtipdoc.substr(6,1);
			presupuestario=codtipdoc.substr(8,1);
			montoproveedor=0;
			if(valido)
			{
				valido=ue_validarcampo(codtipdoc,"El Tipo de Documento no puede estar vacio.",f.cmbcodtipdoc);
			}
			if(valido)
			{
				valido=ue_validarcampo(codigo,"El Proveedor ó Beneficiario no puede estar vacio.",f.txtcodigo);
			}
			if(valido)
			{
				valido=ue_validarcampo(numrecdoc,"El Número de Recepción no puede estar vacio.",f.txtnumrecdoc);
			}
			if(valido)
			{
				valido=ue_validarcampo(dencondoc,"El Concepto no puede estar vacio.",f.txtdencondoc);
			}
			if(valido)
			{
				valido=ue_validarcampo(fecregdoc,"La Fecha de Recepción no puede estar vacia.",f.txtfecregdoc);
			}
			if(valido)
			{
				valido=ue_validarcampo(fecemidoc,"La Fecha dee Emisión no puede estar vacia.",f.txtfecemidoc);
			}
			if(valido)
			{
				valido=ue_validarcampo(fecvendoc,"La Fecha de Vencimiento no puede estar vacia.",f.txtfecvendoc);
			}
			if(valido)
			{
				for(j=1;(j<totrowscg);j++)
				{
					scgcuenta=eval("f.txtscgcuenta"+j+".value");
					mondeb=eval("f.txtmondeb"+j+".value");
					monhab=eval("f.txtmonhab"+j+".value");
					debhab=eval("f.txtdebhab"+j+".value");
					estatus=eval("f.txtestatus"+j+".value");
					if(estatus!="M")
					{
						if(codigocuenta==scgcuenta)
						{
							if(debhab=="D")
							{
								montoproveedor=ue_formato_calculo(mondeb);
							}
							else
							{
								montoproveedor=ue_formato_calculo(monhab);
							}
							j=totrowscg+1;
						}
					}
				}	
				/*************************************************************************************************************************/
				/*********************** MODIFICACIÓN PARA PODER LIQUIDAR ANTICIPOS DEL 100% *********************************************/
				/*************************************************************************************************************************/
				/************************ EL MONTO DEL PROVEEDOR PUEDE SER O PARA LIQUIDACIONES DE ANTICIPO DEL 100% *********************/
				/*************************************************************************************************************************/			
				liqant = (document.getElementById("chkestliqant").checked==true)?1:0;
				if((parseFloat(montoproveedor)==0 && liqant==0)||(parseFloat(montoproveedor)<0))
				{
					if(cerrarasiento==0)
					{
						alert("Antes de Guardar debe primero Cerra el asiento Contable.");
						valido=false;
					}					
					else
					{
						alert("Si no es una liquidación de anticipo el monto de la Cuenta del Proveedor debe ser mayor que Cero.");
						valido=false;
					}
				}
				
			}
			if(valido)
			{
				if((presupuestario=="1")||(presupuestario=="2")||(presupuestario=="5")) // Causa ó compromete y causa
				{
					if(totrowspg==0)
					{
						alert("Debe colocar Detalles Presupuestarios.");
						valido=false;
					}
					li_subtotal=0;
					li_cargos=0;
					for(j=1;(j<totrowspg)&&(valido);j++)
					{
						carg=eval("f.txtcargo"+j+".value");
						spgmonto=eval("f.txtspgmonto"+j+".value");
						if(carg=="0")
						{
							li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(spgmonto));
						}
						else
						{
							li_cargos=eval(li_cargos+"+"+ue_formato_calculo(spgmonto));
						}
					}
					for(j=1;(j<totrowscg)&&(valido);j++)
					{
						estatus=eval("f.txtestatus"+j+".value");
						debhab=eval("f.txtdebhab"+j+".value");
						if(estatus=="M")
						{
							if(debhab=="D")
							{
								monto=eval("f.txtmondeb"+j+".value");
								li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(monto));
							}
							else
							{
								monto=eval("f.txtmonhab"+j+".value");
								li_subtotal=eval(li_subtotal+"-"+ue_formato_calculo(monto));
							}
						}
					}
					li_subtotal=redondear(li_subtotal,2);
					li_cargos=redondear(li_cargos,2);
					subtotal=ue_formato_calculo(subtotal);
					cargos=ue_formato_calculo(cargos);
					capiva=f.capiva.value;
					if(capiva!=1)
					{
						if(parseFloat(subtotal)!=parseFloat(li_subtotal))
						{
							alert("La suma de los detalles Presupuestarios del Gasto Difiere con el Subtotal.");
							valido=false;
						}
						confiva=f.confiva.value;
						if (confiva=="C")
						   {
							 diferencia=(parseFloat(subtotal)-parseFloat(cargos))
							 if (parseFloat(diferencia)<0)
								{
								  alert("El monto de los cargos no debe ser mayor al monto del causado");
								  valido=false;
								}
						   }
						else
						   {
							 if (parseFloat(cargos)!=parseFloat(li_cargos))
								{
								  alert("La suma de los detalles Presupuestarios del Cargo Difiere con los Otros Créditos.");
								  valido=false;
								}
						   }
					}
				}
			}			
			if(valido)
			{
				if(contable=="1") // Contable
				{
					if(totrowscg==0)
					{
						alert("Debe colocar Detalles Contables.");
						valido=false;
					}
				}			
			}			
			if(valido)
			{
				if (totaldebe!=totalhaber)
				{
					alert("La Recepción está descuadrada Contablemente.");
					valido=false;
				}
			}
			if(valido)
			{
				/*************************************************************************************************************************/
				/*********************** MODIFICACIÓN PARA PODER LIQUIDAR ANTICIPOS DEL 100% *********************************************/
				/*************************************************************************************************************************/
				/************************ EL TOTAL GENERAL PUEDE SER O PARA LIQUIDACIONES DE ANTICIPO DEL 100% ***************************/
				/*************************************************************************************************************************/			
				liqant = (document.getElementById("chkestliqant").checked==true)?1:0;				
				if((parseFloat(totalgeneral)==0 && liqant==0)||(parseFloat(totalgeneral)<0))
				{
					alert("Si no es una liquidación de anticipo la Recepción Debe ser Mayor que Cero.");
					valido=false;
				}
			}
			if(valido)
			{
				if(cerrarasiento==0)
				{
					alert("Antes de Guardar debe primero Cerrar el asiento Contable.");
					valido=false;
				}
			}
			if(valido)
			{
				document.getElementById("chkanticipo").disabled=false;
				document.getElementById("txtnroanticipo").disabled=false;
				document.getElementById("txtnrocontrato").disabled=false;
				document.getElementById("txtnumrecdoc").readOnly=true;
				document.getElementById("txtnumref").readOnly=true;
				f.operacion.value="GUARDAR";
				f.action="sigesp_cxp_p_recepcioncontable.php";
				f.submit();		
			}
		}
	}
	else
	{
		alert("No tiene permiso para realizar esta operación");
	}
}

function ue_buscar()
{
	window.open("sigesp_cxp_cat_recepcion.php","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=650,height=400,left=50,top=50,location=no,resizable=no");
}

function ue_activos()
{
	f=document.formulario;
	tipodocumento=f.cmbcodtipdoc.value;
	if(tipodocumento=="-")
	{
		alert("Debe seleccionar un tipo de documento");
		f.chkactivos.checked=false;
	}
	else
	{
		presupuestario=tipodocumento.substr(8,1);
		if(presupuestario=="1"||presupuestario=="5") // Causa
		{
			alert("El tipo de documento no permite modificar este campo");
			f.chkactivos.checked=false;
		}
		else
		{
			if(f.chkactivos.checked==true)
			{
				f.hidestact.value=1;
			}
			else
			{
				f.hidestact.value=0;
			}
		}
	}
}

function ue_cambioctarepcajchi()
{
	f=document.formulario;
	cuenta=f.codigocuenta.value;
	cuenta_repcajchi=f.codigocuentarepcajchi.value;
	//AGREGADO POR OFIMATICA DE VENEZUELA EL 13-06-2011 (BLOQUE 1), valido que se haya seleccionado el destino
	lb_valido=true;
	if(f.txtcodigo.value=="")
	{
		alert("Debe seleccionar el destino de la recepción(Proveedor / Beneficiario)");
		f.chkrepcajchi.checked=false;
		lb_valido=false;
	}
	if(lb_valido)
	{//FIN PRIMERA PARTE BLOQUE 1 AGREGADO POR OFIMATICA DE VENEZUELA EL 13-06-2011 
		if(f.chkrepcajchi.checked==true)
		{
			f.codigocuentarepcajchi.value=cuenta;
			f.codigocuenta.value=cuenta_repcajchi;
		}
		if(f.chkrepcajchi.checked==false)
		{
			f.codigocuentarepcajchi.value=cuenta;
			f.codigocuenta.value=cuenta_repcajchi;
		}
		if((f.codigocuentarepcajchi.value=="")&&(f.codigocuenta.value==""))
		{
			alert("Se ha desconfigurado la opción de caja chica, por favor vuelva a cargar los datos");
			f.operacion.value="NUEVO";
			f.existe.value="FALSE";		
			f.action="sigesp_cxp_p_recepcioncontable.php";
			f.submit();
		}
		else//AGREGADO POR OFIMATICA DE VENEZUELA EL 13-06-2011 (BLOQUE 2), se forza el cierre de asiento automatico al cambiar de estatus de reposicion
		{		
			totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
			if(totrowscg>1)
			{
				ue_cerrar_asiento();
			}	
		}// FIN DE BLOQUE 2 DE OFIMATICA DE VENEZUELA EL 13-06-2011
	}// FIN DE BLOQUE 1 DE OFIMATICA DE VENEZUELA EL 13-06-2011
}

function ue_unidadejecutora()
{
	f=document.formulario;
	tipodocumento=f.cmbcodtipdoc.value;
	if(tipodocumento=="-")
	{
		alert("Debe seleccionar un tipo de documento");
	}
	else
	{
		presupuestario=tipodocumento.substr(8,1);
		if(presupuestario=="1"||presupuestario=="5") // Causa
		{
			alert("El tipo de documento no permite modificar la unidad ejecutora");
		}
		else
		{
			if(presupuestario=="2"||presupuestario=="6")
			{
				destino="";
			}
			else
			{
				destino="CONTABLE";
			}
			totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
			totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
			if((totrowspg==1)&&(totrowscg==1))
			{
				window.open("sigesp_cxp_cat_unidad_ejecutora.php?tipo="+destino,"catalogo","menubar=no,toolbar=no,scrollbars=yes,width=650,height=400,left=50,top=50,location=no,resizable=no");
			}
			else
			{
				alert("No se puede modificar la Unidad Ejecutora. La Recepcion de Documentos ya tiene movimientos");
			}
		}
	}
}

function ue_fuentefinanciamiento()
{
	f=document.formulario;
	totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
	f.totrowspg.value=totrowspg;
	totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
	f.totrowscg.value=totrowscg;
	if((totrowspg==1)&&(totrowscg==1))
	{
		window.open("sigesp_cxp_cat_fuente.php","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=550,height=400,left=50,top=50,location=no,resizable=no");
	}
}

function ue_eliminar()
{
	f=document.formulario;
	li_eliminar=f.eliminar.value;
	lb_existe=f.existe.value;
	if(li_eliminar==1)
	{
		if(lb_existe=="FALSE")
		{
			alert("Debe seleccionar una Recepción de Documentos.");
		}
		else
		{
			estaprord=f.estaprord.value;
			if(estaprord=="1")
			{
				alert("La Recepción de Documentos, no se puede eliminar ha sido Aprobada.");
			}
			else
			{
				procede=f.procede.value;
				if(procede=="CXPRCD")
				{		
					if(confirm("¿Desea eliminar el Registro actual?"))
					{
						valido=true;
						codtipdoc=ue_validarvacio(f.cmbcodtipdoc.value);
						codigo=ue_validarvacio(f.txtcodigo.value);
						numrecdoc=ue_validarvacio(f.txtnumrecdoc.value);
						totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
						f.totrowspg.value=totrowspg;
						totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
						f.totrowscg.value=totrowscg;
						if(valido)
						{
							valido=ue_validarcampo(codtipdoc,"El Tipo de Documento no puede estar vacio.",f.cmbcodtipdoc);
						}
						if(valido)
						{
							valido=ue_validarcampo(codigo,"El Proveedor ó Beneficiario no puede estar vacio.",f.txtcodigo);
						}
						if(valido)
						{
							valido=ue_validarcampo(numrecdoc,"El Número de Recepción no puede estar vacio.",f.txtnumrecdoc);
						}
						if(valido)
						{
							document.getElementById("chkanticipo").disabled=false;
							document.getElementById("txtnroanticipo").disabled=false;
							document.getElementById("txtnrocontrato").disabled=false;
							document.getElementById("txtnumrecdoc").readOnly=true;
							document.getElementById("txtnumref").readOnly=true;
							f.operacion.value="ELIMINAR";
							f.action="sigesp_cxp_p_recepcioncontable.php";
							f.submit();		
						}
					}
				}
				else
				{
					alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede eliminar");
				}
			}
		}
	}
	else
	{
		alert("No tiene permiso para realizar esta operación");
	}
}

function ue_imprimir()
{
	f=document.formulario;
	li_imprimir=f.imprimir.value;
	lb_existe=f.existe.value;
	if(li_imprimir==1)
	{
		if(lb_existe=="TRUE")
		{
			numrecdoc=f.txtnumrecdoc.value;
			tipdes=f.cmbtipdes.value;
			if(tipdes=="P")
			{
				codpro=f.txtcodigo.value;
				cedben="----------";
			}
			else
			{
				codpro="----------";
				cedben=f.txtcodigo.value;			
			}
			tipodocumento=f.cmbcodtipdoc.value;
			codtipdoc=tipodocumento.substr(0,5);
			formato=f.formato.value;
			tiporeporte= f.cmbbsf.value;
			window.open("reportes/"+formato+"?numrecdoc="+numrecdoc+"&codpro="+codpro+"&cedben="+cedben+"&codtipdoc="+codtipdoc+"&tiporeporte="+tiporeporte+"","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=800,height=600,left=0,top=0,location=no,resizable=yes");
		}
		else
		{
			alert("Debe existir un documento a imprimir");
		}
	}
	else
	{
		alert("No tiene permiso para realizar esta operacion");
	}
}

function ue_cerrar()
{
	location.href = "sigespwindow_blank.php";
}

function ue_ordenpagoministerio()
{
	window.open("sigesp_cxp_cat_ordenministerio.php","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=750,height=400,left=50,top=50,location=no,resizable=no");
}
function ue_cambiartipodocumento()
{
	f=document.formulario;
	tipodocumento=f.cmbcodtipdoc.value;
	codtipdoc=tipodocumento.substr(0,5);
	contable=tipodocumento.substr(6,1);
	presupuestario=tipodocumento.substr(8,1);
	f.estatuspresupuesto.value=presupuestario;
	f.estatuscontable.value=contable;
	f.codtipdoc.value=codtipdoc;
	f.totrowspg.value=1;
	f.totrowscg.value=1;
	f.recepcionexiste.value="false";
	ls_proceso="";
	if(presupuestario=="1"||presupuestario=="5") // Causa
	{
		ls_proceso="CAUSA";
	}
	if(presupuestario=="2"||presupuestario=="6") // Compromete y Causa
	{
		ls_proceso="COMPROMETECAUSA";
	}
	if((presupuestario=="3")||(presupuestario=="4")) // Sin afectación presupuestaria
	{
		if(contable=="1")
		{
			ls_proceso="CONTABLE";
		}
	}
	// Div donde se van a cargar los resultados
	divgrid = document.getElementById('cuentas');
	// Instancia del Objeto AJAX
	ajax=objetoAjax();
	// Pagina donde están los métodos para buscar y pintar los resultados
	ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divgrid.innerHTML = ajax.responseText
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	// Enviar todos los campos a la pagina para que haga el procesamiento
	ajax.send("proceso="+ls_proceso+"&totrowspg=1&totrowscg=1&estcontable="+contable+"&estpresupuestario="+presupuestario+"");
}

function ue_cambiardestino()
{
	f=document.formulario;
	// Se verifica si el destino es un proveedor ó beneficiario y se carga el catalogo
	// dependiendo de esa información
	f.txtcodigo.value="";
	f.txtnombre.value="";
	f.recepcionexiste.value="false";
	tipdes=ue_validarvacio(f.cmbtipdes.value);
	if(tipdes!="-")
	{
		//AGREAGADO POR OFIMATICA DE VENEZUELA EL 13-06-2011, verifico que el estatus de reposicion no este tildado, si lo esta lo destildo para que no pierda los valores de cuenta de caja chica en los ocultos
		if(f.chkrepcajchi.checked==true)
		{
			f.chkrepcajchi.checked=false;
			f.codigocuenta.value=f.codigocuentarepcajchi.value;
			f.codigocuentarepcajchi.value="<?php print $_SESSION["la_empresa"]["repcajchi"]?>";
			alert("Si el documento corresponde a reposiciones, debe volver a tildar el estatus");
		}
		//FIN BLOQUE AGREGADO POR OFIMATICA DE VENEZUELA 13-06-2011
		if(tipdes=="P")
		{
			window.open("sigesp_cxp_cat_proveedor.php","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=530,height=400,left=50,top=50,location=no,resizable=no");
		}
		else
		{
			window.open("sigesp_cxp_cat_beneficiario.php","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=530,height=400,left=50,top=50,location=no,resizable=no");
		}	
	}
}

function ue_proveedoralterno()
{
	f=document.formulario;
	// Se verifica si el destino es un proveedor ó beneficiario y se carga el catalogo
	// dependiendo de esa información
	ageviapro=ue_validarvacio(f.ageviapro.value);
	tipo="AEROLINEAS";
	if(ageviapro=="1")
	{
		window.open("sigesp_cxp_cat_proveedor.php?tipo="+tipo,"catalogo","menubar=no,toolbar=no,scrollbars=yes,width=530,height=400,left=50,top=50,location=no,resizable=no");
	}
	else
	{
		alert("Esta opción esta permitida solo para agencias de viajes.");
	}
}

function ue_agregarconcepto()
{
	f=document.formulario;
	id=f.cmbcodcla.selectedIndex;
	valor=f.cmbcodcla[id].value;
	f.codcla.value=valor;
	if(valor=="--")
	{
		valor="proveedor";
	}
	if(f.clactacont.value==1)
	{
		f.codigocuenta.value=eval("f.txt"+valor+".value");
		f.cmbtipdes.disabled=true;
		if(eval("f.txt"+valor+".value")=="")
		{
			alert("Debe configurar la cuenta contable para el clasificador del concepto seleccionado");
		}
	}
	if(id>0)
	{
		texto=f.cmbcodcla[id].text;
		f.txtdencondoc.value=f.txtdencondoc.value+texto;
	}
}

function ue_catalogo_cuentas_spg()
{
	f=document.formulario;
	estaprord = f.estaprord.value;
	valido=true;
	if(estaprord!="1")
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			lb_existe=f.existe.value;
			fechaemision=f.txtfecemidoc.value;
			fechavencimiento=f.txtfecvendoc.value;
			valido=ue_comparar_fechas(fechaemision,fechavencimiento);
			if(valido)
			{
				if((f.recepcionexiste.value=="true")||(lb_existe))
				{
					numdoc=f.txtnumrecdoc.value;
					codtipdoc=f.cmbcodtipdoc.value;
					codproben=f.txtcodigo.value;
					codigocuenta=f.codigocuenta.value;
					presupuesto=f.estatuspresupuesto.value;
					codestpro1=f.txtcodestpro1.value;
					codestpro2=f.txtcodestpro2.value;
					codestpro3=f.txtcodestpro3.value;
					codestpro4=f.txtcodestpro4.value;
					codestpro5=f.txtcodestpro5.value;
					estint=f.hidestint.value;
					cuentaint=f.hidcuentaint.value;
					estcla=f.hidestcla.value;
					if(f.chkactivos.checked==true)
					{
						activo="A";
					}
					else
					{
						activo="-";
					}
					if((presupuesto=="3")||(presupuesto=="4")) // Ninguna ó Sin afectación
					{
						alert("El Documento Seleccionado no permite Comprometer");
					}
					else
					{
						li_cargos=ue_formato_calculo(f.txtcargos.value);
						li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
						if((parseFloat(li_cargos)>0)||(parseFloat(li_deducciones)>0))
						{
							alert("Ya agrego Cargos y/o Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
						}
						else
						{
							if((codtipdoc!='-')&&(codproben!='')&&(numdoc!=''))
							{
								if(f.valclacon.value==1)
								{
									if(f.cmbcodcla.value=="--")
									{
										alert("Debe seleccionar una clasificación del concepto valida.");
										valido=false;
									}
								}
								if(valido)
								{
									pagina="sigesp_cxp_pdt_spgcuentas.php?documento="+numdoc+"&sccuenta="+codigocuenta+
										   "&codestpro1="+codestpro1+"&codestpro2="+codestpro2+"&codestpro3="+codestpro3+
										   "&codestpro4="+codestpro4+"&codestpro5="+codestpro5+"&estcla="+estcla+
										   "&estint="+estint+"&cuentaint="+cuentaint+"&activo="+activo;
									window.open(pagina,"catalogo","menubar=no,toolbar=no,scrollbars=no,width=705,height=270,resizable=no,location=no,dependent=yes");
									f.fecregdoc.value=f.txtfecregdoc.value;
									f.fecvendoc.value=f.txtfecvendoc.value;
									f.fecemidoc.value=f.txtfecemidoc.value;
									f.codtipdoc.value=f.cmbcodtipdoc.value;
									f.tipdes.value=f.cmbtipdes.value;
									f.txtnumrecdoc.readOnly=true;
									f.cmbcodtipdoc.disabled=true;
									f.txtfecregdoc.disabled=true;
									f.txtfecemidoc.disabled=true;
									f.txtfecvendoc.disabled=true;
									f.cmbtipdes.disabled=true;
									f.chkactivos.disabled=true;
									f.cmbcodcla.disabled=true;
								}
							}
							else
							{
								alert("Debe seleccionar el Tipo de Documento, Proveedor/Beneficiario y Escribir el Nùmero de Documento");
							}
						}
					}
				}
				else
				{
					alert("El nro de Recepción de Documentos no ha sido validada por favor tipeelo de nuevo.");
				}
			}
			else
			{
				alert("La fecha de emisión debe ser menor a la fecha de vencimiento.");
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
		}
	}
	else
	{
		alert("La Recepión esta Aprobada no puede realizar ningún cambio.");
	}
}

function ue_catalogo_cuentas_scg(prop)
{	
	
	if(!prop){prop=new Array();}	
	
	f=document.formulario;
	estaprord = f.estaprord.value;
	valido=true;
	window.validador = true;
	if(estaprord!="1")
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			lb_existe=f.existe.value;
			if((f.recepcionexiste.value=="true")||(lb_existe))
			{
				numdoc=f.txtnumrecdoc.value;
				codtipdoc=f.cmbcodtipdoc.value;
				codproben=f.txtcodigo.value;
				codigocuenta=f.codigocuenta.value;
				contable=f.estatuscontable.value;
				presupuestario=f.estatuspresupuesto.value;
				if(contable=="2") // Ninguna ó Sin afectación
				{
					alert("El Documento Seleccionado no permite Afectación contable");
					window.validador = false;
				}
				else
				{			
					li_cargos=ue_formato_calculo(f.txtcargos.value);
					if(presupuestario==1||presupuestario==5)
					{
						li_cargos=0;
					}
					li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
					if((parseFloat(li_cargos)>0)||(parseFloat(li_deducciones)>0))
					{
						alert("Ya agrego Cargos y/o Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
						window.validador = false;
					}
					else
					{
						if((codtipdoc!='-')&&(codproben!='')&&(numdoc!=''))
						{
							if(f.valclacon.value==1)
							{
								if(f.cmbcodcla.value=="--")
								{
									alert("Debe seleccionar una clasificación del concepto valida.");
									window.validador = false;
									valido=false;
								}
							}
							if(valido)
							{
								//alert(til['montotant'] + "\n" + til['sc_cuenta']);
								//alert(til['tildados']);
								/*til['montotant'] = parseFloat(montoant)- parseFloat(montodesc);
								til['filaant'] = nro;
								til['nroanticipo'] = nroanticipo;
								til['sc_cuenta'] = sc_cuenta;*/
								
								stradd="";
								if(prop['anticipo']==1){stradd = "&scg_cuenta="+prop['sc_cuenta']+"&scg_monto="+prop['montotant']+"&anticipo="+prop['anticipo']+"&filaant="+prop['filaant']+"&nroanticipo="+prop['nroanticipo']+"&debhab=H";}
																
								pagina="sigesp_cxp_pdt_scgcuentas.php?documento="+numdoc+"&sccuenta="+codigocuenta+stradd;
								window.open(pagina,"catalogo","menubar=no,toolbar=no,scrollbars=no,width=705,height=270,resizable=no,location=no,dependent=yes");
								f.fecregdoc.value=f.txtfecregdoc.value;
								f.fecvendoc.value=f.txtfecvendoc.value;
								f.fecemidoc.value=f.txtfecemidoc.value;
								f.codtipdoc.value=f.cmbcodtipdoc.value;
								f.tipdes.value=f.cmbtipdes.value;
								f.txtnumrecdoc.readOnly=true;
								f.cmbcodtipdoc.disabled=true;
								f.txtfecregdoc.disabled=true;
								f.txtfecemidoc.disabled=true;
								f.txtfecvendoc.disabled=true;
								f.cmbtipdes.disabled=true;
								f.cmbcodcla.disabled=true;
							}
						}
						else
						{
							alert("Debe seleccionar el Tipo de Documento, Proveedor/Beneficiario y Escribir el Nùmero de Documento");
							window.validador = false;
						}
					}
				}
			}
			else
			{
				alert("El nro de Recepción de Documentos no ha sido validada por favor tipeelo de nuevo.");
				window.validador = false;
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
			window.validador = false;
		}
	}
	else
	{
		alert("La Recepión esta Aprobada no puede realizar ningún cambio.");
		window.validador = false;
	}
}

function ue_catalogo_compromisos()
{
	f=document.formulario;
	estaprord = f.estaprord.value;
	valido=true;
	if(estaprord!="1")
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			if(f.recepcionexiste.value=="true")
			{
				numdoc=f.txtnumrecdoc.value;
				codtipdoc=f.cmbcodtipdoc.value;
				codproben=f.txtcodigo.value;
				presupuesto=f.estatuspresupuesto.value;
				if((presupuesto=="3")||(presupuesto=="4")) // Ninguna ó Sin afectación
				{
					alert("El Documento Seleccionado no permite Causar");
				}
				else
				{			
					li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
					if(parseFloat(li_deducciones)>0)
					{
						alert("Ya agrego Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
					}
					else
					{
						if((codtipdoc!='-')&&(codproben!='')&&(numdoc!=''))
						{
							if(f.valclacon.value==1)
							{
								if(f.cmbcodcla.value=="--")
								{
									alert("Debe seleccionar una clasificación del concepto valida.");
									valido=false;
								}
							}
							if(valido)
							{
								pagina="sigesp_cxp_pdt_compromisos.php";
								window.open(pagina,"catalogo","menubar=no,toolbar=no,scrollbars=yes,width=850,height=325,resizable=no,location=no,dependent=yes");
								f.fecregdoc.value=f.txtfecregdoc.value;
								f.fecvendoc.value=f.txtfecvendoc.value;
								f.fecemidoc.value=f.txtfecemidoc.value;
								f.codtipdoc.value=f.cmbcodtipdoc.value;
								f.tipdes.value=f.cmbtipdes.value;
								f.txtnumrecdoc.readOnly=true;
								f.cmbcodtipdoc.disabled=true;
								f.txtfecregdoc.disabled=true;
								f.txtfecemidoc.disabled=true;
								f.txtfecvendoc.disabled=true;
								f.cmbtipdes.disabled=true;
								f.cmbcodcla.disabled=true;
							}
						}
						else
						{
							alert("Debe seleccionar el Tipo de Documento, Proveedor/Beneficiario y Escribir el Nùmero de Documento");
						}
					}
				}
			}
			else
			{
				alert("El nro de Recepción de Documentos no ha sido validada por favor tipeelo de nuevo.");
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
		}
	}
	else
	{
		alert("La Recepión esta Aprobada no puede realizar ningún cambio.");
	}
}

function ue_catalogo_amortizacion()
{
	f=document.formulario;
	estaprord = f.estaprord.value;
	if(estaprord!="1")
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			if(f.recepcionexiste.value=="true")
			{
				numdoc=f.txtnumrecdoc.value;
				codtipdoc=f.cmbcodtipdoc.value;
				codproben=f.txtcodigo.value;
				presupuesto=f.estatuspresupuesto.value;
				if((presupuesto=="3")||(presupuesto=="4")) // Ninguna ó Sin afectación
				{
					alert("El Documento Seleccionado no permite Causar");
				}
				else
				{			
					if((codtipdoc!='-')&&(codproben!='')&&(numdoc!=''))
					{
						totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
						if(totrowspg>1)
						{
							pagina="sigesp_cxp_pdt_amortizacion.php";
							window.open(pagina,"catalogo","menubar=no,toolbar=no,scrollbars=yes,width=650,height=325,resizable=no,location=no,dependent=yes");
						}
						else
						{
							alert("Debe seleccionar el compromiso");
						}

					}
					else
					{
						alert("Debe seleccionar el Tipo de Documento, Proveedor/Beneficiario y Escribir el Nùmero de Documento");
					}
				}
			}
			else
			{
				alert("El nro de Recepción de Documentos no ha sido validada por favor tipeelo de nuevo.");
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
		}
	}
	else
	{
		alert("La Recepión esta Aprobada no puede realizar ningún cambio.");
	}
}


function ue_catalogocreditos()
{
	f = document.formulario;
	numrecdoc=f.txtnumrecdoc.value;
	subtotal=ue_formato_calculo(f.txtsubtotal.value);
	contable=f.estatuscontable.value;
	presupuesto=f.estatuspresupuesto.value;
	comprobantes="";
	estaprord=f.estaprord.value;
	codproben=f.txtcodigo.value;
	tipocontribuyente=f.tipocontribuyente.value;
	estmodiva=f.estmodiva.value;
	causadoparcial=f.causadoparcial.value;
	totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
	f.totrowspg.value=totrowspg;
	liqimp = (document.getElementById("chkestliqimp").checked==true)?1:0;
	liqant = (document.getElementById("chkestliqant").checked==true)?1:0;
		
	contable=tipodocumento.substr(6,1);
	presupuesto=tipodocumento.substr(8,1);
	
	if (estaprord!='1') // No está Aprobada
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			if(tipocontribuyente!="F") // No es un Contribuyente formal
			{
				if ((contable=='1' && presupuesto=='2')||(causadoparcial=='1')||((estmodiva=='1')&&(contable=='1' && presupuesto=='1')||(presupuesto=='5')||(presupuesto=='6'))) // Compromete y causa  ó si se puede modificar el IVA
				{  // Numero que me indica si el Documento es de tipo Compromete y Causa o
				   // ha reprocesado algun documento Tipo Causa para darle acceso al catalogo de otros Creditos.
				    if((numrecdoc=="")||((parseFloat(subtotal)<=0)&&(liqimp==0&&liqant==0))||(codproben==""))					
					{
						alert("Debe Seleccionar un proveedor ó Beneficiario, escribir el Nùmero de Documento \n y el Monto del Subtotal Debe ser Mayor que Cero");
					}
					else
					{	
						tipodestino=f.cmbtipdes.value;
						if(tipodestino=="P")
						{
							codpro=f.txtcodigo.value;
							cedbene= "----------";
						}
						else
						{
							codpro="----------";
							cedbene=f.txtcodigo.value;
						}    
						codtipdoc=f.cmbcodtipdoc.value;
						procede=f.procede.value;
						estatus=f.txtestatus.value;
						for(i=1;i<totrowspg;i++)
						{
							documento=eval("f.txtspgnrocomp"+i+".value");
							procededoc=eval("f.txtspgprocededoc"+i+".value");
							if(comprobantes.length>0)
							{
								if(comprobantes.indexOf(documento+procededoc)==-1)
								{							
									comprobantes=comprobantes+"="+documento+procededoc;
								}
							}
							else
							{
								comprobantes=documento+procededoc;
							}
						}
						li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
						if(parseFloat(li_deducciones)>0)
						{
							alert("Ya agrego Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
						}
						else
						{
							if(presupuesto=="2"||presupuesto=="6")
							{
								pagina="sigesp_cxp_pdt_otroscreditos.php?numrecdoc="+numrecdoc+"&subtotal="+subtotal+"&procede="+procede+"";
							}
							else
							{
								if((estmodiva=='1')||(causadoparcial='1'))
								{
									pagina="sigesp_cxp_pdt_otroscreditosparcial.php?numrecdoc="+numrecdoc+"&subtotal="+subtotal;
									pagina=pagina+"&procede="+procede+"&comprobantes="+comprobantes;
								}
							}
							window.open(pagina,"Catalogo","menubar=no,toolbar=no,scrollbars=yes,width=700,height=300,resizable=yes,location=no");
						}
					}
				}
				else
				{
					alert("El Tipo de Documento, no admite Otros Créditos. ");
				}
			}
			else
			{
				alert("El contribuyente es formal no se le aplican Otros Créditos");
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
		}
	}
	else
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
	}
}	

function ue_catalogodeducciones()
{
	f=document.formulario;
	numrecdoc=f.txtnumrecdoc.value;
	subtotal=ue_formato_calculo(f.txtsubtotal.value);
	cargos=f.txtcargos.value;
	totalgeneral=f.txttotalgener.value;
	contable=f.estatuscontable.value;
	presupuesto=f.estatuspresupuesto.value;
	totrowspg=f.totrowspg.value;
	comprobantes="";
	estaprord=f.estaprord.value;
	codproben=f.txtcodigo.value;
	liqimp = (document.getElementById("chkestliqimp").checked==true)?1:0;
	liqant = (document.getElementById("chkestliqant").checked==true)?1:0;
	if (estaprord!='1') // No está Aprobada
	{
		if((numrecdoc=="")||((parseFloat(subtotal)<=0)&&(liqimp==0&&liqant==0))||(codproben==""))		
		{
			alert("Debe Seleccionar un proveedor ó Beneficiario, escribir el Nùmero de Documento \n y el Monto del Subtotal Debe ser Mayor que Cero");
		}
		else
		{	
			if(totalgeneral=="0,00"&&!liqimp&&!liqant)
			{
				alert("El monto de la Recepción debe ser Mayor a Cero.");
			}
			else
			{
				if (procede!='SNOCNO')
				{
					tipodestino=f.cmbtipdes.value;
					if(tipodestino=="P")
					{
						codpro=f.txtcodigo.value;
						cedbene= "----------";
					}
					else
					{
						codpro="----------";
						cedbene=f.txtcodigo.value;
					}    
					codtipdoc=f.cmbcodtipdoc.value;
					scgnumcomp=f.txtscgnrocomp1.value;
					procede=f.procede.value;
					estatus=f.txtestatus.value;
					for(i=1;i<totrowspg;i++)
					{
						documento=eval("f.txtspgnrocomp"+i+".value");
						if(comprobantes.length>0)
						{
							comprobantes=comprobantes+"-"+documento;
						}
						else
						{
							comprobantes=documento;
						}
					}
					if(comprobantes=='')
					{
						comprobantes=scgnumcomp;
					}
					pagina="sigesp_cxp_pdt_deducciones.php?numrecdoc="+numrecdoc+"&subtotal="+subtotal+"&procede="+procede+"&cargos="+cargos;
					window.open(pagina,"Catalogo","menubar=no,toolbar=no,scrollbars=yes,width=640,height=300,resizable=yes,location=no");
				}
				else
				{
					alert("La Nómina no puede ser objeto de Deducciones.");
				}
			}
		}
	}
	else
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
	}
}

function ue_delete_spg_cuenta(fila)
{
	f=document.formulario;
	estaprord=f.estaprord.value;
	totalcuentasspg=0;
	if(estaprord=="1")
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
	}
	else
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			li_cargos=ue_formato_calculo(f.txtcargos.value);
			li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
			if((parseFloat(li_cargos)>0)||(parseFloat(li_deducciones)>0))
			{
				alert("Ya agrego Cargos y/o Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
			}
			else
			{
				if(confirm("¿Desea eliminar el Registro actual?"))
				{
					parametros="";
					generarcontable=f.generarcontable.value;
					totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
					f.totrowspg.value=totrowspg;
					totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
					f.totrowscg.value=totrowscg;
					li_i=0;
					li_subtotal=0;
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas presupuestarias
					//---------------------------------------------------------------------------------
					for(j=1;(j<totrowspg);j++)
					{
						if(fila!=j)
						{
							li_i=li_i+1;
							cargo=eval("f.txtcargo"+j+".value");
							spgnrocomp=eval("f.txtspgnrocomp"+j+".value");
							programatica=eval("f.txtprogramatica"+j+".value");
							estcla=eval("f.txtestcla"+j+".value");
							spgcuenta=eval("f.txtspgcuenta"+j+".value");
							spgmonto=eval("f.txtspgmonto"+j+".value");
							codpro=eval("f.txtcodpro"+j+".value");
							original=eval("f.txtoriginal"+j+".value");
							compromiso=eval("f.txtcompromiso"+j+".value");
							spgsccuenta=eval("f.txtspgsccuenta"+j+".value");
							procede=eval("f.txtspgprocededoc"+j+".value");
							codfuefin=eval("f.txtcodfuefin"+j+".value");
							tipbieordcom=eval("f.txttipbieordcom"+j+".value");
							estint=eval("f.txtestint"+j+".value");
							cuentaint=eval("f.txtcuentaint"+j+".value");
							if(cargo=="0")
							{
								li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(spgmonto));
							}
							parametros=parametros+"&txtspgnrocomp"+li_i+"="+spgnrocomp+"&txtprogramatica"+li_i+"="+programatica+"&txtestcla"+li_i+"="+estcla+""+
									   "&txtspgcuenta"+li_i+"="+spgcuenta+"&txtspgmonto"+li_i+"="+spgmonto+""+
									   "&txtcodpro"+li_i+"="+codpro+"&txtcargo"+li_i+"="+cargo+""+ "&txtoriginal"+li_i+"="+original+
									   "&txtspgsccuenta"+li_i+"="+spgsccuenta+ "&txtspgprocededoc"+li_i+"="+procede+
									   "&txtcodfuefin"+li_i+"="+codfuefin+"&txttipbieordcom"+j+"="+tipbieordcom+"&txtcompromiso"+j+"="+compromiso+
								   	   "&txtestint"+j+"="+estint+"&txtcuentaint"+j+"="+cuentaint;
						}
					}
					totalcuentasspg=eval(li_i+"+1");
					parametros=parametros+"&totrowspg="+totalcuentasspg+"";
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas contables
					//---------------------------------------------------------------------------------
					li_i=0;
					for(j=1;(j<totrowscg);j++)
					{
						scgnrocomp=eval("f.txtscgnrocomp"+j+".value");
						scgcuenta=eval("f.txtscgcuenta"+j+".value");
						mondeb=eval("f.txtmondeb"+j+".value");
						monhab=eval("f.txtmonhab"+j+".value");
						debhab=eval("f.txtdebhab"+j+".value");
						estatus=eval("f.txtestatus"+j+".value");
						scgprocededoc=eval("f.txtscgprocededoc"+j+".value");
						if(estatus=="M")
						{
							if(debhab=="D")
							{
								li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(mondeb));
							}
							else
							{
								li_subtotal=eval(li_subtotal+"-"+ue_formato_calculo(monhab));
							}
							li_i=li_i+1;
							parametros=parametros+"&txtscgnrocomp"+li_i+"="+scgnrocomp+"&txtscgcuenta"+li_i+"="+scgcuenta+""+
												  "&txtmondeb"+li_i+"="+mondeb+"&txtmonhab"+li_i+"="+monhab+"&txtdebhab"+li_i+"="+debhab+
												  "&txtestatus"+li_i+"="+estatus+"&txtscgprocededoc"+li_i+"="+scgprocededoc;
						}
					}
					totrowscg=li_i+1;
					parametros=parametros+"&totrowscg="+totrowscg+"";
					presupuestario=f.estatuspresupuesto.value;
					contable=f.estatuscontable.value;
					sccuentaprov=f.codigocuenta.value;
					li_cargos=ue_formato_calculo(f.txtcargos.value);
					li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
					li_total=eval(li_subtotal+"+"+li_cargos);
					li_totalgeneral=eval(li_total+"-"+li_deducciones);
					ls_numrecdoc=f.txtnumrecdoc.value;
					parametros=parametros+"&estcontable="+contable+"&estpresupuestario="+presupuestario+"&sccuentaprov="+sccuentaprov;
					parametros=parametros+"&subtotal="+li_subtotal+"&cargos="+li_cargos+"&total="+li_total+"&numrecdoc="+ls_numrecdoc;
					parametros=parametros+"&deducciones="+li_deducciones+"&totgeneral="+li_totalgeneral+"&generarcontable="+generarcontable;
					if(parametros!="")
					{
						// Div donde se van a cargar los resultados
						divgrid = document.getElementById("cuentas");
						// Instancia del Objeto AJAX
						ajax=objetoAjax();
						// Pagina donde están los métodos para buscar y pintar los resultados
						ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
						ajax.onreadystatechange=function(){
							if(ajax.readyState==1)
							{
								//divgrid.innerHTML = "";//<-- aqui iria la precarga en AJAX 
							}
							else
							{
								if(ajax.readyState==4)
								{
									if(ajax.status==200)
									{//mostramos los datos dentro del contenedor
										divgrid.innerHTML = ajax.responseText
									}
									else
									{
										if(ajax.status==404)
										{
											divgrid.innerHTML = "La página no existe";
										}
										else
										{//mostramos el posible error     
											divgrid.innerHTML = "Error:".ajax.status;
										}
									}
									
								}
							}
						}	
						ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
						// Enviar todos los campos a la pagina para que haga el procesamiento
						ajax.send("proceso=COMPROMETECAUSA"+parametros);						
						if(document.getElementById("totrowspg")!=null){f.totrowspg.value=totalcuentasspg;}
					}
				}
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
		}
	}
}

function ue_delete_scg_cuenta(fila)
{
	f=document.formulario;
	window.validador=true;
	estaprord=f.estaprord.value;
	presupuestario=f.estatuspresupuesto.value;
	causadoparcial=f.causadoparcial.value;
	contable=f.estatuscontable.value;
	totalcuentasspg=0;
	ls_proceso="";
	if(presupuestario=="1"||presupuestario=="5") // Causa
	{
		ls_proceso="CAUSA";
		if(causadoparcial=="1")
		{
			ls_proceso="CAUSAPARCIAL";
		}
	}
	if(presupuestario=="2"||presupuestario=="6") // Compromete y Causa
	{
		ls_proceso="COMPROMETECAUSA";
	}
	if((ls_proceso=="")&&(contable=="1"))// Contable
	{
		ls_proceso="CONTABLE";
	}
	if(estaprord=="1")
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
		window.validador=false;
	}
	else
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			li_cargos=ue_formato_calculo(f.txtcargos.value);
			if(presupuestario==1||presupuestario==5)
			{
				li_cargos=0;
			}
			li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
			if((parseFloat(li_cargos)>0)||(parseFloat(li_deducciones)>0))
			{
				alert("Ya agrego Cargos y/o Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
				window.validador=false;
			}
			else
			{
				confirmar=true;
				if(window.NoPreguntar==0){confirmar = confirm("¿Desea eliminar el Registro actual?");}
				if(confirmar)
				{
					parametros="";
					generarcontable=f.generarcontable.value;
					totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
					f.totrowspg.value=totrowspg;
					totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
					f.totrowscg.value=totrowscg;
					li_i=0;
					li_subtotal=0;
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas presupuestarias
					//---------------------------------------------------------------------------------
					for(li_i=1;(li_i<totrowspg);li_i++)
					{
						cargo=eval("f.txtcargo"+li_i+".value");
						spgnrocomp=eval("f.txtspgnrocomp"+li_i+".value");
						programatica=eval("f.txtprogramatica"+li_i+".value");
						estcla=eval("f.txtestcla"+li_i+".value");
						spgcuenta=eval("f.txtspgcuenta"+li_i+".value");
						spgmonto=eval("f.txtspgmonto"+li_i+".value");
						codpro=eval("f.txtcodpro"+li_i+".value");
						original=eval("f.txtoriginal"+li_i+".value");
						compromiso=eval("f.txtcompromiso"+li_i+".value");
						spgsccuenta=eval("f.txtspgsccuenta"+li_i+".value");
						procede=eval("f.txtspgprocededoc"+li_i+".value");
						codfuefin=eval("f.txtcodfuefin"+li_i+".value");
						tipbieordcom=eval("f.txttipbieordcom"+li_i+".value");
						estint=eval("f.txtestint"+li_i+".value");
						cuentaint=eval("f.txtcuentaint"+li_i+".value");
						if(cargo=="0")
						{
							li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(spgmonto));
						}
						parametros=parametros+"&txtspgnrocomp"+li_i+"="+spgnrocomp+"&txtprogramatica"+li_i+"="+programatica+"&txtestcla"+li_i+"="+estcla+""+
								   "&txtspgcuenta"+li_i+"="+spgcuenta+"&txtspgmonto"+li_i+"="+spgmonto+""+
								   "&txtcodpro"+li_i+"="+codpro+"&txtcargo"+li_i+"="+cargo+""+ "&txtoriginal"+li_i+"="+original+
								   "&txtspgsccuenta"+li_i+"="+spgsccuenta+ "&txtspgprocededoc"+li_i+"="+procede+
								   "&txtcodfuefin"+li_i+"="+codfuefin+"&txttipbieordcom"+li_i+"="+tipbieordcom+"&txtcompromiso"+li_i+"="+compromiso+
								   "&txtestint"+li_i+"="+estint+"&txtcuentaint"+li_i+"="+cuentaint;
					}
					parametros=parametros+"&totrowspg="+totrowspg+"";
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas contables
					//---------------------------------------------------------------------------------
					li_i=0;
					for(j=1;(j<totrowscg);j++)
					{
						if(fila!=j)
						{
							scgnrocomp=eval("f.txtscgnrocomp"+j+".value");
							scgcuenta=eval("f.txtscgcuenta"+j+".value");
							mondeb=eval("f.txtmondeb"+j+".value");
							monhab=eval("f.txtmonhab"+j+".value");
							debhab=eval("f.txtdebhab"+j+".value");
							estatus=eval("f.txtestatus"+j+".value");
							scgprocededoc=eval("f.txtscgprocededoc"+j+".value");
							if(estatus=="M")
							{
								if(debhab=="D")
								{
									li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(mondeb));
								}
								else
								{
									if(ls_proceso!="CONTABLE")
									{
										li_subtotal=eval(li_subtotal+"-"+ue_formato_calculo(monhab));
									}
								}
								li_i=li_i+1;
								parametros=parametros+"&txtscgnrocomp"+li_i+"="+scgnrocomp+"&txtscgcuenta"+li_i+"="+scgcuenta+""+
													  "&txtmondeb"+li_i+"="+mondeb+"&txtmonhab"+li_i+"="+monhab+"&txtdebhab"+li_i+"="+debhab+
													  "&txtestatus"+li_i+"="+estatus+"&txtscgprocededoc"+li_i+"="+scgprocededoc;
							}
						}
					}
					totrowscg=li_i+1;
					parametros=parametros+"&totrowscg="+totrowscg+"";
					sccuentaprov=f.codigocuenta.value;
					li_cargos=ue_formato_calculo(f.txtcargos.value);
					li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
					li_total=eval(li_subtotal+"+"+li_cargos);
					li_totalgeneral=eval(li_total+"-"+li_deducciones);
					ls_numrecdoc=f.txtnumrecdoc.value;
					parametros=parametros+"&estcontable="+contable+"&estpresupuestario="+presupuestario+"&sccuentaprov="+sccuentaprov;
					parametros=parametros+"&subtotal="+li_subtotal+"&cargos="+li_cargos+"&total="+li_total+"&numrecdoc="+ls_numrecdoc;
					parametros=parametros+"&deducciones="+li_deducciones+"&totgeneral="+li_totalgeneral+"&generarcontable="+generarcontable;
					if(parametros!="")
					{
						// Div donde se van a cargar los resultados
						divgrid = document.getElementById("cuentas");
						// Instancia del Objeto AJAX
						ajax=objetoAjax();
						// Pagina donde están los métodos para buscar y pintar los resultados
						ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
						ajax.onreadystatechange=function(){
							if(ajax.readyState==1)
							{
								//divgrid.innerHTML = "";//<-- aqui iria la precarga en AJAX 
							}
							else
							{
								if(ajax.readyState==4)
								{
									if(ajax.status==200)
									{//mostramos los datos dentro del contenedor
										divgrid.innerHTML = ajax.responseText
									}
									else
									{
										if(ajax.status==404)
										{
											divgrid.innerHTML = "La página no existe";
										}
										else
										{//mostramos el posible error     
											divgrid.innerHTML = "Error:".ajax.status;
										}
									}
									
								}
							}
						}	
						ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
						// Enviar todos los campos a la pagina para que haga el procesamiento
						ajax.send("proceso="+ls_proceso+""+parametros);
						if(document.getElementById("totrowspg")!=null){f.totrowspg.value=totalcuentasspg;}
						
					}
				}
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
			window.validador=false;
		}
	}
}

function ue_delete_compromiso(fila)
{
	f=document.formulario;
	estaprord=f.estaprord.value;
	totalcuentasspg=0;
	if(estaprord=="1")
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
	}
	else
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
			if(parseFloat(li_deducciones)>0)
			{
				alert("Ya agrego Deducciones debe proceder a eliminar los movimientos para poder agregar otras cuentas.");
			}
			else
			{
				if(confirm("¿Desea eliminar el Registro actual?"))
				{
					parametros="";
					generarcontable=f.generarcontable.value;
					totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
					f.totrowspg.value=totrowspg;
					totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
					f.totrowscg.value=totrowspg;
					li_i=0;
					li_subtotal=0;
					li_cargos=0;
					comprobante=eval("f.txtspgnrocomp"+fila+".value")
					procededoc=eval("f.txtspgprocededoc"+fila+".value")
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas presupuestarias
					//---------------------------------------------------------------------------------
					for(j=1;(j<totrowspg);j++)
					{
						spgnrocomp=eval("f.txtspgnrocomp"+j+".value");
						procede=eval("f.txtspgprocededoc"+j+".value");
						if((spgnrocomp!=comprobante)||(procede!=procededoc))
						{
							li_i=li_i+1;
							cargo=eval("f.txtcargo"+j+".value");
							programatica=eval("f.txtprogramatica"+j+".value");
							estcla=eval("f.txtestcla"+j+".value");
							spgcuenta=eval("f.txtspgcuenta"+j+".value");
							spgmonto=eval("f.txtspgmonto"+j+".value");
							codpro=eval("f.txtcodpro"+j+".value");
							original=eval("f.txtoriginal"+j+".value");
							compromiso=eval("f.txtcompromiso"+j+".value");
							spgsccuenta=eval("f.txtspgsccuenta"+j+".value");
							codfuefin=eval("f.txtcodfuefin"+j+".value");
							tipbieordcom=eval("f.txttipbieordcom"+j+".value");
							estint=eval("f.txtestint"+j+".value");
							cuentaint=eval("f.txtcuentaint"+j+".value");
							if(cargo=="0")
							{
								li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(spgmonto));
							}
							else
							{
								li_cargos=eval(li_cargos+"+"+ue_formato_calculo(spgmonto));
							}
							parametros=parametros+"&txtspgnrocomp"+li_i+"="+spgnrocomp+"&txtprogramatica"+li_i+"="+programatica+"&txtestcla"+li_i+"="+estcla+""+
									   "&txtspgcuenta"+li_i+"="+spgcuenta+"&txtspgmonto"+li_i+"="+spgmonto+""+
									   "&txtcodpro"+li_i+"="+codpro+"&txtcargo"+li_i+"="+cargo+""+ "&txtoriginal"+li_i+"="+original+
									   "&txtspgsccuenta"+li_i+"="+spgsccuenta+ "&txtspgprocededoc"+li_i+"="+procede+
									   "&txtcodfuefin"+li_i+"="+codfuefin+"&txttipbieordcom"+li_i+"="+tipbieordcom+"&txtcompromiso"+li_i+"="+compromiso+
								   	   "&txtestint"+li_i+"="+estint+"&txtcuentaint"+li_i+"="+cuentaint;
						}
					}
					totalcuentasspg=eval(li_i+"+1");
					parametros=parametros+"&totrowspg="+totalcuentasspg+"";
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas contables
					//---------------------------------------------------------------------------------
					li_i=0;
					for(j=1;(j<totrowscg);j++)
					{
						scgnrocomp=eval("f.txtscgnrocomp"+j+".value");
						scgcuenta=eval("f.txtscgcuenta"+j+".value");
						mondeb=eval("f.txtmondeb"+j+".value");
						monhab=eval("f.txtmonhab"+j+".value");
						debhab=eval("f.txtdebhab"+j+".value");
						estatus=eval("f.txtestatus"+j+".value");
						scgprocededoc=eval("f.txtscgprocededoc"+j+".value");
						if(estatus=="M")
						{
							if(debhab=="D")
							{
								li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(mondeb));
							}
							else
							{
								li_subtotal=eval(li_subtotal+"-"+ue_formato_calculo(monhab));
							}
							li_i=li_i+1;
							parametros=parametros+"&txtscgnrocomp"+li_i+"="+scgnrocomp+"&txtscgcuenta"+li_i+"="+scgcuenta+""+
												  "&txtmondeb"+li_i+"="+mondeb+"&txtmonhab"+li_i+"="+monhab+"&txtdebhab"+li_i+"="+debhab+
												  "&txtestatus"+li_i+"="+estatus+"&txtscgprocededoc"+li_i+"="+scgprocededoc;
						}
					}
					totrowscg=li_i+1;
					parametros=parametros+"&totrowscg="+totrowscg+"";
					presupuestario=f.estatuspresupuesto.value;
					contable=f.estatuscontable.value;
					sccuentaprov=f.codigocuenta.value;
					li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
					li_total=eval(li_subtotal+"+"+li_cargos);
					li_totalgeneral=eval(li_total+"-"+li_deducciones);
					ls_numrecdoc=f.txtnumrecdoc.value;
					parametros=parametros+"&eliminarcargo=1&compromiso="+comprobante+"&procededoc="+procededoc;
					parametros=parametros+"&estcontable="+contable+"&estpresupuestario="+presupuestario+"&sccuentaprov="+sccuentaprov;
					parametros=parametros+"&subtotal="+li_subtotal+"&cargos="+li_cargos+"&total="+li_total+"&numrecdoc="+ls_numrecdoc;
					parametros=parametros+"&deducciones="+li_deducciones+"&totgeneral="+li_totalgeneral+"&generarcontable="+generarcontable;
					if(parametros!="")
					{
						// Div donde se van a cargar los resultados
						divgrid = document.getElementById("cuentas");
						// Instancia del Objeto AJAX
						ajax=objetoAjax();
						// Pagina donde están los métodos para buscar y pintar los resultados
						ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
						ajax.onreadystatechange=function(){
							if(ajax.readyState==1)
							{
								//divgrid.innerHTML = "";//<-- aqui iria la precarga en AJAX 
							}
							else
							{
								if(ajax.readyState==4)
								{
									if(ajax.status==200)
									{//mostramos los datos dentro del contenedor
										divgrid.innerHTML = ajax.responseText
									}
									else
									{
										if(ajax.status==404)
										{
											divgrid.innerHTML = "La página no existe";
										}
										else
										{//mostramos el posible error     
											divgrid.innerHTML = "Error:".ajax.status;
										}
									}
									
								}
							}
						}	
						ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   						ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
						// Enviar todos los campos a la pagina para que haga el procesamiento
						ajax.send("proceso=CAUSA"+parametros);						
						if(document.getElementById("totrowspg")!=null){f.totrowspg.value=totalcuentasspg;}
					}
				}
			}
		}
		else
		{
			alert("La Recepción de Documentos, Fué generada desde otro módulo no se puede modificar");
		}
	}
}

var redondeardosdec = function(numero)
{
	var original=parseFloat(numero);
	var result=Math.round(original*100)/100 ;
	return result;
}

function ue_procesar_comprobante(fila)
{
	f=document.formulario;
	estaprord=f.estaprord.value;
	presupuestario=f.estatuspresupuesto.value;
	contable=f.estatuscontable.value;
	lb_valido=true;
	if(estaprord=="1")
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
	}
	else
	{
		li_cargos=ue_formato_calculo(f.txtcargos.value);
		if(presupuestario==1||presupuestario==5)
		{
			li_cargos=0;
		}
		li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
		if((parseFloat(li_cargos)>0)||(parseFloat(li_deducciones)>0))
		{
			alert("Ya agrego Cargos y/o Deducciones debe proceder a eliminar los movimientos para poder modificar los montos.");
		}
		else
		{
			procede=f.procede.value;
			if(procede=="CXPRCD")
			{		
				compromiso=eval("f.txtspgnrocomp"+fila+".value");
				procededoc=eval("f.txtspgprocededoc"+fila+".value");
				parametros="";
				generarcontable=f.generarcontable.value;
				totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
				f.totrowspg.value=totrowspg;
				totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
				f.totrowscg.value=totrowscg;
				f.causadoparcial.value="1";
				li_i=0;
				li_cargos=0;
				li_subtotal=0;
				//---------------------------------------------------------------------------------
				// recorremos grid de las cuentas presupuestarias
				//---------------------------------------------------------------------------------
				for(j=1;(j<totrowspg);j++)
				{
					cargo=eval("f.txtcargo"+j+".value");
					spgnrocomp=eval("f.txtspgnrocomp"+j+".value");
					programatica=eval("f.txtprogramatica"+j+".value");
					estcla=eval("f.txtestcla"+j+".value");
					spgcuenta=eval("f.txtspgcuenta"+j+".value");
					spgmonto=eval("f.txtspgmonto"+j+".value");
					compromiso=eval("f.txtcompromiso"+j+".value");
					codpro=eval("f.txtcodpro"+j+".value");
					original=eval("f.txtoriginal"+j+".value");
					spgsccuenta=eval("f.txtspgsccuenta"+j+".value");
					procede=eval("f.txtspgprocededoc"+j+".value");
					codfuefin=eval("f.txtcodfuefin"+j+".value");
					//alert(parseFloat(ue_formato_calculo(spgmonto)) + "\n" + parseFloat(original));
					if(parseFloat(ue_formato_calculo(spgmonto))<=parseFloat(original))
					{
						
						jspgmonto = redondeardosdec(parseFloat(ue_formato_calculo(spgmonto)));
						jcompromiso = redondeardosdec(parseFloat(compromiso));
						//alert(jspgmonto + "\n" + jcompromiso);
						if(jspgmonto<=jcompromiso)
						{
							if((cargo=="0")||(((compromiso==spgnrocomp)&&(procededoc==procede))==false))
							{
								li_i=li_i+1;
								if(cargo=="0")
								{
									li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(spgmonto));
								}
								else
								{
									li_cargos=eval(li_cargos+"+"+ue_formato_calculo(spgmonto));	
								}
								parametros=parametros+"&txtspgnrocomp"+li_i+"="+spgnrocomp+"&txtprogramatica"+li_i+"="+programatica+"&txtestcla"+li_i+"="+estcla+""+
										   "&txtspgcuenta"+li_i+"="+spgcuenta+"&txtspgmonto"+li_i+"="+spgmonto+""+
										   "&txtcodpro"+li_i+"="+codpro+"&txtcargo"+li_i+"="+cargo+""+ "&txtoriginal"+li_i+"="+original+
										   "&txtspgsccuenta"+li_i+"="+spgsccuenta+ "&txtspgprocededoc"+li_i+"="+procede+ "&txtcompromiso"+li_i+"="+compromiso+
										   "&txtcodfuefin"+li_i+"="+codfuefin;
							}
						}
						else
						{
							alert("El monto Causado de la cuenta "+spgcuenta+" es mayor que el del Compromiso");
							alert("Monto: " + spgmonto + "\n" + "Compromiso: " + compromiso);
							lb_valido=false;
							j=totrowspg+1;
						}
					}
					else
					{
						alert("El monto Causado de la cuenta "+spgcuenta+" es mayor que el del Compromiso");
						lb_valido=false;
						j=totrowspg+1;
					}
				}
				li_i=li_i+1;
				parametros=parametros+"&totrowspg="+li_i+"";
				//---------------------------------------------------------------------------------
				// recorremos grid de las cuentas contables
				//---------------------------------------------------------------------------------
				li_i=0;
				for(j=1;(j<totrowscg);j++)
				{
					scgnrocomp=eval("f.txtscgnrocomp"+j+".value");
					scgcuenta=eval("f.txtscgcuenta"+j+".value");
					mondeb=eval("f.txtmondeb"+j+".value");
					monhab=eval("f.txtmonhab"+j+".value");
					debhab=eval("f.txtdebhab"+j+".value");
					estatus=eval("f.txtestatus"+j+".value");
					scgprocededoc=eval("f.txtscgprocededoc"+j+".value");
					
					if(estatus=="M")
					{
						if(debhab=="D")
						{
							li_subtotal=eval(li_subtotal+"+"+ue_formato_calculo(mondeb));
						}
						else
						{
							li_subtotal=eval(li_subtotal+"-"+ue_formato_calculo(monhab));
						}
						li_i=li_i+1;
						parametros=parametros+"&txtscgnrocomp"+li_i+"="+scgnrocomp+"&txtscgcuenta"+li_i+"="+scgcuenta+""+
											  "&txtmondeb"+li_i+"="+mondeb+"&txtmonhab"+li_i+"="+monhab+"&txtdebhab"+li_i+"="+debhab+
											  "&txtestatus"+li_i+"="+estatus+"&txtscgprocededoc"+li_i+"="+scgprocededoc;
					}
				}
				totrowscg=li_i+1;
				parametros=parametros+"&totrowscg="+totrowscg+"";
				sccuentaprov=f.codigocuenta.value;
				li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
				li_total=eval(li_subtotal+"+"+li_cargos);
				li_totalgeneral=eval(li_total+"-"+li_deducciones);
				ls_numrecdoc=f.txtnumrecdoc.value;
				parametros=parametros+"&compromiso="+compromiso+"&procededoc="+procededoc+"&eliminarcargo=1";
				parametros=parametros+"&estcontable="+contable+"&estpresupuestario="+presupuestario+"&sccuentaprov="+sccuentaprov;
				parametros=parametros+"&subtotal="+li_subtotal+"&cargos="+li_cargos+"&total="+li_total+"&numrecdoc="+ls_numrecdoc;
				parametros=parametros+"&deducciones="+li_deducciones+"&totgeneral="+li_totalgeneral+"&generarcontable="+generarcontable;
				if((parametros!="")&&(lb_valido))
				{
					// Div donde se van a cargar los resultados
					divgrid = document.getElementById("cuentas");
					// Instancia del Objeto AJAX
					ajax=objetoAjax();
					// Pagina donde están los métodos para buscar y pintar los resultados
					ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
					ajax.onreadystatechange=function(){
						if(ajax.readyState==1)
						{
							//divgrid.innerHTML = "";//<-- aqui iria la precarga en AJAX 
						}
						else
						{
							if(ajax.readyState==4)
							{
								if(ajax.status==200)
								{//mostramos los datos dentro del contenedor
									divgrid.innerHTML = ajax.responseText
								}
								else
								{
									if(ajax.status==404)
									{
										divgrid.innerHTML = "La página no existe";
									}
									else
									{//mostramos el posible error     
										divgrid.innerHTML = "Error:".ajax.status;
									}
								}
								
							}
						}
					}	
					ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
					// Enviar todos los campos a la pagina para que haga el procesamiento
					ajax.send("proceso=CAUSAPARCIAL"+parametros);
				}
			}
		}
	}
}

function ue_cerrar_asiento()
{
	f=document.formulario;
	estaprord=f.estaprord.value;
	lb_valido=true;
	if(estaprord=="1")
	{
		alert("La Recepción de Documentos, no se puede modificar ha sido Aprobada.");
	}
	else
	{
		procede=f.procede.value;
		if(procede=="CXPRCD")
		{		
			//resp = ObjForm.ValidarTipoLiquidacion();
			//if(!resp){return;}
			validarcuenta=f.codigocuenta.value;
			if(validarcuenta!="")
			{
				totrowspg=ue_calcular_total_fila_local("txtspgnrocomp");
				f.totrowspg.value=totrowspg;
				totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
				f.totrowscg.value=totrowscg;
				if((totrowspg>1)||(totrowscg>1))
				{
					//---------------------------------------------------------------------------------
					// Cargar las Cuentas del opener y el seleccionado
					//---------------------------------------------------------------------------------
					parametros="";
					for(j=1;(j<totrowspg);j++)
					{
						spgnrocomp=eval("f.txtspgnrocomp"+j+".value");
						programatica=eval("f.txtprogramatica"+j+".value");
						estcla=eval("f.txtestcla"+j+".value");
						spgcuenta=eval("f.txtspgcuenta"+j+".value");
						spgmonto=eval("f.txtspgmonto"+j+".value");
						codpro=eval("f.txtcodpro"+j+".value");
						cargo=eval("f.txtcargo"+j+".value");
						original=eval("f.txtoriginal"+j+".value");
						compromiso=eval("f.txtcompromiso"+j+".value");
						procededoc=eval("f.txtspgprocededoc"+j+".value");
						spgsccuenta=eval("f.txtspgsccuenta"+j+".value");
						codfuefin=eval("f.txtcodfuefin"+j+".value");
						tipbieordcom=eval("f.txttipbieordcom"+j+".value");
						estint=eval("f.txtestint"+j+".value");
						cuentaint=eval("f.txtcuentaint"+j+".value");
						parametros=parametros+"&txtspgnrocomp"+j+"="+spgnrocomp+"&txtprogramatica"+j+"="+programatica+"&txtestcla"+j+"="+estcla+" "+
								   "&txtspgcuenta"+j+"="+spgcuenta+"&txtspgmonto"+j+"="+spgmonto+""+
								   "&txtcodpro"+j+"="+codpro+"&txtcargo"+j+"="+cargo+"&txtoriginal"+j+"="+original+"&txtcompromiso"+j+"="+compromiso+
								   "&txtspgsccuenta"+j+"="+spgsccuenta+"&txtspgprocededoc"+j+"="+procededoc+
								   "&txtcodfuefin"+j+"="+codfuefin+"&txttipbieordcom"+j+"="+tipbieordcom+
								   "&txtestint"+j+"="+estint+"&txtcuentaint"+j+"="+cuentaint;
					}
					parametros=parametros+"&totrowspg="+totrowspg+"";
					//---------------------------------------------------------------------------------
					// recorremos grid de las cuentas contables
					//---------------------------------------------------------------------------------
					li_i=0;
					for(j=1;(j<totrowscg);j++)
					{
						scgnrocomp=eval("f.txtscgnrocomp"+j+".value");
						scgcuenta=eval("f.txtscgcuenta"+j+".value");
						mondeb=eval("f.txtmondeb"+j+".value");
						monhab=eval("f.txtmonhab"+j+".value");
						debhab=eval("f.txtdebhab"+j+".value");
						estatus=eval("f.txtestatus"+j+".value");
						scgprocededoc=eval("f.txtscgprocededoc"+j+".value");
						if(estatus=="M")
						{
							li_i=li_i+1;
							parametros=parametros+"&txtscgnrocomp"+li_i+"="+scgnrocomp+"&txtscgcuenta"+li_i+"="+scgcuenta+""+
												  "&txtmondeb"+li_i+"="+mondeb+"&txtmonhab"+li_i+"="+monhab+"&txtdebhab"+li_i+"="+debhab+
												  "&txtestatus"+li_i+"="+estatus+"&txtscgprocededoc"+li_i+"="+scgprocededoc;
						}
					}
					totrowscg=li_i+1;
					parametros=parametros+"&totrowscg="+totrowscg+"";
					presupuestario=f.estatuspresupuesto.value;
					causadoparcial=f.causadoparcial.value;
					contable=f.estatuscontable.value;
					ls_proceso="";
					if(presupuestario=="1"||presupuestario=="5") // Causa
					{
						ls_proceso="CAUSA";
						if(causadoparcial=="1")
						{
							ls_proceso="CAUSAPARCIAL";
						}
					}
					if(presupuestario=="2"||presupuestario=="6") // Compromete y Causa
					{
						ls_proceso="COMPROMETECAUSA";
					}
					if((ls_proceso=="")&&(contable=="1"))// Contable
					{
						ls_proceso="CONTABLE";
					}
					sccuentaprov=f.codigocuenta.value;
					li_subtotal=ue_formato_calculo(f.txtsubtotal.value);
					li_cargos=ue_formato_calculo(f.txtcargos.value);
					li_total=ue_formato_calculo(f.txttotal.value);
					li_deducciones=ue_formato_calculo(f.txtdeducciones.value);
					li_totalgeneral=ue_formato_calculo(f.txttotalgener.value);
					ls_numrecdoc=f.txtnumrecdoc.value;
					liqant = (document.getElementById("chkestliqant").checked==true)?1:0;
					parametros=parametros+"&estcontable="+contable+"&estpresupuestario="+presupuestario+"&sccuentaprov="+sccuentaprov;
					parametros=parametros+"&subtotal="+li_subtotal+"&cargos="+li_cargos+"&total="+li_total+"&numrecdoc="+ls_numrecdoc;
					parametros=parametros+"&deducciones="+li_deducciones+"&estliqant="+liqant+"&totgeneral="+li_totalgeneral+"&generarcontable=1";
					parametros=parametros+"&cerrarasiento=1";
					if(parametros!="")
					{
						// Div donde se van a cargar los resultados
						divgrid = document.getElementById("cuentas");
						// Instancia del Objeto AJAX
						ajax=objetoAjax();
						// Pagina donde están los métodos para buscar y pintar los resultados
						ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
						ajax.onreadystatechange=function(){
							if(ajax.readyState==1)
							{
								//divgrid.innerHTML = "";//<-- aqui iria la precarga en AJAX 
							}
							else
							{
								if(ajax.readyState==4)
								{
									if(ajax.status==200)
									{//mostramos los datos dentro del contenedor
										divgrid.innerHTML = ajax.responseText
										f.cerrarasiento.value="1";
									}
									else
									{
										if(ajax.status==404)
										{
											divgrid.innerHTML = "La página no existe";
										}
										else
										{//mostramos el posible error     
											divgrid.innerHTML = "Error:".ajax.status;
										}
									}
									
								}
							}
						}	
						ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
						// Enviar todos los campos a la pagina para que haga el procesamiento
						ajax.send("proceso="+ls_proceso+""+parametros);
					}
				}
				else
				{
					alert("Debe Tener Detalles Preuspuestarios ó contables para poder Cerrar el asiento.");
				}
			}
			else
			{
					alert("La cuenta del proveedor para cerrar el asiento esta mal configurada");
			}
		}
	}
}

function ue_reload()
{
	f=document.formulario;
	f.txtnumrecdoc.readOnly=true;
	f.cmbcodtipdoc.disabled=true;
	f.txtfecregdoc.disabled=true;
	f.txtfecemidoc.disabled=true;
	f.txtfecvendoc.disabled=true;
	f.cmbtipdes.disabled=true;
	f.cmbcodcla.disabled=true;
	presupuestario=f.estatuspresupuesto.value;
	causadoparcial=f.causadoparcial.value;
	contable=f.estatuscontable.value;
	ls_proceso="";
	if(presupuestario=="1"||presupuestario=="5") // Causa
	{
		ls_proceso="CAUSA";
		if(causadoparcial=="1")
		{
			ls_proceso="CAUSAPARCIAL";
		}
	}
	if(presupuestario=="2"||presupuestario=="6") // Compromete y Causa
	{
		ls_proceso="COMPROMETECAUSA";
	}
	if((ls_proceso=="")&&(contable=="1")) // Contable
	{
		ls_proceso="CONTABLE";
	}
	parametros=f.parametros.value;
	if(parametros!="")
	{
		// Div donde se van a cargar los resultados
		divgrid = document.getElementById("cuentas");
		// Instancia del Objeto AJAX
		ajax=objetoAjax();
		// Pagina donde están los métodos para buscar y pintar los resultados
		ajax.open("POST","class_folder/sigesp_cxp_c_recepcion_ajax.php",true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==1)
			{
				//divgrid.innerHTML = "";//<-- aqui iria la precarga en AJAX 
			}
			else
			{
				if(ajax.readyState==4)
				{
					if(ajax.status==200)
					{//mostramos los datos dentro del contenedor
						divgrid.innerHTML = ajax.responseText
						BuscaDescAnticipo('verificar_desc_anticipo');
					}
					else
					{
						if(ajax.status==404)
						{
							divgrid.innerHTML = "La página no existe";
						}
						else
						{//mostramos el posible error     
							divgrid.innerHTML = "Error:".ajax.status;
						}
					}
					
				}
			}
		}	
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
   ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		// Enviar todos los campos a la pagina para que haga el procesamiento
		ajax.send("proceso="+ls_proceso+""+parametros);
	}
}



</script>
<script language="javascript" src="../shared/js/js_intra/datepickercontrol.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/validaciones.js"></script>
<script language="javascript">
ruta = "../";
function envia_datos(criterio){

		f=document.formulario;
		
		if(document.getElementById("chkanticipo").checked==false&&EsContable()){
		        LimpiarAnticipo();    			
				return;
		}
		
		if(EsPresup()&&document.getElementById("chkanticipo").checked==true){
		        document.getElementById("chkanticipo").checked==false;
				LimpiarAnticipo();
		}
		
		HablitarAnticipo()
		
		if(EsPresup()){
		        LimpiarAnticipo();
		}
		
		jtipproben = f.cmbtipdes.value;
		jcodproben = f.txtcodigo.value;
		
		if(jtipproben==''){alert("Debe se seleccionar un Proveedor/Beneficiario !"); document.getElementById("chkanticipo").checked=false; return;}
		if(jcodproben==''){alert("Debe se seleccionar un Proveedor/Beneficiario !"); document.getElementById("chkanticipo").checked=false; return;}
		
		if(jtipproben=='P'){
			jcod_pro=jcodproben;
			jced_bene='----------';
		}
		else{
			jced_bene=jcodproben;
			jcod_pro='----------';
		}
		
		datos = "criterio=" + criterio +
				"&tipproben=" + jtipproben + 
				"&cod_pro=" + jcod_pro + 	
				"&ced_bene=" + jced_bene;	
		//alert(datos);
		enviar_ajax(datos,'sigesp_cxp_p_recepcioncontable_ajax.php','resultados','POST','',ruta);	

}

function LimpiarAnticipo(){
				
		if(document.getElementById("chkanticipo").checked==true){					
			return;
		}	
		
		document.getElementById("txtnroanticipo").value="";
		document.getElementById("txtnrocontrato").value="";
		document.getElementById("txtnumrecdoc").readOnly=false;
		document.getElementById("txtnumref").readOnly=false;
		document.getElementById("txtnumrecdoc").value="";
		document.getElementById("txtnumref").value="";	
			
		
}

function HablitarAnticipo(){
				
		if(EsContable()){
			document.getElementById("chkanticipo").disabled=false;
			document.getElementById("txtnroanticipo").disabled=false;
			document.getElementById("txtnrocontrato").disabled=false;
			if(document.getElementById("chkanticipo").checked==true){
				document.getElementById("txtnumrecdoc").readOnly=true;
				document.getElementById("txtnumref").readOnly=true;
			}				
			return;
		}
		
		document.getElementById("chkanticipo").disabled=true;
		document.getElementById("txtnroanticipo").disabled=true;
		document.getElementById("txtnrocontrato").disabled=true;		
		document.getElementById("txtnroanticipo").value="";
		document.getElementById("txtnrocontrato").value="";
		document.getElementById("chkanticipo").checked=false;
		document.getElementById("txtnumrecdoc").readOnly=false;
		document.getElementById("txtnumref").readOnly=false;
		document.getElementById("txtnumrecdoc").value="";
		document.getElementById("txtnumref").value="";	
			
		
}

function ValidarAnticipo(){		
		
		if(EsContable()){
			envia_datos('generar_numero');
		}
		
		if(EsPresup()){
			envia_datos('verificar_anticipo');
		}
		
}

function EsContable(){

	f=document.formulario;
	tipodocumento = f.cmbcodtipdoc.value
	tipo=tipodocumento.split("-");
	contable = (tipo[2]=='3'||tipo[2]=='4')?1:0;
	
	return contable;
}

function EsPresup(){

	f=document.formulario;
	tipodocumento = f.cmbcodtipdoc.value
	tipo=tipodocumento.split("-");
	presup = (tipo[2]=='1'||tipo[2]=='2'||tipo[2]=='5'||tipo[2]=='6')?1:0;
	
	return presup;
}

function funcion_respuesta(x){
		f=document.form1;
		switch(x){
			
			case 'cargar_nro':
				document.getElementById("txtnroanticipo").value = document.getElementById("hnroanticipo").value;
				document.getElementById("txtnumrecdoc").value = document.getElementById("hnrorecepanticip").value;
				document.getElementById("txtnumref").value = document.getElementById("hnronumrefanticip").value;
				document.getElementById("txtnumrecdoc").readOnly=true;
				document.getElementById("txtnumref").readOnly=true;											
			break;
			
			case 'mostrar_anticipos':
				DatePickerControl.relocateButtons();
				DatePickerControl.init();									
			break;
			
			
		}
	
}

function aceptar_anticipo(nro,nroanticipo,ced_bene,cod_pro,tipproben,numrecdoc,sc_cuenta,montoant,nrocontrato,sc_cuenta,fecemiant){

	f=document.formulario;
	
	alert('N° Recepción: '+numrecdoc + "\n" + 'Fecha: '+fecemiant + "\n" + 'Monto: '+montoant + "\n" + 'Cuenta: '+sc_cuenta);
	
	return;
}

function RecojerAnticiposTildados()
{
		
	f=document.formulario;
	
	datostild = new Array();
	montotant = 0;
		
	if(document.getElementById("chkant")==null){return;}
	
	tildados = '';
	if(!f.chkant.length){			
		return f.chkant.value;
	}
	for (var i=0; i < f.chkant.length; i++)
	   {
		   if (f.chkant[i].checked)
			  {
				if(tildados!=''){tildados += ',' + f.chkant[i].value;}
				else{tildados=f.chkant[i].value;}
				
				DatoChk = f.chkant[i].value;
				DatosAnt=DatoChk.split("|");
				subtotpen = parseFloat(DatosAnt[2])- parseFloat(DatosAnt[3]);
				montotant = montotant + parseFloat(subtotpen);
				ScgCuenta = DatosAnt[4];
			  }
	   }
	  
	 datostild['montotant'] = montotant;
	 datostild['sc_cuenta'] = ScgCuenta;
	 datostild['tildados'] = tildados;
	 
	 return datostild;
		   
}

function DesactAnticipos(nro)
{
		
	f=document.formulario;
	
	if(document.getElementById("chkant")==null){return;}	
	
	if(!f.chkant.length){			
		return;
	}
	for (var i=0; i < f.chkant.length; i++)
	   {
		   if (f.chkant[i].value!=nro)
			  {
				f.chkant[i].checked = false;
				f.chkant[i].disabled = true;
			  }
	   }
	
	 return;
		   
}

function ActivarFilasAnticipos()
{
		
	f=document.formulario;
	
	if(document.getElementById("chkant")==null){return;}	
	
	if(!f.chkant.length){			
		return;
	}
	for (var i=0; i < f.chkant.length; i++)
    { 
		f.chkant[i].checked = false;
		f.chkant[i].disabled = false;
    }
	
	return;
		   
}

function EliminarAnticipo()
{
		
	f=document.formulario;
	
	if(document.getElementById("chkant")==null){return;}	
	
	if(document.getElementById("hcuenta_anticipo").value==""){
		alert("No se encontro la cuenta contable del anticipo !");
		//return;
	}
	if(document.getElementById("hcuenta_anticipo").value!=""){
		fila = ExtraerFilaCuentaSCG(document.getElementById("hcuenta_anticipo").value);
		if(fila!=false){window.NoPreguntar=1; ue_delete_scg_cuenta(fila); window.NoPreguntar=0;}
	}
	if(window.validador==false){return false;}
	LimpiarAnticipo();
	ActivarFilasAnticipos();
	return true;
		   
}

function LimpiarAnticipo(){
	document.getElementById("hestanticipo").value="";
	document.getElementById("hcuenta_anticipo").value.value="";
	document.getElementById("hnrofilaant").value.value="";
	document.getElementById("hnroantact").value.value="";
	document.getElementById("hmontotanticipo").value.value="";
	document.getElementById("hporcantdesc").value="";
}

function ExtraerFilaCuentaSCG(scg_cuenta)
{
	totrowscg=ue_calcular_total_fila_local("txtscgnrocomp");
	if(totrowscg==0){return false;}
		
	for(j=1;(j<totrowscg);j++)
	{
		scgnrocomp=eval("f.txtscgnrocomp"+j+".value");
		scgcuenta=eval("f.txtscgcuenta"+j+".value");
		mondeb=eval("f.txtmondeb"+j+".value");
		monhab=eval("f.txtmonhab"+j+".value");
		debhab=eval("f.txtdebhab"+j+".value");
		estatus=eval("f.txtestatus"+j+".value");
		scgprocededoc=eval("f.txtscgprocededoc"+j+".value");
		
		if(scgcuenta==scg_cuenta&&debhab=='H'){
				return j;
		}
	}
	return;
		   
}


function AgregarCtaAnt(nro,nroanticipo,sc_cuenta,montoant,montodesc,sc_cuenta,obj){
	
	f=document.formulario;	
	if(document.getElementById("chkant")==null){return;}
		
	if(obj.checked==false){ 
		resp = EliminarAnticipo();
		if(resp==false){obj.checked=true;}
		return;
	}
	
	msj = 'Que porcentaje del anticipo desea Descontar: ' + "\n" +  "\n" +
			  '1) 25% ' + "\n" + 
			  '2) 50% ' + "\n" + 
			  '3) 75% ' + "\n" + 
			  '4) 100%';
		
	var respporc=prompt(msj,"4");
	
	if(respporc!="1" && respporc!="2" && respporc!="3" && respporc!="4"){
		alert("Opción inválida !");
		return;
	}
	
	switch(respporc){
		case '1':
			porcanticip = 0.25;
			break;
			
		case '2':
			porcanticip = 0.50;
			break;	
				
		case '3':
			porcanticip = 0.75;
			break;	
		
		case '4':
			porcanticip = 1;
			break;		
	}
		
	til = new Array();
	
	til['montotant'] = redondeardosdec((parseFloat(montoant)- parseFloat(montodesc))*parseFloat(porcanticip));
	til['filaant'] = nro;
	til['nroanticipo'] = nroanticipo;
	til['sc_cuenta'] = sc_cuenta;
	til['anticipo']=1;
	
	if(til['montotant']==0){return;};
	
	ue_catalogo_cuentas_scg(til);
	if(window.validador==true){DesactAnticipos(nro); document.getElementById("hporcantdesc").value=parseFloat(porcanticip)*100;}
	if(window.validador==false){obj.checked=false;}
	
	til = new Array();
	window.validador=true;
	return;
}

function BuscaDescAnticipo(criterio){

		f=document.formulario;
		existe=f.existe.value;
		if(existe!="TRUE"){return;}
		 	
		if(!EsPresup()){
		       return;
		}
		
		jtipproben = f.cmbtipdes.value;
		jcodproben = f.txtcodigo.value;
		
		if(jtipproben==''){alert("Debe se seleccionar un Proveedor/Beneficiario !"); document.getElementById("chkanticipo").checked=false; return;}
		if(jcodproben==''){alert("Debe se seleccionar un Proveedor/Beneficiario !"); document.getElementById("chkanticipo").checked=false; return;}
		
		if(jtipproben=='P'){
			jcod_pro=jcodproben;
			jced_bene='----------';
		}
		else{
			jced_bene=jcodproben;
			jcod_pro='----------';
		}

		datos = "criterio=" + criterio +
				"&tipproben=" + jtipproben + 
				"&cod_pro=" + jcod_pro + 	
				"&ced_bene=" + jced_bene +
				"&numrecdocdes=" + f.txtnumrecdoc.value;	
		//alert(datos);
		enviar_ajax(datos,'sigesp_cxp_p_recepcioncontable_ajax.php','resultados','POST','',ruta);	

}

var ObjForm = {	 
	 'facturas': new Array, 	 
	 'ruta': ruta, 
	 'criterio': '',
	 'claveRow': 0,
	 'contenedor':'resultados',
	 'f': document.form1,
	 'campo': function (idcampo) {
		            if(document.getElementById(idcampo)==null){alert("No existe el campo: " + idcampo); return;}
					return document.getElementById(idcampo).value;
				},
	 'CargarCampo': function (idcampo,valor) {
						if(document.getElementById(idcampo)==null){alert("No existe el campo: " + idcampo); return;}
						document.getElementById(idcampo).value = valor;
						return;
					},
'CargarCampoNumeric': function (nomclav,valor) {
							this.CargarCampo(nomclav,this.FormatoNumero(valor, 2, ',', '.'));				
							return;
						},
	'campoNumeric': function (idcampo) {	                
						valor=parseFloat(formato_numerico_ingles(this.campo(idcampo)));						
						return valor;
					},
	'CargarSelect': function (idcampo,valor) {
						if(document.getElementById(idcampo)==null){alert("No existe el campo: " + idcampo); return;}
						seleccionar_combo(idcampo,valor);
						return;
					},
'LimpiarContenedor':function (id) {
	                    if(document.getElementById(id)==null){alert("No existe el contenedor: " + id); return;}
						document.getElementById(id).innerHTML="";
		           },
'ComparaFechas':function (desde,hasta){							
						return DiasEntreFechas(desde,hasta);						
					},
  'BolquearCampo':function (id,condicion){	
                    if(document.getElementById(id)==null){alert("No existe el campo: " + id); return;}
					document.getElementById(id).disabled=condicion;					
				  },
'campoFilaGrid': function (nomclav) {	                
						if(!this.fila){return;}
						idcampo = this.gridId + '-cell-' + nomclav + this.fila;
						if(document.getElementById(idcampo)==null){alert("No existe el campo: " + idcampo); return;}
						return document.getElementById(idcampo).value;
					},
'campoFilaGridNumeric': function (nomclav) {	                
							valor=parseFloat(formato_numerico_ingles(this.campoFilaGrid(nomclav)));						
							return valor;
						},
'CargarCampoFilaGrid': function (nomclav,valor) {
						if(!this.fila){return;}
						idcampo = this.gridId + '-cell-' + nomclav + this.fila;
						if(document.getElementById(idcampo)==null){alert("No existe el campo: " + idcampo); return;}
						document.getElementById(idcampo).value = valor;
						return;
					},
'CargarCampoGridFilaNumeric': function (nomclav,valor) {
								this.CargarCampoFilaGrid(nomclav,this.FormatoNumero(valor, 2, ',', '.'));				
								return;
							},
		'ChkGrid': function (nomclav,cond) {	                
					if(!this.fila){return;}
					idcampo = this.gridId + '-cell-' + nomclav + this.fila;
					if(document.getElementById(idcampo)==null){alert("No existe el campo check: " + idcampo); return;}
					document.getElementById(idcampo).checked = cond;
					return true;
				},
'campoFilaGridChk': function (nomclav) {	                
						if(!this.fila){return;}
						idcampo = this.gridId + '-cell-' + nomclav + this.fila;
						if(document.getElementById(idcampo)==null){alert("No existe el campo check: " + idcampo); return;}
						document.getElementById(idcampo).checked;
						return document.getElementById(idcampo).checked;
					},
		'campoChk': function (idcampo) {
						if(document.getElementById(idcampo)==null){alert("No existe el campo check: " + idcampo); return;}
						tildado = (document.getElementById(idcampo).checked)?1:0;
						return tildado;
					},
	'CargarCampoChk': function (idcampo,valor) {
						if(document.getElementById(idcampo)==null){alert("No existe el campo check: " + idcampo); return;}
						tildado = (valor)?true:false;
						document.getElementById(idcampo).checked=tildado;
						return true;
					},
	'FormatoNumero':function (numero, decimales, separador_decimal, separador_miles){
							numero=parseFloat(numero);
							if(isNaN(numero)){
								return "";
							}
						
							if(decimales!==undefined){
								// Redondeamos
								numero=numero.toFixed(decimales);
							}
						
							// Convertimos el punto en separador_decimal
							numero=numero.toString().replace(".", separador_decimal!==undefined ? separador_decimal : ",");
						
							if(separador_miles){
								// Añadimos los separadores de miles
								var miles=new RegExp("(-?[0-9]+)([0-9]{3})");
								while(miles.test(numero)) {
									numero=numero.replace(miles, "$1" + separador_miles + "$2");
								}
							}
						
							return numero;
				 },
   'campoTxtAjax': function (campo) {
		                id = "h"+campo+this.claveRow;
						if(document.getElementById(id)==null){alert("No existe el campo: " + id); return;}					
						return document.getElementById(id).value;
					},
	 'datos': function (param) {
		 				 
						 switch(this.criterio){
							    
							    case 'modificar':
								case 'eliminar':
								case 'guardar':
									
									datos = "criterio=" + this.criterio +
											"&codtipviv=" + this.campo('cmbtipviv') + 
											"&vivbenmis=" + this.campo('sel_vivbenmis') + 
											"&vivnrohab=" + this.campo('vivnrohab') + 
											"&vivmonhip=" + this.campo('vivmonhip');									 
									break;						 
						 }
						 
						 return datos;
					 }, 	 
	 'EnviarAjax':function (param) {	               
					window.enviar_ajax(this.datos(),'sigesp_cxp_p_recepcioncontable_ajax.php',this.contenedor,'POST','',this.ruta);	
				 },  
	  'GuardarDatos':function (param) {
		 				this.criterio='guardar';
		 				this.contenedor='resultados';
						this.EnviarAjax();
					 },
	  'ModificarDatos':function (param) {
		 				this.criterio='modificar';
		 				this.contenedor='resultados';
						this.EnviarAjax();
					 },
	  'EliminarRegistro':function (param) {
		 				this.criterio='eliminar';
		 				this.contenedor='resultados';
						this.EnviarAjax();
					 },
	   'Guardar':function (param) {
		   				f=document.form1;
						if(!this.ValidaEntrada()){return;}						
						if(document.form1.hnrotal.value == ""){	
						        if(this.campo("cmbesttal")!='ACT'){mensajes_sigesp("VALIDACIÓN DE DATOS","El talonario debe estar en estatus activo !"); return;}
								if(f.incluir.value!='1'){mensajes_sigesp("VALIDACIÓN DE DATOS","No tiene permisos para guardar!"); return;}								
								valido = confirm("CONFIRMACIÓN DE DATOS" + '\n\n' + "Se va a agregar un talonario " + '\n\n' + "¿Esta de acuerdo?");
								if(valido){this.GuardarDatos();}
								return;
						}
						if(document.form1.hnrotal.value != ""){
								if(f.cambiar.value!='1'){mensajes_sigesp("VALIDACIÓN DE DATOS","No tiene permisos para modificar!"); return;}								
								valido = confirm("CONFIRMACIÓN DE DATOS" + '\n\n' + "Se va a modificar un talonario" + '\n\n' + "¿Esta de acuerdo?");
								if(valido){this.ModificarDatos();}
								return;
						}		   				
		   		},		
		'Eliminar':function (param) {
								f=document.form1;
								if(!f.hnrotal.value){
										mensajes_sigesp("VALIDACIÓN DE DATOS","Cargue primero el Talonario !");
										return;	
								}		
								if(!f.eliminar.value){
										mensajes_sigesp("VALIDACIÓN DE DATOS","No tiene permisos para eliminar.");
										return;	
								}
								if(f.hnrotal.value != ""){									
									valido = confirm("CONFIRMACIÓN DE DATOS" + '\n\n' + "Se va a eliminar un Talonario " + '\n\n' + "¿Esta de acuerdo?");
									if(valido){this.EliminarRegistro();}
									return;
								}
		
						},
		 'ValidaEntrada':function (param) {
			 			
								f=document.form1;	
																
								if(!this.campo("txtcodsuc")){		
									mensajes_sigesp("VALIDACIÓN DE DATOS","Seleccione la sucursal por favor!");		
									f.txtcodsuc.focus();
									return false;
								}
								
								return true;
						 },
		'InitForm':function (param) {
									 
						  },
		   'Salir':function (param) {
							window.close();
						  },

  'BuscarCatalogo':function (catalogo) {
					switch(catalogo){
							case 'sucursal':
							    if(this.campo("hnrotal")){return;}
								window.open('covensol_cxc_cat_sucursal.php','','toolbar=no,directories=no,location=no, width=700, height=300, scrollbars=yes, top=0, left=0, estatus=no');
							break;
							
							case 'talonario':							    
								window.open('covensol_cxc_cat_talonarios.php','','toolbar=no,directories=no,location=no, width=700, height=300, scrollbars=yes, top=0, left=0, estatus=no');
							break;
						}	
				  },
'ValidarLiquidacion':function (param) {
						
		                estpre=parseFloat(this.campo('cmbcodtipdoc').substr(8,1));
						
						if(this.campoChk('chkestliqant')&&estpre!=5&&estpre!=6){
						    msj = "OPERACIÓN NO PERRMITIDA" + '\n' + 
							      "Tipo de documento inválido" + '\n' + 
							      "Tipos aceptados: " + '\n' + 
								  "1) Causa y Paga. " + '\n' + 
								  "2) Compromete, Causa y Paga. ";
						    alert(msj);
							this.CargarCampoChk('chkestliqant',0);
							return;
						}
						
					 },
'ValidarTipoLiquidacion':function (param) {
						
		                estpre=parseFloat(this.campo('cmbcodtipdoc').substr(8,1));
						
						if(!this.campoChk('chkestliqant')&&(estpre==5||estpre==6)){
						    msj = "OPERACIÓN NO PERRMITIDA" + '\n' + 
							      "Tipo de documento inválido" + '\n' + 
							      "Para generar documentos tipo Causa y Paga ó Compromete, Causa y Paga," + '\n' + 
								  "estos deben ser de tipo Liqidación de Anticipo.";
						    alert(msj);							
							return false;
						}
						
						if(this.campoChk('chkestliqant')&&(estpre==5||estpre==6)&&this.campoNumeric('txttotalgener')>0){
						    msj = "OPERACIÓN NO PERRMITIDA" + '\n' + 							      
							      "Para generar documentos tipo Causa y Paga ó Compromete, Causa y Paga," + '\n' + 
								  "El total general debe ser 0 .";
						    alert(msj);							
							return false;
						}
						
						return true;
						
					 },

	    
}

$(document).ready(function() {
	<?php
	if(($ls_operacion=="GUARDAR")||(($ls_operacion=="ELIMINAR")&&(!$lb_valido)))
	{	
		print "ue_reload();";
	}
	?>	
});
</script>
<?php
/*if(($ls_operacion=="GUARDAR")||(($ls_operacion=="ELIMINAR")&&(!$lb_valido)))
{
	print "<script language=JavaScript>";
	print "   ue_reload();";
	print "</script>";
}*/
?>		  
</html>
