Example #1
0
 public function manageEmployeeLeavesAction()
 {
     $userId = $this->_getParam('id');
     $model1 = new Application_Model_User();
     $model = $model1->find($userId);
     if (false === $model) {
         $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/employees'));
     }
     $this->view->user = $model;
     $request = $this->getRequest();
     $form = new Application_Form_UserLeaveAccount();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             $options['userId'] = $userId;
             $model = new Application_Model_UserLeaveAccount($options);
             $id = $model->save();
             if ($id) {
                 $this->_flashMessenger->addMessage(array('success' => 'User leave account has been successfully crided/debited!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/manage-employee-leaves/id/' . $userId));
             } else {
                 $this->_flashMessenger->addMessage(array('error' => 'Failed to credit/debit the user leave account!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/manage-employee-leaves/id/' . $userId));
             }
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }