public function addAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $businessunit_id = $auth->getStorage()->read()->businessunit_id;
         $department_id = $auth->getStorage()->read()->department_id;
     }
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $errorMsg = '';
     $empSummaryModel = new Default_Model_Employee();
     $empData = $empSummaryModel->getEmp_from_summary($loginUserId);
     $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessunit_id, $department_id);
     //echo "<pre>";print_r($appImpleData);echo "</pre>";
     $appInitModel = new Default_Model_Appraisalinit();
     $appraisalInitForm = new Default_Form_Appraisalinit();
     if (count($appImpleData) > 0) {
         $this->view->imple_data = $appImpleData;
         $checkActiveApp = $appInitModel->checkAppraisalExists($businessunit_id, $department_id);
         if (count($checkActiveApp) == 0) {
             $appraisalInitForm->businessunit_name->setValue($empData['businessunit_name']);
             if ($appImpleData['performance_app_flag'] == 0) {
                 $appraisalInitForm->department_name->setValue($empData['department_name']);
             } else {
                 $appraisalInitForm->removeElement("department_name");
             }
             $appraisalInitForm->businessunit_id->setValue($empData['businessunit_id']);
             $appraisalInitForm->department_id->setValue($empData['department_id']);
             $appraisalInitForm->appraisal_mode->setValue($appImpleData['appraisal_mode']);
             $employmentstatusModel = new Default_Model_Employmentstatus();
             $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
             if (!empty($employmentStatusData)) {
                 foreach ($employmentStatusData as $employmentStatusres) {
                     $appraisalInitForm->eligibility->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                 }
             } else {
                 $msgarray['eligibility'] = 'Employment status is not configured yet.';
             }
         } else {
             $errorMsg = 'Appraisal process is already initialized.';
         }
     } else {
         $errorMsg = 'Appraisal process is not yet configured.';
     }
     $msgarray = array();
     $appraisalInitForm->setAttrib('action', DOMAIN . 'appraisalinit/add');
     $this->view->form = $appraisalInitForm;
     $this->view->msgarray = $msgarray;
     $this->view->ermsg = $errorMsg;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($appraisalInitForm);
         $this->view->msgarray = $result;
     }
     $this->render('form');
 }
 /**
  * 
  * Edit function to prepopulate the data.
  * 
  */
 public function editAction($id = '')
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $businessUnit = $auth->getStorage()->read()->businessunit_id;
         $department = $auth->getStorage()->read()->department_id;
     }
     $appInitModel = new Default_Model_Appraisalinit();
     $msgarray = array();
     $buOptions = '';
     $deptOptions = '';
     if ($id == '') {
         $id = $this->getRequest()->getParam('id');
     }
     if ($loginuserRole != SUPERADMINROLE && $loginuserGroup != MANAGEMENT_GROUP) {
         $callval = $this->getRequest()->getParam('call');
         if ($callval == 'ajaxcall') {
             $this->_helper->layout->disableLayout();
         }
         $appraisalratingsform = new Default_Form_Appraisalratings();
         $appraisalratingsmodel = new Default_Model_Appraisalratings();
         $performanceappflag = '';
         $appraisalratingsform->submit->setLabel('Update');
         $res = $appraisalratingsmodel->checkAccessAddratings($businessUnit, $department);
         foreach ($res as $result) {
             $appraisal_rating = $result['appraisal_ratings'];
         }
         $appraisal_rating = $appraisal_rating == 1 ? 5 : 10;
         try {
             if ($id) {
                 if (is_numeric($id) && $id > 0) {
                     $data = $appraisalratingsmodel->getAppraisalRatingsbyInitId($id);
                     if (!empty($data)) {
                         //$data = $data[0];
                         //echo "<pre>"; print_r($data);echo "</pre>";
                         // $appraisal_rating = 1;
                         $appInitdata = $appInitModel->getConfigData($data[0]['pa_initialization_id']);
                         $appraisalratingsform->setAttrib('action', DOMAIN . 'appraisalratings/edit/id/' . $id);
                         /* Fetch business unit and department name*/
                         $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessUnit, $department);
                         $performanceappflag = $appImpleData['performance_app_flag'];
                         $optionsArray = $this->buildoptions($businessUnit, $department, $performanceappflag);
                         $buOptions = $optionsArray['buoptions'];
                         $deptOptions = isset($optionsArray['deptoptions']) ? $optionsArray['deptoptions'] : '';
                         /* End */
                         $this->view->performanceappflag = $performanceappflag;
                         $this->view->buOptions = $buOptions;
                         $this->view->deptOptions = $deptOptions;
                         $this->view->data = $data;
                         $this->view->checkActiveApp = $appInitdata[0];
                         $this->view->appraisal_rating = $appraisal_rating;
                     } else {
                         $this->view->ermsg = 'norecord';
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
         $this->view->form = $appraisalratingsform;
         if ($this->getRequest()->getPost()) {
             $result = $this->save($appraisalratingsform);
             $this->view->msgarray = $result;
         }
         $this->render('form');
     } else {
         $buOptions = '';
         $deptOptions = '';
         $businessUnitId = '';
         $department = '';
         $deptArr = array();
         $flag = 2;
         $appraisaldataArr = $appInitModel->getAppDataById($id);
         if (!empty($appraisaldataArr)) {
             $businessUnitId = $appraisaldataArr['businessunit_id'];
             $departmentId = $appraisaldataArr['department_id'] != 'null' ? $appraisaldataArr['department_id'] : '';
             $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessUnitId, $departmentId);
             $performanceappflag = $appImpleData['performance_app_flag'];
             $optionsArray = $this->buildoptions($businessUnitId, $departmentId, $performanceappflag);
             $buOptions = $optionsArray['buoptions'];
             $deptOptions = isset($optionsArray['deptoptions']) ? $optionsArray['deptoptions'] : '';
         }
         if ($this->getRequest()->getPost()) {
             $result = $this->save($appraisalratingsform);
             $this->view->msgarray = $result;
         }
         $this->view->appraislaid = $id;
         $this->view->performanceappflag = $performanceappflag;
         $this->view->businessUnitId = $businessUnitId;
         $this->view->departmentId = $departmentId;
         $this->view->buOptions = $buOptions;
         $this->view->deptOptions = $deptOptions;
         $this->view->flag = $flag;
         $this->render('managementform');
     }
 }
Пример #3
0
 public function initialize($appraisalid, $initflag)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserArr = array('loginuserid' => $loginUserId, 'loginuserrole' => $loginuserRole, 'loginusergroup' => $loginuserGroup);
         $loginUserEmpId = $auth->getStorage()->read()->employeeId;
         $loginUserfullname = $auth->getStorage()->read()->userfullname;
     }
     $appraisalQsModel = new Default_Model_Appraisalquestions();
     $appraisalQsTmpModel = new Default_Model_Appraisalqstemp();
     $app_init_model = new Default_Model_Appraisalinit();
     $appraisalPrivTempModel = new Default_Model_Appraisalqstemp();
     $appraisalPrivMainModel = new Default_Model_Appraisalqsmain();
     $appraisalempratingsmodel = new Default_Model_Appraisalemployeeratings();
     $app_manager_model = new Default_Model_Appraisalmanager();
     $usersmodel = new Default_Model_Users();
     $departmentsmodel = new Default_Model_Departments();
     $announcementsModel = new Default_Model_Announcements();
     $deptids = '';
     $questions = '';
     $title = 'Performance Appraisal';
     $description = 'Performance appraisal initialized';
     $trDb = Zend_Db_Table::getDefaultAdapter();
     $trDb->beginTransaction();
     try {
         $data = $app_init_model->getConfigData($appraisalid);
         $appraisaldata = $data[0];
         $qsdataArr = $appraisalPrivTempModel->getAppraisalQuestions($appraisalid);
         if (!empty($qsdataArr)) {
             foreach ($qsdataArr as $qs) {
                 $questions .= $qs['hr_qs'] . ',';
             }
             $questions = rtrim($questions, ',');
         }
         $questions = implode(',', array_keys(array_flip(explode(',', $questions))));
         $initdata = array('initialize_status' => 2, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $initwhere = array('id=?' => $appraisalid);
         if ($initflag == 1) {
             $initdata['initialize_status'] = 1;
             $insertQstable = $appraisalQsModel->insertQsData($appraisalid, $loginuserArr);
             $updateTmptable = $appraisalPrivTempModel->updateQsTempData($appraisalid, $loginuserArr);
             $con = $app_init_model->SaveorUpdateAppraisalInitData($initdata, $initwhere);
             if ($appraisaldata['enable_step'] == 2) {
                 /**
                  * Start 
                  * Inserting or Updating employee ratings table when enabled to employees
                  * If record exists then updating else inserting
                  */
                 $employeeidArr = $appraisalPrivMainModel->getemployeeIDs($appraisalid);
                 if (!empty($employeeidArr)) {
                     foreach ($employeeidArr as $emp) {
                         $emprating_Arr = array('pa_initialization_id' => $appraisalid, 'employee_id' => $emp['employee_id'], 'line_manager_1' => $emp['line_manager_1'] != '' ? $emp['line_manager_1'] : NULL, 'line_manager_2' => $emp['line_manager_2'] != '' ? $emp['line_manager_2'] : NULL, 'line_manager_3' => $emp['line_manager_3'] != '' ? $emp['line_manager_3'] : NULL, 'line_manager_4' => $emp['line_manager_4'] != '' ? $emp['line_manager_4'] : NULL, 'line_manager_5' => $emp['line_manager_5'] != '' ? $emp['line_manager_5'] : NULL, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         $employeeexistArr = $appraisalempratingsmodel->checkEmployeeExists($appraisalid, $emp['employee_id']);
                         if ($employeeexistArr[0]['empcount'] > 0) {
                             $qwhere = " employee_id = '" . $emp['employee_id'] . "' and pa_initialization_id='" . $appraisalid . "' and isactive=1";
                         } else {
                             $emprating_Arr['createdby'] = $loginUserId;
                             $emprating_Arr['createdby_role'] = $loginuserRole;
                             $emprating_Arr['createdby_group'] = $loginuserGroup;
                             $emprating_Arr['createddate'] = gmdate("Y-m-d H:i:s");
                             $qwhere = '';
                         }
                         $appraisalempratingsmodel->SaveorUpdateAppraisalSkillsData($emprating_Arr, $qwhere);
                         /**
                          * End
                          */
                     }
                 }
             }
             /*
              *   Logs Storing
              */
             if ($con == 'update') {
                 $actionflag = 2;
             } else {
                 $actionflag = 1;
             }
             $tableid = '';
             $menuID = INITIALIZE_APPRAISAL;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             /*
              *  Logs storing ends
              */
             /**
              * Sending mails to HR,Super Admin,Management,(managers OR employees) based on enable step.
              */
             $appraisalratingsmodel = new Default_Model_Appraisalratings();
             //to get initialization details using appraisal Id for Business Unit,Department,To Year
             $appraisal_details = $appraisalratingsmodel->getappdata($appraisalid);
             if (!empty($appraisal_details)) {
                 $businessUnit = $appraisal_details['businessunit_id'];
                 $department = $appraisal_details['deptid'];
                 $bunit = $appraisal_details['unitname'];
                 $dept = $appraisal_details['deptname'];
                 $to_year = $appraisal_details['to_year'];
                 $appraisalconfigmodel = new Default_Model_Appraisalconfig();
                 if ($department != '') {
                     $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessUnit, $department);
                 } else {
                     $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessUnit, '');
                 }
                 $dept_str = $dept == '' ? " " : "and department <b>{$dept}</b> ";
                 $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})";
                 //Preparing Employee array for Bcc
                 $empArr = array();
                 if (!empty($employeeDetailsArr)) {
                     $empArrList = '';
                     foreach ($employeeDetailsArr as $emp) {
                         array_push($empArr, $emp['emailaddress']);
                     }
                 }
                 $mail_str = $appraisaldata['enable_step'] == 1 ? 'to managers' : 'to employees';
                 $empmgrArr = array();
                 if ($appraisaldata['enable_step'] == 1) {
                     $getLine1ManagerId = $appraisalPrivMainModel->getLine1ManagerIdMain($appraisalid);
                     foreach ($getLine1ManagerId as $mgr) {
                         array_push($empmgrArr, $mgr['emailaddress']);
                     }
                 } else {
                     $empIdArr = array();
                     $empIdList = '';
                     $employeeidArr = $appraisalPrivMainModel->getemployeeIDs($appraisalid);
                     //fetching Employee Ids
                     if (!empty($employeeidArr)) {
                         foreach ($employeeidArr as $emp) {
                             array_push($empIdArr, $emp['employee_id']);
                         }
                         $empIdList = implode(',', $empIdArr);
                         //Preparing Employee Id List
                         $empDetailsArr = $app_manager_model->getUserDetailsByEmpID($empIdList);
                         //Fetching employee details
                         if (!empty($empDetailsArr)) {
                             foreach ($empDetailsArr as $emp) {
                                 array_push($empmgrArr, $emp['emailaddress']);
                                 //preparing Bcc array
                             }
                         }
                     }
                 }
                 $totalArr = array_merge($empArr, $empmgrArr);
                 //Sending mail to Super admin
                 $options['subject'] = APPLICATION_NAME . ': Performance Appraisal Initialization';
                 $options['header'] = 'Performance Appraisal Initialization : ' . $to_year;
                 $options['toEmail'] = SUPERADMIN_EMAIL;
                 $options['toName'] = 'Super Admin';
                 $options['bcc'] = $totalArr;
                 $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Performance appraisal has been initialized {$mail_str} for the year <b>{$to_year}</b> for business unit <b>{$bunit}</b>  {$dept_str} by " . $loginUserfullname . $emp_id_str . " </div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login  to your <b>" . APPLICATION_NAME . "</b> account to check the details.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> ";
                 $mail_id = sapp_Global::_sendEmail($options);
             }
             if ($appraisaldata['enable_step'] == 2) {
                 $appImpleData = sapp_PerformanceHelper::check_per_implmentation($appraisaldata['businessunit_id'], $appraisaldata['department_id']);
             }
             sapp_PerformanceHelper::update_QsParmas_Allemps($questions, $appraisaldata['category_id']);
         } else {
             $app_init_model->SaveorUpdateAppraisalInitData($initdata, $initwhere);
         }
         $trDb->commit();
         if ($initflag == 1) {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => 'Appraisal initialized successfully'));
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => 'Appraisal configurations are saved to be initialized later'));
         }
         return 'success';
     } catch (Exception $e) {
         $trDb->rollBack();
         return 'error';
     }
 }
 public function employeeAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $businessunit_id = $auth->getStorage()->read()->businessunit_id;
         $department_id = $auth->getStorage()->read()->department_id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $errorMsg = '';
     $msgarray = array();
     $bunitdataArr = array();
     $flag = '';
     $appInitModel = new Default_Model_Appraisalinit();
     $app_status_array = array(1 => APP_PENDING_EMP, 2 => APP_PENDING_L1, 3 => APP_PENDING_L2, 4 => APP_PENDING_L3, 5 => APP_PENDING_L4, 6 => APP_PENDING_L5, 7 => APP_COMPLETED);
     if ($loginuserRole != SUPERADMINROLE && $loginuserGroup != MANAGEMENT_GROUP) {
         $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessunit_id, $department_id);
         if (count($appImpleData) > 0) {
             $this->view->imple_data = $appImpleData;
             $checkActiveApp = $appInitModel->checkAppraisalExists($businessunit_id, $department_id, $appImpleData['performance_app_flag']);
             if (count($checkActiveApp) > 0) {
                 $checkActiveApp = $checkActiveApp[0];
                 if ($checkActiveApp['enable_step'] == 2 && $checkActiveApp['status'] == 1) {
                     $this->view->checkActiveApp = $checkActiveApp;
                     $flag = 1;
                 } else {
                     if ($checkActiveApp['enable_step'] == 1) {
                         $errorMsg = 'Appraisal process is enabled to managers.';
                     }
                     if ($checkActiveApp['status'] == 2) {
                         $errorMsg = 'Appraisal process is closed.';
                     }
                 }
             } else {
                 $errorMsg = 'Active Appraisal process is not there.';
             }
         } else {
             $errorMsg = 'Appraisal process is not yet configured.';
         }
     } else {
         $bunitModel = new Default_Model_Businessunits();
         $buids = '';
         $bunitdataArr = array();
         $activeAppraisalManagerArr = $appInitModel->getAppraisalForMgrEmp(2);
         if (!empty($activeAppraisalManagerArr)) {
             foreach ($activeAppraisalManagerArr as $mgrArr) {
                 $buids .= $mgrArr['businessunit_id'] . ',';
             }
             $buids = rtrim($buids, ',');
             if ($buids != '') {
                 $bustr = implode(',', array_unique(explode(',', $buids)));
                 $bunitdataArr = $bunitModel->getBusinessUnits($bustr);
             }
         }
         $this->view->bunitdataarr = $bunitdataArr;
         $flag = 2;
     }
     $this->view->app_status_array = $app_status_array;
     $this->view->msgarray = $msgarray;
     $this->view->ermsg = $errorMsg;
     $this->view->flag = $flag;
 }
 public function initialize($appraisalid, $initflag)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserArr = array('loginuserid' => $loginUserId, 'loginuserrole' => $loginuserRole, 'loginusergroup' => $loginuserGroup);
     }
     $appraisalQsModel = new Default_Model_Appraisalquestions();
     $appraisalQsTmpModel = new Default_Model_Appraisalqstemp();
     $app_init_model = new Default_Model_Appraisalinit();
     $appraisalPrivTempModel = new Default_Model_Appraisalqstemp();
     $appraisalPrivMainModel = new Default_Model_Appraisalqsmain();
     $appraisalempratingsmodel = new Default_Model_Appraisalemployeeratings();
     $usersmodel = new Default_Model_Users();
     $departmentsmodel = new Default_Model_Departments();
     $announcementsModel = new Default_Model_Announcements();
     $deptids = '';
     $questions = '';
     $title = 'Performance Appraisal';
     $description = 'Performance appraisal initialized';
     $trDb = Zend_Db_Table::getDefaultAdapter();
     $trDb->beginTransaction();
     try {
         $data = $app_init_model->getConfigData($appraisalid);
         $appraisaldata = $data[0];
         $qsdataArr = $appraisalPrivTempModel->getAppraisalQuestions($appraisalid);
         if (!empty($qsdataArr)) {
             foreach ($qsdataArr as $qs) {
                 $questions .= $qs['hr_qs'] . ',';
             }
             $questions = rtrim($questions, ',');
         }
         $questions = implode(',', array_keys(array_flip(explode(',', $questions))));
         $initdata = array('initialize_status' => 2, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $initwhere = array('id=?' => $appraisalid);
         if ($initflag == 1) {
             $initdata['initialize_status'] = 1;
             $insertQstable = $appraisalQsModel->insertQsData($appraisalid, $loginuserArr);
             $updateTmptable = $appraisalPrivTempModel->updateQsTempData($appraisalid, $loginuserArr);
             $app_init_model->SaveorUpdateAppraisalInitData($initdata, $initwhere);
             /**
              * Sending mails to managers OR employees based on enable step.
              */
             if ($appraisaldata['enable_step'] == 1) {
                 /**
                  * Start 
                  * Sending Mails to Managers if enabled to managers
                  */
                 $getLine1ManagerId = $appraisalPrivMainModel->getLine1ManagerIdMain($appraisalid);
                 if (!empty($getLine1ManagerId)) {
                     foreach ($getLine1ManagerId as $val) {
                         $options['subject'] = APPLICATION_NAME . ': Appraisal process initiated';
                         $options['header'] = 'Performance Appraisal';
                         $options['toEmail'] = $val['emailaddress'];
                         $options['toName'] = $val['userfullname'];
                         $options['message'] = 'Dear ' . $val['userfullname'] . ', Appraisal process initiated';
                         $options['cron'] = 'yes';
                         //  sapp_Global::_sendEmail($options);
                     }
                 }
                 /**
                  * Mail to performance appraisal group
                  */
                 if (defined('PER_APPRAISAL_' . $appraisaldata['businessunit_id']) && $appraisaldata['businessunit_id'] != '') {
                     $options['subject'] = APPLICATION_NAME . ': Appraisal process initiated to managers.';
                     $options['header'] = 'Performance Appraisal';
                     $options['toEmail'] = constant('PER_APPRAISAL_' . $appraisaldata['businessunit_id']);
                     $options['toName'] = 'Performance Appraisal';
                     $options['message'] = 'Appraisal process initiated to managers.';
                     $options['cron'] = 'yes';
                     // sapp_Global::_sendEmail($options);
                 }
                 /**
                  * End
                  */
             } else {
                 /**
                  * Start 
                  * Inserting or Updating employee ratings table when enabled to employees
                  * If record exists then updating else inserting
                  */
                 $employeeidArr = $appraisalPrivMainModel->getemployeeIDs($appraisalid);
                 if (!empty($employeeidArr)) {
                     foreach ($employeeidArr as $emp) {
                         $emprating_Arr = array('pa_initialization_id' => $appraisalid, 'employee_id' => $emp['employee_id'], 'line_manager_1' => $emp['line_manager_1'] != '' ? $emp['line_manager_1'] : NULL, 'line_manager_2' => $emp['line_manager_2'] != '' ? $emp['line_manager_2'] : NULL, 'line_manager_3' => $emp['line_manager_3'] != '' ? $emp['line_manager_3'] : NULL, 'line_manager_4' => $emp['line_manager_4'] != '' ? $emp['line_manager_4'] : NULL, 'line_manager_5' => $emp['line_manager_5'] != '' ? $emp['line_manager_5'] : NULL, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         $employeeexistArr = $appraisalempratingsmodel->checkEmployeeExists($appraisalid, $emp['employee_id']);
                         if ($employeeexistArr[0]['empcount'] > 0) {
                             $qwhere = " employee_id = '" . $emp['employee_id'] . "' and pa_initialization_id='" . $appraisalid . "' and isactive=1";
                         } else {
                             $emprating_Arr['createdby'] = $loginUserId;
                             $emprating_Arr['createdby_role'] = $loginuserRole;
                             $emprating_Arr['createdby_group'] = $loginuserGroup;
                             $emprating_Arr['createddate'] = gmdate("Y-m-d H:i:s");
                             $qwhere = '';
                         }
                         $appraisalempratingsmodel->SaveorUpdateAppraisalSkillsData($emprating_Arr, $qwhere);
                         /**
                          * End
                          */
                         /** Start
                          * Sending Mails to employees
                          */
                         $employeeDetailsArr = $usersmodel->getUserDetailsByID($emp['employee_id'], '');
                         if (!empty($employeeDetailsArr)) {
                             $options['subject'] = APPLICATION_NAME . ': Appraisal process initiated';
                             $options['header'] = 'Performance Appraisal';
                             $options['toEmail'] = $employeeDetailsArr[0]['emailaddress'];
                             $options['toName'] = $employeeDetailsArr[0]['userfullname'];
                             $options['message'] = 'Dear ' . $employeeDetailsArr[0]['userfullname'] . ', Appraisal process initiated';
                             $options['cron'] = 'yes';
                             // sapp_Global::_sendEmail($options);
                         }
                         /**
                          * End
                          */
                     }
                 }
                 /**
                  * Mail to performance appraisal group
                  */
                 if (defined('PER_APPRAISAL_' . $appraisaldata['businessunit_id']) && $appraisaldata['businessunit_id'] != '') {
                     $options['subject'] = APPLICATION_NAME . ': Appraisal process initiated to employees.';
                     $options['header'] = 'Performance Appraisal';
                     $options['toEmail'] = constant('PER_APPRAISAL_' . $appraisaldata['businessunit_id']);
                     $options['toName'] = 'Performance Appraisal';
                     $options['message'] = 'Appraisal process initiated to employees.';
                     $options['cron'] = 'yes';
                     //  sapp_Global::_sendEmail($options);
                 }
                 /**
                  * End
                  */
             }
             /**
              * End Sending Mails and updating emp ratings table
              */
             if ($appraisaldata['enable_step'] == 2) {
                 $appImpleData = sapp_PerformanceHelper::check_per_implmentation($appraisaldata['businessunit_id'], $appraisaldata['department_id']);
                 /** Start
                  * Announecements
                  */
                 if ($appImpleData['performance_app_flag'] == 1) {
                     $deptArr = $departmentsmodel->getAllDeptsForUnit($appraisaldata['businessunit_id']);
                     if (!empty($deptArr)) {
                         foreach ($deptArr as $dept) {
                             $deptids .= $dept['id'] . ',';
                         }
                         $deptids = rtrim($deptids, ',');
                     }
                 } else {
                     $deptids = $appraisaldata['department_id'];
                 }
                 /*	$announcement_arr = array(
                                               'businessunit_id' => $appraisaldata['businessunit_id']!=''?$appraisaldata['businessunit_id']:NULL,
                                               'department_id' => $deptids!=''?$deptids:NULL,
                                               'title' => $title,
                                               'description' => $description,
                                               'attachments' => NULL,
                                               'status' => 2,
                                               'isactive' => 1,
                 			'createdby' => $loginUserId,
                 						'createdby_role'=>$loginuserRole,
                 			'createdby_group'=>$loginuserGroup,
                                               'modifiedby' => $loginUserId,
                 						'modifiedby_role'=>$loginuserRole,
                 			'modifiedby_group'=>$loginuserGroup,
                 			'createddate'=>gmdate("Y-m-d H:i:s"),
                                               'modifieddate'=>gmdate("Y-m-d H:i:s")
                                   			);
                                   			
                                   	$Id = $announcementsModel->SaveorUpdateAnnouncementsData($announcement_arr, '');		*/
                 /**
                  * End
                  */
             }
             sapp_PerformanceHelper::update_QsParmas_Allemps($questions, $appraisaldata['category_id']);
         } else {
             $app_init_model->SaveorUpdateAppraisalInitData($initdata, $initwhere);
         }
         $trDb->commit();
         if ($initflag == 1) {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => 'Appraisal initialized successfully'));
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => 'Appraisal configurations are saved to be initialized later'));
         }
         return 'success';
     } catch (Exception $e) {
         $trDb->rollBack();
         return 'error';
     }
 }