public function viewAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $login_group_id = $auth->getStorage()->read()->group_id;
         $login_role_id = $auth->getStorage()->read()->emprole;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'appraisalquestions';
     $appraisalCategoryModel = new Default_Model_Appraisalcategory();
     $appraisalquestionsmodel = new Default_Model_Appraisalquestions();
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $data = $appraisalquestionsmodel->getAppraisalQuestionbyID($id);
                 $previ_data = sapp_Global::_checkprivileges(APPRAISALQUESTIONS, $login_group_id, $login_role_id, 'edit');
                 if (!empty($data)) {
                     $data = $data[0];
                     $appraisalCategoriesData = $appraisalCategoryModel->getAppraisalCategoryDatabyID($data['pa_category_id']);
                     if (sizeof($appraisalCategoriesData) > 0) {
                         $this->view->ermsg = '';
                         $this->view->data = $data;
                         $this->view->previ_data = $previ_data;
                         $this->view->id = $id;
                         $this->view->controllername = $objName;
                         $category_name = $appraisalCategoryModel->getAppraisalCategoryNamebyID($appraisalCategoriesData[0]['id']);
                         $category_name = $category_name[0]['category_name'];
                         $this->view->category_name = $category_name;
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'norecord';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
 }
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $messages['msgtype'] = '';
     $count = 0;
     $actionflag = 3;
     if ($id) {
         $appraisalCategoryModel = new Default_Model_Appraisalcategory();
         $appCategorydata = $appraisalCategoryModel->getAppraisalCategoryDatabyID($id);
         if ($appCategorydata[0]['isused'] == 0) {
             $appQuestionModel = new Default_Model_Appraisalquestions();
             $appQuesData = $appQuestionModel->getAppraisalQuestionsByCategotyID($id);
             $d = array();
             foreach ($appQuesData as $key => $value) {
                 $d[] = $value['id'];
             }
             $d = implode(',', $d);
             if (sizeof($appQuesData) == 0) {
                 $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = array('id=?' => $id);
                 $Id = $appraisalCategoryModel->SaveorUpdateAppraisalCategoryData($data, $where);
                 if ($Id == 'update') {
                     $menuID = APPRAISALCATEGORIES;
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                     /***
                     			** commented on 29-04-2015 by sapplica
                     			** need to integrate mail template
                     				$configmail = sapp_Global::send_configuration_mail('Category',$appCategorydata[0]['category_name']);	
                     			***/
                     $messages['message'] = 'Parameter deleted successfully.';
                     $messages['msgtype'] = 'success';
                 } else {
                     $messages['message'] = 'Parameter cannot be deleted.';
                     $messages['msgtype'] = 'error';
                 }
             } else {
                 $messages['message'] = 'Parameter cannot be deleted as there are active questions assigned to it.';
                 $messages['msgtype'] = 'error';
             }
             if (sizeof($appQuesData) > 0) {
                 $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = array('id=?' => $id);
                 $Id = $appraisalCategoryModel->SaveorUpdateAppraisalCategoryData($data, $where);
                 $appQuestionModel->UpdateAppraisalQuestionData($d);
                 if ($Id == 'update') {
                     $menuID = APPRAISALCATEGORIES;
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                     /***
                     			 ** commented on 29-04-2015 by sapplica
                     			 ** need to integrate mail template
                     			 $configmail = sapp_Global::send_configuration_mail('Category',$appCategorydata[0]['category_name']);
                     			***/
                     $messages['message'] = 'Parameter deleted successfully.';
                     $messages['msgtype'] = 'success';
                 } else {
                     $messages['message'] = 'Parameter cannot be deleted.';
                     $messages['msgtype'] = 'error';
                 }
             }
         } else {
             $messages['message'] = 'Parameter cannot be deleted as it is being used in appraisal process.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Parameter cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'appraisalquestions';
     $appraisalquestionsform = new Default_Form_Appraisalquestions();
     $appraisalCategoryModel = new Default_Model_Appraisalcategory();
     $appraisalquestionsmodel = new Default_Model_Appraisalquestions();
     $appraisalquestionsform->removeElement("submit");
     $elements = $appraisalquestionsform->getElements();
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $data = $appraisalquestionsmodel->getAppraisalQuestionbyID($id);
                 if (!empty($data)) {
                     $data = $data[0];
                     $appraisalCategoriesData = $appraisalCategoryModel->getAppraisalCategoryDatabyID($data['pa_category_id']);
                     if (sizeof($appraisalCategoriesData) > 0) {
                         $appraisalquestionsform->pa_category_id->addMultiOption($appraisalCategoriesData[0]['id'], utf8_encode($appraisalCategoriesData[0]['category_name']));
                     }
                     $appraisalquestionsform->populate($data);
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'norecord';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->controllername = $objName;
     $this->view->id = $id;
     $this->view->form = $appraisalquestionsform;
     $this->render('form');
 }
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $messages['msgtype'] = '';
     $count = 0;
     $actionflag = 3;
     if ($id) {
         $appraisalCategoryModel = new Default_Model_Appraisalcategory();
         $menumodel = new Default_Model_Menu();
         $appCategorydata = $appraisalCategoryModel->getAppraisalCategoryDatabyID($id);
         if ($appCategorydata[0]['isused'] == 0) {
             $appQuestionModel = new Default_Model_Appraisalquestions();
             $appQuesData = $appQuestionModel->getAppraisalQuestionsByCategotyID($id);
             if (sizeof($appQuesData) == 0) {
                 $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = array('id=?' => $id);
                 $Id = $appraisalCategoryModel->SaveorUpdateAppraisalCategoryData($data, $where);
                 if ($Id == 'update') {
                     $menuidArr = $menumodel->getMenuObjID('/appraisalcategory');
                     $menuID = $menuidArr[0]['id'];
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                     $configmail = sapp_Global::send_configuration_mail('Category', $appCategorydata[0]['category_name']);
                     $messages['message'] = 'Category deleted successfully.';
                     $messages['msgtype'] = 'success';
                 } else {
                     $messages['message'] = 'Category cannot be deleted.';
                     $messages['msgtype'] = 'error';
                 }
             } else {
                 $messages['message'] = 'Category cannot be deleted. Delete the questions under this category.';
                 $messages['msgtype'] = 'error';
             }
         } else {
             $messages['message'] = 'Category cannot be deleted as its using in appraisal process.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Category cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }