function jsaSetCreditosADespedidos($credito, $fecha, $observaciones)
{
    $msg = "";
    $xCred = new cCredito($credito);
    $xCred->init();
    $xdat = new cFecha(0);
    $fecha = $xdat->getFechaISO($fecha);
    $xCred->init();
    $socio = $xCred->getClaveDePersona();
    $xSoc = new cSocio($socio);
    $xSoc->init();
    $xCred->setCambioProducto(CREDITO_PRODUCTO_DESTINO_DESCARTADOS);
    $xCred->setResetPersonaAsociada($fecha, $observaciones);
    //Agregar operacion de desvinculacion
    $xRe = new cReciboDeOperacion(RECIBOS_TIPO_ESTADISTICO, false, DEFAULT_RECIBO);
    $xRe->init();
    $xRe->setNuevoMvto($fecha, $xCred->getSaldoActual(), OPERACION_CLAVE_DESVINCULACION, $xCred->getPeriodoActual(), "", 1, false, $socio, $credito, $fecha);
    $xRe->setFinalizarRecibo();
    $msg .= $xSoc->getMessages(OUT_TXT);
    $msg .= $xCred->getMessages(OUT_TXT);
    $msg .= $xRe->getMessages(OUT_TXT);
    $xRN = new cReglaDeNegocio();
    $xEmp = new cEmpresas($xCred->getClaveDeEmpresa());
    $xEmp->init();
    $oP = $xCred->getOPersona();
    $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_DESPEDIR);
    $xF = new cFileLog();
    $xF->setWrite($msg);
    $xF->setClose();
    return $xF->getLinkDownload("Descarga de Log");
}
function jsaVincularEmpresa($credito, $observaciones, $empresa)
{
    $msg = "";
    $xCred = new cCredito($credito);
    $xCred->init();
    $xdat = new cFecha(0);
    $fecha = $xdat->get();
    // FechaISO($fecha);
    $xCred->init();
    $socio = $xCred->getClaveDePersona();
    $xSoc = new cSocio($socio);
    $xSoc->init();
    $xCred->setCambioProducto(CREDITO_PRODUCTO_NOMINA);
    $xCred->setResetPersonaAsociada($fecha, $observaciones, $empresa);
    //Agregar operacion de desvinculacion
    $xRe = new cReciboDeOperacion(RECIBOS_TIPO_ESTADISTICO, false, DEFAULT_RECIBO);
    $xRe->init();
    $xRe->setNuevoMvto($fecha, $xCred->getSaldoActual(), OPERACION_CLAVE_VINCULACION, $xCred->getPeriodoActual(), "", 1, false, $socio, $credito, $fecha);
    $xRe->setFinalizarRecibo();
    $msg .= $xSoc->getMessages(OUT_TXT);
    $msg .= $xCred->getMessages(OUT_TXT);
    $msg .= $xRe->getMessages(OUT_TXT);
    $xF = new cFileLog();
    $xF->setWrite($msg);
    $xF->setClose();
    return $xF->getLinkDownload("Descarga de Log");
}
 $xFil = new cFileImporter();
 //var_dump($_FILES["f1"]);
 if ($xFil->processFile($doc1) == true) {
     $data = $xFil->getData();
     $xPlan = new cPlanDePagos();
     //eliminar credito
     $xCred = new cCredito($credito);
     $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);
$xHP->init();
?>
<style>
body {	padding-top:1in;
		padding-bottom:1in;
		padding-left:1in;
		padding-right:1in;
		
	}
