private function saveProfilePermission()
 {
     $this->load->file('application/modules/app/security_profile/form/permissions_form.php');
     $resAjax = new Response_Ajax();
     $frmData = new Form_App_Profile_Permission(TRUE);
     try {
         if (!empty($frmData->id_profile) && !$this->permission->update_permission) {
             throw new Exception('No tiene permisos para editar');
         }
         if (!$frmData->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $eProfilesPermissions = $frmData->getProfilePermissionEntities();
         $oBus = Business_App_Profile::saveProfilePermission($frmData->id_profile, $eProfilesPermissions);
         $resAjax->isSuccess($oBus->isSuccess());
         $resAjax->message($oBus->message());
     } catch (Exception $e) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($e->getMessage());
         $resAjax->form('permission', $frmData->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
 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 loadProfile()
 {
     $this->load->file('application/modules/app/user_profile/form/profile_form.php');
     $resAjax = new Response_Ajax();
     $id_person = Helper_App_Session::getPersonId();
     $oBus = Business_App_Person::loadByPersonId($id_person);
     $data = $oBus->data();
     /* @var $ePerson ePerson  */
     $ePerson = $data['ePerson'];
     $frm_data = new Form_App_Profile();
     $frm_data->setPersonEntity($ePerson);
     /* @var $eCiudad eCiudad */
     $oBus1 = Business_App_Ciudad::loadCiudad($ePerson->id_ciudad, $eCiudad);
     $frm_data->id_provincia = $eCiudad->id_provincia;
     $frm_data->id_pais = $eCiudad->id_pais;
     $id_profile = Helper_App_Session::getProfileId();
     $oBusP = Business_App_Profile::loadProfile($id_profile);
     $dataProfile = $oBusP->data();
     $eProfile = $dataProfile['eProfile'];
     $frm_data->name_profile = $eProfile->name;
     $resAjax->isSuccess($oBus->isSuccess());
     $resAjax->message($oBus->message());
     $resAjax->form('profile', $frm_data->toArray());
     echo $resAjax->toJsonEncode();
 }