function jsaSetDomicilioMismo($socio, $HDomicilio)
{
    $HDomicilio = strtoupper($HDomicilio);
    if ($HDomicilio == "MISMO") {
        $xSoc = new cSocio($socio);
        $xSoc->init();
        $DDom = $xSoc->getDatosDomicilio(99);
        $domicilio = $xSoc->getDomicilio();
        $cDom = new cSocios_aeconomica();
        $cDom->setData($DDom);
        $telefono = $cDom->telefono_ae()->v();
        $estado = $cDom->estado_ae()->v();
        $municipio = $cDom->municipio_ae()->v();
        $localidad = $cDom->localidad_ae()->v();
        $tab = new TinyAjaxBehavior();
        $tab->add(TabSetValue::getBehavior('idtelefono', $telefono));
        $tab->add(TabSetValue::getBehavior('identidadfederativa', $estado));
        $tab->add(TabSetValue::getBehavior('idmunicipio', $municipio));
        $tab->add(TabSetValue::getBehavior('idlocalidad', $localidad));
        $tab->add(TabSetValue::getBehavior('iddomiciliodeactividad', $domicilio));
        return $tab->getString();
    }
}
 function setGenerarPerfilesPorActividadEconomica()
 {
     $xQL = new MQL();
     $rs = $xQL->getDataRecord("SELECT `socios_aeconomica`.* FROM `socios_aeconomica` `socios_aeconomica`");
     $xAct = new cSocios_aeconomica();
     $msg = "";
     foreach ($rs as $rows) {
         $xAct->setData($rows);
         $xAml = new cAMLPersonas($xAct->socio_aeconomica()->v());
         $xAml->addTransaccionalidadPorEmpresa($xAct->dependencia_ae()->v(), $xAct->monto_percibido_ae()->v(), $xAct->fecha_alta()->v());
         $msg .= $xAml->getMessages();
     }
     return $msg;
 }
        break;
    case TPERSONAS_DIRECCIONES:
        $xDom = new cSocios_vivienda();
        $D = obten_filas("SELECT * FROM socios_vivienda WHERE socio_numero = {$data} ORDER BY fecha_alta DESC LIMIT 0,1");
        $xDom->setData($D);
        //setLog("SELECT * FROM socios_vivienda WHERE socio_numero = $data ORDER BY fecha_alta DESC LIMIT 0,1");
        //$value = mb_check_encoding($value, 'UTF-8') ? $value : utf8_encode($value);
        //$comment = iconv('UTF-8', 'UTF-8//IGNORE', $comment);
        //SELECT column1, CONVERT(column2 USING utf8)
        $query = $xDom->query();
        $query->setToUTF8();
        //setLog(json_encode($query->getCampos()) );
        $cnt = $svc->getEncryptData(json_encode($query->getCampos()));
        break;
    case TPERSONAS_ACTIVIDAD_ECONOMICA:
        $xTrab = new cSocios_aeconomica();
        $D = obten_filas("SELECT * FROM `socios_aeconomica` WHERE\t(`socios_aeconomica`.`socio_aeconomica` = {$data} ) ORDER BY `socios_aeconomica`.`fecha_alta` DESC\tLIMIT 0,1");
        $xTrab->setData($D);
        $query = $xTrab->query();
        $query->setToUTF8();
        $cnt = $svc->getEncryptData(json_encode($query->getCampos()));
        break;
    case TCATALOGOS_EMPRESAS:
        $xEmp = new cSocios_aeconomica_dependencias();
        $D = obten_filas("SELECT * FROM `socios_aeconomica_dependencias` WHERE (`socios_aeconomica_dependencias`.`clave_de_persona` ={$data}) LIMIT 0,1");
        $xEmp->setData($D);
        $query = $xEmp->query();
        $query->setToUTF8();
        $cnt = $svc->getEncryptData(json_encode($query->getCampos()));
        break;
}
$ql = new MQL();
$lis = new cSQLListas();
$xF = new cFecha();
$tabla = parametro("tabla", false, MQL_RAW);
$clave = parametro("id", false, MQL_RAW);
$rs = array();
//AND MODO_DEBUG == true
if ($tabla != false and $clave != false) {
    $xObj = new cSAFETabla($tabla);
    if ($xObj->obj() == null) {
        $rs["message"] = "ERROR\tAl eliminar el Registro con ID {$clave} en la Tabla {$tabla}\r\n";
        $rs["error"] = true;
    } else {
        $obj = $xObj->obj();
        $key = $obj->getKey();
        $obj = new cSocios_aeconomica();
        $obj->setData($obj->query()->initByID($clave));
        $data = base64_encode(json_encode($obj->query()->getCampos()));
        $ql->setRawQuery("DELETE FROM {$tabla} WHERE {$key}='{$clave}'");
        $rs["message"] = "OK\tSe elimina el Registro con ID {$clave} en la Tabla {$tabla}\r\n";
        if (MODO_DEBUG == true) {
            $rs["message"] .= $ql->getMessages();
        }
        $rs["error"] = false;
        //guardar error
        $xLog = new cCoreLog();
        $xLog->add($rs["message"] . " {$data}", $xLog->COMMON);
        $xLog->guardar($xLog->OCat()->ELIMINAR_RAW);
        //agregar memo
    }
}
 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;
 }
 function setCorregirActividadEconomica($correcion = false)
 {
     //obtener codigo postal
     $msg = "";
     //verificar si existe persona
     $ql = new MQL();
     $rs = $ql->getDataRecord("SELECT * FROM  `socios_aeconomica` ");
     $xAct = new cSocios_aeconomica();
     //$xT				= new cTipos();
     //$xT->setForceMayus();
     //$xT->setToUTF8();
     //$xT->setForceClean();
     foreach ($rs as $rows) {
         $xAct->setData($rows);
         $persona = $xAct->socio_aeconomica()->v();
         $id = $xAct->idsocios_aeconomica()->v();
         $cp = $xAct->ae_codigo_postal()->v();
         $iddom = $xAct->domicilio_vinculado()->v();
         //===========
         //==
         $xPerAe = new cPersonaActividadEconomica($persona);
         $xPerAe->setID($id);
         $xPerAe->init();
         if ($xPerAe->isInit() == true) {
             if ($xPerAe->setUpdatePorEmpresa(true) == false) {
                 $xPerAe->setUpdatePorDomicilio();
             }
             $msg .= $xPerAe->getMessages();
         } else {
             $msg .= "ERROR\tAl procesar el Domicilio\r\n";
         }
         //verificar si tiene codigo postal
     }
     $rs = $ql->getDataRecord("SELECT * FROM  `socios_aeconomica` WHERE `domicilio_vinculado` <= 1 OR `ae_codigo_postal` <= 1 ");
     $xAct = new cSocios_aeconomica();
     foreach ($rs as $rows) {
         $xAct->setData($rows);
         $persona = $xAct->socio_aeconomica()->v();
         $id = $xAct->idsocios_aeconomica()->v();
         $cp = $xAct->ae_codigo_postal()->v();
         $iddom = $xAct->domicilio_vinculado()->v();
         $idsuc = $xAct->sucursal()->v();
         $xSuc = new cSucursal($idsuc);
         if ($xSuc->init() == true) {
             $xAct->ae_codigo_postal($xSuc->getCodigoPostal());
             $xAct->ae_clave_de_localidad($xSuc->getClaveDeLocalidad());
         }
         $success = $xAct->query()->update()->save($id);
         if ($success != false) {
             $xPerAe = new cPersonaActividadEconomica($persona);
             $xPerAe->setID($id);
             $xPerAe->init();
             if ($xPerAe->isInit() == true) {
                 if ($xPerAe->setUpdatePorEmpresa(true) == false) {
                     $xPerAe->setUpdatePorDomicilio();
                 }
                 $msg .= $xPerAe->getMessages();
             } else {
                 $msg .= "ERROR\tAl procesar el Domicilio con ID {$id} 2\r\n";
             }
         } else {
             $msg .= "ERROR\tAl procesar al actualizar {$id}\r\n";
         }
     }
     return $msg;
 }
         $xSoc = new cSocios_general($dpersona);
         $xSoc->query()->insert()->save();
         //Iniciar Cuenta de Captacion
     }
     break;
 case TPERSONAS_DIRECCIONES:
     $ddomicilio = $svc->getService(SVC_ASOCIADA_HOST . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
     if (is_array($ddomicilio)) {
         $xDom = new cSocios_vivienda($ddomicilio);
         $xDom->query()->insert()->save();
     }
     break;
 case TPERSONAS_ACTIVIDAD_ECONOMICA:
     $dtrabajo = $svc->getService(SVC_ASOCIADA_HOST . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
     if (is_array($dtrabajo)) {
         $xAe = new cSocios_aeconomica($dtrabajo);
         $xAe->query()->insert()->save();
     }
     break;
 case TCATALOGOS_EMPRESAS:
     $dempresa = $svc->getService(SVC_ASOCIADA_HOST . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
     foreach ($dempresa as $indice => $valor) {
         if ($indice == TCATALOGOS_EMPRESAS) {
             $dempresa = $valor;
         }
     }
     if (is_array($dempresa)) {
         $xEmp = new cSocios_aeconomica_dependencias($dempresa);
         $xEmp->query()->insert()->save();
     }
     break;