Example #1
0
 public function createRequestAction()
 {
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     $request = $this->getRequest();
     $form = new Application_Form_Request();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             $options['requestedBy'] = $userId;
             $options['status'] = "Open";
             $model = new Application_Model_Request($options);
             $id = $model->save();
             if ($id) {
                 //send email notificatons to concern department's persons
                 $mail = new Base_Mail();
                 $mail->sendRequestNotification($id);
                 $this->_flashMessenger->addMessage(array('success' => "Your request has been successfully conveyed to the concern person! Your Request No. is #{$id}"));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/employee/my-requests'));
             } else {
                 $this->_flashMessenger->addMessage(array('error' => 'Failed to send request!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/employee/my-requests'));
             }
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Example #2
0
 public function requestAction()
 {
     $form = new Application_Form_Request();
     $params = $this->getRequest()->getParams();
     $form->setDefaults($params);
     $this->view->form = $form;
     if (isset($params['message'])) {
         $this->view->message = (string) $params['message'];
     }
     if (isset($params['success'])) {
         $this->view->success = (int) $params['success'];
     }
 }