function jsaGetNumeroDeCredito($idsocio)
{
    $xSoc = new cSocio($idsocio);
    $xSoc->init();
    $solicitud = $xSoc->getIDNuevoDocto(iDE_CREDITO);
    $tab = new TinyAjaxBehavior();
    $tab->add(TabSetValue::getBehavior('iidsolicitud', $solicitud));
    //tipo de credito y preferencia e pago
    //Mayo/2014
    $xEmp = new cEmpresas($xSoc->getClaveDeEmpresa());
    $xEmp->init();
    $tab->add(TabSetValue::getBehavior('idtipoconvenio', $xEmp->getProductoPref()));
    $tab->add(TabSetValue::getBehavior('idperiocidadpagos', $xEmp->getPeriocidadPref()));
    return $tab->getString();
}
function jsaSetDesvincularPersona($credito, $fecha, $observaciones)
{
    $msg = "";
    $xLng = new cLang();
    $xCred = new cCredito($credito);
    $xCred->init();
    $xdat = new cFecha(0);
    $fecha = $xdat->getFechaISO($fecha);
    $xCred->setResetPersonaAsociada($fecha, $observaciones);
    $oP = $xCred->getOPersona();
    $xEmp = new cEmpresas($xCred->getClaveDeEmpresa());
    $xEmp->init();
    $xRN = new cReglaDeNegocio();
    $xRN->setVariables(array("nombre_de_persona" => $oP->getNombreCompleto(), "mensaje" => $observaciones, "saldo_del_credito" => $xCred->getSaldoActual(), "nombre_de_la_empresa" => $xEmp->getNombreCorto()));
    $xRN->setExecuteActions($xRN->reglas()->RN_NOMINA_AL_DESVINCULAR);
    return $xLng->get(MSG_READY_SAVE);
}
function jsaGetPerfilDeProducto($producto, $persona)
{
    $OConv = new cProductoDeCredito($producto);
    $OConv->init();
    $tab = new TinyAjaxBehavior();
    $xSoc = new cSocio($persona);
    $pagos = $OConv->getNumeroPagosPreferente();
    $periocidad = $OConv->getPeriocidadPrefente();
    if ($xSoc->init() == true) {
        if ($xSoc->getClaveDeEmpresa() != FALLBACK_CLAVE_EMPRESA) {
            $xEmp = new cEmpresas($xSoc->getClaveDeEmpresa());
            $xEmp->init();
            $tab->add(TabSetValue::getBehavior('idproducto', $xEmp->getProductoPref()));
            $periocidad = $xEmp->getPeriocidadPref();
        }
    }
    $tab->add(TabSetValue::getBehavior('idnumerodepagos', $pagos));
    $tab->add(TabSetValue::getBehavior('idperiocidad', $periocidad));
    return $tab->getString();
}
function jsaGetEmpresa($empresa, $periocidad)
{
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $periodo = 0;
    $dias = 24 * 60;
    $xEmp->init();
    $ctrl = "<label for=\"idperiodo\">Periodo</label><input type=\"number\" id=\"idperiodo\" onchange=\"jsaGetMontoDelPeriodo()\" onblur=\"jsaGetMontoDelPeriodo()\" />";
    $xF = new cFecha(0);
    //$observaciones	.= " -- $periodo";
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $periodo = intval($xEmp->getPeriodo()) == 0 ? $periodo : intval($xEmp->getPeriodo());
    //$observaciones	.= "$fecha";
    switch ($periocidad) {
        case CREDITO_TIPO_PERIOCIDAD_SEMANAL:
            //buscar lunes
            $xSel = $xF->getSelectSemanas("idPeriodo", $periodo);
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onchange");
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onblur");
            $xSel->setEnclose(false);
            $ctrl = $xSel->get("idPeriodo", "Periodo", $periodo);
            break;
        case CREDITO_TIPO_PERIOCIDAD_QUINCENAL:
            $xSel = $xF->getSelectQuincenas("idPeriodo", $periodo);
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onchange");
            $xSel->addEvent("jsaGetMontoDelPeriodo()", "onblur");
            $xSel->setEnclose(false);
            $ctrl = $xSel->get("idPeriodo", "Periodo", $periodo);
            break;
        case CREDITO_TIPO_PERIOCIDAD_CATORCENAL:
            break;
        case CREDITO_TIPO_PERIOCIDAD_DECENAL:
            break;
    }
    return $ctrl;
}
function jsaGetDatosEmpresa($dependencia)
{
    //verificar si existe en la BD
    $Emp = new cEmpresas($dependencia);
    $idpersona = $Emp->getClaveDePersona();
    $Emp->init();
    $telefono = $Emp->getTelefono();
    $domicilio = $Emp->getDomicilio();
    $razon = $Emp->getNombre();
    $tab = new TinyAjaxBehavior();
    $tab->add(TabSetValue::getBehavior('idtelefono', $telefono));
    //$tab->add(TabSetValue::getBehavior('iddomiciliodeactividad', $domicilio));
    $tab->add(TabSetValue::getBehavior('idrazonsocialtrabajo', $razon));
    $xSoc = $Emp->getOPersona();
    //$xSoc		= new cSocio();
    if ($xSoc == null) {
    } else {
        $xOBA = $xSoc->getOActividadEconomica();
        if ($xOBA != null) {
            $idactividad = $xOBA->getClaveDeActividad();
            $idsector = $xOBA->getClaveDeSector();
            $idlocalidad = $xOBA->getClaveDeLocalidad();
            $idmunicipio = $xOBA->getClaveDeMunicipio();
            $identidadfederativa = $xOBA->getClaveDeEstado();
            // idlocalidad  idmunicipio identidadfederativa
            $tab->add(TabSetValue::getBehavior('idactividad', $idactividad));
            //$tab->add(TabSetValue::getBehavior('idsectoreconomico', $idsector));
            $tab->add(TabSetValue::getBehavior('idlocalidad', $idlocalidad));
            $tab->add(TabSetValue::getBehavior('identidadfederativa', $identidadfederativa));
            $tab->add(TabSetValue::getBehavior('idmunicipio', $idmunicipio));
            $tab->add(TabSetValue::getBehavior('idnombreacceso', $xOBA->getCalle()));
            $tab->add(TabSetValue::getBehavior('idcodigopostal', $xOBA->getCodigoPostal()));
        }
    }
    //TODO: cargar estado y municiopios
    return $tab->getString();
}
 /**
  * Funcion que Retorna una Ficha Descriptiva por el recibo
  * @param boolean $fieldset
  * @param string $trTool
  * @param string $wTable
  * @return string
  */
 function getFicha($fieldset = false, $trTool = "", $extend = false)
 {
     $this->init();
     $xLg = new cLang();
     $personaAsoc = $this->getPersonaAsociada();
     //$fichaEmpresa	= "";
     if ($this->mReciboIniciado == false) {
         $exoFicha = "<div class='error'>" . $xLg->get(MSG_NO_DATA) . "</div>";
     } else {
         $xLg = new cLang();
         $tool = $trTool;
         if ($extend == true) {
             $xUsr = new cSystemUser($this->getCodigoDeUsuario());
             $xUsr->init();
             $xSoc = new cSocio($this->getCodigoDeSocio());
             $xSoc->init();
             $tool .= "<tr><th class='izq'>" . $xLg->getT("TR.persona") . "</th>";
             $tool .= "<td>" . $xSoc->getNombreCompleto() . "</td>";
             $tool .= "<th class='izq'>" . $xLg->getT("TR.Documento") . "</th>";
             $tool .= "<td>" . $this->getCodigoDeDocumento() . "</td>";
             $tool .= "<tr><th class='izq'>" . $xLg->getT("TR.Elabora") . "</th>";
             $tool .= "<td>" . $xUsr->getNombreCompleto() . "</td>";
             if ($this->isDeEmpresa() == true) {
                 $xEmp = new cEmpresas($personaAsoc);
                 $xEmp->init();
                 $tool .= "<th class='izq'>" . $xLg->getT("TR.Empresa") . "</th>";
                 $tool .= "<td>" . $xEmp->getNombre() . "</td>";
             }
             $tool .= "</tr>";
         }
         if ($this->isDivisaExtranjera() == true) {
             $tool .= "<tr><th class='izq'>" . $xLg->getT("TR.Moneda") . "</th>";
             $tool .= "<td>" . $this->getMoneda() . "</td>";
             $tool .= "<th class='izq'>" . $xLg->getT("TR.Original") . "</th>";
             $tool .= "<td>" . $this->getUnidadesOriginales() . "</td>";
             $tool .= "</tr>";
         }
         $xF = new cFecha(0);
         $exoFicha = "\n\t\t\t\t<table id=\"ficharecibo\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th class='izq'>Numero de Recibo</th>\n\t\t\t\t\t\t<td class='mny'>" . $this->mCodigoDeRecibo . "</td>\n\t\t\t\t\t\t<th class='izq'>Tipo de Recibo</th>\n\t\t\t\t\t\t<td>" . $this->mTipoDescripcion . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th class='izq'>Fecha de Recibo</th>\n\t\t\t\t\t\t<td>" . $xF->getFechaCorta($this->mFechaDeOperacion) . "</td>\n\t\t\t\t\t\t<th class='izq'>Recibo Fiscal</th>\n\t\t\t\t\t\t<td>" . $this->mReciboFiscal . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th class='izq'>Tipo de Pago</th>\n\t\t\t\t\t\t<td>" . strtoupper($this->mTipoDePago) . "</td>\n\t\t\t\t\t\t<th class='izq'>Total</th>\n\t\t\t\t\t\t<td>" . getFMoney($this->mTotalRecibo) . "</td>\n\n\t\t\t\t\t</tr>\n\n\t\t\t\t\t{$tool}\n\t\t\t\t</tbody>\n\t\t\t\t</table>";
         if ($fieldset == true) {
             $exoFicha = "<fieldset>\n\t\t\t\t\t\t\t\t<legend>&nbsp;&nbsp;INFORMACI&Oacute;N DEL RECIBO&nbsp;&nbsp;</legend>\n\t\t\t\t\t\t\t\t{$exoFicha}\n\t\t\t\t\t\t\t</fieldset>";
         }
     }
     return $exoFicha;
 }
 function getFicha($mark = true, $extraTool = "", $extendido = false, $ConPersona = false)
 {
     if ($this->mCreditoInicializado == false) {
         $this->initCredito();
     }
     $lafila = $this->getDatosDeCredito();
     $xL = new cLang();
     $solicitud = $this->getNumeroDeCredito();
     $convenio = $lafila["descripcion_tipoconvenio"];
     $fministracion = $lafila["fecha_ministracion"];
     $fvencimiento = $lafila["fecha_vencimiento"];
     $periocidad_pago = $lafila["descripcion_periocidadpagos"];
     $autorizado = getFMoney($lafila["monto_autorizado"]);
     $saldo = getFMoney($lafila["saldo_actual"]);
     $estatus = $lafila["descripcion_estatus"];
     $tool = $extraTool;
     $tasa = getFMoney($lafila["tasa_interes"] * 100);
     $mora = $lafila["tasa_moratorio"] * 100;
     $pagos = $lafila["pagos_autorizados"];
     $ultimopago = $lafila["ultimo_periodo_afectado"];
     $cls = "";
     $xD = new cFecha(0);
     $TasaIVA = $this->getTasaIVA();
     $TasaMora = $this->getTasaDeMora();
     $trInicial = "";
     $cls = "credito-estado-" . $this->getEstadoActual();
     $montoParc = getFMoney($this->mMontoFijoParcialidad);
     $activo = true;
     if ($ConPersona == true) {
         $xSoc = $this->getOPersona();
         // new cSocio($this->getClaveDePersona(), true);
         $trInicial = "<tr><th>" . $xL->getT("TR.Persona") . "</th><td>" . $xSoc->getCodigo() . "</td><td colspan='2'>" . $xSoc->getNombreCompleto() . "</td></tr>";
     }
     if ($this->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
         if ($this->getClaveDeEmpresa() != DEFAULT_EMPRESA) {
             $xEmp = new cEmpresas($this->getClaveDeEmpresa());
             $xEmp->init();
             $convenio = "{$convenio} - " . $xEmp->getNombreCorto();
         } else {
             $convenio = "{$convenio} - ND";
         }
     }
     $tdSaldo = "<th class='izq'>" . $xL->getT("TR.Saldo Principal") . "</th><td class='mny'>{$saldo}</td>";
     $tdMonto = "<th class='izq'>" . $xL->getT("TR.Monto Original") . "</th><td class='mny'>{$autorizado}</td>";
     $tdFecha = "<th class='izq'>" . $xL->getT("TR.fecha de desembolso") . "</th><td>" . $xD->getFechaCorta($fministracion) . "</td>";
     $tdPagos = $this->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO ? "<td class='mny'>{$ultimopago} de {$pagos} POR \$ {$montoParc}</td>" : "<td class='izq'>UNICO</td>";
     $tdVencimiento = "<th class='izq'>" . $xL->getT("TR.Fecha de Vencimiento") . "</th><td>" . $xD->getDayName($fvencimiento) . "; " . $xD->getFechaCorta($fvencimiento) . "</td>";
     //Si el Estatus es AUTORIZADO
     if ($this->getEstadoActual() == CREDITO_ESTADO_AUTORIZADO) {
         $tdSaldo = "";
         $tdFecha = "<th class='izq'>" . $xL->getT("TR.Fecha de Autorizacion") . "</th><td>" . $xD->getFechaCorta($this->getFechaDeAutorizacion()) . "</td>";
         $activo = false;
         $tdPagos = "<td class='mny'>{$pagos}</td>";
     } elseif ($this->getEstadoActual() == CREDITO_ESTADO_SOLICITADO) {
         $tdSaldo = "";
         $tdMonto = "<th class='izq'>" . $xL->getT("TR.Monto Solicitado") . "</th><td class='mny'>" . getFMoney($this->getMontoSolicitado()) . "</td>";
         $tdFecha = "<th class='izq'>" . $xL->getT("TR.Fecha de Solicitud") . "</th><td>" . $xD->getFechaCorta($this->getFechaDeMinistracion()) . "</td>";
         $activo = false;
         $tdPagos = "<td class='mny'>{$pagos}</td>";
     }
     if ($this->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
         $fvencimiento = $this->getFechaDeMora();
         $tdVencimiento = "<th class='izq'>" . $xL->getT("TR.Fecha de Vencimiento") . "</th><td>" . $xD->getDayName($fvencimiento) . "; " . $xD->getFechaCorta($fvencimiento) . "</td>";
     }
     if ($extendido == true) {
         $xPP = new cCreditos_destinos();
         $xPP->setData($xPP->query()->initByID($this->getClaveDeDestino()));
         $tdExigible = $activo == false ? "" : "<th class='izq'>" . $xL->getT("TR.Saldo exigible") . "</th><td class='mny'>" . getFMoney($this->getSaldoIntegrado(false, true)) . "</td>";
         $oficial = $this->getOOficial()->getNombreCompleto();
         $codigo_de_oficial = $this->getClaveDeOficialDeCredito();
         $tool = "<tr>\n\t\t\t\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Tasa Anualizada de Moratorio") . "</th><td class='mny'>" . getFMoney($TasaMora * 100) . "%</td>\n\t\t\t\t\t\t\t\t{$tdExigible}</tr>\n\t\t\t\t\t<tr><th class='izq'>" . $xL->getT("TR.Destino del Credito") . "</th><td colspan='3'>" . $xPP->descripcion_destinos()->v() . ": " . $this->mDescripcionDestino . "</td></tr>\n\t\t\t\t\t<tr><th class='izq'>Oficial a Cargo</td><td class='notice' colspan='3'>{$oficial}</td></tr>" . $tool;
         if ($activo == true) {
             if ($this->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
                 $letra = $this->getPeriodoActual() + 1;
                 $IntAct = $this->getInteresDevengado(fechasys(), $letra, false, true);
             } else {
                 $IntAct = $this->getInteresDevengado();
             }
             $IntDevNorm = $this->getInteresNormalDevengado();
             $IntDevMor = $this->getInteresMoratorioDev();
             $IntPerNor = $IntAct[SYS_INTERES_NORMAL];
             $IntPerMor = $IntAct[SYS_INTERES_MORATORIO];
             $IntPagMor = $this->getInteresMoratorioPagado();
             $IntPagNor = $this->getInteresNormalPagado();
             $TIntNorm = $IntDevNorm + $IntPerNor - $IntPagNor;
             $TIntMor = $IntDevMor + $IntPerMor - $IntPagMor;
             $BaseIVA = $TIntNorm > 0 ? $TIntNorm : 0;
             $BaseIVA += $TIntMor > 0 ? $TIntMor : 0;
             $IntIVA = setNoMenorQueCero(($TIntNorm + $TIntMor) * $TasaIVA);
             $cargos = $this->getCargosDeCobranza();
             $cargosIVA = setNoMenorQueCero($cargos * TASA_IVA);
             $trCargos = "";
             if ($cargos > 0) {
                 $trCargos = "<tr>\n\t\t\t\t\t\t<td /><td />\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Cargos por Cobranza") . "</th><td class='mny'>" . getFMoney($cargos) . "</td>\n\t\t\t\t\t</tr><tr>\n\t\t\t\t\t\t<td /><td />\n\t\t\t\t\t\t<th>" . $xL->getT("TR.IVA de Otros cargos") . "</th><td class='mny'>" . getFMoney($cargosIVA) . "</td>\n\t\t\t\t\t</tr>\t";
             }
             $tool .= "<tr>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Interes Normal Generado") . "</th><td class='mny'>" . getFMoney($IntDevNorm) . "</td>\n\t\t\t\t\t\t\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Interes Moratorio Generado") . "</th><td class='mny'>" . getFMoney($IntDevMor) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Interes Normal del Mes") . "</th><td class='mny'>" . getFMoney($IntPerNor) . "</td>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Interes Moratorio del mes") . "</th><td class='mny'>" . getFMoney($IntPerMor) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Interes Normal Pagado") . "</th><td class='mny'>(" . getFMoney($IntPagNor) . ")</td>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.Interes Moratorio Pagado") . "</th><td class='mny'>(" . getFMoney($IntPagMor) . ")</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.TOTAL INTERES NORMAL") . "</th><th class='mny'>" . getFMoney($TIntNorm) . "</th>\n\t\t\t\t\t\t<th>" . $xL->getT("TR.TOTAL INTERES MORATORIO") . "</th><th class='mny'>" . getFMoney($TIntMor) . "</th>\n\t\t\t\t\t</tr>\n\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td /><td />\n\t\t\t\t\t\t<th>" . $xL->getT("TR.SALDO DE CAPITAL") . "</th><td class='total, mny'>" . getFMoney($this->getSaldoActual()) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td /><td />\n\t\t\t\t\t\t<th>" . $xL->getT("TR.TOTAL INTERESES") . "</th><td class='mny'>" . getFMoney($TIntNorm + $TIntMor) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td /><td />\n\t\t\t\t\t\t<th>" . $xL->getT("TR.IVA POR INTERESES") . "</th><td class='mny'>" . getFMoney($IntIVA) . "</td>\n\t\t\t\t\t</tr>\t\t\t\t\t\n\t\t\t\t\t\t\t\t{$trCargos}\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td /><td />\n\t\t\t\t\t\t<th>" . $xL->getT("TR.TOTAL POR PAGAR") . "</th><td class='total, mny'>" . getFMoney($TIntNorm + $TIntMor + $IntIVA + $this->getSaldoActual() + ($cargos + $cargosIVA)) . "</td>\n\t\t\t\t\t</tr>";
         }
         $tool = "<tfoot>{$tool}</tfoot>";
     }
     $exoFicha = "\n\t\t<table id='fichadecredito'>\n\t\t\t<tbody>\n\t\t\t\t{$trInicial}\n\t\t\t\t<tr>\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Numero de Credito") . "</th><td>{$solicitud}</td>\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Producto") . "</th><td>{$convenio}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Periocidad de Pago") . "</th><td>{$periocidad_pago}</td>\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Numero de Pagos") . "</th>{$tdPagos}\n\t\t\t\t<tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Tasa Anualizada de interes") . "</th><td class='mny'>" . getFMoney($tasa) . "%</td>\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Estado_actual") . "</th><td  class='{$cls}'>{$estatus}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th class='izq'>" . $xL->getT("TR.Tasa de IVA") . "</th><td class='mny'>" . getFMoney($TasaIVA * 100) . "%</td>\n\t\t\t\t\t<th class='izq'>CAT</th><td class='mny'>" . $this->getCAT() . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>{$tdFecha} {$tdVencimiento}</tr>\n\t\t\t\t<tr>{$tdMonto} {$tdSaldo}</tr>\n\t\t\t</tbody>\n\t\t\t{$tool}\n\t\t</table>";
     if ($mark == true) {
         $exoFicha = "<fieldset><legend>|&nbsp;&nbsp;" . $xL->getT("TR.Informacion de Credito") . "&nbsp;&nbsp;|</legend>{$exoFicha}</fieldset>";
     }
     return $exoFicha;
 }
$xEmp->init();
$xTPer = new cPeriocidadDePago($periocidad);
$xTPer->init();
//if($xEmp->getEsPeriodoCerrado($periocidad, $periodo) == false){	$xHP->goToPageError(20101); }
//$xHP->addStyle("");
$style = " body { margin-top:0; margin-bottom:0.5in; margin-left:0.5in; margin-right:0.5in; \n\t\tfont: 8pt \"Trebuchet MS\", Arial, Helvetica, sans-serif !important; font-stretch: extra-condensed;\ttext-transform: uppercase; }\n#ticket { height: 3.8in; } .npage { page-break-after: always;} .divisormedio { margin-bottom: 1.25in; border-style: dotted;  border-color: transparent; }   ";
$xRPT->setToPrint();
$xRPT->addHeaderCNT("<style>{$style}</style>");
if ($out == OUT_DOC) {
    $xRPT->addHeaderCNT("<style>h1,h2,h3,h4 {text-align:center; font-size: 12pt; } body{ line-height: 10pt; }</style>");
}
$xRPT->setOut($out);
//filtrar domicilio -> socio -> credito -> letra
$sql = $xL->getListadoDeCobranza($idnomina);
$base_contrato = contrato(401, "texto_del_contrato");
$Dep = new cEmpresas($empresa);
$Dep->init();
$nempresa = $Dep->getNombre();
$TCobros = 0;
$rs = getRecordset($sql);
$ppn = 1;
$contar = 1;
while ($rw = mysql_fetch_array($rs)) {
    //cargar datos de la parcialidad
    $numero_de_socio = $rw["persona"];
    $cSoc = new cSocio($numero_de_socio);
    $cSoc->init();
    $DSoc = $cSoc->getDatosInArray();
    $ficha_socio = $cSoc->getFicha();
    $numero_credito = $rw["credito"];
    $xCred = new cCredito($numero_credito, $numero_de_socio);
//$estado		= (isset($_GET["estado"])) ? $_GET["estado"]: "todas";
$fecha_inicial = parametro("idfecha-0", false);
$fecha_inicial = parametro("on", $fecha_inicial);
$fecha_final = parametro("idfecha-1", false);
$fecha_final = parametro("off", $fecha_final);
echo $xHP->getHeader();
echo $xHP->setBodyinit("initComponents();");
$ByFecha = ($fecha_final == false or $fecha_inicial == false) ? "" : " AND\t(`empresas_operaciones`.`fecha_de_operacion` >='" . $xF->getFechaISO($fecha_inicial) . "') AND\t(`empresas_operaciones`.`fecha_de_operacion` <='" . $xF->getFechaISO($fecha_final) . "') ";
$ByPeriodo = $periodo == SYS_TODAS ? "" : "AND ( `periodo_marcado` = {$periodo}) ";
$xRPT = new cReportes();
echo $xRPT->getHInicial("TR.Estado de cuenta de Empresas", $fecha_inicial, $fecha_final);
//TODO: Acabar
$lt = new cSQLListas();
$sql = $lt->getListadoDeOperacionesDeEmpresas($empresa, $periocidad, $ByFecha . $ByPeriodo);
$xT = new cTabla($sql);
$xEmp = new cEmpresas($empresa);
echo $xEmp->getFicha();
$xT->getFieldsSum("monto");
$xT->setTdClassByType();
$xT->setFootSum(array(6 => "envios", 7 => "cobros"));
echo $xT->Show();
echo getRawFooter();
echo $xHP->setBodyEnd();
?>
<script>
<?php 
?>
function initComponents(){
	window.print();
}
</script>
$xF = new cFecha();
//$persona	= parametro("persona", DEFAULT_SOCIO, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$letra = parametro("letra", 0, MQL_INT);
$monto = parametro("monto", 0, MQL_FLOAT);
$fechaI = parametro("on", fechasys());
$fechaF = parametro("off", fechasys());
$fechaEnv = parametro("to", fechasys());
$observaciones = parametro("observaciones", "");
$empresa = parametro("empresa", false);
$periodo = parametro("periodo", false);
$periocidad = parametro("periocidad", false);
$notas = parametro("notas", false);
$rs = array();
$idnomina = parametro("nomina", false);
$xEmp = new cEmpresas($empresa);
$xEmp->init();
$msg = "";
if (setNoMenorQueCero($idnomina) <= 0) {
    $rs["error"] = true;
    $rs["message"] = "Nomina Invalida {$idnomina} ";
} else {
    if (setNoMenorQueCero($credito) > 1) {
        //sucess
        //eliminar anteriores
        $sqlNS = "SELECT getSaldoPendienteDesdeLetra({$credito}, ({$letra}-1)) AS 'saldo_anterior' ";
        $sdo_anterior = mifila($sqlNS, "saldo_anterior");
        $xO = new cEmpresas_cobranza();
        $idoriginal = $xO->query()->getLastID();
        $xO->idempresas_cobranza($idoriginal);
        $xO->clave_de_credito($credito);
function jsaActualizarEmpresa($idempresa)
{
    $xEmp = new cEmpresas($idempresa);
    $xEmp->init();
    $xEmp->setActualizarPorPersona();
    return $xEmp->getMessages(OUT_HTML);
}
$FAnt = new cFecha();
$xRPT = new cReportes("");
if ($periocidad == SYS_TODAS) {
    $xPerNom = new cEmpresas_operaciones();
    $xPerNom->setData($xPerNom->query()->initByID($idnomina));
    $empresa = $xPerNom->clave_de_empresa()->v();
    $periocidad = $xPerNom->periocidad()->v();
    $periodo = $xPerNom->periodo_marcado()->v();
}
$ByMinistracion = "";
//$periodo		= $periodo + $variacion;
$observaciones = isset($_GET["o"]) ? $_GET["o"] : 0;
$xLoc = new cLocal();
$xHP->addJsFile("../js/jquery/jquery.js");
$xHP->addJsFile("../js/general.js");
$xEmp = new cEmpresas($empresa);
$xEmp->init();
$xTPer = new cPeriocidadDePago($periocidad);
$xTPer->init();
if ($xEmp->getEsPeriodoCerrado($periocidad, $periodo) == false) {
    $xHP->goToPageError(20101, $out);
}
$periodo = $xF->semana();
$bheader = "";
$title = $xHP->getTitle() . "_" . $xEmp->getNombre() . "_" . $xTPer->getNombre() . "_{$periodo}";
$xPer = $xEmp->getOPeriodo(false, false, $idnomina);
$xRPT->setTitle($title);
$xRPT->setOut($out);
$xRPT->setSenders($mails);
$xRPT->setResponse();
//if($out == OUT_EXCEL ){
$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);
$xEmp = new cEmpresas($empresa);
$xEmp->init();
$nombre_empresa = $xEmp->getNombre();
$sql = $xL->getListadoDeIncidenciasAhorro($empresa);
$titulo = "";
$archivo = "";
$xRPT = new cReportes($titulo);
$xRPT->setFile($archivo);
$xRPT->setOut($out);
$xRPT->setSQL($sql);
//$xRPT->setTitle($nombre_empresa. "-". $xHP->getTitle());
//============ Reporte
$xT = new cTabla($sql, 2);
$xT->setTipoSalida($out);
$body = $xRPT->getEncabezado($nombre_empresa . "<br/>" . $xHP->getTitle());
$xRPT->setBodyMail($body);
 function addTransaccionalidadPorEmpresa($empresa, $monto, $fecha = false)
 {
     $xEmp = new cEmpresas($empresa);
     $monto = setNoMenorQueCero($monto);
     if ($xEmp->init() == true) {
         $pais = EACP_CLAVE_DE_PAIS;
         $numero = ceil(setNoMenorQueCero(365 / $xEmp->getPeriocidadPref() / 12)) + 1;
         //$xEmp->getOPersona();
         if ($monto > 0 and $numero > 0) {
             $monto = $monto * 2;
             $numero = $numero * 2;
             $this->setGuardarPerfilTransaccional(AML_OPERACIONES_PAGOS_EFVO, $pais, $monto, $numero, "Generado de la Empresa {$empresa}", $fecha);
             //$this->setGuardarPerfilTransaccional(AML_OPERACIONES_PAGOS_EFVO, $pais, $monto, $numero, "Generado de la Empresa $empresa", $fecha);
             //deposito bancario
         }
     }
 }
 function setProcesarProgramacion($id, $arrVars = false, $data = false, $fecha = false)
 {
     $xF = new cFecha();
     $xT = new cTipos();
     $xLog = new cCoreLog();
     $arrVars = $arrVars == false ? $this->mArrVars : $arrVars;
     //idprograma, nombre_del_aviso, forma_de_creacion, programacion, destinatarios, microformato, tipo_de_medios, intent_check, intent_command
     $sql = "SELECT *\tFROM sistema_programacion_de_avisos WHERE idprograma={$id} LIMIT 0,1";
     $d = $data == false ? obten_filas($sql) : $data;
     $mOb = new cSistema_programacion_de_avisos();
     $mOb->setData($d);
     $emails = array();
     $tels = array();
     $enviar = false;
     $fecha = $fecha == false ? fechasys() : $fecha;
     $nombredia = $xF->getDayName();
     $diadelmes = date("j", $xF->getInt());
     $EnviarNota = true;
     $EnviarMail = true;
     $EnviarSMS = false;
     $xLoc = new cLocal();
     //procesar cuerpo del contenido
     $arrVars["fecha"] = !isset($arrVars["fecha"]) ? $fecha : $arrVars["fecha"];
     $arrVars["fecha_dia_siguiente"] = $xF->setSumarDias(1, $fecha);
     $arrVars["fecha_inicio_de_semana"] = $xF->getFechaDeInicioDeSemana($fecha);
     $arrVars["fecha_inicio_de_mes"] = $xF->getDiaInicial($fecha);
     //Dia de la semana inicial
     $arrVars["hora"] = date("H");
     $arrVars["usuario"] = $xLoc->getNombreUsuario();
     $arrVars["clave_de_usuario"] = !isset($arrVars["clave_de_usuario"]) ? getUsuarioActual() : $arrVars["clave_de_usuario"];
     //interpretar DIA
     if (strtoupper($mOb->forma_de_creacion()->v()) == SYS_ALERTA_POR_EVENTO) {
         $enviar = true;
     } else {
         //if($mOb->programacion())
         $programacion = strtoupper($mOb->programacion()->v());
         $periodo = explode(":", $programacion);
         //INTERPRETAR DIA
         if ($periodo[0] == "PROGRAMACION_SEMANAL") {
             if (strpos($nombredia, $programacion) !== false) {
                 $enviar = true;
             }
         } else {
             if ($periodo[0] == "PROGRAMACION_DIARIA") {
                 $enviar = true;
             } else {
                 if (isset($periodo[1])) {
                     $dias = explode(",", $periodo[1]);
                     foreach ($dias as $dias => $iddia) {
                         $mes = $xF->mes();
                         $anno = $xF->anno();
                         if (date("Y-m-d", strtotime("{$anno}-{$mes}-{$iddia}")) == $fecha) {
                             $enviar = true;
                         }
                     }
                 }
             }
         }
     }
     //1.- extraer emails
     $destinatarios = explode("|", $mOb->destinatarios()->v());
     foreach ($destinatarios as $key => $cnt) {
         if (trim($cnt) != "") {
             //1.1 Desfragmentar destinos
             $DS = explode(":", $cnt);
             $mdestino = isset($DS[0]) ? strtoupper($DS[0]) : "";
             switch ($mdestino) {
                 case "OFICIALES":
                     if (isset($DS[1])) {
                         $oficiales = explode(",", $DS[1]);
                         foreach ($oficiales as $ofc => $ofkey) {
                             $xOf = new cOficial($ofkey);
                             $xOf->init();
                             $mail = $xOf->getEmail();
                             $emails[] = $mail;
                             $xLog->add("OK\tOFICIAL\tAgregar mail {$mail}  \r\n", $xLog->DEVELOPER);
                         }
                     }
                     break;
                 case "EMPRESAS":
                     if (isset($DS[1])) {
                         $empresas = explode(",", $DS[1]);
                         foreach ($empresas as $emp => $empkey) {
                             $xEmp = new cEmpresas($empkey);
                             $xEmp->init();
                             //$mail		= $xEmp->getEmailsDeEnvio();
                             //$emails[]	= $mail;
                             $emails = array_merge($emails, $xEmp->getEmailsDeEnvio());
                             $xLog->add("OK\tEMPRESAS\tAgregar mail de la empresa {$empkey}  \r\n", $xLog->DEVELOPER);
                         }
                     }
                     break;
                 case "PERSONAS":
                     if (isset($DS[1])) {
                         $personas = explode(",", $DS[1]);
                         foreach ($personas as $ofc => $ofkey) {
                             $xSoc = new cSocio($ofkey);
                             $xSoc->init();
                             $mail = $xSoc->getCorreoElectronico();
                             $emails[] = $mail;
                             $xLog->add("OK\tPERSONA\tAgregar mail {$mail}  \r\n", $xLog->DEVELOPER);
                             if ($xT->cNumeroTelefonico($xSoc->getTelefonoPrincipal()) != false) {
                                 $EnviarSMS = true;
                                 $tels[] = $xT->cNumeroTelefonico($xSoc->getTelefonoPrincipal());
                             }
                         }
                     }
                     break;
                 case "CORREO":
                     if (isset($DS[1])) {
                         $personas = explode(",", $DS[1]);
                         foreach ($personas as $ofc => $ofkey) {
                             if (filter_var($ofkey, FILTER_VALIDATE_EMAIL)) {
                                 $emails[] = $ofkey;
                             }
                             $xLog->add("OK\tCORREO\tAgregar mail {$ofkey}  \r\n", $xLog->DEVELOPER);
                         }
                     }
                     break;
             }
             //1.1.1 Validar oficiales, empresas, personas
             //if(strpos("OFICIALES:", $needle))
         }
     }
     $this->mMessages .= $xLog->getMessages();
     $texto = $mOb->microformato()->v();
     foreach ($arrVars as $variable => $valor) {
         $texto = str_replace("{" . $variable . "}", $valor, $texto);
     }
     if ($enviar == true) {
         $url = $mOb->intent_command()->v(OUT_TXT);
         //2 procesado del comando
         if (trim($url) == "") {
             $titulo = strtoupper($mOb->nombre_del_aviso()->v());
             $xNot = new cNotificaciones();
             //enviar mail normal
             if ($EnviarSMS == true) {
                 foreach ($tels as $pitm => $ptel) {
                     $xNot->sendSMS($ptel, $texto);
                 }
             }
             if ($EnviarMail == true) {
                 foreach ($emails as $itm => $pmail) {
                     $xNot->sendMail($titulo, $texto, $pmail);
                 }
             }
         } else {
             //execute command
             //rpttesoreria/corte_de_caja.rpt.php?on=2014-5-3&off=2014-5-3&cajero=todas&dependencia=todas
             $smail = "";
             $xHO = new cHObject();
             foreach ($arrVars as $variable => $valor) {
                 $url = str_replace("{" . $variable . "}", $valor, $url);
             }
             foreach ($emails as $id => $rmail) {
                 //$smail	.= ($smail == "") ? "email$id=$rmail" : "&email$id=$rmail";
                 $smail .= "&email{$id}={$rmail}";
             }
             //Iniciar session en contexto &on=$fecha&off=$fecha
             $xSysUser = new cSystemUser();
             $xSysUser->init();
             $url = $url . $smail . "&ctx=" . $xSysUser->getCTX();
             if (MODO_DEBUG == true) {
                 setLog($url);
             }
             $xHO->navigate($url);
         }
     } else {
         $this->mMessages .= "OK\tNo e envia el reporte\r\n";
     }
     setLog($this->mMessages);
     $this->mObProgAv = $mOb;
     //return $this->mObProgAv;
 }
    $xOEmp->directivo_principal($directivo);
    $xOEmp->clave_de_directivo($iddirectivo);
    $xOEmp->periocidad_de_avisos($periocidad1);
    $xOEmp->oficial_que_cierra($oficial);
    $xOEmp->nombre_corto($alias);
    $xOEmp->producto_preferente($producto);
    $xOEmp->email_de_envio($emails);
    $xOEmp->clave_de_persona($idsocio);
    $xOEmp->query()->update()->save($empresa);
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $xEmp->setActualizarPorPersona();
    $msg .= $xEmp->getMessages();
}
if (setNoMenorQueCero($empresa) > 0) {
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    if ($xEmp->isInit() == true) {
        $alias = $xEmp->getNombreCorto();
        //$iddirectivo=
        $iddirectivo = $xEmp->getClaveDeContacto();
        $directivo = $xEmp->getNombreContacto();
        $idsocio = $xEmp->getClaveDePersona();
        $periocidad1 = $xEmp->getPeriocidadPref();
        $lstPeriodos = $xEmp->getListaDePeriocidad();
        $periocidad2 = isset($lstPeriodos[1]) ? $lstPeriodos[1] : $periocidad1;
        $producto = $xEmp->getProductoPref();
        $mails = $xEmp->getEmailsDeEnvio();
        $oficial = $xEmp->getClaveDeOficial();
        $mail1 = isset($mails[0]) ? $mails[0] : "";
        $mail2 = isset($mails[1]) ? $mails[1] : "";
function jsaSetNominaCerrada($empresa, $periocidad, $variacion, $periodo, $monto, $observaciones, $fechaInicial, $fechaFinal, $fechaCobro)
{
    $xF = new cFecha();
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    //$periodo	= $periodo + $variacion;
    $xEmp->setPeriodo($periodo);
    $xEmp->setClearPeriodo(true);
    $fechaInicial = setFechaValida($fechaInicial);
    $fechaFinal = setFechaValida($fechaFinal);
    $fechaCobro = setFechaValida($fechaCobro);
    $idx = $xEmp->addOperacion($monto, $periodo, $periocidad, fechasys(), SYS_UNO, false, $observaciones, $fechaInicial, $fechaFinal, $fechaCobro);
    return $idx;
}
 function setEmpresa($empresa, $puesto, $depto = "", $idempleado = "", $nss = 0, $ExtTelefonica = 0)
 {
     //cargar datos de la empresa
     $this->mClaveEmpresa = $empresa;
     $this->mPuesto = $puesto;
     $this->mDepto = $depto;
     $this->mIDEmpleado = $idempleado;
     $this->mNSS = $nss;
     $this->mExtTelefonica = $ExtTelefonica;
     //iniciar domicilio?
     $xEmp = new cEmpresas($this->mCodigoPostal);
     if ($xEmp->init() == true) {
         $this->mNombreEmpresa = $xEmp->getNombreCorto();
         $this->mDomicilio = $xEmp->getDomicilio();
         $OPers = $xEmp->getOPersona();
         if ($OPers != null) {
             $xViv = $OPers->getODomicilio();
             if ($xViv != null) {
                 $this->mClaveDeEstado = $xViv->getClaveDeEstado();
                 $this->mClaveDeMunicipio = $xViv->getClaveDeMunicipio();
                 $this->mClaveDeLocalidad = $xViv->getClaveDeLocalidad();
                 $this->mNombreDeLocalidad = $xViv->getLocalidad();
                 $this->mNombreDeMunicipio = $xViv->getMunicipio();
                 $this->mNombreDeEstado = $xViv->getEstado();
                 $this->mCodigoPostal = $xViv->getCodigoPostal();
                 $this->mIDDomicilio = $xViv->getClaveUnica();
             }
         }
     }
 }
$xFRM->addHElem($xHChk->get("id1"));
$xFRM->addHElem($xHChk->get("id2"));
$xFRM->addHElem($xHChk->get("id3"));
$xFRM->addHElem($xHChk->get("id4"));
$xSoc = new cSocios_general();
$xSoc->setData($xSoc->query()->initByID(DEFAULT_SOCIO));
var_dump($xSoc->query()->getCampos());
//$xFRM->addAviso( $xSoc->query()->getListaDeCampos() );
$xFRM->OMoneda("ix", 4500, convertirletras("4,455.05"));
$xFRM->OMoneda("ix", 4500, convertirletras("4454.455.05"));
$xFRM->OMoneda("ix", 4500, convertirletras(45000));
//echo $xFRM->get();
$xTabla = new cCreditos_tipoconvenio();
$xFRM = new cHForm("frmcreditos_tipoconvenio", "creditos_tipoconvenio");
$xFRM->addSubmit();
$xEmp = new cEmpresas(100);
$xEmp->init();
if ($xEmp->getOPersona() == null) {
    $xFRM->OText("idper", "SIN PERSONA", "TR.Persona");
} else {
    $xPer = $xEmp->getOPersona()->init();
    $xFRM->OText("idper", $xEmp->getOPersona()->getNombreCompleto(), "TR.Persona");
}
echo $xFRM->get();
#require('lib/gantti.php');
#date_default_timezone_set('UTC');
#setlocale(LC_ALL, 'en_US');
$data = array();
$data[] = array('label' => 'Project 1', 'start' => '2012-04-20', 'end' => '2012-05-12');
$data[] = array('label' => 'Project 2', 'start' => '2012-04-22', 'end' => '2012-05-22', 'class' => 'important');
$data[] = array('label' => 'Project 3', 'start' => '2012-05-25', 'end' => '2012-06-20', 'class' => 'urgent');
 function setCredito($credito)
 {
     $this->mDocumento = $credito;
     $xFDE = new cFecha();
     $xLng = new cLang();
     $cCred = new cCredito($credito);
     $cCred->init();
     $idsolicitud = $credito;
     $DCred = $cCred->getDatosDeCredito();
     $DProd = $cCred->getOProductoDeCredito();
     $OOParam = new cProductoDeCreditoOtrosDatosCatalogo();
     $numero_de_socio = $cCred->getClaveDePersona();
     $this->mPersona = $numero_de_socio;
     $cSoc = new cSocio($numero_de_socio);
     $cSoc->init();
     $svar_info_cred = "";
     $tblInfCred = new cFicha(iDE_CREDITO, $idsolicitud);
     $this->setPersona($numero_de_socio);
     $svar_info_cred = $tblInfCred->show(true);
     //Lista de Beneficiados
     $lst_beneficiados = "";
     $this->getListadoDeAvales($idsolicitud);
     $SQLCBen = "SELECT `socios_relacionestipos`.`descripcion_relacionestipos` AS 'relacion', `socios_relaciones`.`nombres`,\t`socios_relaciones`.`apellido_paterno`,\t`socios_relaciones`.`apellido_materno`,\n\t\t\t`socios_consanguinidad`.`descripcion_consanguinidad` AS 'consaguinidad'\n\t\t\tFROM `socios_relaciones` `socios_relaciones` INNER JOIN `socios_consanguinidad` `socios_consanguinidad` ON `socios_relaciones`.`consanguinidad` = `socios_consanguinidad`.`idsocios_consanguinidad`\n\t\t\tINNER JOIN `socios_relacionestipos` `socios_relacionestipos` ON `socios_relaciones`.`tipo_relacion` = `socios_relacionestipos`.`idsocios_relacionestipos`\n\t\t\tWHERE (`socios_relaciones`.`socio_relacionado` ={$numero_de_socio}) AND (`socios_relaciones`.`credito_relacionado` ={$idsolicitud})\tAND\t(`socios_relaciones`.`tipo_relacion`=11)";
     $tblCBen = new cTabla($SQLCBen);
     $lst_beneficiados = $tblCBen->Show();
     $firmas_de_avales = $this->mFirmasAvales;
     // $cSoc->getCoResponsables("firmas", "avales", $idsolicitud );
     //Plan de Pago segun SQL
     $splan_pagos = $cCred->getPlanDePago(OUT_HTML, true, true);
     //==================================================================================
     $fichas_de_avales = $this->mFichasAvales;
     //$cCred->getAvales_InText();
     $fecha_larga_de_documento = $xFDE->getFechaLarga($cCred->getFechaDeMinistracion());
     $fichas_de_respsolidarios = "";
     //TODO: FALTA
     //Otros Datos
     $monto_ministrado = $cCred->getMontoAutorizado();
     $tasa_interes_mensual_ordinario = round($cCred->getTasaDeInteres() / 12 * 100, 2);
     $tasa_interes_anual_ordinario = $cCred->getTasaDeInteres();
     $fecha_de_vencimiento = $cCred->getFechaDeVencimiento();
     $fecha_de_ministracion = $cCred->getFechaDeMinistracion();
     $tasa_garantia_liquida = $DCred["porciento_garantia_liquida"] * 100;
     $monto_garantia_liquida = $monto_ministrado * $tasa_garantia_liquida;
     $tasa_interes_mensual_moratorio = round($cCred->getTasaDeMora() / 12 * 100, 2);
     $dias_del_credito = $cCred->getDiasAutorizados();
     $meses_del_credito = sprintf("%02d", ceil($dias_del_credito / 30.416666666666668));
     $periocidad = $cCred->getPeriocidadDePago();
     //Tipo de Credito por SQL
     $SQLTCred = "SELECT * FROM creditos_modalidades WHERE idcreditos_modalidades=" . $DCred["tipo_credito"];
     $tipo_de_credito = mifila($SQLTCred, "descripcion_modalidades");
     //Datos del Grupo Solidarios por SQL
     $SQLGAsoc = "SELECT * FROM socios_grupossolidarios WHERE idsocios_grupossolidarios=" . $DCred["grupo_asociado"];
     $InfoGrupo = obten_filas($SQLGAsoc);
     $nombre_rep_social = $InfoGrupo["representante_nombrecompleto"];
     $codigo_rep_social = $InfoGrupo["representante_numerosocio"];
     $nombre_voc_vigila = $InfoGrupo["vocalvigilancia_nombrecompleto"];
     $nombre_del_grupo = $InfoGrupo["nombre_gruposolidario"];
     $domicilio_rep_social = domicilio($codigo_rep_social);
     $tabla_asociadas = "";
     $lista_asociadas = "";
     $tasa_de_cat = $cCred->getCAT();
     $DPeriocidad = new cPeriocidadDePago($cCred->getPeriocidadDePago());
     $DPeriocidad->init();
     $monto_con_interes = "";
     $monto_con_interes_letras = "";
     if ($DCred["grupo_asociado"] != DEFAULT_GRUPO) {
         $SQL_get_grupo = "SELECT `socios_general`.`codigo`, CONCAT(`socios_general`.`nombrecompleto`, ' ', `socios_general`.`apellidopaterno`, ' ', `socios_general`.`apellidomaterno`) AS 'nombre_completo'\n\t\t\t\t\t\t\t\t\tFROM `socios_general` `socios_general` WHERE (`socios_general`.`grupo_solidario` =" . $DCred["grupo_asociado"] . ")";
         $rsg = getRecordset($SQL_get_grupo);
         while ($rwt = mysql_fetch_array($rsg)) {
             $lista_asociadas .= ", " . $rwt["nombre_completo"];
         }
     }
     if (EACP_INCLUDE_INTERES_IN_PAGARE == true) {
         if ($periocidad == CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) {
             $monto_con_interes = $cCred->getMontoAutorizado() + $cCred->getInteresDiariogenerado() * $cCred->getDiasAutorizados();
         } else {
             $sqlInt = "SELECT `operaciones_mvtos`.`docto_afectado`, `operaciones_mvtos`.`tipo_operacion`, COUNT(`operaciones_mvtos`.`idoperaciones_mvtos`) AS `mvtos`,\n\t\t\t\t\tSUM(`operaciones_mvtos`.`afectacion_real` *\t`eacp_config_bases_de_integracion_miembros`.`afectacion`) AS 'monto'\n\t\t\t\t\tFROM `operaciones_mvtos` `operaciones_mvtos` INNER JOIN `eacp_config_bases_de_integracion_miembros`\t`eacp_config_bases_de_integracion_miembros`\n\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `eacp_config_bases_de_integracion_miembros`.`miembro` WHERE (`operaciones_mvtos`.`docto_afectado` = {$idsolicitud})\n\t\t\t\t\tAND (`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` = 2601)\n\t\t\t\t\tGROUP BY `operaciones_mvtos`.`docto_afectado`, `eacp_config_bases_de_integracion_miembros`.`codigo_de_base`\n\t\t\t\t\tORDER BY `eacp_config_bases_de_integracion_miembros`.`codigo_de_base`, `operaciones_mvtos`.`fecha_afectacion`, `operaciones_mvtos`.`socio_afectado`\t";
             $xF = obten_filas($sqlInt);
             $monto_con_interes = $xF["monto"];
         }
         $monto_con_interes_letras = convertirletras($monto_con_interes);
         $monto_con_interes = getFMoney($monto_con_interes);
     }
     $this->mArr["variable_informacion_del_credito"] = $cCred->getFicha();
     //"variable_lista_de_beneficiados" 		=> $lst_beneficiados,
     $this->mArr["variable_tipo_de_credito"] = $tipo_de_credito;
     $this->mArr["variable_monto2_ministrado_con_intereses_en_letras"] = $monto_con_interes_letras;
     $this->mArr["variable_monto2_ministrado_con_intereses"] = $monto_con_interes;
     $this->mArr["variable_monto_ministrado"] = getFMoney($monto_ministrado);
     $this->mArr["variable_tasa_mensual_de_interes_ordinario"] = $tasa_interes_mensual_ordinario;
     $this->mArr["variable_credito_fecha_de_vencimiento"] = $xFDE->getFechaMediana($fecha_de_vencimiento);
     $this->mArr["variable_monto_garantia_liquida"] = getFMoney($monto_garantia_liquida);
     $this->mArr["variable_tasa_mensual_de_interes_moratorio"] = $tasa_interes_mensual_moratorio . "";
     $this->mArr["variable_tasa_de_garantia_liquida"] = $tasa_garantia_liquida . "";
     $this->mArr["variable_plan_de_pagos"] = $splan_pagos;
     $this->mArr["variable_docto_fecha_larga_actual"] = $fecha_larga_de_documento;
     $this->mArr["variable_nombre_de_la_representante_social"] = $nombre_rep_social;
     $this->mArr["variable_listado_de_integrantes"] = $lista_asociadas;
     $this->mArr["variable_nombre_de_la_vocal_de_vigilancia"] = $nombre_voc_vigila;
     $this->mArr["variable_nombre_del_grupo_solidario"] = $nombre_del_grupo;
     $this->mArr["variable_domicilio_de_la_representante_social"] = $domicilio_rep_social;
     $this->mArr["variable_meses_de_duracion_del_credito"] = $meses_del_credito;
     $this->mArr["variable_en_letras_monto_ministrado"] = convertirletras($monto_ministrado);
     $this->mArr["variable_credito_fecha_de_ministracion"] = $xFDE->getFechaCorta($fecha_de_ministracion);
     $this->mArr["variable_tasa_cat"] = $tasa_de_cat;
     $this->mArr["variable_credito_periocidad"] = $DPeriocidad->getNombre();
     $this->mArr["variable_credito_monto_parcialidad_fija"] = getFMoney($cCred->getMontoDeParcialidad());
     $this->mArr["variable_credito_numero_de_pagos"] = $cCred->getPagosAutorizados();
     $this->mArr["variable_tasa_anual_de_interes_moratorio"] = $cCred->getTasaDeInteres() * 2 * 100 . "%";
     $this->mArr["variable_tasa_anual_de_interes_ordinario"] = $cCred->getTasaDeInteres() * 100 . "%";
     //sobreescribir datos de la empresa
     $xEmp = new cEmpresas($cCred->getClaveDeEmpresa());
     $xEmp->init();
     $this->mArr["variable_nombre_de_la_empresa"] = $xEmp->getNombre();
     $this->mArr["variable_nombre_de_empresa"] = $xEmp->getNombre();
     $this->mArr["variable_fecha_de_primer_pago"] = $xFDE->getFechaMediana($cCred->getFechaPrimeraParc());
     $this->mArr["variable_avales_en_fichas"] = $fichas_de_avales;
     $this->mArr["variable_firmas_de_avales"] = $firmas_de_avales;
     $this->mArr["variable_avales_autorizacion_central_riesgo"] = $this->mFichaRiesgoAv;
     $this->mArr["variable_fecha_ultimo_abono"] = $xFDE->getFechaLarga($cCred->getFechaUltimaParc());
     $this->mArr["variable_fecha_de_primer_abono"] = $xFDE->getFechaMediana($cCred->getFechaPrimeraParc());
     //$this->mArr["variable_fecha_de_primer_abono"]						=
     $this->mArr["variable_en_letras_tasa_mensual_de_interes_moratorio"] = convertirletras_porcentaje($tasa_interes_mensual_moratorio);
     $this->mArr["variable_lista_de_avales_con_domicilio"] = $this->mLAvalesConDir;
     /*variable_aval1_nombre_completo variable_aval1_domicilio_completo variable_aval1_domicilio_localidad variable_aval1_domicilio_municipio*/
     //Cargar Avales
     $this->mArr["variable_listado_de_garantias"] = $this->getListadoDeGarantias();
     //$this->mArr["variable_modalidad_de_credito"]					= $cCred->getOEstado()
     $this->mArr["variable_estado_de_credito"] = $cCred->getOEstado()->descripcion_estatus()->v(OUT_TXT);
     //$this->mArr["variable_credito_num_de_pago_actual"]				= $cCred->getPeriodoActual();
     $this->mArr["variable_contrato_id_legal"] = $DProd->getOtrosParametros($OOParam->CONTRATO_ID_LEGAL);
     $this->mArr["variable_producto_comision_apertura"] = $DProd->getOtrosParametros($OOParam->TASA_DE_COMISION_AP);
 }
 function initPorCredito($idcredito, $dataCredito = false)
 {
     $xCred = new cCredito($idcredito);
     $xCred->init($dataCredito);
     $xF = new cFecha();
     if ($xCred->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
         //cargar datos de la empresa
         $idemp = $xCred->getClaveDeEmpresa();
         $periocidad = $xCred->getPeriocidadDePago();
         $this->setPeriocidadDePago($periocidad);
         $this->mTipoCreditoSis = $xCred->getTipoEnSistema();
         $this->mClaveDePlan = setNoMenorQueCero($xCred->getNumeroDePlanDePagos());
         if ($this->mClaveDePlan > 0) {
             //TODO: validar fecha de primer pago en calculos automaticos
             $this->mFechaPrimerPago = $xCred->getFechaPrimeraParc();
         } else {
             $this->mFechaPrimerPago = $this->getFechaDePago($xCred->getFechaDeMinistracion(), 1);
         }
         if ($xCred->getFechaPrimeraParc() == $this->mFechaFail or $xF->getInt($xCred->getFechaPrimeraParc()) <= $xF->getInt($xCred->getFechaDeMinistracion())) {
             $this->mFechaPrimerPago = $this->getFechaDePago($xCred->getFechaDeMinistracion(), 1);
         }
         $xEmp = new cEmpresas($idemp);
         $xEmp->init();
         $DDias = $xEmp->getDiasDeNomina($periocidad);
         $this->mDiaDeAbono1 = isset($DDias[0]) ? setNoMenorQueCero($DDias[0]) : $this->mDiaDeAbono1;
         $this->mDiaDeAbono2 = isset($DDias[1]) ? setNoMenorQueCero($DDias[1]) : $this->mDiaDeAbono2;
         $this->mDiaDeAbono3 = isset($DDias[2]) ? setNoMenorQueCero($DDias[2]) : $this->mDiaDeAbono3;
     } else {
         $this->mFechaPrimerPago = $this->getFechaDePago($xCred->getFechaDeMinistracion(), 1);
     }
 }
function jsaSetGuardarDeposito($tipo_pago, $banco, $monto, $cobranza, $fecha, $observaciones, $empresa, $periodo)
{
    //'idtipo_pago', 'idcodigodecuenta', 'idmontodeposito', 'idsumacbza', 'idfecha-0', 'idobservaciones', 'idcodigodeempresas', 'idperiodo'
    $diferencia = $monto - $cobranza;
    $xEmp = new cEmpresas($empresa);
    $xEmp->init();
    $persona = $xEmp->getClaveDePersona();
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $xCaja = new cCaja();
    $documento = DEFAULT_CREDITO;
    $nombreemp = $xEmp->getNombreCorto();
    $xPer = $xEmp->getOPeriodo(false, false, $periodo);
    $periodo2 = $xPer->periodo_marcado()->v();
    $periocidad = $xPer->periocidad()->v();
    $observaciones = "{$empresa}-{$nombreemp}-{$periocidad}-{$periodo2}-ID.{$periodo}-" . $observaciones;
    if ($tipo_pago == TESORERIA_COBRO_TRANSFERENCIA) {
        $op = $xCaja->setCobroTransferencia(DEFAULT_RECIBO, $banco, $monto, $diferencia, $fecha, $observaciones, $persona, $documento);
    } elseif ($tipo_pago == TESORERIA_COBRO_EFECTIVO) {
        $xCaja->setCobroEfectivo(DEFAULT_RECIBO, $monto, $cobranza, $observaciones);
    }
    //Agregar operacion de la empresa
    $xEmp->addOperacion($monto, $periodo2, $periocidad, $fecha, -1, false, $observaciones);
}