public function editAppriciationAction() { $id = $this->_getParam('id'); $this->view->user_id = $id; $model1 = new Application_Model_Appriciation(); $model = $model1->find($id); if (false === $model) { $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/appriciation')); } $options['user_id'] = $model->getUserId(); $options['appriciationDate'] = $model->getAppriciationDate(); $options['appriciationTypeId'] = $model->getAppriciationTypeId(); $options['remarks'] = $model->getRemarks(); $request = $this->getRequest(); $form = new Application_Form_Appriciation(); $form->populate($options); $options = $request->getPost(); if ($request->isPost()) { if ($form->isValid($options)) { $model->setOptions($options); $model->save(); $this->_flashMessenger->addMessage(array('success' => 'Appriciation has been updated successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/edit-appriciation/id/' . $id)); } else { $this->_flashMessenger->addMessage(array('error' => 'Unable to save the data. Please provide valid inputs and try again.')); $form->reset(); $form->populate($options); } } $this->view->form = $form; }
private function setModel($row) { $model = new Application_Model_Appriciation(); $model->setId($row->id)->setUserId($row->user_id)->setRemarks($row->remarks)->setAppriciationDate($row->appriciation_date)->setAppriciationTypeId($row->appriciation_type_id)->setAddedon($row->addedon)->setUpdatedon($row->updatedon); if ($appriciationType = $row->findParentRow("Application_Model_DbTable_AppriciationType", 'AppriciationType')) { $model->setAppriciationType($appriciationType->title); } if ($user = $row->findParentRow("Application_Model_DbTable_User", 'User')) { $userM = new Application_Model_User(); $model->setUser($userM->setModel($user)); } return $model; }
public function getLatestAppriciations() { $obj = new Application_Model_Appriciation(); return $obj->getLatestAppriciations(); }