Exemplo n.º 1
0
 public function savecommentsAction()
 {
     try {
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $loginUserId = $auth->getStorage()->read()->id;
             $loginuserRole = $auth->getStorage()->read()->emprole;
             $loginuserGroup = $auth->getStorage()->read()->group_id;
         }
         $detailId = $this->_request->getParam('detailid');
         $comment = $this->_request->getParam('comment');
         $agency_id = $this->_request->getParam('agency_id');
         $hr_id = $this->_request->getParam('hr_id');
         $emp_screening_model = new Default_Model_Empscreening();
         if (isset($comment) && $comment != '') {
             if ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) {
                 $toId = $agency_id;
             } else {
                 $toId = $hr_id;
             }
             $date = new Zend_Date();
             $data = array('bgdet_id' => $detailId, 'comment' => $comment, 'from_id' => $loginUserId, 'to_id' => $toId, 'createddate' => gmdate("Y-m-d H:i:s"));
             $where = '';
             $commentsModel = new Default_Model_Comments();
             $tableid = $commentsModel->SaveorUpdateComments($data, $where);
             $commData = array('recentlycommentedby' => $loginUserId, 'recentlycommenteddate' => gmdate("Y-m-d H:i:s"));
             $commwhere = "id='{$detailId}'";
             $emp_screening_model->SaveorUpdateDetails($commData, $commwhere);
             $actualcommentData = $commentsModel->getComments($detailId, 'all');
             if (sizeof($actualcommentData) > 2) {
                 $updateresult['commentcount'] = 'morethan2';
             } else {
                 $updateresult['commentcount'] = '';
             }
             $updateresult['result'] = 'saved';
         } else {
             $updateresult['commentcount'] = '';
             $updateresult['result'] = 'error';
         }
         $this->_helper->json($updateresult);
     } catch (Exception $e) {
         exit($e->getMessage());
     }
 }