public function addAction()
 {
     $emptyFlag = 0;
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserUnitID = $auth->getStorage()->read()->businessunit_id;
         $loginuserDeptID = $auth->getStorage()->read()->department_id;
     }
     $employeeform = new Default_Form_Myteamemployee();
     $usersModel = new Default_Model_Users();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $busineesUnitModel = new Default_Model_Businessunits();
     $user_model = new Default_Model_Usermanagement();
     $candidate_model = new Default_Model_Candidatedetails();
     $role_model = new Default_Model_Roles();
     $jobtitlesModel = new Default_Model_Jobtitles();
     $prefixModel = new Default_Model_Prefix();
     $msgarray = array();
     $identity_code_model = new Default_Model_Identitycodes();
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
     if ($emp_identity_code != '') {
         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
     } else {
         $emp_id = '';
         $msgarray['employeeId'] = 'Identity codes are not configured yet.';
     }
     $employeeform->employeeId->setValue($emp_id);
     $employeeform->modeofentry->setValue('Direct');
     $roles_arr = $role_model->getRolesListByGroupID(EMPLOYEE_GROUP);
     if (sizeof($roles_arr) > 0) {
         $employeeform->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
     } else {
         $employeeform->emprole->addMultiOptions(array('' => 'Select Role'));
         $msgarray['emprole'] = 'Roles are not configured yet.';
     }
     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
     $employeeform->emp_status_id->addMultiOption('', 'Select Employment Status');
     if (!empty($employmentStatusData)) {
         foreach ($employmentStatusData as $employmentStatusres) {
             $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     } else {
         $msgarray['emp_status_id'] = 'Employment status is not configured yet.';
         $emptyFlag++;
     }
     $businessunitData = $busineesUnitModel->getDeparmentList();
     if (!empty($businessunitData)) {
         foreach ($businessunitData as $businessunitres) {
             if ($businessunitres['id'] == $loginuserUnitID) {
                 $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']);
             }
         }
         $departmentsmodel = new Default_Model_Departments();
         $loginUserdepartmentData = $departmentsmodel->getSingleDepartmentData($loginuserDeptID);
         $totalDeptList = $departmentsmodel->getTotalDepartmentList();
         $employeeform->department_id->clearMultiOptions();
         if (count($loginUserdepartmentData) > 0) {
             $employeeform->department_id->addMultiOption($loginUserdepartmentData['id'], utf8_encode($loginUserdepartmentData['deptname']));
         }
         if (empty($totalDeptList)) {
             $msgarray['department_id'] = 'Departments are not added yet.';
         }
     } else {
         $msgarray['businessunit_id'] = 'Business units are not added yet.';
         $emptyFlag++;
     }
     $jobtitleData = $jobtitlesModel->getJobTitleList();
     $employeeform->jobtitle_id->addMultiOption('', 'Select Job Title');
     if (!empty($jobtitleData)) {
         foreach ($jobtitleData as $jobtitleres) {
             $employeeform->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
         }
     } else {
         $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
         $msgarray['position_id'] = 'Positions are not configured yet.';
         $emptyFlag++;
     }
     $prefixData = $prefixModel->getPrefixList();
     $employeeform->prefix_id->addMultiOption('', 'Select Prefix');
     if (!empty($prefixData)) {
         foreach ($prefixData as $prefixres) {
             $employeeform->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
         }
     } else {
         $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         $emptyFlag++;
     }
     $userData = $usersModel->getUserDetails($loginUserId);
     if (count($userData) > 0) {
         $employeeform->reporting_manager->addMultiOption($userData[0]['id'], $userData[0]['userfullname']);
     }
     $employeeform->setAttrib('action', DOMAIN . 'myemployees/add');
     $this->view->form = $employeeform;
     $this->view->msgarray = $msgarray;
     $this->view->emptyFlag = $emptyFlag++;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($employeeform);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $appraisalinitform = new Default_Form_Appraisalinit();
     $appraisalinitform->submit->setLabel('Update');
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $appraisalinitmodel = new Default_Model_Appraisalinit();
                 $data = $appraisalinitmodel->getConfigData($id);
                 if (!empty($data)) {
                     $empSummaryModel = new Default_Model_Employee();
                     $empData = $empSummaryModel->getEmp_from_summary($loginUserId);
                     $appraisalinitform->businessunit_name->setValue($empData['businessunit_name']);
                     $appraisalinitform->department_name->setValue($empData['department_name']);
                     $employmentstatusModel = new Default_Model_Employmentstatus();
                     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
                     if (!empty($employmentStatusData)) {
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $appraisalinitform->eligibility->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $data = $data[0];
                     $appraisalinitform->populate($data);
                     $appraisalinitform->setAttrib('action', DOMAIN . 'appraisalinit/edit/id/' . $id);
                     $this->view->data = $data;
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = '';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->eligibility_value = $data['eligibility'];
     $this->view->form = $appraisalinitform;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($appraisalinitform);
         $this->view->msgarray = $result;
     }
     $this->render('form');
 }
 public function addpopupAction()
 {
     $screenFlag = "";
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     if ($this->getRequest()->getParam('screenflag')) {
         $screenFlag = $this->getRequest()->getParam('screenflag');
     }
     $boxid = $this->_getParam('boxid', null);
     $fromcontroller = $this->_getParam('fromcontroller', null);
     $msgarray = array();
     $controllername = 'employmentstatus';
     $employmentstatusform = new Default_Form_employmentstatus();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $employmentstatusform->setAction(BASE_URL . 'employmentstatus/addpopup');
     $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
     $newarr = array();
     $empstatusstr = '';
     if (!empty($activeEmploymentStatusArr)) {
         for ($i = 0; $i < sizeof($activeEmploymentStatusArr); $i++) {
             $newarr1[] = $activeEmploymentStatusArr[$i]['workcodename'];
         }
         if ($screenFlag == 'add') {
             array_push($newarr1, 8, 9, 10);
         }
         $empstatusstr = implode(",", $newarr1);
     }
     if ($empstatusstr != '') {
         $statusArr = $employmentstatusmodel->getStatuslist($empstatusstr);
     } else {
         $statusArr = $employmentstatusmodel->getCompleteStatuslist();
     }
     if (!empty($statusArr)) {
         $employmentstatusform->workcodename->addMultiOption('', 'Select Work Code');
         for ($i = 0; $i < sizeof($statusArr); $i++) {
             if ($fromcontroller == 'requisition') {
                 if (!in_array($statusArr[$i]['id'], array(5, 7, 8, 9, 10))) {
                     $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
                 }
             } else {
                 $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
             }
         }
     }
     $this->view->statusArr = $statusArr;
     $this->view->ermsg = '';
     if ($this->getRequest()->getPost()) {
         if ($employmentstatusform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $workcode = $this->_request->getParam('workcode');
             $workcodename = $this->_request->getParam('workcodename');
             $default_leaves = $this->_request->getParam('default_leaves');
             $description = $this->_request->getParam('description');
             $screenFlag = $this->getRequest()->getParam('screenflag');
             $date = new Zend_Date();
             $actionflag = '';
             $tableid = '';
             $data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
             }
             $Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($data, $where);
             $tableid = $Id;
             $menuID = EMPLOYMENTSTATUS;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
             if (isset($_POST['fromcontroller']) && $_POST['fromcontroller'] != '') {
                 $fromcontroller = $_POST['fromcontroller'];
             }
             if (isset($_POST['boxid']) && $_POST['boxid'] != '') {
                 $boxid = $_POST['boxid'];
             }
         } else {
             $messages = $employmentstatusform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $opt = '';
     if ($fromcontroller == '') {
         if ($screenFlag == 'edit') {
             $empstatusData = $employmentstatusmodel->getempstatuslist();
         }
         if ($screenFlag == 'add') {
             $empstatusData = $employmentstatusmodel->getempstatusActivelist();
         }
         if (!empty($empstatusData)) {
             foreach ($empstatusData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['workcodename'], $record['statusname']);
             }
         }
     } else {
         if ($fromcontroller == 'requisition') {
             $requi_model = new Default_Model_Requisition();
             $empstatusData = $requi_model->getStatusOptionsForRequi();
             foreach ($empstatusData as $stat_id => $stat_name) {
                 $opt .= sapp_Global::selectOptionBuilder($stat_id, $stat_name);
             }
         }
     }
     $this->view->empstatusData = $opt;
     $this->view->screenFlag = $screenFlag;
     $this->view->controllername = $controllername;
     $this->view->form = $employmentstatusform;
     $this->view->ermsg = '';
     $this->view->boxid = $boxid;
     $this->view->fromcontroller = $fromcontroller;
 }
Example #4
0
 public function addemppopupAction()
 {
     $flag = 'true';
     $controllername = 'employee';
     $msgarray = array();
     $emptyFlag = 0;
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $deptidforhead = $this->_getParam('deptidforhead', null);
     $report_opt = array();
     $emp_form = new Default_Form_employee();
     $user_model = new Default_Model_Usermanagement();
     $role_model = new Default_Model_Roles();
     $prefixModel = new Default_Model_Prefix();
     $identity_code_model = new Default_Model_Identitycodes();
     $jobtitlesModel = new Default_Model_Jobtitles();
     $deptModel = new Default_Model_Departments();
     $positionsmodel = new Default_Model_Positions();
     $employeeModal = new Default_Model_Employee();
     $usersModel2 = new Default_Model_Users();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $emp_form->setAction(BASE_URL . 'employee/addemppopup/deptidforhead/' . $deptidforhead);
     $emp_form->removeElement('department_id');
     $emp_form->removeElement('modeofentry');
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
     if ($emp_identity_code != '') {
         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
     } else {
         $emp_id = '';
         $msgarray['employeeId'] = 'Identity codes are not configured yet.';
         $flag = 'false';
     }
     $emp_form->employeeId->setValue($emp_id);
     $role_data = $role_model->getRolesList_Dept();
     $emp_form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
     if (empty($role_data)) {
         $msgarray['emprole'] = 'Roles are not configured yet.';
         $flag = 'false';
     }
     $prefixData = $prefixModel->getPrefixList();
     $emp_form->prefix_id->addMultiOption('', 'Select Prefix');
     if (!empty($prefixData)) {
         foreach ($prefixData as $prefixres) {
             $emp_form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
         }
     } else {
         $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         //$flag = 'false';
     }
     $jobtitleData = $jobtitlesModel->getJobTitleList();
     if (!empty($jobtitleData)) {
         foreach ($jobtitleData as $jobtitleres) {
             $emp_form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
         }
     } else {
         $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
         $msgarray['position_id'] = 'Positions are not configured yet.';
         //$flag = 'false';
     }
     if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
         $positionlistArr = $positionsmodel->getPositionList($_POST['jobtitle_id']);
         if (sizeof($positionlistArr) > 0) {
             $emp_form->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistres) {
                 $emp_form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
             }
         }
     }
     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
     $emp_form->emp_status_id->addMultiOption('', 'Select Employment Status');
     if (!empty($employmentStatusData)) {
         foreach ($employmentStatusData as $employmentStatusres) {
             $emp_form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     } else {
         $msgarray['emp_status_id'] = 'Employment status is not configured yet.';
         $emptyFlag++;
     }
     $reportingManagerData = $usersModel2->getReportingManagerList_employees('', '', MANAGEMENT_GROUP);
     if (!empty($reportingManagerData)) {
         $report_opt = $reportingManagerData;
         if (isset($_POST['reporting_manager']) && $_POST['reporting_manager'] != '') {
             $emp_form->setDefault('reporting_manager', $_POST['reporting_manager']);
         }
     } else {
         $msgarray['reporting_manager'] = 'Reporting managers are not added yet.';
         $flag = 'false';
     }
     if ($this->getRequest()->getPost()) {
         if ($emp_form->isValid($this->_request->getPost()) && $flag == 'true') {
             $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
             $position_id = $this->_request->getParam('position_id', null);
             $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database');
             $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
             $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
             $employeeId = $this->_getParam('employeeId', null);
             $emprole = $this->_getParam('emprole', null);
             $reporting_manager = $this->_getParam('reporting_manager', null);
             $emailaddress = $this->_getParam('emailaddress', null);
             $emppassword = sapp_Global::generatePassword();
             $firstname = trim($this->_getParam('firstname', null));
             $lastname = trim($this->_getParam('lastname', null));
             $userfullname = $firstname . ' ' . $lastname;
             //$userfullname = trim($this->_request->getParam('userfullname',null));
             $prefix_id = $this->_getParam('prefix_id', null);
             $user_id = $this->_getParam('user_id', null);
             $emp_status_id = $this->_getParam('emp_status_id', null);
             $user_data = array('emprole' => $emprole, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => 'Direct', 'selecteddate' => $date_of_joining, 'userstatus' => 'old');
             $emp_data = array('user_id' => $user_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'department_id' => $deptidforhead, 'reporting_manager' => $reporting_manager, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'emp_status_id' => $emp_status_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $user_data['createdby'] = $loginUserId;
             $user_data['createddate'] = gmdate("Y-m-d H:i:s");
             $user_data['isactive'] = 1;
             if ($emp_identity_code != '') {
                 $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
             } else {
                 $emp_id = '';
             }
             $user_data['employeeId'] = $emp_id;
             $user_id = $user_model->SaveorUpdateUserData($user_data, '');
             $emp_data['user_id'] = $user_id;
             $emp_data['createdby'] = $loginUserId;
             $emp_data['createddate'] = gmdate("Y-m-d H:i:s");
             $emp_data['isactive'] = 1;
             $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
             //end of saving into employee table.
             $tableid = $user_id;
             $actionflag = 1;
             $menuID = ORGANISATIONINFO;
             try {
                 $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             } catch (Exception $e) {
             }
             $managementUsersData = $deptModel->getDeptHeads();
             $opt = '';
             foreach ($managementUsersData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['userfullname']);
             }
             $this->view->managementUsersData = $opt;
             /* Send Mail to the user */
             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
             $view = $this->getHelper('ViewRenderer')->view;
             $this->view->emp_name = $userfullname;
             $this->view->password = $emppassword;
             $this->view->emp_id = $employeeId;
             $this->view->base_url = $base_url;
             $text = $view->render('mailtemplates/newpassword.phtml');
             $options['subject'] = APPLICATION_NAME . ' login Credentials';
             $options['header'] = 'Greetings from Sentrifugo';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $this->view->emp_name;
             $options['message'] = $text;
             $result = sapp_Global::_sendEmail($options);
             /* END */
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $emp_form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->msgarray = $msgarray;
     $this->view->report_opt = $report_opt;
     $this->view->controllername = $controllername;
     $this->view->emp_form = $emp_form;
 }
 public function editAction()
 {
     $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;
     }
     $this->view->loginuserRole = $loginuserRole;
     $this->view->loginuserGroup = $loginuserGroup;
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $appraisalinitform = new Default_Form_Appraisalinit();
     $app_rating_model = new Default_Model_Appraisalratings();
     $appraisalinitform->submit->setLabel('Update');
     $disable_arr = array();
     $ratings = '';
     $eligibilityvalue = '';
     $ratingsflag = 'false';
     $data = array();
     try {
         if ($id != '') {
             if (is_numeric($id) && $id > 0) {
                 $appraisalinitmodel = new Default_Model_Appraisalinit();
                 $checkRatingsExists = $app_rating_model->getAppraisalRatingsbyInitId($id);
                 if (!empty($checkRatingsExists)) {
                     $ratingsflag = 'true';
                 }
                 $this->view->ratingsflag = $ratingsflag;
                 $data = $appraisalinitmodel->getConfigData($id);
                 if (!empty($data)) {
                     $data = $data[0];
                     $performance_app_flag = isset($data['performance_app_flag']) ? $data['performance_app_flag'] : '';
                     $this->view->performance_app_flag = $performance_app_flag;
                     $app_rating_type = isset($data['appraisal_ratings']) ? $data['appraisal_ratings'] : 0;
                     $this->view->init_id = $id;
                     if ($data['initialize_status'] == 1) {
                         $this->appraisalinitialized($data);
                     } else {
                         if ($loginuserRole != SUPERADMINROLE && $loginuserGroup != MANAGEMENT_GROUP) {
                             // $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessunit_id, $department_id);
                             $empSummaryModel = new Default_Model_Employee();
                             $empData = $empSummaryModel->getEmp_from_summary($loginUserId);
                             $appraisalinitform->businessunit_name->setValue($empData['businessunit_name']);
                             if ($performance_app_flag == 0) {
                                 $appraisalinitform->department_name->setValue($empData['department_name']);
                             } else {
                                 $appraisalinitform->removeElement("department_name");
                             }
                         } else {
                             // $appImpleData = sapp_PerformanceHelper::check_per_implmentation($data['businessunit_id'], $data['department_id']);
                             $businessunits = $appraisalinitmodel->getbusinnessunits_admin($data['businessunit_id']);
                             $this->view->businessunits = $businessunits;
                             $dept_model = new Default_Model_Departments();
                             if ($performance_app_flag == 0) {
                                 $dept_data = $dept_model->getParicularDepartmentId($data['department_id']);
                                 if (count($dept_data) > 0) {
                                     $dept_data = $dept_data[0];
                                     $appraisalinitform->department_id->addMultiOption($dept_data['id'], $dept_data['deptname']);
                                 }
                             }
                         }
                         // $this->view->imple_data = $appImpleData;
                         $employmentstatusModel = new Default_Model_Employmentstatus();
                         $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
                         if (!empty($employmentStatusData)) {
                             foreach ($employmentStatusData as $employmentStatusres) {
                                 $appraisalinitform->eligibility->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                                 $appraisalinitform->eligibility_hidden->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                                 $eligibilityvalue .= $employmentStatusres['workcodename'] . ',';
                             }
                             $eligibilityvalue = rtrim($eligibilityvalue, ',');
                         }
                         $category_model = new Default_Model_Appraisalcategory();
                         $category_data = $category_model->getAppraisalCategorysData();
                         foreach ($category_data as $cdata) {
                             $appraisalinitform->category_id->addMultiOption($cdata['id'], $cdata['category_name']);
                         }
                         // Set default values for 'To Year' field
                         $following_year = $data["from_year"] + 1;
                         $appraisalinitform->to_year->addMultiOptions(array($data["from_year"] => $data["from_year"], $following_year => $following_year));
                         $appraisalinitform->populate($data);
                         // if($appImpleData['appraisal_ratings'] == 1)
                         // if($app_rating_type == 1)
                         // $ratings = '1-5';
                         // else
                         // $ratings = '1-10';
                         $appraisalinitform->appraisal_ratings->setValue($app_rating_type);
                         if ($eligibilityvalue != '') {
                             $appraisalinitform->eligibility_value->setValue($eligibilityvalue);
                         }
                         $appraisalinitform->setAttrib('action', BASE_URL . 'appraisalinit/edit/id/' . $id);
                         $appraisalinitform->eligibilityflag->setValue('1');
                         $appraisalinitform->eligibility_hidden->setAttrib("disabled", "disabled");
                         /*$cnt = $appraisalinitmodel->check_delete($id);
                           if($cnt > 0)
                           {
                               $disable_arr[] = "management_appraisal"; 
                           }*/
                         if ($data['enable_step'] == 2) {
                             $appraisalinitform->enable_step->removeMultiOption(1);
                         }
                         $this->view->period_disp = $this->period_helper($data['appraisal_mode'], $data['appraisal_period']);
                         $this->view->data = $data;
                         $this->view->category_id_value = $data['category_id'];
                         $this->view->businessunit_id = $businessunit_id;
                         $this->view->employmentStatusData = $employmentStatusData;
                         $this->view->eligibilityvalue = $eligibilityvalue;
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = '';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->eligibility_value = isset($data['eligibility']) ? $data['eligibility'] : '';
     $this->view->form = $appraisalinitform;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($appraisalinitform, $is_edit = 1);
         $this->view->msgarray = $result;
     }
     //$this->view->disable_arr = $disable_arr;
     if (!empty($data) && $data['initialize_status'] == 1) {
         $this->render('edit');
     } else {
         $this->render('form');
     }
 }