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);
 }
 private function loadComponents()
 {
     $resAjax = new Response_Ajax();
     $arrType = array('TIPO_IDENT', 'ESTADO_CIVIL', 'GENDER', 'TIPO_DE_SANGRE');
     try {
         $oBus = Business_App_Catalog::listByType($arrType);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $oBus1 = Business_App_Profile::listProfile('', NULL, NULL);
         $dataCatalogo = $oBus->data();
         $eCatalogs = $dataCatalogo['eCatalogs'];
         $dataProfile = $oBus1->data();
         $eProfiles = $dataProfile['eProfiles'];
         $eProfiles = Helper_Array::entitiesToIdText($eProfiles, 'id', 'name', 'value', 'text');
         $oBus2 = Business_App_Company_Branch::listByCompany(Helper_App_Session::getCompanyId(), 1);
         $dataCompanyBranch = $oBus2->data();
         $eCompanyBranches = $dataCompanyBranch['eCompanyBranchs'];
         $eCompanyBranches = Helper_Array::entitiesToIdText($eCompanyBranches, 'id', 'name', 'value', 'text');
         $resAjax->isSuccess(TRUE);
     } catch (Exception $e) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($e->getMessage());
     }
     $resAjax->data(array('eCatalogs' => $eCatalogs, 'eProfiles' => $eProfiles, 'eCompanyBranches' => $eCompanyBranches));
     echo $resAjax->toJsonEncode();
 }
 private function loadComponentsModalModule()
 {
     $resAjax = new Response_Ajax();
     $id_company = Helper_App_Session::getCompanyId();
     $combo_modules = array(array('id' => 0, 'name' => '<< --MÓDULO PADRE-- >>'));
     try {
         $oBus = Business_App_Module::listModules(NULL);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $data = $oBus->data();
         $eModules = $data['eModules'];
         $combo_modules2 = Helper_Array::entitiesToIdText($eModules, 'id', 'name', 'id', 'name');
         $combo_modules = array_merge($combo_modules, $combo_modules2);
         $resAjax->isSuccess(TRUE);
     } catch (Exception $e) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($e->getMessage());
     }
     $resAjax->data(array('combo-modules' => $combo_modules));
     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 saveCompanyBranch()
 {
     $this->load->file('application/modules/app/utility_company_and_company_branch/form/company_branch_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_App_Company_Branch(TRUE);
     try {
         if (!$this->permission->update_branch) {
             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');
         }
         $eCompanyBranch = $frm_data->getCompanyBranchEntity();
         $eCompanyBranch->id_company = Helper_App_Session::getCompanyId();
         $oBus = Business_App_Company_Branch::saveCompanyBranch($eCompanyBranch);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message($oBus->message());
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('company_branch', $frm_data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }