public function index() { $login_title = 'INGRESO AL SISTEMA'; $MY =& MY_Controller::get_instance(); /* @var $mCompany Company_Model */ $mCompany =& $MY->mCompany; /* @var $mProfile Profile_Model */ $mProfile =& $MY->mProfile; /* @var $mUser User_Model */ $mUser =& $MY->mUser; /* @var $mPerson Person_Model */ $mPerson =& $MY->mPerson; /* @var $mAppVersion App_Version_Model */ $mAppVersion =& $MY->mAppVersion; $id_company = Helper_App_Session::getCompanyId(); $id_profile = Helper_App_Session::getProfileId(); $id_user = Helper_App_Session::getUserId(); $id_person = Helper_App_Session::getPersonId(); /* @var $eCompany eCompany */ $eCompany = $mCompany->load($id_company); /* @var $eProfile eProfile */ $eProfile = $mProfile->load($id_profile); /* @var $eUser eUser */ $eUser = $mUser->load($id_user); /* @var $ePerson ePerson */ $ePerson = $mPerson->load($id_person); /* @var $eAppVersion eAppVersion */ $eAppVersion = $mAppVersion->loadArray(array('isActive' => 1, 'isProject' => 1)); $params_view = array('login_title' => $login_title, 'browser_message' => $this->browser['isSuccess'] ? $this->browser['message'] : '', 'ePerson' => $ePerson, 'eProfile' => $eProfile, 'eUser' => $eUser, 'eCompany' => $eCompany, 'eAppVersion' => $eAppVersion); Helper_App_View::view('app/html/pages/login/advanced', $params_view); }
public static function get() { $MY =& MY_Controller::get_instance(); /* @var $mSessionsActivity Session_Activity_Model */ $mSessionsActivity =& $MY->mSessionsActivity; $id_user = Helper_App_Session::getUserId(); $session_id = Helper_App_Session::getSessionID(); /* @var $eSessionActivity eSessionActivity */ $eSessionActivity = $mSessionsActivity->loadArray(['id_user' => $id_user, 'inUse' => 1, 'session_id' => $session_id]); return $eSessionActivity; }
public function mvcjs() { $this->load->file('application/modules/app/user_profile/form/profile_form.php'); $this->load->file('application/modules/app/user_profile/form/user_form.php'); $frmProfile = new Form_App_Profile(); $frmUser = new Form_App_User(); $oBus = Business_App_User::loadUser(Helper_App_Session::getUserId()); $data = $oBus->data(); $eUser = $data['eUser']; $frmUser->username = $eUser->username; $params = array('link' => $this->link, 'linkx' => $this->linkx, 'permissions' => $this->permission->toArray(), 'profile_form_default' => $frmProfile->toArray(), 'user_form_default' => $frmUser->toArray()); Helper_App_JS::showMVC('user_profile', $params); }
public static function write($var, $isEncode = FALSE, $LOG_TYPE = self::LOG_DEFAULT) { $MY =& MY_Controller::get_instance(); /* @var $mUserLog User_Log_Model */ $mUserLog =& $MY->mUserLog; /* @var $mConfigurationSystem Configuration_System_Model */ $mConfigurationSystem =& $MY->mConfigurationSystem; $id_system = Helper_App_Session::getConfigurationSystemId(); // ******************* // CONFIGURATION SYSTEM // ******************* $eConfigurationSystem = $mConfigurationSystem->load($id_system); $id_user = Helper_App_Session::getUserId(); $navegador = Helper_App_Session::getBrowser(); $action = ''; if ($LOG_TYPE == self::LOG_DEFAULT) { $action = 'ACTION_DEFAULT'; } if ($LOG_TYPE == self::LOG_LOGIN) { $action = 'ACTION_LOGIN'; } if ($LOG_TYPE == self::LOG_INSERT) { $action = 'ACTION_INSERT'; } if ($LOG_TYPE == self::LOG_UPDATE) { $action = 'ACTION_UPDATE'; } if ($LOG_TYPE == self::LOG_DELETE) { $action = 'ACTION_DELETE'; } Helper_Log::write(print_r($var, true), Helper_Log::LOG_APP); if (!empty($eConfigurationSystem->isSaveBinnacle)) { if (!empty($id_user)) { $eUserLog = new eUserLog(); $eUserLog->id_user = $id_user; $eUserLog->date_time = date('Y-m-d H:i:s'); $eUserLog->info = $isEncode ? json_encode($var) : $var; $eUserLog->action = $action; $eUserLog->url = current_url(); $eUserLog->browser = $navegador->browser . ' ' . $navegador->device_type . ' ' . $navegador->platform_maker . ' ' . $navegador->platform_description . ' de ' . $navegador->platform_bits; $eUserLog->ip = $MY->input->ip_address(); $mUserLog->save($eUserLog); } } }
public static function write($info) { $MY =& MY_Controller::get_instance(); //$MY->load->model('user_log_model','mUserLog'); $id_personal = Helper_App_Session::getUserId(); Helper_Log::write($info, Helper_Log::LOG_PROCESS); /*if( empty($id_personal) ) { } /* else { $MY->mUserLog->save(array( 'id_user' => $id_personal, 'date_time' => date('Y-m-d H:i:s'), 'info' => $info )); }*/ }
private function updatePassword() { $this->load->file('application/modules/app/layout/layout_password_data.php'); $resAjax = new Response_Ajax(); $data = new Data_App_Layout_Password(TRUE); try { if (!$data->isValid()) { throw new Exception('Complete correctamente todos los campos'); } $id_user = Helper_App_Session::getUserId(); $oBus = Business_App_User::checkPassword($id_user, $data->password_current); if (!$oBus->isSuccess()) { throw new Exception($oBus->message()); } $data_isValid = $oBus->data(); $isValid = $data_isValid['isValid']; if (!$isValid) { throw new Exception('Contraseña incorrecta.'); } $oBus2 = Business_App_User::updatePassword($id_user, $data->password_new); if (!$oBus2->isSuccess()) { throw new Exception($oBus2->message()); } $data_changed = $oBus2->data(); $changed = $data_changed['changed']; if (!$changed) { throw new Exception("No fue posible cambiar la contraseña"); } $resAjax->isSuccess(TRUE); $resAjax->message("Contraseña cambiada con éxito."); } catch (Exception $ex) { $resAjax->isSuccess(FALSE); $resAjax->message($ex->getMessage()); $resAjax->form('change_password', $data->toArray()); } echo $resAjax->toJsonEncode(); }
static function layout($view, $arrParams = array(), $arrParamsLayout = array(), $useIframe = FALSE) { $MY =& MY_Controller::get_instance(); /* @var $mConfigurationSystem Configuration_System_Model */ $mConfigurationSystem =& $MY->mConfigurationSystem; /* @var $mCompany Company_Model */ $mCompany =& $MY->mCompany; /* @var $mCompanyBranch Company_Branch_Model */ $mCompanyBranch =& $MY->mCompanyBranch; /* @var $mProfile profile_Model */ $mProfile =& $MY->mProfile; /* @var $mUser User_Model */ $mUser =& $MY->mUser; /* @var $mPerson Person_Model */ $mPerson =& $MY->mPerson; /* @var $mUserProfile User_Profile_Model*/ $mUserProfile =& $MY->mUserProfile; /* @var $mUserProfileCompanyBranch User_Profile_Company_Branch_Model */ $mUserProfileCompanyBranch =& $MY->mUserProfileCompanyBranch; /* @var $mAppVersion App_Version_Model */ $mAppVersion =& $MY->mAppVersion; $id_system = Helper_Config::getSystemId(); $id_company = Helper_App_Session::getCompanyId(); $id_company_branch = Helper_App_Session::getCompanyBranchId(); $id_profile = Helper_App_Session::getProfileId(); $id_user = Helper_App_Session::getUserId(); /* @var $eConfigurationSystem eConfigurationSystem */ $eConfigurationSystem = $mConfigurationSystem->load($id_system); /* @var $eCompany eCompany */ $eCompany = $mCompany->load($id_company); /* @var $eProfile eProfile */ $eProfile = $mProfile->load($id_profile); /* @var $eUser eUser */ $eUser = $mUser->load($id_user); /* @var $ePerson ePerson */ $ePerson = $mPerson->load($eUser->id_person); /* @var $eAppVersion eAppVersion */ $eAppVersion = $mAppVersion->loadArray(array('isActive' => 1, 'isProject' => 1)); $resources_path = 'resources/assets/app'; $arrMenu = Helper_App_Permission::getMenu(); $controller_current = $MY->uri->rsegment(1); $function_current = $MY->uri->rsegment(2); // ================================================================ // ================================================================ $eProfiles = $mUserProfile->listProfilesByUser($id_user, 1); $show_combo_perfiles = TRUE; $combo_perfiles = Helper_Array::entitiesToIdText($eProfiles, 'id', 'name', 'value', 'text', $id_profile); // ================================================================ // ================================================================ if (empty($eProfiles)) { $flash = new Response_Flash(); $flash->message('Ningun Perfil disponible!'); $flash->flashType(Response_Flash::FLASH_ERROR); Helper_App_Flash::set($flash); $show_combo_perfiles = FALSE; $useIframe = TRUE; $view = 'app/html/error/403'; } // ================================================================ // ================================================================ $eCompanyBranches = Helper_App_Session::isSuperAdminProfile() || Helper_App_Session::isAdminProfile() ? $mCompanyBranch->listByCompany($id_company) : $mUserProfileCompanyBranch->listCompanyBranchsByUserProfile($id_user, $id_profile); $show_combo_sedes = TRUE; $combo_sedes = Helper_Array::entitiesToIdText($eCompanyBranches, 'id', 'name', 'value', 'text', $id_company_branch); if (empty($eCompanyBranches)) { $flash = new Response_Flash(); $flash->message('Ninguna Sucursal disponible!'); $flash->flashType(Response_Flash::FLASH_ERROR); Helper_App_Flash::set($flash); $show_combo_sedes = FALSE; $useIframe = TRUE; $view = 'app/html/error/403'; } $content = ''; if (is_array($view)) { foreach ($view as $v) { $content .= $MY->load->view($v, $arrParams, true); } } else { $content = $MY->load->view($view, $arrParams, true); } $browser = Helper_App_Session::isIExplorer(); $arrParamsLayoutDefault = array('useIframe' => $useIframe, 'resources_path' => $resources_path, 'content' => $content, 'arrMenu' => $arrMenu, 'controller_current' => $controller_current, 'function_current' => $function_current, 'navegador' => $browser, 'eConfigurationSystem' => $eConfigurationSystem, 'eCompany' => $eCompany, 'eProfile' => $eProfile, 'ePerson' => $ePerson, 'eUser' => $eUser, 'eAppVersion' => $eAppVersion, 'show_combo_perfiles' => $show_combo_perfiles, 'combo_perfiles' => $combo_perfiles, 'show_combo_sedes' => $show_combo_sedes, 'combo_sedes' => $combo_sedes); $MY->load->view('app/html/layout/layout', array_merge($arrParamsLayoutDefault, $arrParamsLayout)); }
private function saveUser() { $this->load->file('application/modules/app/user_profile/form/user_form.php'); $resAjax = new Response_Ajax(); $frm_data = new Form_App_User(TRUE); try { if (!$this->permission->update) { throw new Exception('No tiene permisos para editar/actualizar'); } if (!$frm_data->isValid()) { throw new Exception('Debe ingresar la información en todos los campos'); } $oBus = Business_App_User::loadUser(Helper_App_Session::getUserId()); $data = $oBus->data(); $eUser = $data['eUser']; $oBus = Business_App_User::login($eUser->username, $frm_data->password_current); if (!$oBus->isSuccess()) { throw new Exception('Contraseña Incorrecta'); } $oBus = Business_App_User::updatePassword($eUser->id, $frm_data->password_new_repeat); $resAjax->isSuccess(TRUE); $resAjax->message('Contraseña Actualizada'); } catch (Exception $ex) { $resAjax->isSuccess(FALSE); $resAjax->message($ex->getMessage()); $resAjax->form('user', $frm_data->toArray()); } echo $resAjax->toJsonEncode(); }