/** * This function is used to check login id user is a request receiver or not. * @param integer $emp_id = id of login user * @param integer $businessunit_id = id of business unit * @param integer $service_desk_flag = service desk flag value * @return string Yes/No */ public function check_receiver($emp_id, $businessunit_id) { $status = "no"; if ($emp_id != '') { if ($businessunit_id == 0) { $service_desk_flag = '0'; } else { $bu_model = new Default_Model_Businessunits(); $bu_data = $bu_model->getSingleUnitData($businessunit_id); $service_desk_flag = $bu_data['service_desk_flag']; } if ($service_desk_flag != '' && $businessunit_id != '') { $db = Zend_Db_Table::getDefaultAdapter(); $query = "select count(*) cnt from main_sd_configurations " . "where isactive = 1 and businessunit_id = " . $businessunit_id . " and service_desk_flag = " . $service_desk_flag . " " . "and find_in_set(" . $emp_id . ",request_recievers) "; $result = $db->query($query); $row = $result->fetch(); if ($row['cnt'] != '' && $row['cnt'] > 0) { $status = "yes"; } } } return $status; }
/** * * Edit function to prepopulate the data. * */ public function editAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $id = $this->getRequest()->getParam('id'); $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $appraisalconfigform = new Default_Form_Appraisalconfig(); $bunitModel = new Default_Model_Businessunits(); $appraisalconfigmodel = new Default_Model_Appraisalconfig(); $departmentsmodel = new Default_Model_Departments(); $msgarray = array(); $appraisalconfigform->submit->setLabel('Update'); try { if ($id) { if (is_numeric($id) && $id > 0) { /** to show/hide edit button **/ $chkFlagForEdit = $appraisalconfigmodel->checkInitializationData($id); $this->view->chkFlagForEdit = $chkFlagForEdit; if (empty($chkFlagForEdit)) { $data = $appraisalconfigmodel->getAppraisalConfigbyID($id); if (!empty($data)) { $data = $data[0]; if ($data['department_id'] != '' && $data['department_id'] != 'NULL') { $deptdata = $departmentsmodel->getSingleDepartmentData($data['department_id']); if (sizeof($deptdata) > 0) { $appraisalconfigform->department_id->addMultiOption($deptdata['id'], utf8_encode($deptdata['deptname'])); } } $bunitData = $bunitModel->getSingleUnitData($data['businessunit_id']); if (!empty($bunitData)) { $appraisalconfigform->businessunit_id->addMultiOption($bunitData['id'], utf8_encode($bunitData['unitname'])); } if ($data['department_id'] != '' && $data['department_id'] != 'NULL') { $departmentlistArr = $departmentsmodel->getDepartmentList($data['businessunit_id']); $departmentlistArr = $departmentsmodel->getSingleDepartmentData($data['department_id']); } else { $departmentlistArr = array(); } // Disable 'Business unit wise' option when 'No Business Unit' was selected if ($data["businessunit_id"] == 0) { $appraisalconfigform->performance_app_flag->setOptions(array('disable' => array(1))); } $appraisalconfigform->populate($data); $appraisalconfigform->setDefault('businessunit_id', $data['businessunit_id']); if (sizeof($departmentlistArr) > 0) { $appraisalconfigform->setDefault('department_id', $data['department_id']); } $this->view->performance_app_flag = $data['performance_app_flag']; $appraisalconfigform->setAttrib('action', DOMAIN . 'appraisalconfig/edit/id/' . $id); $this->view->data = $data; /**** $chk_cnt = $appraisalconfigmodel->check_act_init($id); $this->view->chk_cnt = $chk_cnt; if($chk_cnt > 0) { $appraisalconfigform->businessunit_id->setAttrib("disabled", "disabled"); $appraisalconfigform->performance_app_flag->setAttrib("disabled", "disabled"); $appraisalconfigform->department_id->setAttrib("disabled", "disabled"); $appraisalconfigform->appraisal_mode->setAttrib("disabled", "disabled"); $appraisalconfigform->appraisal_ratings->setAttrib("disabled", "disabled"); //added on 13-04-2015 by soujanya } *****/ } else { $this->view->ermsg = 'norecord'; } } else { $this->view->ermsg = 'noedit'; } } else { $this->view->ermsg = 'norecord'; } } else { $this->view->ermsg = 'nodata'; } } catch (Exception $e) { $this->view->ermsg = 'nodata'; } $this->view->form = $appraisalconfigform; if ($this->getRequest()->getPost()) { $result = $this->save($appraisalconfigform); $this->view->msgarray = $result; } $this->render('form'); }
public static function getbudeptname($appraisalid) { $appInitModel = new Default_Model_Appraisalinit(); $businessunitmodel = new Default_Model_Businessunits(); $deptmodel = new Default_Model_Departments(); $buname = ''; $deptname = ''; $perf_impl_flag = ''; $appraisaldataArr = array(); if ($appraisalid) { $appraisaldataArr = $appInitModel->getAppDataById($appraisalid); if (!empty($appraisaldataArr)) { if ($appraisaldataArr['businessunit_id'] != '') { $buDataArr = $businessunitmodel->getSingleUnitData($appraisaldataArr['businessunit_id']); // $perfimplementation = $appInitModel->check_performance_implmentation($appraisaldataArr['businessunit_id']); if (!empty($buDataArr)) { $buname = $buDataArr['unitname']; } /*if(!empty($perfimplementation)) { $perf_impl_flag = $perfimplementation['performance_app_flag']; }*/ $perf_impl_flag = isset($appraisaldataArr['performance_app_flag']) ? $appraisaldataArr['performance_app_flag'] : 1; } if ($perf_impl_flag == 0) { if ($appraisaldataArr['department_id'] != '') { $deptArr = $deptmodel->getSingleDepartmentData($appraisaldataArr['department_id']); } if (!empty($deptArr)) { $deptname = $deptArr['deptname']; } } } } return array('buname' => $buname, 'deptname' => $deptname, 'perf_app_flag' => $perf_impl_flag, 'appdata' => $appraisaldataArr); }
public function getdepartmentsAction() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('getdepartments', 'html')->initContext(); $businessunitsmodel = new Default_Model_Businessunits(); $bunitid = $this->_request->getParam('bunitid'); $deptid = $this->_request->getParam('deptid'); $implementationData = array(); if ($bunitid != '') { $implementationData = $businessunitsmodel->getSingleUnitData($bunitid); } $this->_helper->_json($implementationData); }
public function buildoptions($businessUnitId, $departmentId, $performanceappflag) { $businessunitmodel = new Default_Model_Businessunits(); $deptmodel = new Default_Model_Departments(); $deptOptions = ''; $buDataArr = $businessunitmodel->getSingleUnitData($businessUnitId); if (!empty($buDataArr)) { $buOptions = "<option value=" . $buDataArr['id'] . ">" . utf8_encode($buDataArr['unitname']) . "</option>"; } if ($performanceappflag == 0) { if ($departmentId != '') { $deptArr = $deptmodel->getSingleDepartmentData($departmentId); } } if (!empty($deptArr)) { $deptOptions = "<option value=" . $deptArr['id'] . ">" . utf8_encode($deptArr['deptname']) . "</option>"; } return array('buoptions' => $buOptions, 'deptoptions' => $deptOptions); }
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 getbunitimplementationAction() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('getbunitimplementation', 'json')->initContext(); $businessunitsmodel = new Default_Model_Businessunits(); $servicedeskconfmodel = new Default_Model_Servicedeskconf(); $bunitid = $this->_request->getParam('bunitid'); $result = array(); if ($bunitid != '') { $pendingRequestdata = $servicedeskconfmodel->getPendingServiceReqData($bunitid); if (!empty($pendingRequestdata)) { $result['count'] = $pendingRequestdata[0]['count']; } $implementationdata = $businessunitsmodel->getSingleUnitData($bunitid); if (!empty($implementationdata)) { $result['result'] = $implementationdata['service_desk_flag']; } } $this->_helper->_json($result); }
/** * */ public function addAction() { $sd_req_model = new Default_Model_Servicerequests(); $request_form = new Default_Form_Servicerequest(); $isUpdate = "0"; $msgarray = array(); $auth = Zend_Auth::getInstance(); $grid_type = $this->_getParam('t', null); $status_value = $this->_getParam('v', null); $this->view->x_grid_type = $grid_type; $this->view->x_status_value = $status_value; if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; $login_bu = $auth->getStorage()->read()->businessunit_id; $login_dept = $auth->getStorage()->read()->department_id; $reporting_manager = $auth->getStorage()->read()->reporting_manager; $org_head_flag = $auth->getStorage()->read()->is_orghead; } if ($org_head_flag == 1) { $this->view->ermsg = 'norecord'; $this->render('form'); } if ($grid_type != '') { if ($login_bu == 0) { $service_desk_flag = 0; } else { $bu_model = new Default_Model_Businessunits(); $bu_data = $bu_model->getSingleUnitData($login_bu); $service_desk_flag = $bu_data['service_desk_flag']; } $service_types_data = $sd_req_model->getServiceTypes($login_bu, $login_dept, $service_desk_flag); $grid_type = sapp_Global::_decrypt($grid_type); $grid_type_arr = $sd_req_model->getGridtypearr(); if ($login_bu == 0 && $login_dept == 0) { $msgarray['service_desk_conf_id'] = "To use service request management, please assign to any department."; } $this->view->msgarray = $msgarray; $this->view->form = $request_form; $this->view->service_types_data = $service_types_data; $this->view->action_name = $this->getRequest()->getActionName(); $this->view->grid_type = $grid_type_arr[$grid_type]; $this->view->grid_type_arr = $sd_req_model->getGridtypearr_rev(); $this->view->status_value = $status_value; $id = $this->getRequest()->getParam('id', null); $where = ""; $actionflag = 1; if ($id > 0 && is_numeric($id)) { //update code $actionflag = 2; $id = abs($id); $serviceticketdata = $sd_req_model->getServiceTicketByID($id); if ($serviceticketdata != false) { $request_form->setDefault('service_desk_conf_id', $serviceticketdata['service_desk_conf_id']); $request_form->setDefault('priority', $serviceticketdata['priority']); $request_form->setDefault('description', $serviceticketdata['description']); $sd_dept_model = new Default_Model_Servicedeskdepartment(); $servicedeskrequesttypes = $sd_dept_model->getRequestIDNameById($serviceticketdata['service_desk_conf_id']); $request_form->service_request_id->addMultiOptions(array('' => 'Select Request') + $servicedeskrequesttypes); $request_form->setDefault('service_request_id', $serviceticketdata['service_request_id']); $request_form->submit->setLabel('Update'); } else { $this->view->ermsg = 'norecord'; } } if ($this->getRequest()->getPost()) { if ($request_form->isValid($this->_request->getPost())) { $service_desk_id = $this->_getParam('service_desk_id', null); $service_desk_conf_id = $this->_getParam('service_desk_conf_id', null); if ($service_desk_id == "") { $service_desk_id = $service_desk_conf_id; } $service_request_id = $this->_getParam('service_request_id', null); $priority = $this->_getParam('priority', null); $description = $this->_getParam('description', null); $attachment = $this->_getParam('attachment', null); $check_raiser = $sd_req_model->check_raiser($service_desk_conf_id, $loginUserId); if ($check_raiser == 'yes') { $file_original_names = $this->_getParam('file_original_names', null); $file_new_names = $this->_getParam('file_new_names', null); $org_names = explode(',', $file_original_names); $new_names = explode(',', $file_new_names); $attachment_array = array(); for ($i = 0; $i < count($org_names); $i++) { if ($new_names[$i] != '') { $attachment_array[$org_names[$i]] = $new_names[$i]; } } $data = array('service_desk_id' => $service_desk_id, 'service_desk_conf_id' => $service_desk_conf_id, 'service_request_id' => $service_request_id, 'priority' => $priority, 'description' => $description, 'attachment' => count($attachment_array) > 0 ? json_encode($attachment_array) : null, 'status' => 'Open', 'reporting_manager_id' => $reporting_manager, 'raised_by' => $loginUserId, 'isactive' => 1, 'createdby' => $loginUserId, 'modifiedby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s")); $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { if ($id != '') { $isUpdate = "1"; unset($data['createdby']); unset($data['createdon']); $where = "id = " . $id; $actionflag = 2; $result = $sd_req_model->SaveorUpdateRequestData($data, $where); $rslt = "Request updated successfully."; //start of saving history $reqh_model = new Default_Model_Requesthistory(); $reqh_data = array('request_id' => $id, 'description' => ucfirst($rslt), 'emp_id' => $loginUserId, 'emp_name' => ucfirst($auth->getStorage()->read()->userfullname), 'emp_profileimg' => $auth->getStorage()->read()->profileimg, 'createdby' => $loginUserId, 'modifiedby' => $loginUserId, 'comments' => trim($description), 'isactive' => 1, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s")); $reqh_model->SaveorUpdateRhistory($reqh_data, ''); } else { $id = $sd_req_model->SaveorUpdateRequestData($data, ''); $data = array('modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'ticket_number' => "SD" . str_pad($id, 4, '0', STR_PAD_LEFT)); $sd_req_model->SaveorUpdateRequestData($data, 'id = ' . $id); $rslt = "Request raised successfully."; } if (count($new_names) > 0) { foreach ($new_names as $n) { if ($n != '') { if (file_exists(SD_TEMP_UPLOAD_PATH . $n)) { copy(SD_TEMP_UPLOAD_PATH . $n, SD_UPLOAD_PATH . $n); unlink(SD_TEMP_UPLOAD_PATH . $n); } } } } $result = sapp_Global::logManager(SERVICEDESK, 1, $loginUserId, $id); $this->send_req_mails($id, $isUpdate); $trDb->commit(); $this->_helper->getHelper("FlashMessenger")->addMessage(array(array("success" => $rslt))); $this->_redirect('servicerequests/index/t/' . sapp_Global::_encrypt('1')); } catch (Exception $ex) { $trDb->rollBack(); $msgarray['service_desk_conf_id'] = "Something went wrong, please try again."; $this->view->msgarray = $msgarray; } } else { $msgarray['service_desk_conf_id'] = "You cannot raise the request as you are the request receiver."; $this->view->msgarray = $msgarray; } } else { $file_original_names = $this->_getParam('file_original_names', null); $file_new_names = $this->_getParam('file_new_names', null); $show_attachment = $this->_getParam('show_attachment', null); $messages = $request_form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $this->view->msgarray = $msgarray; $this->view->file_original_names = $file_original_names; $this->view->file_new_names = $file_new_names; $this->view->show_attachment = $show_attachment; } if (count($msgarray) > 0) { $sd_dept_model = new Default_Model_Servicedeskdepartment(); $data = $sd_dept_model->getRequestsById($this->_getParam('service_desk_id')); $ser_req_options = array('' => 'Select request'); if (count($data) > 0) { foreach ($data as $opt) { $ser_req_options[$opt['id']] = $opt['service_request_name']; } } $request_form->service_request_id->addMultiOptions($ser_req_options); } } } else { $this->view->ermsg = 'norecord'; } $this->render('form'); }