/** * This function is used for ajax call to get departments based on * business unit id. * @parameters * @param {Integer} bunitid = id of business unit. * * @return Array of departments in json format. */ public function getdepartmentsAction() { $bunit_id = $this->_getParam('bunitid', null); $dept_model = new Default_Model_Departments(); $options_data = ""; $options_data .= sapp_Global::selectOptionBuilder('', 'Select Department'); if ($bunit_id != '') { $dept_data = $dept_model->getAllDeptsForUnit($bunit_id); foreach ($dept_data as $dept) { $options_data .= sapp_Global::selectOptionBuilder($dept['id'], $dept['deptname']); } } $this->_helper->json(array('options' => $options_data)); }
public function viewAction() { $orgInfoModel = new Default_Model_Organisationinfo(); $getorgData = $orgInfoModel->getorgrecords(); if (!empty($getorgData)) { $orgdata = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $permission = 'No'; $id = $this->getRequest()->getParam('id'); if (is_numeric($id) && $id > 0) { $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $objName = 'businessunits'; $businessunitsform = new Default_Form_businessunits(); $deptModel = new Default_Model_Departments(); $businessunitsform->removeElement("submit"); $elements = $businessunitsform->getElements(); if (count($elements) > 0) { foreach ($elements as $key => $element) { if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") { $element->setAttrib("disabled", "disabled"); } } } $businessunitsmodel = new Default_Model_Businessunits(); $data = $businessunitsmodel->getSingleUnitData($id); if (!empty($data)) { $businessunitsform->populate($data); $countryId = $data['country']; $stateId = $data['state']; $cityId = $data['city']; if ($countryId && $stateId) { $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $statesData = $statesmodel->getBasicStatesList($countryId); $citiesData = $citiesmodel->getBasicCitiesList($stateId); foreach ($statesData as $res) { $businessunitsform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state'])); } foreach ($citiesData as $res) { $businessunitsform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city'])); } $businessunitsform->setDefault('country', $countryId); $businessunitsform->setDefault('state', $stateId); $businessunitsform->setDefault('city', $cityId); } $st_date = sapp_Global::change_date($data["startdate"], 'view'); $businessunitsform->setDefault('start_date', $st_date); $permission = sapp_Global::_checkprivileges(BUSINESSUNITS, $loginuserGroup, $loginuserRole, 'edit'); $deptData = $deptModel->getAllDeptsForUnit($id); $this->view->deptData = sizeof($deptData); $this->view->dataArray = $this->departmentGrid($id); $this->view->ermsg = ''; } else { $this->view->ermsg = 'nodata'; } $this->view->editpermission = $permission; $this->view->controllername = $objName; $this->view->id = $id; $this->view->form = $businessunitsform; $this->view->role = $loginuserRole; } else { $this->view->ermsg = 'nodata'; } } else { $orgdata = 'noorgdata'; $this->view->orgdata = $orgdata; } }
public function closeappraisal($appraisalid, $status, $enablestepflag, $buid, $perfflag, $deptid) { $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); } $appraisalinitmodel = new Default_Model_Appraisalinit(); $appraisalqsmodel = 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 = ''; $title = 'Performance Appraisal'; $description = 'Performance appraisal initialized'; $result = array(); $employeeidArr = array(); if ($status == 2) { $statustext = 'Closed'; } else { $statustext = 'Forcefully Closed'; } if ($appraisalid) { $trDb = Zend_Db_Table::getDefaultAdapter(); $trDb->beginTransaction(); try { /** Start * Updating initialization table */ $init_Arr = array('status' => $status, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $appraisalid); $Id = $appraisalinitmodel->SaveorUpdateAppraisalInitData($init_Arr, $where); /** End */ /** Start * Sending Mails to employees */ if ($enablestepflag == 1) { $employeeidArr = $appraisalqsmodel->getemployeeIDs($appraisalid); } else { $employeeidArr = $appraisalempratingsmodel->getEmployeeIds($appraisalid); } if (!empty($employeeidArr)) { foreach ($employeeidArr as $emp) { $employeeDetailsArr = $usersmodel->getUserDetailsByID($emp['employee_id'], ''); if (!empty($employeeDetailsArr)) { $options['subject'] = APPLICATION_NAME . ': Performance Appraisal ' . $statustext; $options['header'] = 'Performance Appraisal ' . $statustext; $options['toEmail'] = $employeeDetailsArr[0]['emailaddress']; $options['toName'] = $employeeDetailsArr[0]['userfullname']; $options['message'] = 'Dear ' . $employeeDetailsArr[0]['userfullname'] . ', performance appraisal ' . $statustext; $options['cron'] = 'yes'; // sapp_Global::_sendEmail($options); } } } /** * End */ /** * Mail to performance Appraisal Group */ if (defined('PER_APPRAISAL_' . $buid) && $buid != '') { $options['subject'] = APPLICATION_NAME . ': Performance Appraisal ' . $statustext; $options['header'] = 'Performance Appraisal'; $options['toEmail'] = constant('PER_APPRAISAL_' . $buid); $options['toName'] = 'Performance Appraisal'; $options['message'] = 'Performance appraisal initiated ' . $statustext; $options['cron'] = 'yes'; // sapp_Global::_sendEmail($options); } /** * End */ /** Start * Announecements */ if ($perfflag == 1) { $deptArr = $departmentsmodel->getAllDeptsForUnit($buid); if (!empty($deptArr)) { foreach ($deptArr as $dept) { $deptids .= $dept['id'] . ','; } $deptids = rtrim($deptids, ','); } } else { $deptids = $deptid; } /* $announcement_arr = array( 'businessunit_id' => $buid!=''?$buid: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 */ $trDb->commit(); $result['msg'] = 'Performance Appraisal ' . $statustext; $result['result'] = 'success'; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Performance Appraisal " . $statustext)); } catch (Exception $e) { $trDb->rollBack(); $result['msg'] = $e->getMessage(); $result['result'] = 'error'; } } return $result; }