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); }
private function saveProfile() { $this->load->file('application/modules/app/user_profile/form/profile_form.php'); $resAjax = new Response_Ajax(); $frm_data = new Form_App_Profile(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'); } $ePerson = $frm_data->getPersonEntity(); $ePerson->id = Helper_App_Session::getPersonId(); $oBus = Business_App_User_Profile::savePerson($ePerson); 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('profile', $frm_data->toArray()); } echo $resAjax->toJsonEncode(); }