</style>
<!-- -->
<?php 
$xFecha = new cFecha();
$xCred = new cCredito($idsolicitud);
$xCred->initCredito();
$acreditante = $xCred->getClaveDePersona();
$xFMT = new cFormato($formato);
$xFMT->setCredito($idsolicitud);
$xFMT->setProcesarVars();
echo $xFMT->get();
$mSQL = new cSQLListas();
$mql = new MQL();
$sql = $mSQL->getListadoDeAvales($idsolicitud, $acreditante);
$rs = $mql->getDataRecord($sql);
//setLog($sql);
$forma = 5002;
//$xAval		= new cSocios_relaciones();
foreach ($rs as $rows) {
    echo "<br class='nuevapagina' />";
    $persona = $rows["numero_socio"];
    $idrelacion = $rows["num"];
$persona = parametro("persona", DEFAULT_SOCIO, MQL_INT);
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$credito = parametro("idsolicitud", $credito, MQL_INT);
$credito = parametro("solicitud", $credito, MQL_INT);
$cuenta = parametro("cuenta", DEFAULT_CUENTA_CORRIENTE, MQL_INT);
$cuenta = parametro("idcuenta", $cuenta, MQL_INT);
$jscallback = parametro("callback");
$tiny = parametro("tiny");
$form = parametro("form");
$action = parametro("action", SYS_NINGUNO);
$xHP->init();
$xFRM = new cHForm("frm", "plan_de_pagos");
if ($credito > DEFAULT_CREDITO) {
    $xCred = new cCredito($credito);
    $xCred->init();
    $persona = $xCred->getClaveDePersona();
    $xFRM->OHidden("idsolicitud", $credito, "");
    $xFRM->OHidden("idsocio", $persona, "");
    $xFRM->addHElem($xCred->getFicha(true, "", false, true));
    if ($xCred->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
    }
} else {
    $xFRM->addJsBasico();
    $xFRM->addCreditBasico();
    $xFRM->addSubmit();
}
echo $xFRM->get();
$jxc->drawJavaScript(false, true);
$xHP->fin();
} else {
    $oFrm->OButton("TR.Recargar", "jsRecargar()", "refrescar", "refrescar");
    //Tabs
    $xHTabs = new cHTabs();
    $xBtn = new cHButton("");
    $xCred = new cCredito($idsolicitud);
    if ($xCred->init() == false) {
        $idsocio = getPersonaEnSession();
        $oFrm->addToolbar($xBtn->getRegresar("../index.xul.php?p=frmcreditos/creditos.panel.frm.php", true));
        $oFrm->addCreditBasico();
        $oFrm->addSubmit();
        $oFrm->addAviso($xCred->getMessages());
        //echo $oFrm->get();
    } else {
        if (setNoMenorQueCero($idsocio) <= 0) {
            $idsocio = $xCred->getClaveDePersona();
        }
        $xOPdto = $xCred->getOProductoDeCredito();
        if ($idsocio != $xCred->getClaveDePersona()) {
            $msg = "ERROR\tLa Persona {$idsocio} no es la propietaria del credito, el credito marca " . $xCred->getClaveDePersona() . "\r\n";
            $oFrm->addToolbar($xBtn->getRegresar("../index.xul.php?p=frmcreditos/creditos.panel.frm.php", true));
            $oFrm->addAviso($msg);
        } else {
            $oFrm->addHTML($xCred->getFichaDeSocio(true));
            $oFrm->addHTML($xCred->getFicha(true, "", true));
            $codigo_de_oficial = $xCred->getClaveDeOficialDeCredito();
            if (MODO_DEBUG == true) {
                $oFrm->addToolbar($xBtn->getBasic("TR.EDICION_AVANZADA", "jsActualizarCreditoRAW()", "aviso", "edit-credito2", false));
                $oFrm->addToolbar($xBtn->getBasic("TESTING", "var xG=new Gen();xG.w({url:'../unit/core.creditos.test.php?credito={$idsolicitud}'})", "checar", "test-cred", false));
            }
            $oFrm->addCreditoComandos($idsolicitud);
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$credito = parametro("credito", DEFAULT_CREDITO, MQL_INT);
$credito = parametro("idsolicitud", $credito, MQL_INT);
$credito = parametro("solicitud", $credito, MQL_INT);
$cuenta = parametro("cuenta", DEFAULT_CUENTA_CORRIENTE, MQL_INT);
$cuenta = parametro("idcuenta", $cuenta, MQL_INT);
$jscallback = parametro("callback");
$tiny = parametro("tiny");
$form = parametro("form");
$action = parametro("action", SYS_NINGUNO);
$monto = 0;
if (setNoMenorQueCero($persona) <= DEFAULT_SOCIO) {
    $xDoc = new cCredito($credito);
    $xDoc->init();
    $persona = $xDoc->getClaveDePersona();
    $monto = $xDoc->getMontoAutorizado();
}
$xHP->init();
$xFRM = new cHForm("frm", "./");
$xHSel = new cHSelect();
$xChk = new cHCheckBox();
$xText = new cHText();
$msg = "";
$xFRM->addPersonaBasico();
$xFRM->addGuardar("jsVincularAval()");
$xFRM->addHElem($xChk->get("TR.es dependiente_economico", "dependiente"));
$xFRM->addHElem($xHSel->getListaDeTiposDeRelaciones("", PERSONAS_REL_CLASE_AVAL)->get(true));
$xFRM->addHElem($xHSel->getListaDeTiposDeParentesco()->get(true));
$xFRM->OMoneda("idmonto", $monto, "TR.Monto Avalado");
$xFRM->OHidden("iddocumentorelacionado", $credito, "");
$xAML = new cAMLPersonas($persona_de_pruebas);
$x2AML = new cAMLPersonas_PerfilTransaccional($persona_de_pruebas);
if ($runTest == true) {
    $xCred = new cCredito($credito_de_pruebas);
    $init = true;
    $xCred->init();
    //Ministrar
    if ($xCred->getEsAfectable() == false) {
        $xCred->setForceMinistracion();
        $xCred->setMinistrar("", DEFAULT_CHEQUE, 0, DEFAULT_CUENTA_BANCARIA, 0, 0, "", '2014-01-01');
        $init = $xCred->init();
    }
    if ($init == true) {
        $xRec = new cReciboDeOperacion(RECIBOS_TIPO_PAGO_CREDITO, true);
        $xRec->setDocumento($xCred->getNumeroDeCredito());
        $xRec->setSocio($xCred->getClaveDePersona());
        $idrec = $xRec->setNuevoRecibo($xCred->getClaveDePersona(), $xCred->getNumeroDeCredito(), fechasys(), 1);
        $xCred->setReciboDeOperacion($idrec);
        //agregar pagos
        $xCred->setAbonoCapital(2200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-01-15");
        //if($xCred->getORecibo() != null){ $xCred->getORecibo()->setFinalizarRecibo(true); }
        $xCred->setAbonoCapital(5200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-01-20");
        //if($xCred->getORecibo() != null){ $xCred->getORecibo()->setFinalizarRecibo(true); }
        $xCred->setAbonoCapital(6200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-01-30");
        //if($xCred->getORecibo() != null){ $xCred->getORecibo()->setFinalizarRecibo(true); }
        $xCred->setAbonoCapital(8200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-02-05");
        //if($xCred->getORecibo() != null){ $xCred->getORecibo()->setFinalizarRecibo(true); }
        $xCred->setAbonoCapital(9200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-02-06");
        $xCred->setAbonoCapital(9200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-02-10");
        //if($xCred->getORecibo() != null){ $xCred->getORecibo()->setFinalizarRecibo(true); }
        $xCred->setAbonoCapital(2200, 1, DEFAULT_CHEQUE, TESORERIA_COBRO_EFECTIVO, DEFAULT_RECIBO_FISCAL, "", DEFAULT_GRUPO, "2014-02-15");
		border-color: #808080;
        text-align: justify;
        border-left-color: #FFFFFF !important;
        
	}
	table {
		border-width: 1px;
		border-style: solid;
		border-color: #808080;
        border-spacing: 0;
        border-collapse: collapse;
	}
@page {
	/*size: portrait;*/
}	
</style>
<body>
<?php 
$xFecha = new cFecha();
$xCred = new cCredito($idsolicitud);
$xCred->initCredito();
$DCred = $xCred->getDatosDeCredito();
$numero_de_socio = $xCred->getClaveDePersona();
$xForma = new cFormato($formato);
$xForma->setCredito($idsolicitud);
$xForma->setProcesarVars();
echo $xForma->get();
?>
</body>
</html>
 function init($arrData = false, $credito = false, $dataPagos = false)
 {
     $fecha = $this->mFechaDeCorte;
     $credito = $credito == false ? $this->mClaveDeCredito : $credito;
     $xCred = new cCredito($credito);
     $xCred->init($arrData);
     $xCred->initPagosEfectuados($dataPagos, $fecha);
     //setLog($dataPagos);
     $xSoc = new cSocio($xCred->getClaveDePersona());
     $xSoc->init();
     $this->mInfoLinea[1] = $this->getText($this->getClaveDeOtorgante());
     $this->mInfoLinea[2] = $this->getText($this->getNombreOtorgante());
     $this->mInfoLinea[3] = $this->getFechaDeReporte();
     $this->mInfoLinea[4] = $this->getText($xSoc->getApellidoPaterno());
     $this->mInfoLinea[5] = $this->getText($xSoc->getApellidoMaterno());
     $this->mInfoLinea[6] = "";
     $nombres = explode(" ", $xSoc->getNombre(), 2);
     $this->mInfoLinea[7] = isset($nombres[SYS_CERO]) ? $this->getText($nombres[SYS_CERO]) : "";
     $this->mInfoLinea[8] = isset($nombres[SYS_UNO]) ? $this->getText($nombres[SYS_UNO]) : "";
     $this->mInfoLinea[9] = $this->getDate($xSoc->getFechaDeNacimiento());
     $this->mInfoLinea[10] = $this->getText($xSoc->getRFC());
     $this->mInfoLinea[11] = isset($this->mTituloPersonal[$xSoc->getTipoGenero()]) ? $this->mTituloPersonal[$xSoc->getTipoGenero()] : "";
     //Hiber Tadeo
     $this->mInfoLinea[12] = $this->getEstadoCivil($xSoc->getEstadoCivil());
     $this->mInfoLinea[13] = $this->mEquivGenero[$xSoc->getTipoGenero()];
     //TODO: terminar defuncion/muerte de la persona
     $this->mInfoLinea[14] = "";
     $this->mInfoLinea[15] = "";
     $xDom = $xSoc->getODomicilio();
     if ($xDom == null) {
         for ($i = 16; $i <= 23; $i++) {
             $this->mInfoLinea[$i] = "";
         }
     } else {
         $this->mInfoLinea[16] = $this->getText($xDom->getCalleConNumero());
         $this->mInfoLinea[17] = "";
         $this->mInfoLinea[18] = $this->getText($xDom->getColonia());
         $this->mInfoLinea[19] = $this->getText($xDom->getMunicipio());
         $this->mInfoLinea[20] = $this->getText($xDom->getCiudad());
         $this->mInfoLinea[21] = $this->getText($xDom->getClaveDeEstadoEnSIC());
         $this->mInfoLinea[22] = $this->getText($xDom->getCodigoPostal());
         $xTel = $xSoc->getTelefonoPrincipal();
         //Hiber Tadeo
         $this->mInfoLinea[23] = $xTel == 0 ? "" : $xTel;
         //Hiber Tadeo
     }
     $xAE = $xSoc->getOActividadEconomica();
     if ($xAE == null) {
         $this->mInfoLinea[24] = $this->getText($xSoc->getRFC(true));
         //Para Finsureste debe de ser este RFC del cliente
         $this->mInfoLinea[33] = 0;
     } else {
         $this->mInfoLinea[24] = $this->getText($xSoc->getRFC(true));
         //Para Finsureste debe de ser este RFC del cliente//$this->getText($xAE->getNombreEmpresa());
         $this->mInfoLinea[33] = $this->getText($xDom->getCalleConNumero());
         //Para Finsureste debe de ser direccion del cliente //Hiber Tadeo Aca es direccion
     }
     //direccion 2
     $this->mInfoLinea[25] = "";
     $this->mInfoLinea[26] = $this->getText($xDom->getColonia());
     //Para Finsureste
     $this->mInfoLinea[27] = $this->getText($xDom->getMunicipio());
     //Para Finsureste
     $this->mInfoLinea[28] = $this->getText($xDom->getCiudad());
     //Para Finsureste
     $this->mInfoLinea[29] = $this->getText($xDom->getClaveDeEstadoEnSIC());
     //Para Finsureste
     $this->mInfoLinea[30] = $this->getText($xDom->getCodigoPostal());
     //Para Finsureste
     $this->mInfoLinea[31] = $xTel == 0 ? "" : $xTel;
     //Hiber Tadeo  //Para Finsureste
     $this->mInfoLinea[32] = "";
     $this->mInfoLinea[34] = $this->getClaveDeOtorgante();
     $this->mInfoLinea[35] = $this->getText($this->getNombreOtorgante());
     $this->mInfoLinea[36] = $xCred->getNumeroDeCredito();
     $this->mInfoLinea[38] = $this->getTipoDeCuenta($xCred->getTipoDePago());
     //datos del convenio
     $DConv = $xCred->getOProductoDeCredito();
     $this->mInfoLinea[37] = $this->getTipoDeResponsabilidad($DConv->getTipoDeIntegracion());
     $this->mInfoLinea[39] = $DConv->getTipoDeContratoCR();
     //"PL";//$DConv->getTipoDeContratoCR(); //Hiber Tadeo CL=LINEA DE CREDITO PL=PRESTAMO PERSONAL
     $this->mInfoLinea[40] = AML_CLAVE_MONEDA_LOCAL;
     //TODO: mejorar
     $this->mInfoLinea[41] = $xCred->getPagosAutorizados();
     if ($xCred->getTipoEnSistema() == CREDITO_PRODUCTO_NOMINA) {
         //TODO: Parchar con el de TADEO
         $this->mInfoLinea[42] = "P";
     } else {
         $this->mInfoLinea[42] = $this->mEquivFrecPagos[$xCred->getPeriocidadDePago()];
     }
     $this->mInfoLinea[43] = $this->getDate($xCred->getFechaDeMinistracion());
     $this->mInfoLinea[44] = $this->getMonto($xCred->getMontoDeParcialidad());
     $this->mInfoLinea[45] = $this->getDate($xCred->getFechaUltimoDePago());
     $this->mInfoLinea[46] = $this->getDate($xCred->getFechaDeMinistracion());
     $this->mInfoLinea[47] = "";
     //$this->getDate("2029-12-31" );
     if ($xCred->getSaldoActual($fecha) <= TOLERANCIA_SALDOS) {
         $this->mInfoLinea[47] = $this->getDate($xCred->getFechaUltimoDePago());
     }
     $this->mInfoLinea[48] = $this->getFechaDeReporte();
     $DCapacidad = $xSoc->getOCapacidadDePago();
     $this->mInfoLinea[49] = $this->getMonto($DCapacidad->getMontoDeCreditoMaximo());
     $this->mInfoLinea[50] = $this->getMonto($xCred->getSaldoIntegrado($fecha));
     //$xCred->getSaldoActual();
     $this->mInfoLinea[51] = $this->getMonto($DCapacidad->getLimiteDeCredito());
     $this->mInfoLinea[52] = $this->getMonto($xCred->getSaldoVencido());
     //53 numero de pagos vencidos
     $this->mInfoLinea[53] = 0;
     //54 forma mop
     $this->mInfoLinea[54] = $xCred->getMOP($fecha);
     // ($this->mOut == OUT_CSV) ? "01" : "'01";
     //55 clave de observacion, segun catalogo
     $this->mInfoLinea[55] = "";
     //56 clave de otorgante anterior
     //57 nombre otorgante anterior
     $this->mInfoLinea[56] = "";
     $this->mInfoLinea[57] = "";
     $this->mInfoLinea[58] = "";
     //Numero de cuenta anterior en caso de cartera tranferida
     $this->mInfoLinea[59] = $xCred->getFechaDePrimerAtraso() == null ? "" : $this->getDate($xCred->getFechaDePrimerAtraso());
     //TODO: Fecha de Primera atraso
     $this->mInfoLinea[60] = $this->getMonto($xCred->getSaldoActual($fecha));
     //Saldo Insoluto del Principal
     $this->mInfoLinea[61] = $this->getMonto($xCred->getMontoUltimoPago());
     // $xCred->getMontoDeParcialidad();//0; //TODO: Monto de Ultimo pago
     if (MODO_DEBUG == true) {
         $this->mMessages .= $xCred->getMessages(OUT_TXT);
     }
 }
$xDate2 = new cHDate(2, false, FECHA_TIPO_NACIMIENTO);
$xSel = new cHSelect();
$xHNot = new cHNotif();
$xChk = new cHCheckBox();
if ($action == SYS_NINGUNO) {
    $xFRM->addGuardar("jsCheck()");
}
//=========================================== AVALES
if (setNoMenorQueCero($con_relacion) > 0) {
    $xHSel = new cHSelect();
    $tipoRe = "";
    if (setNoMenorQueCero($persona_rel) <= 0) {
        if ($con_relacion == iDE_CREDITO) {
            $xDoc = new cCredito($documento_rel);
            $xDoc->init();
            $persona_rel = $xDoc->getClaveDePersona();
            $tipoRe = PERSONAS_REL_CLASE_AVAL;
        }
        //TODO: Iniciar cuenta de captacion
    }
    $tipo_de_ingreso = TIPO_INGRESO_RELACION;
    $con_domicilio = true;
    $con_actividad = true;
    $desde_sucursal = getSucursal();
    $xFRM->addHElem($xSel->getListaDeTiposDeRelaciones("", $tipoRe)->get(true));
    $xFRM->addHElem($xChk->get("TR.es dependiente_economico", "dependiente"));
    $xFRM->addHElem($xHSel->getListaDeTiposDeParentesco()->get(true));
    $xFRM->OHidden("iddocumentorelacionado", $documento_rel, "");
    $xFRM->OHidden("idpersonarelacionado", $persona_rel, "");
    $xFRM->OHidden("idorigenrelacionado", $con_relacion, "");
}
<style>
body {
		padding-top:1in;
		padding-bottom:1in;
		padding-left:1in;
		padding-right:1in;	
	}
</style>
<?php 
    echo $xHP->setBodyinit("javascript:window.print()");
    $arrQ = array("aumento" => 1, "disminucion" => -1, "ninguna" => 0);
    //capturar datos del recibo
    $DRec = array();
    $cCred = new cCredito($credito);
    $cCred->init();
    $idsocio = $cCred->getClaveDePersona();
    $numero_de_socio = $cCred->getClaveDePersona();
    $afectaCaja = 1;
    //datos del socio
    $cSoc = new cSocio($numero_de_socio);
    $DSoc = $cSoc->getDatosInArray();
    $numero_caja_local = $DSoc["cajalocal"];
    $cCL = new cCajaLocal($numero_caja_local);
    $caja_local = $cCL->getNombre();
    $variable_nombre_del_socio = $idsocio == DEFAULT_SOCIO ? $DRec["cadena_distributiva"] : $cSoc->getNombreCompleto();
    $tipo_de_pago = "efectivo";
    //$variable_nombre_del_cajero
    //
    $tipoderecibo = 1;
    $docto = $cCred->getNumeroDeCredito();
    $origen = "";
 function setCambiarPersonaDeCredito($credito, $nueva_persona)
 {
     $xCred = new cCredito($credito);
     $xCred->init();
     $numero_socio = $xCred->getClaveDePersona();
     $numero_nuevo = $nueva_persona;
     $var = array();
     $xQL = new MQL();
     $run = false;
     $msg = "";
     $msg .= "================== MODIFICANDO UN NUMERO DE SOCIO \r\n";
     $msg .= "================== SE ACTUALIZA DEL {$numero_socio} AL  {$numero_nuevo} \r\n";
     //$var2["aml_alerts"]["C"]						="documento_relacionado";
     //$var2["aml_alerts"]["P"]						="persona_de_destino";
     $var["aml_risk_register"]["C"] = "documento_relacionado";
     $var["aml_risk_register"]["P"] = "persona_relacionada";
     $var["bancos_operaciones"]["C"] = "numero_de_documento";
     $var["bancos_operaciones"]["P"] = "numero_de_socio";
     $var["captacion_cuentas"]["C"] = "numero_solicitud";
     $var["captacion_cuentas"]["P"] = "numero_socio";
     $var["contable_polizas_proforma"]["C"] = "documento";
     $var["contable_polizas_proforma"]["P"] = "socio";
     $var["creditos_flujoefvo"]["C"] = "solicitud_flujo";
     $var["creditos_flujoefvo"]["P"] = "socio_flujo";
     $var["creditos_garantias"]["C"] = "solicitud_garantia";
     $var["creditos_garantias"]["P"] = "socio_garantia";
     $var["creditos_parametros_negociados"]["C"] = "numero_de_credito";
     $var["creditos_parametros_negociados"]["P"] = "numero_de_socio";
     $var["creditos_sdpm_historico"]["C"] = "numero_de_credito";
     $var["creditos_sdpm_historico"]["P"] = "numero_de_socio";
     $var["creditos_solicitud"]["C"] = "numero_solicitud";
     $var["creditos_solicitud"]["P"] = "numero_socio";
     $var["operaciones_mvtos"]["C"] = "docto_afectado";
     $var["operaciones_mvtos"]["P"] = "socio_afectado";
     $var["operaciones_recibos"]["C"] = "docto_afectado";
     $var["operaciones_recibos"]["P"] = "numero_socio";
     $var["seguimiento_compromisos"]["C"] = "credito_comprometido";
     $var["seguimiento_compromisos"]["P"] = "socio_comprometido";
     $var["seguimiento_llamadas"]["C"] = "numero_solicitud";
     $var["seguimiento_llamadas"]["P"] = "numero_socio";
     $var["seguimiento_notificaciones"]["C"] = "numero_solicitud";
     $var["seguimiento_notificaciones"]["P"] = "socio_notificado";
     $var["socios_memo"]["C"] = "numero_solicitud";
     $var["socios_memo"]["P"] = "numero_socio";
     $var["socios_relaciones"]["C"] = "credito_relacionado";
     $var["socios_relaciones"]["P"] = "socio_relacionado";
     $var["tesoreria_cajas_movimientos"]["C"] = "documento";
     $var["tesoreria_cajas_movimientos"]["P"] = "persona";
     $var["usuarios_web_notas"]["C"] = "documento";
     $var["usuarios_web_notas"]["P"] = "socio";
     $var["aml_alerts"]["C"] = "documento_relacionado";
     $var["aml_alerts"]["P"] = "persona_de_origen";
     //? Funciona bien?
     //$var2["creditos_solicitud"]["C"]			="numero_solicitud";
     //$var2["creditos_solicitud"]["P"]			="persona_asociada";
     //$var2["socios_relaciones"]["C"]			="credito_relacionado";
     //$var2["socios_relaciones"]["P"]			="numero_socio";
     //$var2["operaciones_recibos"]["C"]			="docto_afectado";
     //$var2["operaciones_recibos"]["P"]			="persona_asociada";
     foreach ($var as $tabla => $items) {
         if (isset($items["P"]) and isset($items["C"])) {
             $campo = $items["P"];
             $filtro = $items["C"];
             $msg .= "WARN\tCambiar Registros de la Tabla { {$tabla} }, Campo [ {$campo} ] de #{$numero_socio} - #{$numero_nuevo} con filtro ({$filtro}).\r\n";
             //$msg	.= "UPDATE  $tabla SET $campo = $numero_nuevo WHERE $filtro = $credito AND $campo = $numero_socio\r\n";
             $xQL->setRawQuery("UPDATE  {$tabla} SET {$campo} = {$numero_nuevo} WHERE {$filtro} = {$credito} AND {$campo} = {$numero_socio}");
             $run = true;
         }
     }
     if ($run = true) {
         $xSoc1 = new cSocio($numero_nuevo);
         $xSoc1->init();
         $xSoc2 = new cSocio($numero_socio);
         $xSoc2->init();
         $xSoc1->addMemo(MEMOS_TIPO_NOTA_RENOVACION, "Cambio de Propietario del Credito {$credito} desde la Persona {$numero_socio}", $credito);
         $xSoc2->addMemo(MEMOS_TIPO_NOTA_RENOVACION, "Cambio de Propietario del Credito {$credito} a la Persona {$numero_nuevo}", $credito);
     }
     $this->mMessages .= $msg;
     return $msg;
 }
$entidad = EACP_NAME;
if ($idsolicitud == DEFAULT_CREDITO) {
    echo JS_CLOSE;
} else {
    $xCred = new cCredito($idsolicitud);
    $xCred->init();
    $siavales = isset($_GET["avales"]) ? $_GET["avales"] : SYS_NINGUNO;
    $sigarantias = isset($_GET["garantias"]) ? $_GET["garantias"] : SYS_NINGUNO;
    $sipatrimonio = isset($_GET["patrimonio"]) ? $_GET["patrimonio"] : SYS_NINGUNO;
    $siflujo = isset($_GET["flujo"]) ? $_GET["flujo"] : SYS_NINGUNO;
    $sihistorial = isset($_GET["historial"]) ? $_GET["historial"] : SYS_NINGUNO;
    $nowdate = fechasys();
    $rwc = $xCred->getDatosDeCredito();
    $fecha_de_solicitud = $rwc["fecha_solicitud"];
    // datos generales del socio
    $idsocio = $xCred->getClaveDePersona();
    // Numero de Socio
    $xSocio = new cSocio($idsocio);
    $xSocio->init();
    $mynom = $xSocio->getNombreCompleto();
    $thisdom = $xSocio->getDomicilio();
    $sqlconv = "SELECT * FROM creditos_tipoconvenio WHERE idcreditos_tipoconvenio =" . $xCred->getClaveDeConvenio();
    $dconv = obten_filas($sqlconv);
    $convenio = $dconv["descripcion_tipoconvenio"];
    $mod_del_conv = $dconv["tipo_de_integracion"];
    ?>
<!-- -->
<h2>SOLICITUD DE CR&Eacute;DITO [<?php 
    echo $convenio;
    ?>
 # <?php 
 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 initByCredito($ClaveCredito = false)
 {
     $ClaveCredito = $ClaveCredito == false ? $this->mCredito : $ClaveCredito;
     $xCred = new cCredito($ClaveCredito);
     $xCred->init();
     $this->mClaveDeCredito = $xCred->getNumeroDeCredito();
     $this->mClaveDePersona = $xCred->getClaveDePersona();
     $this->mClaveDeGrupo = $xCred->getClaveDeGrupo();
     $this->mClaveDeEmpresa = $xCred->getClaveDeEmpresa();
     $this->mTasaDeIVA = $xCred->getTasaIVA();
     $this->mTotalParciales = $xCred->getPagosAutorizados();
     if ($this->mDiasTolerancia == 0) {
         $DProducto = $xCred->getOProductoDeCredito();
         $this->mDiasTolerancia = $DProducto->getDiasTolerados();
     }
     if ($xCred->getNumeroDePlanDePagos() != false) {
         $this->mNumeroDePlan = $xCred->getNumeroDePlanDePagos();
         $this->init();
     }
     $this->mIsInit = true;
     $this->mMessages .= $xCred->getMessages(OUT_TXT);
     return $this->mNumeroDePlan;
 }
        exit;
    }
}
$xCred = new cCredito($solicitud, $socio);
$xCred->init();
$xLetra = null;
$tds = "";
$esp_tds = "";
$mMvtos = array();
$alerts = "";
//Movimientos que afectan al Capital
$cAfectCapital = new cBases(2004);
$aAfectCapital = $cAfectCapital->getMembers_InArray();
$mAfectCapital = 0;
$plan_de_pagos = false;
$socio = $xCred->getClaveDePersona();
$dcredito = $xCred->getDatosDeCredito();
$fecha_ministracion = $xCred->getFechaDeMinistracion();
// $dcredito["fecha_ministracion"];
$fecha_ult_mvto = $xCred->getFechaUltimoDePago();
$fecha_vencimiento = $xCred->getFechaDeVencimiento();
// $dcredito["fecha_vencimiento"];
$numero_de_pagos = $xCred->getPagosAutorizados();
$estatus_del_credito = $xCred->getEstadoActual();
$saldo_actual = $xCred->getSaldoActual();
$saldo_del_credito = $saldo_actual;
$interes_anticipado = $dcredito["sdo_int_ant"];
$grupo = $xCred->getClaveDeGrupo();
$OProducto = $xCred->getOProductoDeCredito();
//$OEstado					= $xCred->getOEstado();
$tasa_iva = $generarIVA == false ? 0 : $xCred->getTasaIVA();