function generateContent($cell, $args)
 {
     /*			sprintf("<a href='$cell'%s>%s</a>", 
     				!empty($args["target"]) ? " target='".$args["target"]."'" : "",
     				!empty($args["display"]) ? $args["display"] : $cell
     				)**/
     $ret = $cell;
     if (function_exists("setLog")) {
         //setLog("Celda es $cell");
     }
     if ($args["mode"] == "edit" || $args["mode"] == "insert") {
         if (class_exists("MQL")) {
             $mql = new MQL();
             if (isset($args["sql"])) {
                 $opts = "";
                 $qry = $mql->getRecordset($args["sql"]);
                 $rs = $qry->fetch_array(MYSQLI_NUM);
                 /*$result = $mysqli->query($query);
                 		$row = $result->fetch_array(MYSQLI_NUM);
                 		printf ("%s (%s)\n", $row[0], $row[1]);*/
                 //getDataRecord($args["sql"]);
                 //setLog($args["sql"]);
                 foreach ($rs as $row) {
                     $opts .= "<option value=\"" . $row[0] . "\">" . $row[1] . "</option>";
                 }
                 if ($opts != "") {
                     $ret = sprintf("<select>{$opts}</select>");
                 }
             }
         }
     }
     return $ret;
 }
 function init()
 {
     $id = $this->mCodigo;
     $sql_errors = "SELECT  idgeneral_error_codigos, description_error, type_err \r\n    \t\t\t\t\t\t\tFROM general_error_codigos WHERE idgeneral_error_codigos={$id}\r\n    \t\t\t\t\t\t\tLIMIT 0,1 ";
     $mql = new MQL();
     $rs = $mql->getDataRecord($sql_errors);
     foreach ($rs as $rw) {
         $this->mCodigo = $rw["idgeneral_error_codigos"];
         $this->mDescripcion = $rw["description_error"];
     }
 }
function jsaGetCuentas($cuenta)
{
    $xCta = new cCuentaContableEsquema($cuenta);
    $sql = "SELECT numero, nombre FROM contable_catalogo WHERE numero LIKE '" . $xCta->CUENTARAW . "%' AND afectable=1  ORDER BY numero LIMIT 0,10";
    $ql = new MQL();
    $rs = $ql->getDataRecord($sql);
    $h = "";
    foreach ($rs as $rows) {
        $xCta2 = new cCuentaContableEsquema($rows["numero"]);
        $h .= "<option value=\"" . $rows["numero"] . "\">" . $xCta2->CUENTARAW . "-" . $rows["nombre"] . "</option>";
    }
    return $h;
}
function jsaGetDatosEmpresa($idEmpresa)
{
    $xEmp = new cEmpresas($idEmpresa);
    $xF = new cFecha();
    $ql = new MQL();
    $xl = new cSQLListas();
    $observaciones = "";
    $xEmp->init();
    $persona = $xEmp->getClaveDePersona();
    $xF = new cFecha(0);
    $opts = "";
    $exT = "";
    $periocidad = $xEmp->getPeriocidadPref();
    $periodo = $periocidad == CREDITO_TIPO_PERIOCIDAD_SEMANAL ? $xF->semana() : $xF->quincena();
    $periodo = intval($xEmp->getPeriodo()) < 1 ? $periodo : intval($xEmp->getPeriodo());
    $data = $ql->getDataRecord($xl->getListadoDePeriodoPorEmpresa($idEmpresa));
    $variacion = "0";
    $fecha_inicial = $xF->getFechaMX();
    $fecha_final = $xF->getFechaMX();
    $control = 0;
    $ctrl = "<label for=\"idperiodo\">Periodo {$periodo}</label><input type=\"number\" id=\"idperiodo\" onchange=\"jsGetCobranza()\" onblur=\"jsGetCobranza()\" />";
    $contar = 1;
    $max = 5;
    foreach ($data as $rw) {
        $idsel = "";
        $idclave = $rw["codigo"];
        $xPer = $xEmp->getOPeriodo(false, false, $idclave);
        if ($periodo == $xPer->periodo_marcado()->v() and $periocidad == $xPer->periocidad()->v()) {
            $control = $idclave;
            $periodo = $xPer->periodo_marcado()->v();
            $periocidad = $xPer->periocidad()->v();
            $fecha_final = $xPer->fecha_final()->v();
            $fecha_inicial = $xPer->fecha_inicial()->v();
            $idsel = " selected=\"true\" ";
        }
        if ($contar <= $max) {
            $opts .= "<option value=\"" . $idclave . " \"{$idsel}>" . $rw["nombre_periocidad"] . "[" . $xPer->periodo_marcado()->v() . "]";
            $opts .= "  - DEL: " . $xF->getFechaDDMM($rw["fecha_inicial"]) . " - " . $xF->getFechaDDMM($rw["fecha_final"]) . " SALDO " . getFMoney($rw["saldo"]) . "</option>";
        }
        $contar++;
    }
    if ($opts != "") {
        $ctrl = "<label for='idperiodo'>Periodo</label><select id=\"idperiodo\" name=\"idperiodo\" onblur=\"jsGetCobranza()\" onchange=\"jsGetCobranza()\">{$opts}</select>";
    }
    $ctrl .= "<input type=\"hidden\" id=\"idvariacion\" value=\"{$variacion}\" />";
    $ctrl .= "<input type=\"hidden\" id=\"idperiodo\" value=\"{$periodo}\" />";
    $ctrl .= "<input type=\"hidden\" id=\"idperiocidad\" value=\"{$periocidad}\" />";
    $ctrl .= "<input type=\"hidden\" id=\"idclavedepersona\" value=\"{$periocidad}\" />";
    return $ctrl;
}
function jsaCargaDeCreditos($persona)
{
    $xL = new cSQLListas();
    $ql = new MQL();
    $xs = new cHSelect();
    $xs->setDivClass("");
    $sql = $xL->getListadoDeCreditos($persona);
    $rs = $ql->getDataRecord($sql);
    $aOpts = array();
    //setLog($sql);
    foreach ($rs as $row) {
        $aOpts[$row["credito"]] = $row["credito"] . "-" . $row["producto"] . "-" . $row["periocidad"] . "-" . $row["saldo"];
    }
    $xs->addOptions($aOpts);
    return $xs->get("idcreditodescontado", "TR.CLAVE_de_credito");
}
$tiny = parametro("tiny");
$form = parametro("form");
$action = parametro("action", SYS_NINGUNO);
echo $xHP->getHeader();
echo $xHP->setBodyinit();
$xFRM = new cHForm("frmpugarentidades", "purgar-entidadesfederativas.frm.php?action=next");
$xBtn = new cHButton();
$xTxt = new cHText();
$xDate = new cHDate();
$xSel = new cHSelect();
$xChk = new cHCheckBox();
$msg = "";
$xFRM->setTitle("TR.purgar de entidadades federativas");
$xFRM->addJsBasico();
//$xFRM->addCreditBasico();
$mql = new MQL();
//Obtener lista de estados
$sql = "SELECT * FROM `general_estados` ";
$data = $mql->getDataRecord($sql);
$cEs = new cGeneral_estados();
foreach ($data as $rows) {
    $cEs->setData($rows);
    if ($action == SYS_NINGUNO) {
        $xFRM->addHTML($xChk->get($cEs->nombre()->v(), "estado" . $cEs->clave_numerica()->v()));
    } else {
        $eliminar = parametro("estado" . $cEs->clave_numerica()->v(), false, MQL_BOOL);
        $estado = $cEs->clave_numerica()->v();
        if ($eliminar == true) {
            my_query("DELETE FROM `general_colonias` WHERE `codigo_de_estado` = {$estado} ");
            my_query("DELETE FROM `general_municipios` WHERE `clave_de_entidad` = {$estado} ");
            //my_query("DELETE FROM `catalogos_localidades` WHERE `clave_de_estado` = $estado ");
 function setRegenerarSDPM($PFechaInicial, $PFechaFinal, $GenerarInteres = true, $incluirSinSaldo = false, $NumeroCuenta = false)
 {
     //		$PFechaFinal		= "";
     $mBase = 3100;
     $xT = new cTipos();
     $ql = new MQL();
     $BySaldo = $incluirSinSaldo == false ? " AND captacion_cuentas.saldo_cuenta >=" . TOLERANCIA_SALDOS : "";
     $ByCuentaSDPM = $NumeroCuenta == false ? "" : " AND `captacion_sdpm_historico`.`cuenta` = {$NumeroCuenta} ";
     $ByCuentaMvto = $NumeroCuenta == false ? "" : " AND `operaciones_mvtos`.`docto_afectado` = {$NumeroCuenta} ";
     $ByCuentaCta = $NumeroCuenta == false ? "" : " AND captacion_cuentas.numero_cuenta = {$NumeroCuenta} ";
     $msg = "";
     $msg .= "==========================================================================================\r\n";
     $msg .= "==================\tGenerando SDPM desde el {$PFechaInicial} al {$PFechaFinal}\r\n";
     $msg .= "==========================================================================================\r\n";
     $msg .= "Socio\tCuenta\tOPER\tEjercicio\tPeriodo\tFecha\tDias\tMonto\tSaldo\tSDPM\r\n";
     $sqlM = "SELECT \n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion`  AS 'fecha_operacion',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado` AS 'recibo_afectado',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`docto_afectado` AS 'docto_afectado',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`afectacion_real` AS 'afectacion_real',\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`valor_afectacion`,\n\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`afectacion` AS 'afectacion'\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\t\t\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = \n\t\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro` \n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` ={$mBase})\n\t\t\t\t\t\t\t\t\t{$ByCuentaMvto}\n\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion` ASC";
     $rsM = getRecordset($sqlM);
     $arrOps = array();
     //Array de montos de operacion
     $arrRecs = array();
     //Array de Recibos de Operacion
     while ($rwM = mysql_fetch_array($rsM)) {
         //clave cuenta fecha
         $cuenta = $rwM["docto_afectado"];
         $fecha = $rwM["fecha_operacion"];
         if (isset($arrOps[$cuenta . "-" . $fecha])) {
             $arrOps[$cuenta . "-" . $fecha] += $rwM["afectacion_real"] * $rwM["afectacion"];
         } else {
             $arrOps[$cuenta . "-" . $fecha] = $rwM["afectacion_real"] * $rwM["afectacion"];
         }
         $arrRecs[$cuenta . "-" . $fecha] = $rwM["recibo_afectado"];
         //$msg					.= "WARN\t$cuenta\tAgregar " . ($rwM["afectacion_real"] * $rwM["afectacion"] ) . "\r\n";
     }
     //Eliminar periodos anteriores
     $sqlDF = "DELETE FROM captacion_sdpm_historico WHERE (fecha>='{$PFechaInicial}' AND fecha<='{$PFechaFinal}') {$ByCuentaSDPM} ";
     my_query($sqlDF);
     //FECHAS
     $xF = new cFecha(0);
     //
     $xTbl = new cSAFETabla(TCAPTACION_CUENTAS);
     $sqlCX = $xTbl->getQueryInicial() . " WHERE captacion_cuentas.tipo_cuenta = " . CAPTACION_TIPO_VISTA . " {$BySaldo} {$ByCuentaCta} ";
     $rs1 = getRecordset($sqlCX);
     while ($rw1 = mysql_fetch_array($rs1)) {
         $socio = $rw1["numero_socio"];
         $cuenta = $rw1["numero_cuenta"];
         $xCta = new cCuentaALaVista($cuenta, $socio);
         $xCta->init($rw1);
         $DCta = $xCta->getDatosInArray();
         $FApertura = $DCta["fecha_apertura"];
         $dias = $xF->setRestarFechas($PFechaFinal, $FApertura);
         $dias += 1;
         $sucursal = $DCta["sucursal"];
         $FechaAnterior = $FApertura;
         $saldoAnterior = 0;
         $xF2 = new cFecha(1);
         for ($i = 0; $i <= $dias; $i++) {
             $OpFecha = $xF->setSumarDias($i, $FApertura);
             $xF->set($OpFecha);
             $OpFechaFin = $xF->getDiaFinal();
             $OpMonto = isset($arrOps[$cuenta . "-" . $OpFecha]) ? $arrOps[$cuenta . "-" . $OpFecha] : 0;
             $idrecibo = isset($arrRecs[$cuenta . "-" . $OpFecha]) ? $arrRecs[$cuenta . "-" . $OpFecha] : DEFAULT_RECIBO;
             //si la operacion es mayor a cero o es FIN DE MES
             if ($OpMonto != 0 or $OpFecha == $OpFechaFin) {
                 $diasTrans = $xF2->setRestarFechas($OpFecha, $FechaAnterior);
                 $xF2->set($OpFecha);
                 $ejercicio = $xF2->anno();
                 $periodo = $xF2->mes();
                 $sdpd = $saldoAnterior * $diasTrans;
                 $nuevatasa = $xCta->getTasaAplicable(0, 0, $saldoAnterior);
                 //corregir fecha
                 $sqlUSPM = "INSERT INTO captacion_sdpm_historico\n\t\t\t\t\t\t\t\t\t\t(ejercicio, periodo, cuenta, fecha, dias, tasa, monto, recibo, numero_de_socio, sucursal)\n\t    \t\t\t\t\t\t\t\tVALUES( {$ejercicio}, {$periodo}, {$cuenta}, '{$OpFecha}', {$diasTrans}, {$nuevatasa}, {$sdpd}, {$idrecibo}, {$socio}, '{$sucursal}') ";
                 //si es valida la operacion, se actualizan
                 if ($OpFecha >= $PFechaInicial and $OpFecha <= $PFechaFinal) {
                     my_query($sqlUSPM);
                     $msg .= "{$socio}\t{$cuenta}\t+SDPM\t{$ejercicio}\t{$periodo}\t{$OpFecha}\t{$diasTrans}\t{$OpMonto}\t{$saldoAnterior}\t{$sdpd}\r\n";
                 } else {
                     $msg .= "{$socio}\t{$cuenta}\t=SDPM\t{$ejercicio}\t{$periodo}\t{$OpFecha}\t{$diasTrans}\t{$OpMonto}\t{$saldoAnterior}\t{$sdpd}\r\n";
                 }
                 $FechaAnterior = $OpFecha;
                 $saldoAnterior += $OpMonto;
             }
         }
     }
     //Agregar Movimientos Finales del MES.
     //FIXME: Corregir incidencias
     //opcional: agregar Interes
     if ($GenerarInteres == true) {
         $xRec = new cReciboDeOperacion(12, false);
         $recibo = $xRec->setNuevoRecibo(DEFAULT_SOCIO, 1, $PFechaFinal, 1, 12, "REGENERAR_INTERES_SDPM_{$PFechaFinal}", "NA", "ninguno", "NA", DEFAULT_GRUPO);
         $msg .= "==========================================================================================\r\n";
         $msg .= "==================\tAGREGADO INTERES :: RECIBO {$recibo}\r\n";
         $msg .= "==========================================================================================\r\n";
         $_SESSION["recibo_en_proceso"] = $recibo;
         //sumar sdpm del mes por cuenta
         $sqlSDPM = "SELECT\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`numero_de_socio`,\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`cuenta`,\n\t\t\t\t\t\t\t\tSUM(`captacion_sdpm_historico`.`dias`)  AS `dias_transcurridos`,\n\t\t\t\t\t\t\t\tSUM(`captacion_sdpm_historico`.`monto`) AS `sdpm`,\n\t\t\t\t\t\t\t\tROUND( (`captacion_sdpm_historico`.`monto` / `captacion_sdpm_historico`.`dias`), 2) AS `ultimo_saldo`,\n\t\t\t\t\t\t\t\tMAX(`captacion_sdpm_historico`.`fecha`) AS 'UltimaFecha'\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico` `captacion_sdpm_historico` \n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(`captacion_sdpm_historico`.`fecha` >= '{$PFechaInicial}')\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(`captacion_sdpm_historico`.`fecha` <= '{$PFechaFinal}')\n\t\t\t\t\t\t\t\t{$ByCuentaSDPM}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`cuenta`,\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`ejercicio`,\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`periodo`\n\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t`captacion_sdpm_historico`.`fecha` DESC ";
         $rsCAP = $ql->getDataRecord($sqlSDPM);
         //setLog($sqlSDPM);
         foreach ($rsCAP as $rwC) {
             $socio = $rwC["numero_de_socio"];
             $cuenta = $rwC["cuenta"];
             $dias_de_calc = $rwC["dias_transcurridos"];
             $sumaSDPM = $rwC["sdpm"];
             $FechaI = $rwC["UltimaFecha"];
             $promedio = $xT->cFloat($sumaSDPM / $dias_de_calc, 2);
             //XXX: Solucionar Tasa de Interes y hacer las rapida la consulta
             $xCta = new cCuentaDeCaptacion($cuenta);
             $xCta->init();
             $subtipo = $xCta->getTipoDeSubproducto();
             $tasa_nueva = obtentasa($promedio, CAPTACION_TIPO_VISTA, 0, $subtipo);
             $interes = $sumaSDPM * $tasa_nueva / EACP_DIAS_INTERES;
             $interes = $xT->cFloat($interes, 2);
             //agregar movimiento
             if ($interes > 0) {
                 setNuevoMvto($socio, $cuenta, $recibo, $FechaI, $interes, 222, 1, "CALCULO_AUTOMATICO_DESDE_{$PFechaInicial}");
                 $msg .= "{$socio}\t{$cuenta}\tAGREGAR\tInteres por {$interes}, tasa {$tasa_nueva}, Promedio {$promedio}, SDPM {$sumaSDPM}, Dias {$dias_de_calc}\r\n";
             } else {
                 $msg .= "{$socio}\t{$cuenta}\tIGNORAR\tInteres por {$interes}, tasa {$tasa_nueva}, Promedio {$promedio}, SDPM {$sumaSDPM}, Dias {$dias_de_calc}\r\n";
             }
         }
     }
     return $msg;
 }
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("TR.Panel de Control de personas", HP_FORM);
$jxc = new TinyAjax();
$xql = new cSQLListas();
$ql = new MQL();
$xImg = new cHImg();
$xF = new cFecha();
$jsTabs = "";
$idempresa = 0;
$oficial = elusuario($iduser);
$idsocio = parametro("idsocio", false, MQL_INT);
$idsocio = parametro("persona", $idsocio, MQL_INT);
$idsocio = parametro("socio", $idsocio, MQL_INT);
$xJsB = new jsBasicForm("extrasocios");
function jsaReVivienda($idsocio)
{
    $ql = new cSQLListas();
    $sqlvv = "SELECT socios_vivienda.idsocios_vivienda AS 'num',\n\t\t\n\t\t\t\t\tCONCAT('Calle ', socios_vivienda.calle, ' Num. ',\n\t\t\t\t\tsocios_vivienda.numero_exterior, '-', socios_vivienda.numero_interior, ' Col. ',\n\t\t\t\t  \tsocios_vivienda.colonia, ', ', socios_vivienda.localidad, ', ', estado)\n\t\t\t\t\tAS 'domicilio_completo',\n\t\t\t\t\tgetBooleanMX(socios_vivienda.principal) AS 'es_principal'\n\t\t\t\t    FROM socios_vivienda WHERE socio_numero={$idsocio}  LIMIT 0,10";
    $cTbl = new cTabla($sqlvv);
    $cTbl->setWidth();
 */
//=====================================================================================================
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.db.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("", HP_FORM);
$xQL = new MQL();
$DDATA = $_REQUEST;
$action = isset($DDATA["action"]) ? $DDATA["action"] : SYS_CERO;
//$jxc = new TinyAjax();
//$jxc ->exportFunction('datos_del_pago', array('idsolicitud', 'idparcialidad'), "#iddatos_pago");
//$jxc ->process();
echo $xHP->getHeader();
$jsb = new jsBasicForm("frmdocumentos");
//$jxc ->drawJavaScript(false, true);
$ByType = "";
echo $xHP->setBodyinit();
$xFRM = new cHForm("frmsdn", "sdn.upload.frm.php?action=" . SYS_UNO);
$xFRM->setEnc("multipart/form-data");
$xFRM->setTitle($xHP->getTitle());
$arrOps = array("ADR" => $xHP->lang("domicilio") . "(ADD.PIP)", "SDN" => $xHP->lang("persona") . "(SDN.PIP)", "ALT" => $xHP->lang("alias") . "(ALT.PIP)");
$xBtn = new cHButton();
 function set($valor, $parametro)
 {
     $parametro = strtoupper($parametro);
     //, fecha_de_alta='2014-5-23', fecha_de_expiracion='2014-5-23'
     $sql = "UPDATE creditos_productos_otros_parametros SET  valor_del_parametro='{$valor}' WHERE clave_del_producto=" . $this->mProducto . " AND clave_del_parametro='{$parametro}' ";
     $ql = new MQL();
     $ql->setRawQuery($sql);
 }
 function init($data = false)
 {
     $clave = $this->mClave;
     if (is_array($data)) {
     } else {
         $ql = new MQL();
         $data = $ql->getDataRow("SELECT * FROM `tesoreria_monedas` WHERE `clave_de_moneda`='{$clave}' ");
     }
     $this->mObj = new cTesoreria_monedas();
     $this->mObj->setData($data);
     $this->mData = $data;
 }
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("Recibo de Cobros", HP_RECIBO);
$xHP->addCSS("../css/tinybox.css");
$xHP->addJsFile("../js/tinybox.js");
$oficial = elusuario($iduser);
$xT = new cTipos();
$xFRM = new cHForm("frmrecibo");
$xF = new cFecha();
$recibo = parametro("recibo", false);
$xQl = new MQL();
echo $xHP->getHeader();
if ($recibo == false) {
    header("location:../404.php?i=" . DEFAULT_CODIGO_DE_ERROR);
}
$arrQ = array("aumento" => 1, "disminucion" => -1, "ninguna" => 0);
//capturar datos del recibo
$xRec = new cReciboDeOperacion(false, false, $recibo);
$xRec->init();
$DRec = $xRec->getDatosInArray();
$idsocio = $xRec->getCodigoDeSocio();
// $DRec["numero_socio"];
$numero_de_socio = $xRec->getCodigoDeSocio();
//$DRec["numero_socio"];
$afectaCaja = $arrQ[$DRec["afectacion_en_flujo_efvo"]];
//datos del socio
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("TR.Plan_de_Pagos", HP_REPORT);
$xF = new cFecha();
$ql = new MQL();
$oficial = elusuario($iduser);
$idrecibo = parametro("idrecibo", false, MQL_INT);
$idrecibo = parametro("recibo", $idrecibo, MQL_INT);
$idsolicitud = parametro("is", false, MQL_INT);
$idsolicitud = parametro("credito", $idsolicitud, MQL_INT);
$ShowAvales = parametro("p", false, MQL_BOOL);
if ($idrecibo == false) {
    if ($idsolicitud != false) {
        $xCred = new cCredito($idsolicitud);
        $xCred->init();
        $idrecibo = $xCred->getNumeroDePlanDePagos();
        if (setNoMenorQueCero($idrecibo) > 0) {
        } else {
            exit(JS_CLOSE);
        }
$OrderBy = ($UseMeta == true or $UseJW) ? "" : "ORDER BY\t`socios_general`.`apellidopaterno`,\t`socios_general`.`apellidomaterno`,\t`socios_general`.`nombrecompleto` ";
if ($ByAMaterno != "" and $ByAPaterno != "") {
    $ByAPaterno = "AND ( (apellidopaterno SOUNDS LIKE '%{$apaterno}%' OR apellidopaterno LIKE '%{$apaterno}%') OR (apellidomaterno SOUNDS LIKE '%{$amaterno}%' OR apellidomaterno LIKE '%{$amaterno}%') ) ";
    $ByAMaterno = "";
}
$sql = "SELECT\n\t\t`socios_general`.`codigo`          AS `codigo`,\n\t\t`socios_general`.`apellidopaterno` AS `primerapellido`,\n\t\t`socios_general`.`apellidomaterno` AS `segundoapellido`,\n\t\t`socios_general`.`nombrecompleto`  AS `nombres`,\n\t\t`socios_general`.`curp`,\n\t\t'soundlike' AS 'tipo'\n\tFROM\n\t\t`socios_general`\n\tWHERE\n\t\tcodigo != " . DEFAULT_SOCIO . " AND (`tipoingreso`= " . TIPO_INGRESO_SDN . " OR `nivel_de_riesgo_aml` = 100)\n\t\t{$ByNombre} {$ByAPaterno} {$ByAMaterno} {$OrderBy} LIMIT 0,10";
if ($UseJW == true) {
    $sql .= " UNION SELECT\n\t\t`socios_general`.`codigo`          AS `codigo`,\n\t\t`socios_general`.`apellidopaterno` AS `primerapellido`,\n\t\t`socios_general`.`apellidomaterno` AS `segundoapellido`,\n\t\t`socios_general`.`nombrecompleto`  AS `nombres`,\n\t\t`socios_general`.`curp`,\n\t\t'jarowinkler' AS 'tipo'\n\tFROM\n\t\t`socios_general`\n\tWHERE\n\t\tcodigo != " . DEFAULT_SOCIO . " AND (`tipoingreso`= " . TIPO_INGRESO_SDN . " OR `nivel_de_riesgo_aml` = 100)\n\t\t\t{$ByJWNombre}  {$ByJWAPaterno} {$ByJWAMaterno} {$OrderBy}\n\t\t\tLIMIT 0,10";
}
if ($UseMeta == true) {
    $sql .= " UNION SELECT\n\t\t`socios_general`.`codigo`          AS `codigo`,\n\t\t`socios_general`.`apellidopaterno` AS `primerapellido`,\n\t\t`socios_general`.`apellidomaterno` AS `segundoapellido`,\n\t\t`socios_general`.`nombrecompleto`  AS `nombres`,\n\t\t`socios_general`.`curp`,\n\t\t'metaphone' AS 'tipo'\n\tFROM\n\t\t`socios_general`\n\tWHERE\n\t\tcodigo != " . DEFAULT_SOCIO . "\n\t\tAND (`tipoingreso`= " . TIPO_INGRESO_SDN . "\tOR `nivel_de_riesgo_aml` = 100)\n\t\t\t{$ByMNombre} {$ByMAPaterno} {$ByMAMaterno} {$OrderBy} LIMIT 0,10\n\t\t\t";
}
//exit($sql);
header('Content-type: application/json');
$json = array();
$mql = new MQL();
$rs = $mql->getRecordset($sql);
$idx = 0;
$xLng = new cLang();
if ($rs) {
    while ($row = $rs->fetch_assoc()) {
        foreach ($row as $campo => $valor) {
            if (is_string($valor)) {
                $valor = htmlentities($valor);
                //htmlentities( (string) $valor, ENT_QUOTES, 'utf-8', FALSE);
            }
            $json["record_{$idx}"][$campo] = $valor;
            //base64_encode($valor);//utf8_encode($valor);
        }
        $idx++;
        //Generar el Acuse
 function setRun()
 {
     $ejercicio = $this->mEjercicio;
     $periodo = $this->mPeriodo;
     $tipoPoliza = $this->mTipoDePoliza;
     $numeroPoliza = $this->mNumeroDePoliza;
     $QL = new MQL();
     $sqlMvtos = "SELECT\r\n\t\t\t\t\t\t`contable_movimientos`.* \r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t`contable_movimientos` `contable_movimientos` \r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t(`contable_movimientos`.`ejercicio` ={$ejercicio}) AND\r\n\t\t\t\t\t\t\t(`contable_movimientos`.`periodo` ={$periodo}) AND\r\n\t\t\t\t\t\t\t(`contable_movimientos`.`tipopoliza` ={$tipoPoliza}) AND\r\n\t\t\t\t\t\t\t(`contable_movimientos`.`numeropoliza` ={$numeroPoliza})\r\n\t\t\t\t\t\tORDER BY `contable_movimientos`.`ejercicio`,\r\n\t\t\t\t\t\t`contable_movimientos`.`periodo`,\r\n\t\t\t\t\t\t`contable_movimientos`.`tipopoliza`,\r\n\t\t\t\t\t\t`contable_movimientos`.`numeropoliza`,\r\n\t\t\t\t\t\t`contable_movimientos`.`numeromovimiento` ";
     $MRs = $QL->getDataRecord($sqlMvtos);
     foreach ($MRs as $MRw) {
         $cuenta = $MRw["numerocuenta"];
         $referencia = $MRw["referencia"];
         //$TipoDeMovimiento, $cuenta, $monto, $referencia = "", $concepto = ""
         $tipoMvto = $MRw["tipomovimiento"];
         $monto = $MRw["importe"];
         $concepto = $MRw["concepto"];
         $this->addMovimiento($tipoMvto, $cuenta, $monto, $referencia, $concepto);
     }
 }
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
$iduser = $_SESSION["log_id"];
//=====================================================================================================
$xHP = new cHPage("TR.Movimientos de Auxiliares del Catalogo", HP_REPORT);
$xF = new cFecha();
$QL = new MQL();
$cuenta_inicial = parametro("for", 0, MQL_INT);
$cuenta_final = parametro("to", 0, MQL_INT);
$out = parametro("out", SYS_DEFAULT, MQL_RAW);
$ejercicio = parametro("ejercicio", 0, MQL_INT);
$periodo = parametro("periodo", 0, MQL_INT);
//---------------- Valuar Tipo de Cuenta ----------------
$tipo_cuentas = parametro("tipo", SYS_TODAS, MQL_RAW);
$nivel_cuentas = parametro("nivel", SYS_TODAS, MQL_RAW);
$incluir_cuentas = parametro("estado", SYS_TODAS, MQL_RAW);
$ByCuentas = "";
$ByCuentasSaldos = "";
if ($cuenta_inicial > 0 and $cuenta_final > 0) {
    $xCtaInit = new cCuentaContableEsquema($cuenta_inicial);
    $cuenta_inicial = $xCtaInit->CUENTA;
    $ByCuentas .= " AND (`contable_catalogo`.`numero`>={$cuenta_inicial}) ";
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.db.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("TR.VISTA_PREVIA DEL REPORTE_X_HORAS", HP_REPORT);
$mql = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$xT = new cTipos();
$xLoc = new cLocal();
$xLayout = new cReportes_Layout();
$xHTable = new cHTabla();
$xHNot = new cHNotif();
$estatus = parametro("estado", SYS_TODAS);
$frecuencia = parametro("periocidad", SYS_TODAS);
$producto = parametro("convenio", SYS_TODAS);
$producto = parametro("producto", $producto);
$empresa = parametro("empresa", SYS_TODAS);
$out = parametro("out", SYS_DEFAULT);
$FechaInicial = parametro("on", false);
$FechaInicial = parametro("fecha-1", $FechaInicial);
$FechaInicial = $FechaInicial == false ? FECHA_INICIO_OPERACIONES_SISTEMA : $xF->getFechaISO($FechaInicial);
$FechaFinal = parametro("off", false);
$idrecibo = DEFAULT_RECIBO;
$xL = new cSQLListas();
//$xRec		= new cReciboDeOperacion(12);
//$xRec->setGenerarPoliza();
//$xRec->setForceUpdateSaldos();
//$idrecibo	=  $xRec->setNuevoRecibo(1,1,$fechaop, 1, 12, "CIERRE_DE_SEGUIMIENTO", "NA", "ninguno", "NA", DEFAULT_GRUPO);
//$xRec->setNumeroDeRecibo($idrecibo);
$messages .= "=======================================================================================\r\n";
$messages .= "=========================\t\t" . EACP_NAME . " \r\n";
$messages .= "=========================\t\t" . getSucursal() . " \r\n";
$messages .= "=======================================================================================\r\n";
$messages .= "=========================\t\tINICIANDO EL CIERRE DE RIESGOS ===================\r\n";
$messages .= "=========================\t\tRECIBO: {$idrecibo}\t\t\t\t   ====================\r\n";
$messages .= "=======================================================================================\r\n";
if (MODULO_AML_ACTIVADO == true) {
    $mql = new MQL();
    //crear arbol de relaciones
    $xUtils = new cPersonas_utils();
    $xUtils->setCrearArbolRelaciones();
    //Validar perfiles transaccionales
    //Validar Documentos
    //TODO: Agregar cierre de riesgos
    //checar documentos de todos los socios
    $OSoc = new cSocios_general();
    $rs = $OSoc->query()->select()->exec();
    foreach ($rs as $data) {
        $OSoc->setData($data);
        $xAml = new cAMLPersonas($OSoc->codigo()->v());
        $xAml->init();
        //$xAml->setForceAlerts();
        $xAml->setVerificarDocumentosCompletos($fechaop);
//=====>	INICIO_H
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
//=====================================================================================================
$xInit = new cHPage("", HP_SERVICE);
$txt = "";
$ql = new MQL();
$lis = new cSQLListas();
$xF = new cFecha();
$persona = parametro("persona", DEFAULT_SOCIO, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$tipo = parametro("tipo", false, MQL_INT);
$estado = parametro("estado", false, MQL_INT);
$rs = array();
if (setNoMenorQueCero($persona) > DEFAULT_SOCIO) {
    //$xSoc	= new cSocio($persona); $xSoc->init();
    //$tipo 	= ( setNoMenorQueCero($tipo)  > 0) ? $tipo : SYS_TODAS;
    $estado = setNoMenorQueCero($estado) > 0 ? $estado : SYS_TODAS;
    $SinSaldo = ($estado == CREDITO_ESTADO_AUTORIZADO or $estado == CREDITO_ESTADO_SOLICITADO) ? true : false;
    $sql = $lis->getListadoDeCreditos($persona, $SinSaldo, $estado);
    $datos = $ql->getDataRecord($sql);
    foreach ($datos as $row) {
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
//=====================================================================================================
ini_set("max_execution_time", 600);
$xHP = new cHPage("", HP_REPORT);
$mql = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$xLoc = new cLocal();
$xLog = new cCoreLog();
$xCR = new cReporteCirculoDeCredito_tipo();
$ClaveOtorgante = $xCR->getClaveDeOtorgante();
$NombreOtorgante = $xCR->getNombreOtorgante();
$ByPersona1 = "";
$ByPersona2 = "";
$ByPersona3 = "";
$FechaInicial = isset($_GET["on"]) ? $_GET["on"] : FECHA_INICIO_OPERACIONES_SISTEMA;
$FechaFinal = isset($_GET["off"]) ? $_GET["off"] : fechasys();
$toJson = false;
//parametro("beauty", false, MQL_BOOL);
$lineaJson = array();
$itemJson = array();
$FechaExtraccion = date("Ymd", strtotime($FechaFinal));
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.db.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("TR.Estado de Cuenta de Intedeses ", HP_REPORT);
$xL = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$persona = parametro("persona", DEFAULT_SOCIO, MQL_INT);
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$credito = parametro("idsolicitud", $credito, MQL_INT);
$credito = parametro("solicitud", $credito, MQL_INT);
$estatus = parametro("estado", SYS_TODAS);
$frecuencia = parametro("periocidad", SYS_TODAS);
$producto = parametro("convenio", SYS_TODAS);
$producto = parametro("producto", $producto);
$empresa = parametro("empresa", SYS_TODAS);
$out = parametro("out", SYS_DEFAULT);
$FechaInicial = parametro("on", false);
$FechaInicial = parametro("fecha-0", $FechaInicial);
$FechaInicial = $FechaInicial == false ? FECHA_INICIO_OPERACIONES_SISTEMA : $xF->getFechaISO($FechaInicial);
 function setPermisos($permisos, $id = false)
 {
     $msg = "";
     $id = $id == false ? $this->mID : $id;
     $mql = new MQL();
     $gl = $this->mGlobalM;
     //actualizar padres y parent
     $sql = "UPDATE general_menu set menu_rules='{$permisos}' WHERE (menu_parent != {$gl}) AND (menu_parent={$id} OR `idgeneral_menu` = {$id} )";
     $ics = my_query($sql);
     $msg .= "OK\tAplicacion Recursiva de {$id} " . $ics["rows"] . "\r\n";
     $sql2 = "SELECT * FROM general_menu WHERE menu_parent={$id}";
     $rs = $mql->getDataRecord($sql2);
     $xMen = new cGeneral_menu();
     foreach ($rs as $row) {
         $xMen->setData($row);
         $ide = $xMen->idgeneral_menu()->v();
         $sqlP = "UPDATE general_menu SET menu_rules='{$permisos}' WHERE menu_parent={$ide} OR `idgeneral_menu` = {$ide} ";
         $idcs = my_query($sqlP);
         $msg .= "OK\tSubmenu {$ide} padre {$id} " . $idcs["rows"] . "\r\n";
     }
     $this->mMessages .= $msg;
     return $msg;
 }
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
//=====================================================================================================
$xHP = new cHPage("TR.Carga de Personas");
ini_set("max_execution_time", 600);
$action = isset($_GET["o"]) ? $_GET["o"] : false;
$xHP->init();
$xFRM = new cHForm("frmSendFiles", "mae.socios.upload.frm.php?o=u");
$xFRM->setEnc("multipart/form-data");
$xBtn = new cHButton();
$xTxt = new cHText();
$xDate = new cHDate();
$xSel = new cHSelect();
$msg = "";
$ql = new MQL();
$xDiv = new cHDiv();
$xFil = new cHFile();
$xChk = new cHCheckBox();
$xImp = new cFileImporter();
//Si la Operacion es Configurar los Datos
if ($action == false) {
    $xFRM->addHElem($xFil->getBasic("idarchivo", ""));
    $xFRM->addHElem($xChk->get("TR.Afectar Base de Datos", "idaplicar"));
    $xFRM->addSubmit();
    $xFRM->addFootElement('<input type="hidden" name="MAX_FILE_SIZE" value="1024000">');
} elseif ($action == "u") {
    //cargar datos alfanumericos del estados
    $sqlEstados = " SELECT\t`general_estados`.`clave_alfanumerica`,\t`general_estados`.`nombre` FROM\t`general_estados` `general_estados` ";
    $arrEstados = $ql->getArrayRecord($sqlEstados);
    $sqlEmpresas = "SELECT\t`socios_aeconomica_dependencias`.`idsocios_aeconomica_dependencias`, `socios_aeconomica_dependencias`.`descripcion_dependencia` FROM\t`socios_aeconomica_dependencias` `socios_aeconomica_dependencias`";
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.db.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//=====================================================================================================
$xHP = new cHPage("TR.REPORTE DE ", HP_REPORT);
$xL = new cSQLListas();
$xF = new cFecha();
$query = new MQL();
$estatus = parametro("estado", SYS_TODAS);
$frecuencia = parametro("periocidad", SYS_TODAS);
$producto = parametro("convenio", SYS_TODAS);
$producto = parametro("producto", $producto);
$empresa = parametro("empresa", SYS_TODAS);
$out = parametro("out", SYS_DEFAULT);
$FechaInicial = parametro("on", false);
$FechaInicial = parametro("fecha-0", $FechaInicial);
$FechaInicial = $FechaInicial == false ? FECHA_INICIO_OPERACIONES_SISTEMA : $xF->getFechaISO($FechaInicial);
$FechaFinal = parametro("off", false);
$FechaFinal = parametro("fecha-1", $FechaFinal);
$FechaFinal = $FechaFinal == false ? fechasys() : $xF->getFechaISO($FechaFinal);
$jsEvent = $out != OUT_EXCEL ? "initComponents()" : "";
$senders = getEmails($_REQUEST);
$sql = "SELECT * FROM socios LIMIT 0,100";
function getSIPAKALPermissions($myFile)
{
    //Tratar el __FILE__, eliminar el directorio
    $vUno = substr_count($myFile, "/");
    $vDos = substr_count($myFile, "\\");
    $notes = "";
    $pUSRID = isset($_SESSION["SN_b80bb7740288fda1f201890375a60c8f"]) ? $_SESSION["SN_b80bb7740288fda1f201890375a60c8f"] : 0;
    $pUSRNivel = isset($_SESSION["SN_d567c9b2d95fbc0a51e94d665abe9da3"]) ? $_SESSION["SN_d567c9b2d95fbc0a51e94d665abe9da3"] : 0;
    $pUSRPWD = isset($_SESSION["SN_0d35c1f17675a8a2bf3caaacd59a65de"]) ? $_SESSION["SN_0d35c1f17675a8a2bf3caaacd59a65de"] : "";
    $mUSR = isset($_SESSION["SN_0a744893951e0d1706ff74a7afccf561"]) ? $_SESSION["SN_0a744893951e0d1706ff74a7afccf561"] : "";
    //
    //obtener variables por CONTEXT
    if (isset($_REQUEST)) {
        if (isset($_REQUEST["ctx"])) {
            $ctx = md5($_REQUEST["ctx"]);
            $sql = "SELECT\t`t_03f996214fba4a1d05a68b18fece8e71`.*\r\n\t\t\tFROM `t_03f996214fba4a1d05a68b18fece8e71` WHERE \r\n\t\t\t(MD5(MD5(CONCAT(MD5(`t_03f996214fba4a1d05a68b18fece8e71`.`idusuarios`) , '|', MD5(`t_03f996214fba4a1d05a68b18fece8e71`.`f_34023acbff254d34664f94c3e08d836e`)))) = '{$ctx}') \r\n\t\t\tOR\r\n\t\t\t(MD5(MD5(CONCAT(MD5(`t_03f996214fba4a1d05a68b18fece8e71`.`f_28fb96d57b21090705cfdf8bc3445d2a`) , '|', MD5(`t_03f996214fba4a1d05a68b18fece8e71`.`f_34023acbff254d34664f94c3e08d836e`)))) = '{$ctx}')\r\n\t\t\tLIMIT 0,1 ";
            //$notes		= $sql;
            $xMQL = new MQL();
            $data = $xMQL->getDataRecord($sql);
            foreach ($data as $rows) {
                $pUSRID = $rows["idusuarios"];
                $pUSRNivel = $rows["f_f2cd801e90b78ef4dc673a4659c1482d"];
                $pUSRPWD = $rows["f_34023acbff254d34664f94c3e08d836e"];
                $mUSR = $rows["f_28fb96d57b21090705cfdf8bc3445d2a"];
                $_SESSION["SN_b80bb7740288fda1f201890375a60c8f"] = $pUSRID;
                $_SESSION["SN_d567c9b2d95fbc0a51e94d665abe9da3"] = $pUSRNivel;
                $_SESSION["SN_0d35c1f17675a8a2bf3caaacd59a65de"] = $pUSRPWD;
                $_SESSION["SN_0a744893951e0d1706ff74a7afccf561"] = $mUSR;
            }
            //
        }
    }
    $PUBLICSVC = array("personas.svc.php" => true, "personas.actividades.economicas.php" => true, "listanegra.svc.php" => true, "equivalente.moneda.svc.php" => true, "cantidad_en_letras.php" => true);
    //servicios publicos
    $PFile = "";
    $myPermission = false;
    if ($vUno >= 1) {
        $DCFile = explode("/", $myFile);
        $elems = count($DCFile) - 1;
        if ($elems >= 0) {
            $PFile = $DCFile[$elems];
        }
    } else {
        $DCFile = explode("\\", $myFile);
        $elems = count($DCFile) - 1;
        if ($elems >= 0) {
            $PFile = $DCFile[$elems];
        }
    }
    if (isset($PUBLICSVC[$PFile])) {
        $myPermission = true;
        //setLog("Acceso Publico al Servicio $PFile");
    } else {
        $tmpPWD = $mUSR != "" ? goLogged("contrasenna", $mUSR) : md5(session_id());
        if ($tmpPWD != $pUSRPWD) {
            $myPermission = false;
            //salvar el error
            saveError(98, session_id(), "NO HA DEFINIDO UNA SESSION PARA EL ARCHIVO {$myFile} {$notes}");
            //salir si no esta definida la session
            session_unset();
            // Finalmente, destruye la sesi&oacute;n
            session_destroy();
            header("location:inicio.php");
            exit;
        }
        $myPermission = false;
        //checar si la variable esta inicializada
        //si no enviar un unsetsession
        if (isset($pUSRNivel) and $pUSRNivel > 0) {
            $sqlRULES = "SELECT COUNT(idgeneral_menu) AS 'items', menu_rules FROM general_menu\r\n\t\t\t\t\t\tWHERE menu_file LIKE '%{$PFile}'\r\n\t\t\t\t\t\tAND (FIND_IN_SET('{$pUSRNivel}@rw', menu_rules)>0\r\n\t\t\t\t\t\tOR FIND_IN_SET('{$pUSRNivel}@ro', menu_rules)>0)\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t/*LIMIT 0,1*/ ";
            //setLog($sqlRULES);
            $cnxT = mysql_connect(WORK_HOST, USR_PERMISSIONS, PWD_PERMISSIONS);
            $dbT = mysql_select_db(MY_DB_IN, $cnxT);
            $rsRULES = mysql_query($sqlRULES, $cnxT);
            if (!isset($rsRULES)) {
                saveError(98, $_SESSION["SN_b80bb7740288fda1f201890375a60c8f"], mysql_error($cnxT));
            }
            $aRULES = mysql_fetch_array($rsRULES);
            /**
             * Verifica la autenticacion
             * busca la pocision del permiso
             * //
             **/
            $mos = strtoupper(substr(PHP_OS, 0, 3));
            $myFile = str_replace("/", "|", $myFile);
            $myFile = str_replace("\\", "|", $myFile);
            $dFile = explode("|", $myFile);
            $idfile = sizeof($dFile) - 1;
            $myFile = $dFile[$idfile - 1] . "/" . $dFile[$idfile];
            //DIRECTORY_SEPARATOR
            if ($aRULES["items"] == 0) {
                $sqlA = "INSERT INTO `general_menu` (`menu_title`, `menu_file`) VALUES ('{$PFile}', '{$myFile}')";
                @mysql_query($sqlA, $cnxT);
            }
            if (!isset($aRULES["menu_rules"]) or empty($aRULES["menu_rules"]) or $aRULES["menu_rules"] == "") {
                //saveError(97, $_SESSION["SN_b80bb7740288fda1f201890375a60c8f"], $sqlRULES);
                saveError(999, $_SESSION["SN_b80bb7740288fda1f201890375a60c8f"], "Acceso no permitido a :" . addslashes($myFile) . " {$notes}");
                $myPermission = false;
            } else {
                $ARls = explode(",", $aRULES["menu_rules"]);
                if (in_array("{$pUSRNivel}@rw", $ARls)) {
                    $myPermission = "ReadWrite";
                } else {
                    $myPermission = "ReadOnly";
                }
            }
            @mysql_free_result($rsRULES);
            @mysql_close($cnxT);
            unset($rsRULES);
            unset($cnxT);
            unset($dbT);
        } else {
            $myPermission = false;
            //salvar el error
            saveError(98, session_id(), "NO HA DEFINIDO UNA SESSION PARA EL ARCHIVO {$myFile} {$notes}\r\n");
            //salir si no esta definida la session
            session_unset();
            // Finalmente, destruye la sesi&oacute;n
            session_destroy();
            header("location:inicio.php");
            exit;
        }
    }
    return $myPermission;
}
 function init($data = false)
 {
     if (!is_array($data)) {
         $ql = new MQL();
         $sql = "SELECT * FROM `bancos_operaciones` WHERE (`idcontrol` =" . $this->mCodigo . ") LIMIT 0,1";
         $data = $ql->getDataRow($sql);
     }
     $this->mObj = new cBancos_operaciones();
     $this->mObj->setData($data);
     $this->mNumeroBancario = $this->mObj->cuenta_bancaria()->v();
     $this->mTipoDeOperacion = $this->mObj->tipo_operacion()->v(OUT_TXT);
     $this->mMonto = setNoMenorQueCero($this->mObj->monto_real()->v(OUT_TXT));
     switch ($this->mTipoDeOperacion) {
         case $this->CHEQUE:
             $this->mNumeroDeCheque = setNoMenorQueCero($this->mObj->numero_de_documento()->v(OUT_TXT));
             break;
     }
 }
 function setActualizarNivelDeRiesgo($actualizar = false)
 {
     $xQL = new MQL();
     $xLi = new cSQLListas();
     $xLog = new cCoreLog();
     //$xLi->getInicialDeCuentas()
     $rs = $xQL->getDataRecord($xLi->getInicialDePersonas());
     foreach ($rs as $rows) {
         $persona = $rows["codigo"];
         $xAml = new cAMLPersonas($persona);
         $xAml->init($persona, $rows);
         $riesgo = $xAml->setAnalizarNivelDeRiesgo();
         $NivelActual = $xAml->getOPersona()->getNivelDeRiesgo();
         if ($riesgo != $NivelActual) {
             if ($riesgo >= SYS_RIESGO_MEDIO) {
                 $xLog->add($xAml->getMessages(), $xLog->DEVELOPER);
             }
             if ($actualizar == true) {
                 $xAml->getOPersona()->setActualizarNivelDeRiesgo($riesgo, $xAml->getMessages());
             }
             $xLog->add($xAml->getOPersona()->getMessages(), $xLog->DEVELOPER);
         }
     }
     return $xLog->getMessages();
 }
 function setEditar($cuenta, $cargo = false, $abono = false, $referencia = false, $concepto = false, $diario = DEFAULT_CONTABLE_DIARIO_MVTOS)
 {
     $xLog = new cCoreLog();
     //,$NumMvto = false, $Fecha = false
     $xCta = new cCuentaContableEsquema($cuenta);
     $cuenta = $xCta->CUENTA;
     $rebuild = false;
     if ($cargo !== false) {
         $cargo = setNoMenorQueCero($cargo);
         if ($cargo != $this->mCargo) {
             $rebuild = true;
             $this->mCargo = $cargo;
             $this->mAbono = 0;
         }
     }
     $referencia = $referencia == false ? $this->mObj->referencia()->v(OUT_TXT) : $referencia;
     $concepto = $concepto == false ? $this->mObj->concepto()->v(OUT_TXT) : $concepto;
     if ($abono !== false) {
         $abono = setNoMenorQueCero($abono);
         if ($abono != $this->mAbono) {
             $rebuild = true;
             $this->mAbono = $abono;
             $this->mCargo = 0;
         }
     }
     if ($this->mNumeroCuenta != $cuenta) {
         $rebuild = true;
         $this->mNumeroCuenta = $cuenta;
     }
     //========================
     if ($rebuild == true) {
         //eliminar
         $this->setEliminar();
         //agregar
         $xPol = new cPoliza($this->mTipoDePoliza);
         $xPol->setPorCodigo($this->getCodigoDePoliza());
         $xPol->addMovimiento($this->mNumeroCuenta, $this->mCargo, $this->mAbono, $referencia, $concepto, $this->mNumeroDeMvto);
         $xLog->add($xPol->getMessages(), $xLog->DEVELOPER);
     } else {
         $sql = "UPDATE contable_movimientos\n\t\t\tSET referencia='{$referencia}', concepto='{$concepto}' \n\t\t\tWHERE clave_unica= " . $this->mCodigoUnico;
         $ql = new MQL();
         $ql->setRawQuery($sql);
     }
     $this->mMessages .= $xLog->getMessages();
     return $xLog->getMessages();
 }
ini_set("max_execution_time", 1600);
$key = isset($_GET["k"]) ? true : false;
$parser = !isset($_GET["s"]) ? false : $_GET["s"];
//Obtiene la llave del
//if ($key == MY_KEY) {
$messages = "";
$fechaop = parametro("f", fechasys());
$xF = new cFecha(0, $fechaop);
/**
 * Generar el Archivo HTMl del LOG
 * eventos-del-cierre + fecha_de_cierre + .html
 *
 */
$aliasFil = getSucursal() . "-eventos-al-cierre-de-colocacion-del-dia-{$fechaop}";
$xLog = new cFileLog($aliasFil);
$ql = new MQL();
$xRec = new cReciboDeOperacion(12);
$xRec->setGenerarPoliza();
$xRec->setForceUpdateSaldos();
$idrecibo = $xRec->setNuevoRecibo(DEFAULT_SOCIO, DEFAULT_CREDITO, $fechaop, 1, 12, "CIERRE_DE_COLOCACION_{$fechaop}", DEFAULT_CHEQUE, DEFAULT_TIPO_PAGO, DEFAULT_RECIBO_FISCAL, DEFAULT_GRUPO);
$xRec->setNumeroDeRecibo($idrecibo);
$messages .= "=======================================================================================\r\n";
$messages .= "=========================\t\t" . EACP_NAME . " \r\n";
$messages .= "=========================\t\t" . getSucursal() . " \r\n";
$messages .= "=======================================================================================\r\n";
$messages .= "=========================\t\tINICIANDO EL CIERRE DE COLOCACION ====================\r\n";
$messages .= "=========================\t\tRECIBO: {$idrecibo}\t\t\t\t   ====================\r\n";
//reconstruir db de pagos
$ql->setRawQuery("CALL `proc_historial_de_pagos` ");
$xCUtils = new cUtileriasParaCreditos();
$messages .= $xCUtils->setEstatusDeCreditos($idrecibo, $fechaop, false, true);
//=====>	INICIO_H
include_once "../core/go.login.inc.php";
include_once "../core/core.error.inc.php";
include_once "../core/core.html.inc.php";
include_once "../core/core.init.inc.php";
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
//=====================================================================================================
$xInit = new cHPage("", HP_SERVICE);
$txt = "";
$ql = new MQL();
$lis = new cSQLListas();
$xF = new cFecha();
$tabla = parametro("tabla", false, MQL_RAW);
$clave = parametro("id", false, MQL_RAW);
$rs = array();
//AND MODO_DEBUG == true
if ($tabla != false and $clave != false) {
    $xObj = new cSAFETabla($tabla);
    if ($xObj->obj() == null) {
        $rs["message"] = "ERROR\tAl eliminar el Registro con ID {$clave} en la Tabla {$tabla}\r\n";
        $rs["error"] = true;
    } else {
        $obj = $xObj->obj();
        $key = $obj->getKey();
        $obj = new cSocios_aeconomica();