function Common_c8581154ac4e27cb0e122d71341dd7d8($strCmd)
{
    $DPar = explode(STD_LITERAL_DIVISOR, $strCmd);
    $xTip = new cTipos();
    //
    $socio = $xTip->cInt($DPar[0]);
    $cuenta = $xTip->cInt($DPar[1]);
    $deposito = $xTip->cFloat($DPar[2]);
    $retiro = $xTip->cFloat($DPar[3]);
    $nota = $xTip->cChar($DPar[4]);
    $numero = $xTip->cInt($DPar[5]);
    $limit = $xTip->cInt($DPar[6]);
    if (isset($_SESSION["recibo_en_proceso"])) {
        $recibo = $_SESSION["recibo_en_proceso"];
        $fecha = fechasys();
        $_SESSION["total_recibo_en_proceso"] += $deposito - $retiro;
        $xRec = new cReciboDeOperacion(200, false, $recibo);
        $xRec->setNumeroDeRecibo($recibo, true);
        $DRec = $xRec->getDatosInArray();
        $cheque = $DRec["cheque_afectador"];
        $tipopago = $DRec["tipo_pago"];
        $recibofiscal = $DRec["recibo_fiscal"];
        if ($deposito > 0 or $retiro > 0) {
            $xC = new cCuentaALaVista($cuenta);
            $grupo = DEFAULT_GRUPO;
            $xC->setSocioTitular($socio);
            $xC->setReciboDeOperacion($recibo);
            if ($deposito > 0) {
                $xC->setDeposito($deposito, $cheque, $tipopago, $recibofiscal, $nota, $grupo, $fecha, $recibo);
            }
            if ($retiro > 0) {
                $xC->setRetiro($retiro, $cheque, $tipopago, $recibofiscal, $nota, $grupo, $fecha, $recibo);
            }
        }
        if ($numero == $limit) {
            $xRec->setForceUpdateSaldos();
            $xRec->setFinalizarRecibo(true);
            //$MsgEnd		.= "**** proceso terminado ****";
        }
    }
    //retorna el id del control de origen para neutralizar
    return "-{$numero}";
}
/**
 * Funcion que obtiene el Nombre del socio
 *
 * @param integer $params
 * @return string
 */
