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 jsaGuardarVerificacion($fecha, $oficial, $tipo, $id, $notas, $socio)
{
    $xF = new cFecha();
    $fecha = $xF->getFechaISO($fecha);
    $tipo = $tipo == "d" ? TPERSONAS_DIRECCIONES : TPERSONAS_ACTIVIDAD_ECONOMICA;
    $xSoc = new cSocio($socio);
    $xSoc->init();
    $xSoc->setVerificacion($tipo, $id, $fecha, $notas, $oficial);
    return $xSoc->getMessages(OUT_HTML);
}
     if ($origen_relacion == iDE_CREDITO) {
         $xCred = new cCredito($documentorelacionado);
         $xCred->init();
         $MontoAvalado = $xCred->getMontoAutorizado();
         $addAval = $xCred->addAval($persona, $MontoAvalado, $idtipoderelacion, $idtipodeparentesco, $dependiente, $idobservaciones);
         $msg .= $xCred->getMessages();
     }
     //captacion
     //persona
     if ($origen_relacion == iDE_SOCIO) {
         if ($personarelacionado > 0) {
             $xPer = new cSocio($personarelacionado);
             if ($xPer->init() == true) {
                 $addRel = $xPer->addRelacion($persona, $idtipoderelacion, $idtipodeparentesco, $dependiente, $idobservaciones);
             }
             $msg .= $xPer->getMessages();
         } else {
             $msg .= "ERROR\tError al agregar a la Relacion, no existe relacionado \r\n";
         }
     }
 }
 $xCat = new cPersonasCatalogoOtrosDatos();
 //AGREGAR PEP
 if ($espep == true and setNoMenorQueCero($persona) > 0) {
     $xSoc->addOtrosParametros($xCat->AML_PEP_PRINCIPAL, "1");
 }
 if ($esextranjero == true and setNoMenorQueCero($persona) > 0) {
     $xSoc->addOtrosParametros($xCat->PERSONAS_ES_EXTRANJERO, "1");
 }
 //agregar Relacion
 if (MODO_DEBUG == true) {
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");
}
 function getMontoIDE($fecha = false, $monto = 0, $tipodepago = "efectivo")
 {
     $ide = 0;
     if (CAPTACION_IMPUESTOS_A_DEPOSITOS_ACTIVO == true) {
         if ($this->mCuentaIniciada == false) {
             $this->init();
         }
         $xSoc = new cSocio($this->mSocioTitular, true);
         $ide = $xSoc->getIDExPagarByPeriodo($fecha, $monto, $tipodepago);
         $this->mMessages .= $xSoc->getMessages();
         $this->mIDExRetener = $ide;
     }
     return $ide;
 }
                                //limpiar calle
                                $DCalle = split("NUMERO", $calle);
                                //(strpos($calle, "NUMERO") === false) ? split(" ", $calle) :  split("NUMERO", $calle);
                                $calle = trim($DCalle[0]);
                                $numero = isset($DCalle[1]) ? trim($DCalle[1]) : "SN";
                                $codigo_postal = $cT->cInt(trim($datos[15]));
                                $colonia = $cT->cChar(trim($datos[14]));
                                $referencia = isset($datos[7]) ? "ENTRE " . $cT->cChar(trim($datos[7])) . " Y " . $cT->cChar(trim($datos[8])) : "";
                                $telefono1 = $cT->cChar(trim($datos[10]));
                                $telefono2 = $cT->cChar(trim($datos[12]));
                                $es_principal = $tdom == 1 ? TIPO_DOMICILIO_PRINCIPAL : TIPO_DOMICILIO_ORDINARIO;
                                $tipo_dom = $tdom == 1 ? TIPO_DOMICILIO_PARTICULAR : DEFAULT_TIPO_DOMICILIO;
                                $fechaVivienda = $xF->getFechaISO($cT->cChar(trim($datos[9])));
                                $tiempo_de_residir = $xF->getEscalaTiempo($fechaVivienda);
                                $xSoc->addVivienda($calle, $numero, $codigo_postal, "", $referencia, $telefono1, $telefono2, $es_principal, TIPO_VIVIENDA_PROPIA, $tipo_dom, $tiempo_de_residir, $colonia);
                                $msg .= $xSoc->getMessages("txt") . "\n";
                            }
                        }
                        $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)) {
 function setActualizarRiesgoPorNucleo()
 {
     //si todos son riesgo
     $xLi = new cSQLListas();
     $xQL = new MQL();
     $sql = $xLi->getListadoDePersonasExpuestas($this->mClaveDePersona);
     $rs = $xQL->getDataRecord($sql);
     $xCat = new cPersonasCatalogoOtrosDatos();
     foreach ($rs as $rows) {
         $idpersona = $rows["numero_socio"];
         $afinidad = $rows["grado_de_afinidad"];
         $consanguinidad = $rows["grado_de_consanguinidad"];
         $vinculoeconom = $rows["tiene_vinculo_patrimonial"];
         //agregar
         $tipoaml = $consanguinidad > 0 ? $xCat->AML_PEP_CONSANGUINIDAD : "";
         $tipoaml = ($afinidad > 0 and $tipoaml == "") ? $xCat->AML_PEP_AFINIDAD : $tipoaml;
         $tipoaml = ($vinculoeconom > 0 and $tipoaml == "") ? $xCat->AML_PEP_VINCULO_ECONOM : $tipoaml;
         if ($tipoaml != "") {
             $xRel = new cSocio($idpersona);
             if ($xRel->init() == true) {
                 $xRel->addOtrosParametros($tipoaml, "1");
                 $this->mMessages .= $xRel->getMessages();
             }
         }
     }
 }
             		*/
             $idpersona = $xFi->getEntero($tmp->ID_PERSONA);
             if ($idpersona > 0) {
                 $xSoc->setOmitirAML();
                 $pass = $xSoc->add($xFi->getV($tmp->NOMBRES), $xFi->getV($tmp->PRIMER_APELLIDO), $xFi->getV($tmp->SEGUNDO_APELLIDO), $xFi->getV($tmp->ID_FISCAL), $xFi->getV($tmp->ID_POBLACIONAL), getCajaLocal(), $xFi->getV($tmp->FECHA_NACIMIENTO), $xFi->getV($tmp->CIUDAD_NACIMIENTO), DEFAULT_TIPO_INGRESO, $xFi->getV($tmp->ESTADO_CIVIL, DEFAULT_ESTADO_CIVIL, MQL_INT, $arrEcivil), $xFi->getV($tmp->GENERO, DEFAULT_GENERO, MQL_INT, $arrGenero), FALLBACK_CLAVE_EMPRESA, DEFAULT_REGIMEN_CONYUGAL, $xFi->getV($tmp->TIPO_PERSONA, FALLBACK_PERSONAS_FIGURA_JURIDICA, MQL_INT, $arrFJuridica), FALLBACK_CLAVE_DE_GRUPO, "", FALLBACK_PERSONAS_TIPO_IDENTIFICACION, $xFi->getV($tmp->ID_POBLACIONAL), $idpersona, getSucursal(), 0, "", 0, $xFi->getV($tmp->FECHA_ALTA));
                 //sucess
                 if ($pass == true) {
                     $ingreso = $xFi->getFlotante($tmp->INGRESOS_MENSUALES);
                     if ($ingreso > 0) {
                         if ($xSoc->init() == true) {
                             $xSoc->addActividadEconomica($xFi->getV($tmp->EMPRESA_TRABAJO, ""), $ingreso, $xFi->getV($tmp->OCUPACION, ""));
                         }
                     }
                 }
             }
             $msg .= $xSoc->getMessages();
         }
         $conteo++;
     }
 }
 $msg .= $xFi->getMessages();
 if (MODO_DEBUG == true) {
     $xLog = new cFileLog();
     $xLog->setWrite($msg);
     $xFRM->addToolbar($xLog->getLinkDownload("Archivo del proceso", ""));
 }
 //==================================================================================================================
 /*			fclose ($gestor);
 				$xLog->setWrite($msg);
 				$xFRM->addToolbar( $xLog->getLinkDownload("Archivo del proceso", ""));
 		}	else {
 function add($clave_de_actividad, $ingreso, $antiguedad = DEFAULT_TIEMPO, $nombrecomercial = "", $codigo_postal = 0, $telefono = 0, $idlocalidad = 0, $nombrelocalidad = "", $nombremunicipio = "", $nombreestado = "")
 {
     $codigo_postal = setNoMenorQueCero($codigo_postal) <= 0 ? $this->mCodigoPostal : $codigo_postal;
     $idlocalidad = setNoMenorQueCero($idlocalidad) <= 0 ? $this->mClaveDeLocalidad : $idlocalidad;
     $nombreestado = $nombreestado == "" ? $this->mNombreDeEstado : $nombreestado;
     $nombremunicipio = $nombremunicipio == "" ? $this->mNombreDeMunicipio : $nombremunicipio;
     $nombrelocalidad = $nombrelocalidad == "" ? $this->mNombreDeLocalidad : $nombrelocalidad;
     $nombrecomercial = $nombrecomercial == "" ? $this->mNombreEmpresa : $nombrecomercial;
     $telefono = setNoMenorQueCero($telefono);
     $telefono = $telefono <= 0 ? $this->mTelefono : $telefono;
     $ingreso = setNoMenorQueCero($ingreso);
     $this->mIDDomicilio = setNoMenorQueCero($this->mIDDomicilio) <= 0 ? FALLBACK_DOMICILIO : $this->mIDDomicilio;
     $persona = $this->mPersona;
     $xAE = new cSocios_aeconomica();
     $xSoc = new cSocio($persona);
     $success = false;
     $xAE->ae_clave_de_localidad($idlocalidad);
     $xAE->ae_codigo_postal($codigo_postal);
     $xAE->antiguedad_ae($antiguedad);
     $xAE->departamento_ae($this->mDepto);
     $xAE->dependencia_ae($this->mClaveEmpresa);
     $xAE->domicilio_ae($this->mDomicilio);
     $xAE->domicilio_vinculado($this->mIDDomicilio);
     $xAE->estado_actual(99);
     //99= No verificado
     $xAE->estado_ae($nombreestado);
     $xAE->extension_ae($this->mExtTelefonica);
     $xAE->telefono_ae($telefono);
     $xAE->fecha_alta(fechasys());
     $xAE->fecha_de_verificacion(fechasys());
     $xAE->idusuario(getUsuarioActual());
     $xAE->localidad_ae($nombrelocalidad);
     $xAE->monto_percibido_ae($ingreso);
     $xAE->municipio_ae($nombremunicipio);
     $xAE->nombre_ae($nombrecomercial);
     $xAE->numero_de_seguridad_social($this->mNSS);
     $xAE->numero_empleado($this->mIDEmpleado);
     $xAE->oficial_de_verificacion(getUsuarioActual());
     $xAE->puesto($this->mPuesto);
     $xAE->sector_economico(FALLBACK_SECTOR_ECONOMICO);
     $xAE->socio_aeconomica($this->mPersona);
     $xAE->sucursal(getSucursal());
     $xAE->telefono_ae($telefono);
     $xAE->tipo_aeconomica($clave_de_actividad);
     if ($xSoc->init() == true) {
         $id = $xAE->query()->getLastID();
         $xAE->idsocios_aeconomica($id);
         //$clave_de_actividad != FALLBACK_ACTIVIDAD_ECONOMICA AND
         if ($ingreso > 0) {
             $id = $xAE->query()->insert()->save();
             if ($id > 0) {
                 $success = true;
                 $this->mMessages .= "OK\t{$persona}\tSe agrego con exito la ACTIVIDAD ECONOMICA {$clave_de_actividad} ({$id}) \r\n";
                 //actualizar la persona a la dependencia o empresa
                 if ($this->mClaveEmpresa != FALLBACK_CLAVE_EMPRESA) {
                     $xSoc->setResetEmpresa($this->mClaveEmpresa);
                     $this->mMessages .= "OK\t{$persona}\tSe Actualiza la empresa relacionada a " . $this->mClaveEmpresa . "\r\n";
                 }
                 if (MODULO_AML_ACTIVADO == true) {
                     //agregar al perfil transaccional
                     //$xAML				= new cAMLPersonas($persona);
                     //$xAML->init($persona, $xSoc->getDatosInArray());
                     //$periodos			= 2;
                     //$xAML->s
                 }
                 $xSoc->setCuandoSeActualiza();
             } else {
                 $this->mMessages .= "ERROR\t{$persona}\tHubo un error al dar de alta a la ACTIVIDAD ECONOMICA\r\n";
             }
         } else {
             $this->mMessages .= "ERROR\t{$persona}\tEl Ingreso ({$ingreso}) debe ser superior a CERO y la Clave ({$clave_de_actividad}) debe tener un valor valido\r\n";
         }
         //Aviso AML
         $this->mMessages .= $xSoc->getMessages();
     }
     return $success;
 }
foreach ($rs as $rw) {
    $xCaja = new cCaja();
    $xCaja->init($rw["codigo"]);
    if ($xCaja->setActualizaFondosCobrados() > TOLERANCIA_SALDOS) {
        $messages .= "ERROR\t Caja No cerrada por tener fondos pendientes \r\n";
    } else {
        $xCaja->setCloseBox(getUsuarioActual(), 0);
    }
    $messages .= $xCaja->getMessages(OUT_TXT);
}
//Verificar lo Valores por defecto
if ($xSuc->existeSocio(DEFAULT_SOCIO) == false) {
    $cajaLocalR = $xSuc->getCajaLocalResidente();
    $xSoc = new cSocio(DEFAULT_SOCIO);
    $xSoc->add("", "PUBLICO_GENERAL", "", "POR_REGISTRAR", "POR_REGISTRAR", $cajaLocalR, false, "DESCONOCIDO", 99, 99, 99, 99, 99, 1, DEFAULT_GRUPO, "", 1, "0", DEFAULT_SOCIO, getSucursal());
    $messages .= $xSoc->getMessages(OUT_TXT);
}
if ($xSuc->existeCredito(DEFAULT_CREDITO) == false) {
    $xCred = new cCredito(DEFAULT_CREDITO, DEFAULT_SOCIO);
    $xCred->add(DEFAULT_TIPO_CONVENIO, DEFAULT_SOCIO, DEFAULT_CUENTA_CORRIENTE, 0, CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO, 1, 1, CREDITO_DEFAULT_DESTINO, DEFAULT_CREDITO, DEFAULT_GRUPO, "CREDITO POR DEFECTO");
    $messages .= $xCred->getMessages(OUT_TXT);
}
if ($xSuc->existeCuenta(DEFAULT_CUENTA_CORRIENTE) == false) {
    $xCta = new cCuentaALaVista(DEFAULT_CUENTA_CORRIENTE);
    $xCta->setNuevaCuenta("99", "99", DEFAULT_SOCIO);
    $messages .= $xCta->getMessages(OUT_TXT);
}
$ql = new MQL();
/*
 * ====================================================================================================================================================
 * Agregar codigo de actualizar menores a personas fisicas
$xFec = new cHDate();
$xTa = new cHTextArea();
if ($action == SYS_NINGUNO) {
    $xUsers = $xSel->getUsuarios("idusuarioreportado");
    $xFRM->setTitle($xHP->getTitle());
    $xFRM->addPersonaBasico("", false, $persona);
    $xFRM->addJsBasico(iDE_AML);
    $xFRM->ODate("idfechaevento", false, "TR.Fecha de Evento");
    $xFRM->addHElem($xSel->getListaDeNivelDeRiesgo("", $nivelcargado)->get("TR.Nivel de Riesgo", true));
    $xFRM->addHElem($xTa->get("idmensaje", $notas, "TR.Razones por la cual se cambia el Nivel de riesgo"));
    $xFRM->addSubmit();
} else {
    if (setNoMenorQueCero($persona) > 0) {
        $fecha = parametro("idfechaevento", false, MQL_DATE);
        $mensaje = parametro("idmensaje");
        $nivel = parametro("idnivelderiesgo", 0, MQL_INT);
        $xSoc = new cSocio($persona);
        $xSoc->init();
        $xSoc->setActualizarNivelDeRiesgo($nivel, $mensaje, $fecha);
        if (MODO_DEBUG == true) {
            $xFRM->addAviso($xSoc->getMessages());
        }
    }
}
echo $xFRM->get();
?>
<script>

</script>
<?php 
$xHP->fin();
 function setPersona($clave_de_persona)
 {
     $this->mPersona = $clave_de_persona;
     $cSoc = new cSocio($clave_de_persona);
     $fichas_de_respsolidarios = "";
     $firmas_de_respsolidarios = "";
     if ($cSoc->init() == true) {
         $domicilio_del_socio = $cSoc->getDomicilio();
         $ficha_socio = $cSoc->getFicha(true, true);
         $xODom = $cSoc->getODomicilio();
         $xOAE = $cSoc->getOActividadEconomica();
         //Caja local por SQL
         $SQLCL = "SELECT idsocios_cajalocal, descripcion_cajalocal, ultimosocio, region, sucursal FROM socios_cajalocal WHERE idsocios_cajalocal=" . $cSoc->getNumeroDeCajaLocal();
         $caja_local = mifila($SQLCL, "descripcion_cajalocal");
         $xFecha = new cFecha();
         $this->mArr["variable_domicilio_del_socio"] = $domicilio_del_socio;
         $this->mArr["variable_rfc_del_socio"] = $cSoc->getRFC();
         $this->mArr["variable_curp_del_socio"] = $cSoc->getCURP();
         $this->mArr["variable_numero_de_socio"] = $cSoc->getCodigo();
         $this->mArr["variable_nombre_caja_local"] = $caja_local;
         $this->mArr["variable_informacion_del_socio"] = $ficha_socio;
         $this->mArr["variable_fecha_de_nacimiento_del_socio"] = $xFecha->getFechaMediana($cSoc->getFechaDeNacimiento());
         $this->mArr["variable_ciudad_de_nacimiento_del_socio"] = $cSoc->getLugarDeNacimiento();
         if ($xODom != null) {
             $this->mArr["variable_sin_ciudad_domicilio_del_socio"] = $xODom->getDireccionBasica();
             $this->mArr["variable_ciudad_del_socio"] = $xODom->getCiudad();
             $this->mArr["variable_persona_domicilio_municipio"] = $xODom->getMunicipio();
         }
         if ($xOAE != null) {
             $this->mArr["variable_actividad_economica_del_socio"] = $xOAE->getPuesto();
             $this->mArr["variable_estado_de_actividad_economica"] = $xOAE->getNombreEstado();
             $this->mArr["variable_municipio_de_actividad_economica"] = $xOAE->getNombreMunicipio();
             $this->mArr["variable_nombre_de_la_empresa"] = $xOAE->getNombreEmpresa();
             $this->mArr["variable_socio_actividad_ciudad"] = $xOAE->getLocalidad();
             $this->mArr["variable_socio_actividad_telefono"] = $xOAE->getTelefono();
         }
         $this->mArr["variable_nombre_del_socio"] = $cSoc->getNombreCompleto();
         $this->mArr["variable_persona_nombre_completo"] = $cSoc->getNombreCompleto();
         $idestadocivil = $cSoc->getEstadoCivil();
         $DEstadoCivil = new cSocios_estadocivil();
         $DEstadoCivil->setData($DEstadoCivil->query()->initByID($idestadocivil));
         $nombre_estadocivil = $DEstadoCivil->descripcion_estadocivil()->v();
         $this->mArr["variable_estado_civil_del_socio"] = $nombre_estadocivil;
         $firmas_de_respsolidarios = $cSoc->getCoResponsables("firmas");
     } else {
         if (MODO_DEBUG == true) {
             setLog($cSoc->getMessages());
         }
     }
     $this->mArr["variable_responsable_solidario_en_fichas"] = $fichas_de_respsolidarios;
     $this->mArr["variable_firmas_de_obligados_solidarios"] = $firmas_de_respsolidarios;
 }
$xChk = new cHCheckBox();
$msg = "";
$xFRM->addJsBasico();
$xFRM->addCreditBasico();
$xFRM->addSubmit();
$xFRM->addHElem($xSel->getListaDeTiposDeMemoPersonas()->get(true));
$xFRM->addHElem($xChk->get("TR.Notificar", "idnotificar"));
$xFRM->OTextArea("idmemo", $mem, "TR.Texto del memo");
if ($persona > DEFAULT_SOCIO) {
    $idgrupo = parametro("idgrupo", DEFAULT_GRUPO, MQL_INT);
    $txtmemo = parametro("idmemo");
    $tipomemo = parametro("idtipodememo");
    $notificar = parametro("idnotificar", false, MQL_BOOL);
    $fechamemo = fechasys();
    if (trim($txtmemo) != "") {
        $xSoc = new cSocio($persona);
        $xSoc->init();
        $xSoc->addMemo($tipomemo, $txtmemo, $credito, $fechamemo, $notificar, $notificar);
        $xFRM->addAviso("EL REGISTRO SE HA HECHO SATISFACTORIAMENTE");
        if (MODO_DEBUG == true) {
            $xFRM->addLog($xSoc->getMessages());
        }
    }
}
//.-
echo $xFRM->get();
?>

</body>
</html>
        //$cCta->init();
        //Imprime la Ficha del Documento
        $xCDestino->init();
        $fd = $xCDestino->getFicha(true);
        $xCOrigen->init();
        $fo = $xCOrigen->getFicha(true);
        echo "<fieldset><legend>DATOS DEL TRAPASO</legend>\n\t\t\t\tCuenta de Origen:<br />\n\t\t\t\t{$fo}\t\n\t\tCuenta de Destino:<br />\n\t\t{$fd}\n\t\t</fieldset>";
        $mRec = new cFicha(iDE_RECIBO, $ReciboTrasp);
        $mRec->setTableWidth();
        $mRec->show();
        // *****************************************************************************
        echo "<input type='button' name='btsend' value='IMPRIMIR/VER RECIBO DE TRASPASO' onClick='jsGetComprobanteDeTraspaso();'>";
    } else {
        $xBtn = new cHButton("");
        if (MODO_DEBUG == true) {
            $msg .= $xSoc->getMessages("html");
        }
        echo "<p class='aviso'>{$msg}<br />" . $xBtn->getRegresar() . "</p>";
    }
}
?>
</body>
<script  >
function jsGetCuentas(){
	getCuentasForPut();
}
function jsSetSaldoCuenta(){
	jsGetSaldoCuenta();
}
function jsGetComprobanteDeTraspaso(){
	var elUrl= "../rpt_formatos/frmrecibogeneral.php?recibo=<?php 
 $xConv->init();
 if (USE_OFICIAL_BY_PRODUCTO == true) {
     $oficial_de_seguimiento = $xConv->getOficialDeSeguimiento();
 }
 if ($esrenovado == true) {
     $TipoDeAutorizacion = CREDITO_AUTORIZACION_RENOVADO;
     $msg .= "WARN\tCredito marcado como Renovado \r\n";
 }
 $xCred = new cCredito();
 $result = $xCred->add($tipoconvenio, $persona, $contrato_corriente, $monto_solicitado, $periocidad, $numeropagos, $dias_solicitados, $rubro_destino, false, $grupo_asociado, $amp_destino, $observaciones, $oficial_de_credito, $fecha_solicitud, $tipo_de_pago, INTERES_POR_SALDO_INSOLUTO, false, $fecha_ministracion, $xSoc->getClaveDeEmpresa(), $TipoDeAutorizacion);
 if ($result == false) {
     $xFRM->addToolbar($xBtn->getRegresar("solicitud_de_credito.frm.php", true));
     $xFRM->addAviso($xHP->lang(MSG_ERROR_SAVE));
     $xFL = new cFileLog();
     $xFL->setWrite($xCred->getMessages(OUT_TXT));
     $xFL->setWrite($xSoc->getMessages());
     $xFL->setClose();
     $xFRM->addToolbar($xFL->getLinkDownload("Log de eventos", ""));
     $xFRM->addAviso($xCred->getMessages());
 } else {
     $xCred->init();
     $credito = $xCred->getNumeroDeCredito();
     //Si es Automatizado
     $xCat = new cCreditosOtrosDatos();
     if ($tieneprops == true) {
         $xCred->setOtrosDatos($xCat->AML_CON_PROPIETARIO, "1");
     }
     if ($tieneprovs == true) {
         $xCred->setOtrosDatos($xCat->AML_CON_PROVEEDOR, "1");
     }
     if ($xCred->getTipoDeAutorizacion() == CREDITO_TIPO_AUTORIZACION_AUTOMATICA) {
$persona = parametro("persona", DEFAULT_SOCIO, MQL_INT);
$persona = parametro("socio", $persona, MQL_INT);
$persona = parametro("idsocio", $persona, MQL_INT);
$relacionado = parametro("relacionado", DEFAULT_SOCIO, MQL_INT);
$tipo = parametro("tipo", 0, MQL_INT);
$parentesco = parametro("parentesco", 0, MQL_INT);
$depende = parametro("depende", false, MQL_BOOL);
$documento = parametro("documento", false, MQL_INT);
$rs["error"] = false;
if ($persona > DEFAULT_SOCIO and $relacionado > DEFAULT_SOCIO) {
    $xPer = new cSocio($persona);
    if ($xPer->init() == true) {
        if ($xPer->addRelacion($relacionado, $tipo, $parentesco, $depende, "", 0, 1, false, $documento) == true) {
            $txt .= "OK\tSe agrega la Relacion {$relacionado} - {$persona} ({$documento})\r\n";
        } else {
            $rs["error"] = true;
            $txt .= "ERROR\tAl agregar la Relacion {$relacionado} - {$persona} ({$documento})\r\n";
        }
    } else {
        $rs["error"] = true;
        $txt .= "ERROR\tNo existe la persona {$persona}\r\n";
    }
    if (MODO_DEBUG == true) {
        $txt .= $xPer->getMessages();
    }
}
$rs["msg"] = $txt;
header('Content-type: application/json');
echo json_encode($rs);
//setLog(json_encode($rs));
//setLog($sql);
function jsaSetEnviarParaAsociada($idpersona)
{
    $xSoc = new cSocio($idpersona);
    $xSoc->init();
    $xSoc->setMontoAhorroPreferente(0);
    return $xSoc->getMessages();
}
         //Obtener pais
         $pais = trim($xFil->cleanString($xFil->getV(5), array("/-0-/")));
         $sqlPais = "SELECT * FROM `personas_domicilios_paises` WHERE `nombre_oficial` SOUNDS LIKE '%{$pais}%' LIMIT 0,1";
         $idpais = mifila($sqlPais, "clave_de_control");
         $idpais = $idpais == 0 ? EACP_CLAVE_DE_PAIS : $idpais;
         //Obtener Localidad
         $sqllocal = "SELECT * FROM `catalogos_localidades` WHERE `nombre_de_la_localidad` LIKE '%{$estado} {$pais}%' LIMIT 0,1";
         $DLocal = $xQL->getDataRow($sqllocal);
         if (setNoMenorQueCero($DLocal["clave_unica"]) > 0) {
             $idlocal = setNoMenorQueCero($DLocal["clave_unica"]);
             $localidad = $DLocal["nombre_de_la_localidad"];
         }
         $xSoc->addVivienda($calle, $numero, $cp, "", $referencia, "0", "0", SYS_UNO, FALLBACK_PERSONAS_REGIMEN_VIV, FALLBACK_PERSONAS_TIPO_VIV, DEFAULT_TIEMPO, $colonia, "calle", "", $idlocal, $idpais, $pais, $estado, $municipio, $localidad);
         //Actualizar pais
     }
     $msg .= $xSoc->getMessages(OUT_TXT);
     break;
 case "ALT":
     /*
     1597|1190|"aka"|"OCTOBER HOLDING COMPANY"|-0- 
     1661|1229|"aka"|"PESMAR S.A."|-0-
     6857|4607|"aka"|"CARDENAS GUILLEN, Oscar"|-0-
     */
     //$someword = strtolower(preg_replace("/[^a-z]+/i", "-", $theword));
     $xSoc = new cSocio($id);
     if ($xSoc->existe($id) == true) {
         $xFil->setDataRow($cont);
         $eq = array("AKA" => 511, "FKA" => 512);
         $xRel = new cSocios_relaciones();
         //$xRel->apellido_materno()
         $idrelacion = $xFil->getEntero(2);
 /**
  * funcion que agrega un aval al crédito
  *
  * */
 function addAval($AvalNumeroSocio, $MontoAvalado, $TipoDeAval, $Consanguinidad = 99, $Dependiente = 2, $Observaciones = "")
 {
     if ($this->mCreditoInicializado == false) {
         $this->init();
     }
     $xSoc = new cSocio($this->getClaveDePersona());
     $xSoc->init();
     $porcentaje = (setNoMenorQueCero($MontoAvalado) > 0 and setNoMenorQueCero($this->mMontoAutorizado) > 0) ? round($MontoAvalado / $this->mMontoAutorizado, 2) : $this->mMontoAutorizado;
     $fecha = fechasys();
     $rs = $xSoc->addRelacion($AvalNumeroSocio, $TipoDeAval, $Consanguinidad, $Dependiente, $Observaciones, $MontoAvalado, $porcentaje, $fecha, $this->mNumeroCredito);
     $this->mMessages .= $rs == true ? "OK\tAval Codigo {$AvalNumeroSocio} agregado al credito " . $this->mNumeroCredito . "\r\n" : "ERROR\tError en alta de Aval\r\n";
     if (MODO_DEBUG == true) {
         $this->mMessages .= $xSoc->getMessages();
     }
     return $rs;
 }
        if (trim($_FILES["idnuevoarchivo"]["name"]) == "") {
            $archivoenviado = null;
        }
    }
    $xSoc = new cSocio($persona);
    $xSoc->init();
    if ($doc1 !== false) {
        $ready = $xSoc->setGuardarDocumento($tipodedocto, $doc1, $pagina, $observaciones, false, $archivoenviado);
        if ($ready == true) {
            $xFRM->addAvisoRegistroOK();
        } else {
            $xFRM->addAvisoRegistroError();
        }
    }
    if (MODO_DEBUG == true) {
        $xFRM->addLog($xSoc->getMessages(OUT_TXT));
    }
}
echo $xFRM->get();
//$jsb->show();
?>
<!-- HTML content -->
<script>
var xG	= new Gen();
function jsGetDocto(){
	xG.w({
		url : "../frmutils/docs.explorer.php?callback=jsSetDocto"
		});
}
function jsSetDocto(mfile){
	$("#iddocumento").val(mfile);
function jsaPrevalidarCredito($socio, $solicitud, $numpagos, $periocidad, $convenio, $contrato, $fechaMin, $fechaVenc, $monto)
{
    $clave = md5($socio . $solicitud . ROTTER_KEY . date("Ymd"));
    $out = false;
    $msg = "";
    $ctrl = "";
    $xHO = new cHObject();
    $xBtn = new cHButton();
    $arrDatos = array("numero_de_solicitud" => $solicitud, "periocidad_de_pago" => $periocidad, "tipo_de_producto" => $convenio, "numero_de_pagos" => $numpagos, "contrato_corriente_relacionado" => $contrato, "fecha_de_ministracion" => $fechaMin, "fecha_de_vencimiento" => $fechaVenc);
    if ($socio == DEFAULT_SOCIO or $socio == 0) {
        $msg .= "ERROR\t{$socio}\tClave de Persona no Valido\r\n";
        $out = false;
    } else {
        if ($solicitud == DEFAULT_CREDITO or $solicitud == 0) {
            $msg .= "ERROR\t{$socio}\t{$solicitud}\tNumero de Credito no Valido\r\n";
            $out = false;
        } else {
            //Valorar Numero de Creditos por Socio
            $xSoc = new cSocio($socio);
            if ($xSoc->existe($socio) == false) {
                $msg .= "ERROR\t{$socio}\tEl Socio No Existe\r\n";
                $out = false;
            } else {
                $xSoc->init();
                $out = $xSoc->setPrevalidarCredito($arrDatos);
                $msg .= $xSoc->getMessages();
            }
        }
    }
    if ($out == true) {
        $msg .= "OK\tEL CREDITO HA SIDO VALIDADO POR EL SISTEMA - CUMPLE LOS REQUISITOS\r\n";
        $ctrl .= $xBtn->getBasic("TR.guardar credito", "jsFormularioValidado('{$clave}')", "guardar", "idvalidarok");
        $ctrl .= $xBtn->getBasic("TR.validar nuevamente", "jsPrevalidarCredito()", "checar", "idnuevavalidacion");
    } else {
        //$ctrl = "<input type=\"button\" name=\"cmdSubmit\" onclick=\"jsPrevalidarCredito();\" value=\"VALIDAR CREDITO NUEVAMENTE\" />";
        $ctrl .= $xBtn->getBasic("TR.validar nuevamente", "jsPrevalidarCredito()", "checar", "idnuevavalidacion");
    }
    $msg = $xHO->Out($msg, OUT_HTML);
    $svalidate = "{$msg} {$ctrl}";
    return $svalidate;
}
                                $numero_interior = "";
                                $referencia = "";
                                $telefono_fijo = $cT->cChar(trim($datos[18]));
                                $telefono_movil = $cT->cChar(trim($datos[17]));
                                $es_principal = TIPO_DOMICILIO_PRINCIPAL;
                                $regimen_vivienda = TIPO_VIVIENDA_PROPIA;
                                $relRFC = "";
                                $tipo_persona = TIPO_JURIDICO_FISICA;
                                $tipo_relacion = $arrRefTipo[trim($datos[5])];
                                $xRel->add($relNombre, $relApPat, $relApMat, $relRFC, "", getCajaLocal(), false, "", TIPO_INGRESO_RELACION, DEFAULT_ESTADO_CIVIL, $relGenero, DEFAULT_EMPRESA, DEFAULT_REGIMEN_CONYUGAL, $tipo_persona, $grupo_solidario, "", DEFAULT_TIPO_IDENTIFICACION, "", $idRelSocio, false, "{$relTelP}", "{$relMail}", 0);
                                //Agregar domicilio
                                $xRel->addVivienda($relCalle, $numero, $codigo_postal, $numero_interior, $referencia, $telefono_fijo, $telefono_movil, $es_principal, $regimen_vivienda, TIPO_DOMICILIO_PARTICULAR, DEFAULT_TIEMPO, $relColonia);
                                $xRel->init();
                                $xSoc->addRelacion($xRel->getCodigo(), $tipo_relacion, DEFAULT_TIPO_CONSANGUINIDAD, 1, "Importado");
                                $msg .= $xSoc->getMessages("txt");
                                $msg .= $xRel->getMessages("txt");
                            }
                        }
                        $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)) {