Пример #1
0
 function leavecreateAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     // parent::createAction();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit();
     $formvalues['id'] = $id = decode($formvalues['id']);
     $leave = new LeaveType();
     if (!isArrayKeyAnEmptyString('id', $formvalues)) {
         $leave->populate($id);
         $formvalues['lastupdatedby'] = $session->getVar('userid');
     } else {
         $formvalues['createdby'] = $session->getVar('userid');
     }
     $leave->processPost($formvalues);
     if ($leave->hasError()) {
         /* debugMessage($leave->toArray());
         			 debugMessage('errors are '.$leave->getErrorStackAsString());
         			exit(); */
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     try {
         $leave->save();
         //debugMessage($leave->toArray());
         $session->setVar(SUCCESS_MESSAGE, $this->_getParam('successmessage'));
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_SUCCESS)));
     } catch (Exception $e) {
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
         //debugMessage('save error '.$e->getMessage());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
 }