function Common_695bad33e1f2af343f99c6a4ceb9d045($params)
{
    $nombre = MSG_NO_PARAM_VALID;
    $xT = new cTipos();
    $socio = $xT->cInt($params);
    $xSoc = new cSocio($socio);
    if ($xSoc->existe($socio) == true) {
        $xSoc->init();
        $nombre = $xSoc->getNombreCompleto(OUT_TXT);
    }
    return $nombre;
}
 function getTelMovil($telefono)
 {
     $xT = new cTipos();
     $tel = $xT->cInt($telefono);
     $tm = strlen($tel);
     if (MODO_DEBUG == true) {
         $this->mMessages .= "WARN\tTelefono {$telefono} longitud {$tm}\r\n";
     }
     switch (EACP_CLAVE_DE_PAIS) {
         case "MX":
             switch ($tm) {
                 case 13:
                     $tel = substr($tel, -10);
                     break;
                 case 12:
                     $tel = null;
                     $this->mValido = false;
                     break;
                 case 10:
                     break;
                 case 7:
                     $tel = null;
                     $this->mValido = false;
                     break;
                 default:
                     $tel = null;
                     $this->mValido = false;
                     break;
             }
             //10 98164 == 7
             //981 10 98164 == 10
             //044 981 10 98164 == 13
             //01 981 10 98164 == 12
             if ($tel != null) {
                 $tel = "52{$tel}";
             }
             break;
     }
     return $tel;
 }
 //$bufer			= stream_get_line($gestor, "\r\n");
 if (!isset($bufer)) {
     $msg .= "La Linea({$iReg}) no se leyo({$bufer})\r\n";
 }
 $socio = DEFAULT_SOCIO;
 $credito = DEFAULT_CREDITO;
 $letras = 0;
 $capital = 0;
 $interes = 0;
 $ahorro = 0;
 $iva = 0;
 $cls = '';
 $observaciones = "";
 $cadena = explode(",", trim($bufer), 8);
 //Depurar
 $socio = $xT->cInt($cadena[0]);
 $credito = $xT->cInt($cadena[1]);
 $letra = $xT->cInt($cadena[2]);
 $capital = round($xT->cFloat($cadena[3]), 2);
 $interes = round($xT->cFloat($cadena[4]), 2);
 $iva = round($xT->cFloat($cadena[5]), 2);
 $ahorro = round($xT->cFloat($cadena[6]), 2);
 $observaciones = $xT->cChar($cadena[7]);
 $total = $capital + $ahorro + $interes + $iva;
 if (isset($socio) and isset($credito) and !empty($socio) and !empty($credito)) {
     $DSoc = new cSocio($socio);
     $SocioExiste = $DSoc->existe($socio);
     $CreditoExiste = $DSoc->existeCredito($credito);
     if ($SocioExiste == true and $CreditoExiste == true) {
         $DSoc->init();
         $nombre = $DSoc->getNombreCompleto();
                $gestor = @fopen($completePath, "r");
                $iReg = 0;
                $cT = new cTipos();
                //inicializa el LOG del proceso
                $aliasFil = getSucursal() . "-carga -batch-de-socios-" . fechasys();
                $xLog = new cFileLog($aliasFil, true);
                if ($gestor) {
                    while (!feof($gestor)) {
                        $bufer = fgets($gestor, 4096);
                        //$bufer			= stream_get_line($gestor, "\r\n");
                        if (!isset($bufer)) {
                            $msg .= "{$iReg}\t\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
                        } else {
                            $bufer = trim($bufer);
                            $datos = explode(",", $bufer, 6);
                            $socio = $cT->cInt($datos[0]);
                        }
                        $iReg++;
                    }
                }
                fclose($gestor);
                $xLog->setWrite($msg);
                echo $xLog->getLinkDownload("Archivo del proceso");
            } else {
                echo "<p class='aviso'>EL TIPO DE ARCHIVO DE " . $usrFiles[$i]['name'] . "(" . $mExt . ") NO SE ACEPTA</p>";
            }
        }
    }
}
if (!isset($iReg)) {
    $iReg = 0;
 function setCambiarPeriocidad($NuevaPeriocidad, $nuevosPagos = false, $formaPago = false, $fecha = false)
 {
     $pagos = $this->getPagosAutorizados();
     $periocidad = $this->getPeriocidadDePago();
     $dias = $this->getDiasAutorizados();
     $formaPago = $formaPago == false ? $this->getFormaDePago() : $formaPago;
     $pagoActual = $this->getPeriodoActual();
     $cT = new cTipos();
     $xF = new cFecha();
     $msg = "";
     $success = true;
     $nuevosDias = $nuevosPagos == false ? $dias : $NuevaPeriocidad * $nuevosPagos;
     $nuevosPagos = $nuevosPagos == false ? $cT->cInt($dias / $NuevaPeriocidad) : $nuevosPagos;
     //cuadrar periodo actual
     if ($NuevaPeriocidad > $periocidad) {
         //15 > 7 ? 15/7 :: 7 24/1
         $factoria = $NuevaPeriocidad / $periocidad;
         $pagoActual = $cT->cInt($pagoActual / $factoria);
     }
     if ($NuevaPeriocidad < $periocidad) {
         //30 > 15 :: 30/5 = 2
         $factoria = $periocidad / $NuevaPeriocidad;
         $pagoActual = $cT->cInt($pagoActual * $factoria);
     }
     $xConv = new cProductoDeCredito($this->getClaveDeProducto());
     $DConv = $xConv->obj();
     if ($NuevaPeriocidad == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
         $nuevosPagos = SYS_UNO;
         $formaPago = CREDITO_TIPO_PAGO_UNICO;
         if ($fecha != false) {
             $nuevosDias = $xF->setRestarFechas($fecha, $this->getFechaDeMinistracion());
         } else {
             $nuevosDias = $this->getDiasAutorizados();
         }
     }
     if ($nuevosDias > $DConv->dias_maximo()->v()) {
         //sucees false
         $success = false;
         $msg .= "ERROR\\Periocidad Limitada a Maximo de dias\r\n";
     }
     $fechaVencmiento = $xF->setSumarDias($nuevosDias, $this->getFechaDeMinistracion());
     if ($success == true) {
         if ($this->isAFinalDePlazo() == false) {
             //eliminar plan de pagos
             $idPlan = $this->getNumeroDePlanDePagos();
             if ($idPlan > 0) {
                 $xPlan = new cReciboDeOperacion(false, true, $idPlan);
                 $xPlan->init();
                 $xPlan->setRevertir(true);
                 $msg .= $xPlan->getMessages();
             }
         }
         //actualizar credito
         $this->setUpdate(array($this->obj()->dias_autorizados()->get() => $nuevosDias, $this->obj()->plazo_en_dias()->get() => $nuevosDias, $this->obj()->periocidad_de_pago()->get() => $NuevaPeriocidad, $this->obj()->pagos_autorizados()->get() => $nuevosPagos, $this->obj()->fecha_vencimiento()->get() => $fechaVencmiento, $this->obj()->fecha_vencimiento_dinamico()->get() => $fechaVencmiento, $this->obj()->tipo_de_pago()->get() => $formaPago, $this->obj()->ultimo_periodo_afectado()->get() => $pagoActual));
         $this->init();
         $msg .= $this->setReestructurarIntereses();
     }
     $this->mMessages .= $msg;
     return $msg;
 }
if ($xCaja->getEstatus() == TESORERIA_CAJA_CERRADA) {
    $xHP->goToPageError(200);
}
$xHP->init();
$xFRM = new cHForm("frmmultas", "frmcobrodemultas.php?action=" . MQL_ADD);
if ($action == SYS_NINGUNO) {
    $xFRM->addPersonaBasico();
    $xFRM->ODate("idfechaactual", false, "TR.Fecha de cobro");
    $xFRM->addCobroBasico();
    $xFRM->OText("idconceptomulta", "", "TR.Concepto de Multa");
    $xFRM->OMoneda("idmontomulta", 0, "TR.Monto de Multa", true);
    $xFRM->addGuardar();
} else {
    $xT = new cTipos();
    //===========================================================================
    $idsocio = isset($_POST["idsocio"]) ? $xT->cInt($_POST["idsocio"]) : 0;
    $observaciones = isset($_POST["idconceptomulta"]) ? $xT->cChar($_POST["idconceptomulta"]) : "";
    $monto = isset($_POST["idmontomulta"]) ? $xT->cFloat($_POST["idmontomulta"]) : 0;
    $cheque = isset($_POST["cheque"]) ? $xT->cChar($_POST["cheque"]) : DEFAULT_CHEQUE;
    $comopago = isset($_POST["ctipo_pago"]) ? $xT->cChar($_POST["ctipo_pago"]) : DEFAULT_TIPO_PAGO;
    $foliofiscal = isset($_POST["foliofiscal"]) ? $xT->cChar($_POST["foliofiscal"]) : DEFAULT_RECIBO_FISCAL;
    if (setNoMenorQueCero($idsocio) <= 0) {
        //header("location: frmcobrodemultas.php?msg=FALTAN_DATOS");
        $xFRM->addAvisoRegistroError();
    } else {
        if (setNoMenorQueCero($monto) <= 0) {
            $xFRM->addAvisoRegistroError();
        } else {
            $iddocto = DEFAULT_CREDITO;
            $xRec = new cReciboDeOperacion(RECIBOS_TIPO_TERCEROS, false, false);
            $xRec->setGenerarBancos();
 $gestor = @fopen($completePath, "r");
 $iReg = 0;
 $cT = new cTipos();
 //inicializa el LOG del proceso
 $aliasFil = getSucursal() . "-carga-batch-de-inversiones-" . fechasys();
 $xLog = new cFileLog($aliasFil, true);
 if ($gestor) {
     while (!feof($gestor)) {
         $bufer = fgets($gestor, 4096);
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "{$iReg}\t\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
         } else {
             $bufer = trim($bufer);
             $datos = explode(",", $bufer, 6);
             $socio = $cT->cInt($datos[0]);
             $importe = $cT->cFloat($datos[1]);
             $fechaApertura = $cT->cFecha($datos[2]);
             $plazo = $cT->cInt($datos[3]);
             $tasa = $cT->cFloat($datos[4]);
             $observaciones = $cT->cChar($datos[5]);
             $ClaveCuenta = false;
             //Iniciar el Socio
             //$msg .= "$iReg\t$socio\tERROR_SOCIO\t$socio -- $importe -- $fechaApertura -- $plazo -- $tasa -- $observaciones\r\n";
             $xCL = new cCajaLocal(99);
             if ($xCL->getExistenciaSocio($socio) <= 0) {
                 $msg .= "{$iReg}\t{$socio}\tERROR_SOCIO\tLa Linea({$iReg}) no se leyo por que no existe el socio({$bufer})\r\n";
             } else {
                 $xInv = new cCuentaInversionPlazoFijo(false, $socio, $plazo, $tasa, $fechaApertura);
                 //Agrega la Cuenta
                 $ClaveCuenta = $xInv->setNuevaCuenta(99, 2, $socio, $observaciones, DEFAULT_CREDITO, "", "", DEFAULT_GRUPO, $fechaApertura, CAPTACION_TIPO_PLAZO, 99, $plazo, $tasa);
 $observaciones = isset($DDATA["idobservaciones"]) ? $DDATA["idobservaciones"] : "";
 $xFil = new cFileImporter();
 $xFil->setCharDelimiter("|");
 //var_dump($_FILES["f1"]);
 if ($xFil->processFile($doc1) == true) {
     $data = $xFil->getData();
     $linea = 0;
     foreach ($data as $valores => $cont) {
         //
         if ($linea == 0) {
         } else {
             $idlocalidad = $cont[0];
             $nombrelocal = $xT->setNoAcentos($cont[1]);
             $estadolocal = $cont[2];
             $paislocal = $cont[3];
             $idestadoloc = $xT->cInt($cont[4]);
             //cosulta de pais
             $municipio = EACP_CLAVE_DE_MUNICIPIO;
             $estado = EACP_CLAVE_DE_ENTIDADFED;
             if (setNoMenorQueCero($idestadoloc) == 0) {
                 $D = obten_filas("SELECT * FROM general_estados WHERE nombre LIKE '%{$estadolocal}%' LIMIT 0,1");
                 if (isset($D["clave_numerica"])) {
                     $idestadoloc = $D["clave_numerica"];
                 }
             }
             //calcular pais
             $D = obten_filas("SELECT * FROM `personas_domicilios_paises` WHERE `nombre_oficial` LIKE '%{$paislocal}%' LIMIT 0,1");
             if (isset($D["clave_de_control"])) {
                 $paislocal = $D["clave_de_control"];
             } else {
                 $paislocal = EACP_CLAVE_DE_PAIS;
 //analizar el Archivo
 $gestor = @fopen($completePath, "r");
 $iReg = 0;
 if ($gestor) {
     //eliminar los datos diferentes a la actual sucursal
     while (!feof($gestor)) {
         $bufer = fgets($gestor, 4096);
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "La Linea({$iReg}) no se leyo({$bufer})\r\n";
         } else {
             $datos = explode(",", trim($bufer), 3);
             $cuenta = trim($datos[0]);
             $DCuenta = explode("-", $cuenta);
             $saldoCW = $cT->cFloat(trim($datos[2]), 2);
             $socioCW = $cT->cInt(trim($DCuenta[5]), true);
             //$msg		.= "COMPACW\tSaldo $saldoCW SOCIO $socioCW\r\n";
             $aCompacW[$socioCW] += $saldoCW;
             $aCompacWC[$socioCW] .= "{$cuenta}\t{$saldoCW}\t";
         }
         $iReg++;
     }
 }
 fclose($gestor);
 foreach ($aCompacW as $key => $value) {
     $socio = $cT->cInt($key, true);
     $sdoCW = $cT->cFloat($value);
     //Filtrar por sucursal
     $xSoc = new cSocio($socio);
     if ($xSoc->existe($socio) == true) {
         switch ($TipoDeImportacion) {
 //var_dump($_FILES["f1"]);
 if ($xFil->processFile($doc1) == true) {
     $data = $xFil->getData();
     $linea = 0;
     foreach ($data as $valores => $cont) {
         //
         if ($linea == 0) {
         } else {
             //0clave_interna	1clave_de_actividad	2nombre_de_la_actividad
             //3descripcion_detallada	4productos	5clasificacion	6clave_de_superior
             //7nivel_de_riesgo	8califica_para_pep
             $idactividad = $cont[0];
             $nombre = $xT->setNoAcentos($cont[2]);
             $claveuif = $xT->cSerial(7, $cont[1]);
             $esPep = setNoMenorQueCero($cont[8]);
             $riesgo = $xT->cInt($cont[7]);
             $xAct = new cPersonas_actividad_economica_tipos();
             //eliminar primero
             $xAct->query()->setRawQuery("DELETE FROM personas_actividad_economica_tipos WHERE clave_interna={$idactividad}");
             //asignar valores
             $xAct->califica_para_pep($esPep);
             $xAct->clasificacion("CLASE");
             $xAct->clave_de_actividad($claveuif);
             $xAct->clave_de_superior(0);
             $xAct->clave_interna($idactividad);
             $xAct->descripcion_detallada($nombre);
             $xAct->nivel_de_riesgo($riesgo);
             $xAct->nombre_de_la_actividad($nombre);
             $xAct->productos("");
             /*$xLoc->altitud(0);
             		$xLoc->clave_de_estado($idestadoloc);
 }
 while (!feof($gestor)) {
     $bufer = fgets($gestor, 4096);
     //$bufer			= stream_get_line($gestor, "\r\n");
     if (!isset($bufer)) {
         $msg .= "La Linea({$iReg}) no se leyo({$bufer})\r\n";
     } else {
         $datos = explode(",", trim($bufer), 3);
         $cuenta = trim($datos[0]);
         $nombre = strtoupper(trim($datos[1]));
         $estatus = $arrEstatus[substr($cuenta, 0, 6)];
         $TCuenta = isset($arrTCuenta[substr($cuenta, 0, 12)]) ? $arrTCuenta[substr($cuenta, 0, 12)] : 0;
         $monto = $cT->cFloat(trim($datos[2]));
         $modalidad = 1;
         $aDCuenta = explode("-", $cuenta);
         $socio = $cT->cInt($aDCuenta[5]);
         $sucursal = mifila("SELECT sucursal FROM socios_general WHERE codigo = {$socio} LIMIT 0,1 ", "sucursal");
         if ($sucursal != getSucursal()) {
             $sucursal = "otra";
         }
         //1-3-01-02
         if (substr($cuenta, 7, 2) == "02") {
             $modalidad = 3;
         }
         if ($monto > 0 and $socio != 0) {
             if ($TipoDeImportacion == "credito") {
                 $sqlD = "DELETE FROM sisbancs_temp_creditos WHERE cuenta_contable = '{$cuenta}' ";
                 my_query($sqlD);
                 //
                 if ($socio != 0) {
                     $sqlI = "INSERT INTO sisbancs_temp_creditos(numero_de_socio, cuenta_contable, nombre,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\testatus, modalidad, saldo, sucursal)\n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES({$socio}, '{$cuenta}', '{$nombre}', {$estatus}, {$modalidad} , {$monto}, '{$sucursal}') ";
 function __construct($codigo_de_socio, $init = false)
 {
     $xT = new cTipos();
     $this->mCodigo = $xT->cInt($codigo_de_socio);
     if ($init == true) {
         $this->init();
     }
     $this->mUsuarioActual = getUsuarioActual();
 }
 $cT = new cTipos();
 if ($gestor) {
     while (!feof($gestor)) {
         $bufer = $cT->setNoAcentos(fgets($gestor, 4096));
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "La Linea({$iReg}) no se leyo({$bufer})\r\n";
             $msg .= "DEL\tSe Eiminan todas las Colonias\r\n";
         } else {
             $datos = explode("|", $bufer, 16);
             $cpostal = $datos[0];
             $ncolonia = $cT->cChar($datos[1]);
             $tcolonia = $cT->cChar($datos[2]);
             $estado = $cT->cChar($datos[4]);
             $municipio = $cT->cChar($datos[3]);
             $numEstado = $cT->cInt($datos[7]);
             $ciudad = $cT->cChar($datos[5]);
             if (trim($ciudad) == "") {
                 $ciudad = $ncolonia;
             }
             $numMunicipio = $cargaGlobal == 1 ? $cT->cInt($datos[11]) : $cT->cInt($datos[10]);
             $fecha = fechasys();
             $sucursal = getSucursal();
             $sql = "INSERT INTO general_colonias(codigo_postal, nombre_colonia, tipo_colonia,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\testado_colonia, ciudad_colonia, municipio_colonia,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfecha_de_revision,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcodigo_de_estado, codigo_de_municipio, sucursal)\n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES({$cpostal}, '{$ncolonia}', '{$tcolonia}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$estado}', '{$ciudad}', '{$municipio}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fecha}', {$numEstado}, {$numMunicipio}, '{$sucursal}')";
             $sqDC = "DELETE FROM general_colonias WHERE codigo_postal = {$cpostal} AND fecha_de_revision != '{$fecha}' ";
             if ($cpostal != 0 and trim($ncolonia) != "") {
                 if ($EliminarDatos == 0) {
                     // si es falso, eliminar individualmente, modo actualizar
                     $xd = my_query($sqDC);
                     $msg .= $xd["info"] . "\r\n";
                 }
 function getPurgueTel($valor)
 {
     $xT = new cTipos();
     $valor = strtoupper($valor);
     $valor = str_replace(".", "", $valor);
     if (strpos($valor, "EXT") !== false) {
         $d = explode("EXT", $valor);
         $this->mTelefono = $xT->cInt($d[0]);
         $this->mTelefonoExt = $xT->cInt($d[1]);
     } else {
         $this->mTelefono = $xT->cInt($valor);
     }
     if (strlen($this->mTelefono) <= 5) {
         $this->mTelefono = "";
         $this->mTelefonoExt = "";
     }
 }
 $iReg = 0;
 $cT = new cTipos();
 //inicializa el LOG del proceso
 $aliasFil = getSucursal() . "-carga-batch-de-vista-" . fechasys();
 $xLog = new cFileLog($aliasFil, true);
 if ($gestor) {
     while (!feof($gestor)) {
         $bufer = fgets($gestor, 4096);
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "{$iReg}\t\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
         } else {
             $bufer = trim($bufer);
             $datos = explode(",", $bufer, 6);
             //numero de socio //[numero de cuenta] //[FechaDeApertura] //[clave de producto] //saldo //[observaciones]
             $socio = $cT->cInt($datos[0]);
             $NumCuenta = $cT->cInt($datos[1]);
             $fechaApertura = $cT->cFecha($datos[2]);
             $Producto = $cT->cInt($datos[3]);
             $importe = $cT->cFloat($datos[4]);
             $observaciones = $cT->cChar($datos[5]);
             if ($NumCuenta == 0 or $NumCuenta == "") {
                 $NumCuenta = false;
             }
             //$ClaveCuenta	= false;
             //Iniciar el Socio
             //$msg .= "$iReg\t$socio\tERROR_SOCIO\t$socio -- $importe -- $fechaApertura -- $plazo -- $tasa -- $observaciones\r\n";
             $xCL = new cCajaLocal(99);
             if ($xCL->getExistenciaSocio($socio) <= 0) {
                 $msg .= "{$iReg}\t{$socio}\tERROR_SOCIO\tLa Linea({$iReg}) no se leyo por que no existe el socio. (" . substr($bufer, 0, 20) . ")\r\n";
             } else {
     //echo "<p class='aviso'> SE FALLO AL GUARDAR " . $usrFiles[$i]['name'] . "</p>";
 }
 //analizar el Archivo
 $gestor = @fopen($completePath, "r");
 $iReg = 0;
 $cT = new cTipos();
 if ($gestor) {
     while (!feof($gestor)) {
         $bufer = fgets($gestor, 4096);
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "{$iReg}\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
         } else {
             //layout : socio , nombre, monto, cuenta
             $datos = explode(",", trim($bufer), 4);
             $socio = $cT->cInt($datos[0]);
             $nombre = isset($datos[1]) ? $cT->cChar(trim($datos[1])) : "";
             $monto = isset($datos[2]) ? $datos[2] : 0;
             $cuenta = isset($datos[3]) ? $datos[3] : 0;
             if ($socio != 0 and $socio != 0) {
                 //
                 $xSoc = new cSocio($socio);
                 if ($xSoc->existe($socio) == false) {
                     //
                     $msg .= "{$iReg}\tERROR\t{$socio}\tEl Socio NO EXISTE\r\n";
                     $txt .= "{$socio},{$nombre},{$monto},{$cuenta},NO_EXISTE\r\n";
                 } else {
                     $xSoc->init();
                     $D = $xSoc->getDatosInArray();
                     $estatus = $cT->cInt($D["estatusactual"]);
                     //
 $iReg = 0;
 $cT = new cTipos();
 //inicializa el LOG del proceso
 $aliasFil = getSucursal() . "-carga -batch-de-creditos-" . fechasys();
 $xLog = new cFileLog($aliasFil, true);
 if ($gestor) {
     while (!feof($gestor)) {
         $bufer = fgets($gestor, 4096);
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "{$iReg}\t\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
         } else {
             $bufer = trim($bufer);
             $datos = explode("|", $bufer, 18);
             $xF = new cFecha();
             $socio = $cT->cInt($datos[1]);
             $credito = false;
             //$cT->cInt($datos[1]);
             $monto = $cT->cFloat($datos[8]);
             $periocidad = $cT->cInt($arrPeriodos[trim($datos[7])]);
             $pagos = $cT->cInt($datos[6]);
             $ministracion = $xF->getFechaISO($datos[10]);
             $fechaSolicitado = $xF->getFechaISO($datos[5]);
             $descDestino = $cT->cChar($datos[9]);
             $tasa = $cT->cFloat($datos[15]);
             $tasa = $tasa / 100;
             $dias = $periocidad * $pagos;
             $aplicacion = $cT->cChar($datos[17]) == "S" ? 501 : 100;
             $vencimiento = $xF->setSumarDias($dias, $ministracion);
             //$cT->cFecha($datos[5]);
             $saldo = $cT->cFloat($datos[11]);
 function __construct($numero_de_cuenta, $socio = 0, $dias_invertidos = 0, $tasa = false, $fecha = false)
 {
     $xT = new cTipos();
     $this->mNumeroCuenta = $xT->cInt($numero_de_cuenta);
     $xF = new cFecha();
     $socio = $xT->cInt($socio);
     if ($socio != 0) {
         $this->mSocioTitular = $socio;
     }
     $this->mFechaOperacion = $fecha == false ? fechasys() : $fecha;
     $tasa = $tasa == false ? 0 : $tasa;
     if (isset($numero_de_cuenta)) {
         $this->init();
         //Datos para Operar
         //Inicia los dias Invertidos y la Tasa de Interes
         $this->mDiasInvertidos = $dias_invertidos > 0 ? $dias_invertidos : $this->mDiasInvertidos;
         $this->mTasaInteres = $tasa > 0 ? $tasa : $this->mTasaInteres;
         //Asigna la fecha de Vencimiento
         $this->mFechaVencimiento = $dias_invertidos > 0 ? sumardias($this->mFechaOperacion, $this->mDiasInvertidos) : $this->mFechaVencimiento;
         //Array de estatus no permitidos para operar
         $this->mEstatusNoOperativos = array(20, 30, 31);
     }
     //vuelve a verificar los datos, despues de iniciar las cuentas
     $this->mDiasInvertidos = (!isset($this->mDiasInvertidos) or $this->mDiasInvertidos == false) ? 0 : $this->mDiasInvertidos;
     $this->mTasaInteres = (!isset($this->mTasaInteres) or $this->mTasaInteres == false) ? 0 : $this->mTasaInteres;
     //Asigna la fecha de Vencimiento
     $this->mFechaVencimiento = (!isset($this->mFechaVencimiento) or $this->mFechaVencimiento == false) ? fechasys() : $this->mFechaVencimiento;
 }
 function setRestore($Fecha = false)
 {
     $gestor = @fopen(PATH_BACKUPS . "safeosms-permissions-" . getSucursal() . "-{$Fecha}.sbk", "r");
     $msg = "";
     $iReg = 0;
     $cT = new cTipos();
     if ($gestor) {
         while (!feof($gestor)) {
             $bufer = fgets($gestor, 4096);
             if (!isset($bufer)) {
                 $msg .= "{$iReg}\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
             } else {
                 $bufer = trim($bufer);
                 $datos = explode("|", $bufer, 2);
                 $indice = $cT->cInt($datos[0]);
                 if ($indice != 0) {
                     $perms = html_entity_decode($datos[1]);
                     $sql = "UPDATE general_menul SET menu_rules = \"{$perms}\" WHERE idgeneral_menu = {$indice} ";
                     $msg .= "Cargando el Indice {$indice} con Permisos ({$perms})\r\n";
                     my_query($sql);
                 }
             }
             $iReg++;
         }
     }
     @fclose($gestor);
     $this->mMessages .= $msg;
     return $msg;
 }
 $xCred->init();
 $fecha_operacion = $xCred->getFechaDeMinistracion();
 if ($xCred->getNumeroDePlanDePagos() != false) {
     $xPlan->init($xCred->getNumeroDePlanDePagos());
     $xPlan->setEliminar();
 }
 $xPlan->initByCredito($credito);
 $xPlan->setClaveDeCredito($credito);
 $xPlan->setClaveDePersona($xCred->getClaveDePersona());
 $idrecibo = $xPlan->add($observaciones, $fecha_operacion);
 $xPlan->init($idrecibo);
 foreach ($data as $valores => $cont) {
     //periodo 	fecha 	saldo_inicial 	intereses 	impuesto 	capital 	pago_total 	saldo_final
     //0		1	2		3		4		5		6		7
     //Periodo,Fecha de Pago,Saldo inicial,Intereses,Impuesto,Pago a Capital,Pago Total,Saldo final
     if ($xT->cInt($cont[0]) > 0) {
         $interes = $xT->cFloat($cont[3], 2);
         $fecha = $xF->getFechaISO($cont[1]);
         $periodo = $xT->cInt($cont[0]);
         $capital = $xT->cFloat($cont[5], 2);
         $total_parcial = $xT->cFloat($cont[6], 2);
         $saldo_inicial = $xT->cFloat($cont[2], 2);
         $saldo_final = $xT->cFloat($cont[7], 2);
         $xPlan->setMontoOperado($total_parcial);
         $xPlan->setSaldoInicial($saldo_inicial);
         $xPlan->setSaldoFinal($saldo_final);
         $xPlan->addMvtoDeInteres($interes, $fecha, $periodo);
         $xPlan->addMvtoDeIVA($fecha, $periodo);
         $xPlan->addMvtoDeCapital($capital, $fecha, $periodo);
     } else {
         $msg .= "WARN\tLINEA OMITIDA\r\n";
function JScheckSaldoCuenta($cuenta)
{
    $xT = new cTipos();
    $cuenta = $xT->cInt($cuenta);
    $cuenta = getCuentaCompleta($cuenta);
    $stpeval = "\n\t\tsetEliminarCuenta();\n\t\t";
    $cuenta = cuenta_completa($cuenta);
    $sql_CMvto = "SELECT SUM(importe) AS 'neto' FROM contable_movimientos WHERE numerocuenta = {$cuenta}";
    $sql_CSup = "SELECT COUNT(subcuenta) AS 'ctas' FROM contable_catalogorelacion WHERE cuentasuperior={$cuenta}";
    $subcuentas = mifila($sql_CSup, "ctas");
    $saldo = mifila($sql_CMvto, "neto");
    if ($saldo > 0) {
        $stpeval = "alert(\"     La Cuenta Tiene Movimientos     \\n \" +\n\t\t\t  \"       por un Monto de {$saldo}      \\n \" +\n\t\t\t  \" Las Cuentas con saldo No se eliminan\");\t";
    }
    if ($subcuentas > 0) {
        $stpeval = "alert(\"    La Cuenta Tiene {$subcuentas} Subcuentas     \\n \" +\n\t\t\t  \" Las Cuentas con Subcuentas No se eliminan\");";
    }
    return $stpeval;
}
 function setUltimoCheque($cheque = 0, $CuentaBancaria = false)
 {
     $this->set($CuentaBancaria);
     $CuentaBancaria = $this->mCuenta;
     $documento = 1;
     $xT = new cTipos();
     $cheque = setNoMenorQueCero($cheque);
     if ($cheque <= 0) {
         //Obtiene el Cheque de un Conteo SQL
         $sql = "SELECT numero_de_documento\r\n\t\t\tFROM bancos_operaciones\r\n\t\t\tWHERE cuenta_bancaria = {$CuentaBancaria}\r\n\t\t\tORDER BY idcontrol ASC, fecha_expedicion ASC\r\n\t\t\tLIMIT 0,1";
         $documento = getFila($sql, "numero_de_documento");
         $documento = $xT->cInt($documento);
         $documento = $documento + 1;
     } else {
         $documento = $xT->cInt($cheque);
     }
     $sqlD = "UPDATE bancos_cuentas SET consecutivo_actual = {$documento}\r\n\t\tWHERE idbancos_cuentas = {$CuentaBancaria}";
     my_query($sqlD);
 }
function setAfectarSuperior($cuenta, $monto, $tipo = 1, $periodo = false, $ejercicio = false)
{
    $xTip = new cTipos();
    $myper = $xTip->cInt($periodo);
    if (!isset($ejercicio) or $ejercicio == false) {
        $ejercicio = EJERCICIO_CONTABLE;
    }
    if (!isset($periodo) or $periodo == false) {
        $periodo = EACP_PER_CONTABLE;
    }
    //$cuenta = str_replace(CDIVISOR, "", $cuenta);
    $cuenta = getCuentaCompleta($cuenta);
    //$cuenta = trim($cuenta);
    $ejer = $ejercicio;
    $myper = (int) $myper;
    for ($i = $myper; $i <= 14; $i++) {
        $sql_us = "UPDATE contable_saldos SET imp{$i}= (imp{$i} + ({$monto}))\tWHERE ejercicio={$ejer} AND cuenta={$cuenta} AND tipo={$tipo}";
        if ($i != 0) {
            my_query($sql_us);
        }
    }
    //afectar los periodos
    //5 = niveles del catalogo
    for ($i = 0; $i <= 5; $i++) {
        //Encuentra Superior
        $sql_as = "SELECT cuentasuperior\n\t\t\t\t\t\t\tFROM contable_catalogorelacion\n\t\t\t\t\t\t\tWHERE subcuenta={$cuenta} ";
        $dsup = getFilas($sql_as);
        $cta_superior = $dsup["cuentasuperior"];
        //14 = Numero de Periodos en la tabla de Contable Saldos
        if (isset($cta_superior)) {
            for ($i_ = $myper; $i_ <= 14; $i_++) {
                //
                $sql_us = "UPDATE contable_saldos SET imp{$i_} = (imp{$i_} + ({$monto}))\n\t\t\t\tWHERE ejercicio={$ejer}\n\t\t\t\tAND cuenta={$cta_superior}\n\t\t\t\tAND tipo={$tipo}";
                if (isset($cta_superior)) {
                    my_query($sql_us);
                }
                //saveError(2, 99, "$sql_us - $cta_superior - $i ");
            }
            if ($i != 5) {
                $cuenta = $cta_superior;
            }
        }
        //saveError(2, 99, "$sql_us - $sql_as -$cuenta - $cta_superior - $i ");
    }
    //return 0;
}
         if ($vl == "LATITUD") {
             $IDLatitud = $id;
         }
         if ($vl == "LONGITUD") {
             $IDLongitud = $id;
         }
         if ($vl == "ALTITUD") {
             $IDAltitud = $id;
         }
     }
 } else {
     //CVE_ENT,NOM_ENT,NOM_ABR,
     //CVE_MUN,NOM_MUN,
     //CVE_LOC,NOM_LOC,
     //LATITUD,LONGITUD,ALTITUD,CVE_CARTA,AMBITO,PTOT,PMAS,PFEM,VTOT
     $ClaveUnica = $xT->cInt($datos[$IDEntidad] . $datos[$IDMunicipio] . $datos[$IDLocalidad], true);
     $ClaveEntidad = $xT->cInt($datos[$IDEntidad], true);
     $claveMunicipio = $xT->cInt($datos[$IDMunicipio], true);
     $ClaveLocalidad = $xT->cInt($datos[$IDLocalidad], true);
     $NombreLocalidad = $xT->cChar($datos[$IDNombre]);
     //iconv("UTF-8", "ISO-8859-1", $datos[$IDNombre]);
     $latitud = $datos[$IDLatitud];
     $altitud = $datos[$IDAltitud];
     $longitud = $datos[$IDLongitud];
     $sql = "INSERT INTO catalogos_localidades(clave_unica, nombre_de_la_localidad, clave_de_estado, clave_de_municipio, clave_de_localidad, longitud, altitud, latitud) \n\t    \t\t\t\t\t\t\t\t\t\t\t\t\tVALUES({$ClaveUnica}, '{$NombreLocalidad}', {$ClaveEntidad}, {$claveMunicipio}, {$ClaveLocalidad}, '{$longitud}', '{$altitud}', '{$latitud}') ";
     if ($ClaveUnica != 0) {
         my_query($sql);
     }
     $msg .= "{$ClaveEntidad}\t{$claveMunicipio}\t{$ClaveLocalidad}\tAgregando la Localidad {$NombreLocalidad} con codigo {$ClaveUnica}\r\n";
 }
 $iReg++;
    $xFRM->addFootElement('<input type="hidden" name="MAX_FILE_SIZE" value="1024000">');
    echo $xFRM->get();
} else {
    $doc1 = isset($_FILES["f1"]) ? $_FILES["f1"] : false;
    $observaciones = isset($DDATA["idobservaciones"]) ? $DDATA["idobservaciones"] : "";
    $tipoimportacion = isset($DDATA["idtipoimportacion"]) ? $DDATA["idtipoimportacion"] : "SDN";
    $xFil = new cFileImporter();
    $limit = $tipoimportacion == "SDN" ? 12 : 6;
    $xFil->setLimitCampos($limit);
    $xFil->setCharDelimiter("|");
    $xFil->setType("PIP");
    //var_dump($_FILES["f1"]);
    if ($xFil->processFile($doc1) == true) {
        $data = $xFil->getData();
        foreach ($data as $valores => $cont) {
            $id = $xT->cInt($cont[0]);
            switch ($tipoimportacion) {
                case "SDN":
                    $xFil->setDataRow($cont);
                    /*
                    4149|"CAVIEDES CRUZ, Leonardo"|"individual"|"SDNT"|
                    -5  - 6  - 7  - 8  -  9 - 10 - 11
                    -0- |-0- |-0- |-0- |-0- |-0- |-0-
                    -12 
                    |"DOB 23 Nov 1952; Cedula No. 16593470 (Colombia); Passport AB151486 (Colombia); alt. Passport AC444270 (Colombia); alt. Passport OC444290 (Colombia)." 
                    					 * */
                    $tipo = $xT->cChar(str_replace('"', "", $cont[2]));
                    if ($id > 0) {
                        if ($tipo == "individual" or $tipo == "-0-") {
                            $xSoc = new cSocio($id);
                            $programa = strtoupper(str_replace('"', "", $cont[3]));
 $gestor = @fopen($completePath, "r");
 $iReg = 0;
 $cT = new cTipos();
 //inicializa el LOG del proceso
 $aliasFil = getSucursal() . "-carga -batch-de-creditos-" . fechasys();
 $xLog = new cFileLog($aliasFil, true);
 if ($gestor) {
     while (!feof($gestor)) {
         $bufer = fgets($gestor, 4096);
         //$bufer			= stream_get_line($gestor, "\r\n");
         if (!isset($bufer)) {
             $msg .= "{$iReg}\t\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
         } else {
             $bufer = trim($bufer);
             $datos = explode(",", $bufer, 12);
             $socio = $cT->cInt($datos[0]);
             $credito = $cT->cInt($datos[1]);
             $producto = $cT->cInt($datos[2]);
             $monto = $cT->cFloat($datos[3]);
             $ministracion = $cT->cFecha($datos[4]);
             $vencimiento = $cT->cFecha($datos[5]);
             $pagos = $cT->cInt($datos[6]);
             $periocidad = $cT->cInt($datos[7]);
             $saldo = $cT->cFloat($datos[8]);
             $UltimaOperacion = $cT->cFecha($datos[9]);
             $ContratoCorriente = $cT->cInt($datos[10]);
             if ($socio == 0) {
                 $msg .= "{$iReg}\t\tERROR\tLa Linea({$iReg}) no se leyo({$bufer})\r\n";
             } else {
                 $xCred = new cCredito();
                 //Crear Contrato corriente si el producto tiene ahorro
/**
 * Funcion que Guarda el Monto de la Parcialidad
 * @param string $params Indica los parametros a cruzar
 **/
function Common_1fff3ce8ffd3d2dfdee69fd04ba831ac($params)
{
    $stdDiv = STD_LITERAL_DIVISOR;
    $DPar = explode($stdDiv, $params, 2);
    $mFecha = new cFecha();
    //grupo
    $xTip = new cTipos();
    //
    $credito = $xTip->cInt($DPar[0]);
    //
    $pagos = $xTip->cInt($DPar[1]);
    $fecha_de_vencimiento = $xTip->cFecha($DPar[2]);
    $dias_autorizados = 0;
    $pagos_autorizados = 0;
    $convenio = 0;
    $saldo_actual = 0;
    $parcialidad = 0;
    $fecha_de_revision = $mFecha->get();
    $grupo = 0;
    $fecha_de_ministracion = 0;
    $contrato_corriente = 0;
    $sql = "UPDATE creditos_solicitud\n    SET\n        numero_pagos\t\t\t= {$pagos_autorizados},\n        fecha_vencimiento\t\t= '{$fecha_de_vencimiento}',\n        pagos_autorizados\t\t= {$pagos_autorizados},\n        saldo_actual\t\t\t= {$saldo_actual},\n        tipo_convenio\t\t\t= {$convenio},\n        ultimo_periodo_afectado\t\t= {$parcialidad},\n        grupo_asociado\t\t\t= {$grupo},\n        fecha_ministracion\t\t= '{$fecha_de_ministracion}',\n        contrato_corriente_relacionado={$contrato_corriente},\n        monto_parcialidad={$parcialidad},\n        fecha_revision='{$fecha_de_revision}',\n        /* tipo_de_pago= ,\n        tipo_de_calculo_de_interes=0,\n        causa_de_mora=0 */\n    WHERE\n    numero_solicitud={$credito}\n";
}
 function init($formato = false)
 {
     $xT = new cTipos();
     $fecha = $this->mFecha;
     $this->mCurrentAnno = $xT->cInt(date("Y", strtotime($fecha)), true);
     $this->mCurrentMonth = $xT->cInt(date("n", strtotime($fecha)), true);
     $this->mCurrentDay = $xT->cInt(date("j", strtotime($fecha)), true);
     $this->mDiasDelMes = $xT->cInt(date("t", strtotime($fecha)), true);
     $this->mCurrentWeekday = $xT->cInt(date("N", strtotime($fecha)), true);
     $this->mCurrentNumberWeek = $xT->cInt(date("W", strtotime($fecha)), true);
     $this->mFormat = $formato == false ? $this->mFormat : $formato;
 }
 function setReestructurarSDPM($SoloConSaldos = false, $credito = false, $forzarTodos = false, $fechaCorte = false, $fechaInicial = false, $EliminarTodo = true)
 {
     //FIXME: probar con saldo anterior
     $fechaCorte = $fechaCorte == false ? fechasys() : $fechaCorte;
     $msg = "";
     $wCredito1 = $credito != false ? "  `creditos_mvtos_asdpm`.`documento` = {$credito}" : " `documento` > 0 ";
     $wCredito2 = $credito != false ? "  numero_de_credito = {$credito} " : " numero_de_credito > 0";
     $ByRTM = $credito != false ? " " : " SQL_CACHE ";
     $wFecha1 = " AND (fecha >='{$fechaInicial}' AND fecha <='{$fechaCorte}' ) ";
     $wFecha2 = " AND (`fecha_actual` >= '{$fechaInicial}' AND `fecha_actual`<='{$fechaCorte}' ) ";
     $ql = new MQL();
     $arrEstatusD = array(OPERACION_CLAVE_MINISTRACION, 111, 114, 115);
     $arrEstatus = array(OPERACION_CLAVE_MINISTRACION => CREDITO_ESTADO_VIGENTE, 111 => CREDITO_ESTADO_VENCIDO, 114 => CREDITO_ESTADO_VIGENTE, 115 => CREDITO_ESTADO_MOROSO);
     //Eliminar el SDPM
     if ($EliminarTodo == true) {
         $DAction = $ql->setRawQuery("DELETE FROM creditos_sdpm_historico WHERE {$wCredito2} {$wFecha2} ");
         if (MODO_DEBUG == true) {
             $msg .= "WARN\tEliminando SDPM\r\n";
         }
     }
     if ($credito != false) {
         $ql->setRawQuery("DELETE FROM operaciones_mvtos WHERE docto_afectado={$credito} AND tipo_operacion = 420");
         if (MODO_DEBUG == true) {
             $msg .= "WARN\tEliminando Operaciones 420 del credito {$credito}\r\n";
         }
     }
     $msg .= "Socio\tCredito\tFecha\tMonto\tSaldo\tDias\tOperacion\tEstatus\tInteres\tMoratorios\r\n";
     //Generar saldos de credito por mes
     $sql = "SELECT {$ByRTM}\n\t\t`creditos_mvtos_asdpm`.`socio`,\n\t\t`creditos_mvtos_asdpm`.`documento`,\n\t\t`creditos_mvtos_asdpm`.`recibo`,\n\t\t`creditos_mvtos_asdpm`.`fecha`,\n\t\t`creditos_mvtos_asdpm`.`operacion`,\n\t\t`creditos_mvtos_asdpm`.`monto`,\n\t\t`creditos_mvtos_asdpm`.`afectacion`\n\t\tFROM `creditos_mvtos_asdpm`\tWHERE {$wCredito1} {$wFecha1} ";
     //setLog($sql);
     $rsM = $ql->getDataRecord($sql);
     $saldo = 0;
     $creditoA = 0;
     $xT = new cTipos();
     $xF = new cFecha();
     $FECHA_DE_ULTIMO_PAGO = "1998-01-01";
     $CREDITO_SALDO_ANTERIOR = 0;
     $MvtoAnterior = OPERACION_CLAVE_MINISTRACION;
     $ESTADO_ACTUAL = CREDITO_ESTADO_VIGENTE;
     $DIVISOR_DE_INTERESES = EACP_DIAS_INTERES;
     $DCred = array();
     $IsCredNew = true;
     $xCred = null;
     foreach ($rsM as $rw) {
         $socio = $xT->cInt($rw["socio"]);
         $credito = $xT->cInt($rw["documento"]);
         $fecha = $rw["fecha"];
         $nota = "";
         //
         $IsCredNew = true;
         if ($creditoA != $credito) {
             $saldo = 0;
             $FECHA_DE_ULTIMO_PAGO = $fecha;
             $ESTADO_ACTUAL = CREDITO_ESTADO_VIGENTE;
             $xCred = new cCredito($credito, $socio);
             $xCred->init();
             $DCred = $xCred->getDatosDeCredito();
             $CREDITO_SALDO_ANTERIOR = 0;
             //si es Ministracion
             if ($MvtoAnterior == OPERACION_CLAVE_MINISTRACION) {
                 $FECHA_DE_ULTIMO_PAGO = $xCred->getFechaDeMinistracion();
             }
             $msg .= "------------------------\tNUEVO_CREDITO : {$credito}------------------------------\r\n";
             if ($EliminarTodo == false) {
                 my_query("DELETE FROM creditos_sdpm_historico WHERE numero_de_credito = {$credito} {$wFecha2}");
             }
         } else {
             $IsCredNew = false;
         }
         $OProd = $xCred->getOProductoDeCredito();
         $recibo = $rw["recibo"];
         $operacion = $rw["operacion"];
         $afectacion = $rw["afectacion"];
         $monto = $xT->cFloat($rw["monto"], 2);
         $periocidad = $xCred->getPeriocidadDePago();
         $FechaVencimiento = $xCred->getFechaDeVencimiento();
         //(!isset( $DCred["fecha_vencimiento_dinamico"])) ? $xCred->getFechaDeVencimiento() : $DCred["fecha_vencimiento_dinamico"];
         $DiaInteresMax = $xF->setSumarDias(INTERES_DIAS_MAXIMO_A_DEVENGAR, $FechaVencimiento);
         $dias_transcurridos = $xF->setRestarFechas($fecha, $FECHA_DE_ULTIMO_PAGO);
         $saldo_calculado = $dias_transcurridos * $saldo;
         //No poner la afectacion
         $saldo += $xT->cFloat($monto * $afectacion, 2);
         // si es normal, calcular normal, si es mora: Calcular mora y normal, si es vencido: calcular normal y mora
         $interes = 0;
         $moratorio = 0;
         $TASA_NORMAL = $xCred->getTasaDeInteres();
         $TASA_MORA = $xCred->getTasaDeMora();
         $TIPO_DE_PAGO = $xCred->getTipoDePago();
         $PAGOS_SIN_CAPITAL = $xCred->getPagosSinCapital();
         $MONTO_ORIGINAL_DE_CREDITO = $xCred->getMontoAutorizado();
         $saldoBase = $xT->cFloat($saldo, 2);
         if ($operacion == OPERACION_CLAVE_PAGO_CAPITAL and $saldo == 0) {
             $saldoBase = $CREDITO_SALDO_ANTERIOR;
         }
         if ($MvtoAnterior == OPERACION_CLAVE_MINISTRACION) {
             $saldoBase = $CREDITO_SALDO_ANTERIOR;
             $saldo_calculado = $dias_transcurridos * $CREDITO_SALDO_ANTERIOR;
         }
         $SALDO_ACTUAL = $xCred->getSaldoActual();
         $BASE_NORMAL = $saldo_calculado;
         $BASE_MORA = $saldo_calculado;
         eval($OProd->getPreModInteres());
         //considerar si es un maximo de x dias devengar en vencidos
         switch ($ESTADO_ACTUAL) {
             case CREDITO_ESTADO_VIGENTE:
                 $interes = $BASE_NORMAL * $TASA_NORMAL / $DIVISOR_DE_INTERESES;
                 break;
             case CREDITO_ESTADO_VENCIDO:
                 //validar si tiene un maximo de dias transcurridos de devengado
                 if ($xF->getInt($fecha) <= $xF->getInt($DiaInteresMax)) {
                     $interes = $BASE_NORMAL * $TASA_NORMAL / $DIVISOR_DE_INTERESES;
                     $moratorio = $BASE_MORA * $TASA_MORA / $DIVISOR_DE_INTERESES;
                 } else {
                     $interes = 0;
                     $moratorio = 0;
                     $nota = "Despues del {$DiaInteresMax} no se acumula Interes, Vencimiento : {$FechaVencimiento}";
                 }
                 break;
             case CREDITO_ESTADO_MOROSO:
                 $interes = $BASE_NORMAL * $TASA_NORMAL / $DIVISOR_DE_INTERESES;
                 $moratorio = $BASE_MORA * $TASA_MORA / $DIVISOR_DE_INTERESES;
                 break;
         }
         //END_SWITCH
         $interes = $xT->cFloat($interes, 2);
         if ($periocidad == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
             $moratorio = $xT->cFloat($moratorio, 2);
             //0; //2012-04-10
         } else {
             //$moratorio			= 0;
         }
         eval($OProd->getPosModInteres());
         $msg .= "{$socio}\t{$credito}\t{$fecha}\t{$monto}\t{$saldo}\t{$dias_transcurridos}\t{$operacion}\t{$ESTADO_ACTUAL}\t{$interes}\t{$moratorio}\t{$nota}\r\n";
         if ($xF->getInt($fecha) <= $xF->getInt(SYS_FECHA_DE_MIGRACION)) {
             $interes = 0;
             $moratorio = 0;
             if (MODO_DEBUG == true) {
                 $msg .= "WARN\tOMITIR Interes {$interes} y MORA por {$moratorio} por estar antes de la migracion {$fecha}\r\n";
             }
         }
         if ($xF->getInt($fecha) <= $xF->getInt($fechaCorte)) {
             $msgSDPM = $xCred->addSDPM($interes, $moratorio, $FECHA_DE_ULTIMO_PAGO, $saldo, $ESTADO_ACTUAL, $fecha, $operacion, $saldo_calculado);
             //if(MODO_DEBUG == true){ $msg	.= $msgSDPM;	}
         }
         if ($saldo <= TOLERANCIA_SALDOS) {
             $msg .= "------------------------------------------------------\r\n";
         }
         $creditoA = $credito;
         $FECHA_DE_ULTIMO_PAGO = $fecha;
         $CREDITO_SALDO_ANTERIOR = $saldo;
         $MvtoAnterior = $operacion;
         /*
          * si existe la operacion de cambio de estatus, validar en el array, y actualizar el valor
          * Este estatus se aplicara en el siguiente
          */
         if (in_array($operacion, $arrEstatusD)) {
             $ESTADO_ACTUAL = $arrEstatus[$operacion];
         }
     }
     return $msg;
 }