/** * EditAction for Users * * @return void */ public function editAction() { $this->view->title = "Edit Users"; $form = new User_Form_User(); $form->submit->setLabel('Save'); $form->removeElement('password'); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $model = new User_Model_Users(); $id = $this->getRequest()->getPost('id'); $model->update($form->getValues(), 'id = ' . (int) $id); return $this->_helper->redirector('index'); } else { $form->populate($this->getRequest()->getPost()); } } else { $id = $this->_getParam('id', 0); if ($id > 0) { $model = new User_Model_Users(); $form->populate($model->fetchEntry($id)); } } $this->view->form = $form; }
public function addAction() { if ($this->_isUserAllowed(User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_CREATE)) { $form = new User_Form_User(User_Form_User::ACTION_ADD); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); if (isset($data['save'])) { if ($form->isValid($data)) { try { $data = $form->getValues(); $data['appaccount_id'] = Zend_Auth::getInstance()->getIdentity()->appaccount_id; $this->_add($data); $msg = 'New user created'; $this->_helper->flashMessenger->addMessage(array('success' => $msg)); $this->_helper->redirector(array('action' => 'list', 'controller' => 'admin', 'module' => 'user')); } catch (Exception $e) { $this->_addSavingExceptionMessage($e); } } else { $this->_addValidationMessage(); } } else { if (isset($data['cancel'])) { $this->_helper->redirector(array('action' => 'list', 'controller' => 'admin', 'module' => 'user')); } } } $this->view->form = $form; } }
public function edituserdetailAction() { //calling the form $addForm = new User_Form_User(); $this->view->form = $addForm; //listing designation $designation = $this->view->adm->viewRecord("ourbank_master_designation", "id", "DESC"); foreach ($designation as $designation) { $addForm->designation->addMultiOption($designation['id'], $designation['name']); } //;isting institution $bankname = $this->view->adm->viewRecord("ourbank_office", "id", "DESC"); foreach ($bankname as $bankname) { $addForm->bank_id->addMultiOption($bankname['id'], $bankname['name']); } $department = $this->view->adm->viewRecord("ourbank_master_department", "id", "DESC"); foreach ($department as $department) { $addForm->department->addMultiOption($department['id'], $department['name']); } //listing grants $grant = $this->view->adm->viewRecord("ourbank_grant", "id", "DESC"); foreach ($grant as $grant) { $addForm->grant_id->addMultiOption($grant['id'], $grant['name']); } //listing gender $gender = $this->view->adm->viewRecord("ourbank_master_gender", "id", "DESC"); foreach ($gender as $gender) { $addForm->gender->addMultiOption($gender['id'], $gender['name']); } $this->view->title = "Edit User"; //Acl // $access = new App_Model_Access(); // $checkaccess = $access->accessRights('User',$this->view->globalvalue[0]['name'],'edituserdetail'); // if (($checkaccess != NULL)) { //getting the id $id = $this->_getParam('id'); $this->view->id = $id; //displaying datas to be edited $userdetails = $this->view->adm->editRecord("ourbank_user", $id); $addForm->populate($userdetails[0]); //submit action if ($this->_request->isPost() && $this->_request->getPost('Update')) { $id = $this->_getParam('id'); $formData = $this->_request->getPost(); if ($addForm->isValid($formData)) { //editing record $previousdata = $this->view->adm->editRecord("ourbank_user", $id); //echo "<pre>"; print_r($previousdata); $this->view->adm->updateLog("ourbank_user_log", $previousdata[0], $id); $this->view->adm->updateRecord("ourbank_user", $id, $addForm->getValues()); $this->_redirect('user'); } // } else { // $this->_redirect('index/index'); } }
/** * EditAction for Users * * @return void */ public function editownuserAction() { $this->view->title = "Edit Users"; $form = new User_Form_User(); $form->submit->setLabel('Save'); $form->removeElement('password'); $form->removeElement('company_id'); $id = $_SESSION["gpms"]["storage"]->id; $this->gpms = new Zend_Session_Namespace('gpms'); //TODO pasar el role implementador y administrador sin hardcode //si es un usuario sin permiso solo puede editar su usuario y no su role_id $form->removeElement('role_id'); $id = $this->gpms->storage->id; if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $model = new User_Model_Users(); $id = $this->getRequest()->getPost('id'); $model->update($form->getValues(), 'id = ' . (int) $id); $this->_helper->redirector('index', 'company', 'company'); } else { $form->populate($this->getRequest()->getPost()); } } else { if ($id > 0) { $model = new User_Model_Users(); $data = $model->fetchEntry($id); if ($model->haveContact($id)) { $form->removeElement('add_contact'); } $form->populate($data); } } $this->view->form = $form; }