public function getdetailedratingsbyquesAction()
 {
     $ff_id = $this->_request->getParam('ff_id');
     $mgr_id = $this->_request->getParam('mgr_id');
     $pa_conf_id = $this->_request->getParam('pa_conf_id');
     $ques_id = $this->_request->getParam('ques_id');
     $ffinitModel = new Default_Model_Feedforwardinit();
     $ffEmpRatModel = new Default_Model_Feedforwardemployeeratings();
     $empsData = $ffinitModel->getDetailEmpsDataByMgrId($ff_id, $mgr_id);
     $quesData = $ffEmpRatModel->getFFQuesDataByIDs($empsData[0]['question_ids']);
     // Employee response
     $emp_response = array();
     if ($empsData[0]['employee_response']) {
         $emp_response = json_decode($empsData[0]['employee_response'], true);
     }
     // get rating details using configuration id
     $ratingsData = $ffEmpRatModel->getAppRatingsDataByConfgId($pa_conf_id);
     $ratingType = $ratingsData[0]['rating_type'];
     $ratingText = array();
     $ratingTextDisplay = array();
     $ratingValues = array();
     foreach ($ratingsData as $rd) {
         $ratingText[] = $rd['rating_text'];
         $ratingTextDisplay[$rd['id']] = $rd['rating_text'];
         $ratingValues[$rd['id']] = $rd['rating_value'];
     }
     $this->view->empsData = $empsData;
     $this->view->quesData = $quesData;
     $this->view->ratingType = $ratingType;
     $this->view->ratingTextDisplay = $ratingTextDisplay;
     $this->view->ratingText = json_encode($ratingText);
     $this->view->ratingValues = $ratingValues;
     $this->view->emp_response = $emp_response;
     $this->view->ques_id = $ques_id;
     $this->view->emp_view_flag = $this->_request->getParam('emp_view_flag');
     //Condition is for checking of additional questions click event
     $this->view->additional_Qflag = '';
     if ($ques_id == '') {
         $this->view->additional_Qflag = 'additional_flag';
     }
 }
 public function saveAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserFullName = $auth->getStorage()->read()->userfullname;
         $loginuserProfileImg = $auth->getStorage()->read()->profileimg;
     }
     try {
         $ffEmpRatingsModel = new Default_Model_Feedforwardemployeeratings();
         $id = $this->_request->getParam('id');
         $employee_id = $this->_request->getParam('employee_id');
         $initialization_id = $this->_request->getParam('initialization_id');
         $config_id = $this->_request->getParam('config_id');
         $flag = $this->_request->getParam('flag');
         $ratingsData = $ffEmpRatingsModel->getAppRatingsDataByConfgId($config_id);
         $ratingValues = array();
         foreach ($ratingsData as $rd) {
             $ratingValues[$rd['id']] = $rd['rating_value'];
         }
         $appData = array('additional_comments' => trim($this->_request->getParam('additional_comments')), 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $emp_rating_arr = $this->_request->getParam('emp_rating');
         $emp_comment_arr = $this->_request->getParam('emp_comment');
         $emp_response = array();
         $rating_sum = 0;
         $ratings_given = 0;
         if (sizeof($emp_rating_arr) > 0 || sizeof($emp_comment_arr) > 0) {
             foreach ($emp_rating_arr as $qid => $val) {
                 if (isset($emp_rating_arr[$qid])) {
                     $rating_id = array_search($emp_rating_arr[$qid], $ratingValues);
                     $rating_sum += $emp_rating_arr[$qid];
                     $ratings_given++;
                 } else {
                     $rating_id = '';
                 }
                 $emp_response[$qid] = array('comment' => $emp_comment_arr[$qid], 'rating_id' => $rating_id);
             }
         }
         $appData['employee_response'] = json_encode($emp_response, true);
         if ($flag == 'submit') {
             $appData['ff_status'] = 2;
             $appData['consolidated_rating'] = $rating_sum / $ratings_given;
         }
         $appWhere = array('id=?' => $id);
         $result1 = $ffEmpRatingsModel->SaveorUpdateFFEmpRatingsData($appData, $appWhere);
         if ($result1) {
             $msg = 'saved';
             if ($flag != 'submit') {
                 $this->_redirect('feedforwardemployee/edit/msg/saved/flags/draft');
             } else {
                 //Logs storing
                 $tableid = '';
                 $actionflag = 1;
                 $menuID = APPRAISE_YOUR_MANAGER;
                 $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                 $this->_redirect('feedforwardemployee');
             }
         } else {
             $msg = 'err';
         }
     } catch (Exception $e) {
         $msg = "Something went wrong, please try again.";
     }
     //$this->_helper->json(array('msg'=>$msg));
 }