public function saverequesttypes() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $servicedeskrequestmodel = new Default_Model_Servicedeskrequest(); $msgarray = array(); $errorflag = 'true'; $service_desk_id = $this->_request->getParam('category_id'); $requesttype_arr = $this->_request->getParam('requesttype'); $description_arr = $this->_request->getParam('description'); if (!empty($requesttype_arr)) { $requestArr = array_count_values($requesttype_arr); for ($i = 0; $i < sizeof($requesttype_arr); $i++) { if ($requesttype_arr[$i] == '') { $msgarray['request_name'][$i] = 'Please enter request type.'; $errorflag = 'false'; } else { if (!preg_match('/^[a-zA-Z0-9.\\- ?]+$/', $requesttype_arr[$i])) { $msgarray['request_name'][$i] = 'Please enter valid request type.'; $errorflag = 'false'; } else { if ($i > 0 && $requestArr[$requesttype_arr[$i]] > 1) { $msgarray['request_name'][$i] = 'Please enter different request type.'; $errorflag = 'false'; } else { if ($service_desk_id) { $isduplicaterequest = $servicedeskrequestmodel->checkduplicaterequestname($service_desk_id, $requesttype_arr[$i]); if (!empty($isduplicaterequest)) { if ($isduplicaterequest[0]['count'] > 0) { $msgarray['request_name'][$i] = 'request type already exist.'; $errorflag = 'false'; } } } } } } } $msgarray['categorysize'] = sizeof($requesttype_arr); } if ($errorflag == 'true') { try { $menumodel = new Default_Model_Menu(); $actionflag = 1; $tableid = ''; $where = ''; $date = new Zend_Date(); for ($i = 0; $i < sizeof($requesttype_arr); $i++) { $data = array('service_desk_id' => $service_desk_id, 'service_request_name' => $requesttype_arr[$i], 'description' => $description_arr[$i] != '' ? $description_arr[$i] : NULL, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); $Id = $servicedeskrequestmodel->SaveorUpdateServiceDeskRequestData($data, $where); $tableid = $Id; $menuID = SERVICEDESKREQUEST; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); } $wizard_model = new Default_Model_Wizard(); $wizardData = $wizard_model->getWizardData(); $wizardarray = array('servicerequest' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($wizardData['site_config'] == 2 && $wizardData['org_details'] == 2 && $wizardData['departments'] == 2) { $wizardarray['iscomplete'] = 2; } $wizard_model->SaveorUpdateWizardData($wizardarray, ''); $this->_helper->getHelper("FlashMessenger")->addMessage("Categories added successfully."); $this->_redirect('wizard/configureservicerequest'); } catch (Exception $e) { $msgarray['category_id'] = "Something went wrong, please try again."; return $msgarray; } } else { return $msgarray; } }
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) { $servicedeskdepartmentmodel = new Default_Model_Servicedeskdepartment(); $servicedeskrequestmodel = new Default_Model_Servicedeskrequest(); $servicedeskconfmodel = new Default_Model_Servicedeskconf(); $menumodel = new Default_Model_Menu(); $pendingRequestdata = $servicedeskconfmodel->getServiceReqDeptCount($id, 1); if (!empty($pendingRequestdata)) { $count = $pendingRequestdata[0]['count']; } $service_req_cnt = $servicedeskrequestmodel->getReqCnt($id); if ($service_req_cnt > 0) { $count = $count + $service_req_cnt; } if ($count < 1) { $servicedeskdepartmentdata = $servicedeskdepartmentmodel->getServiceDeskDepartmentDatabyID($id); $data = array('isactive' => 0, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $id); $reqwhere = array('service_desk_id=?' => $id); $Id = $servicedeskdepartmentmodel->SaveorUpdateServiceDeskDepartmentData($data, $where); $RId = $servicedeskrequestmodel->SaveorUpdateServiceDeskRequestData($data, $reqwhere); if ($Id == 'update') { $menuidArr = $menumodel->getMenuObjID('/servicedeskdepartment'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); $configmail = sapp_Global::send_configuration_mail('Category', $servicedeskdepartmentdata[0]['service_desk_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.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Category cannot be deleted.'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); }
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) { $servicedeskrequestmodel = new Default_Model_Servicedeskrequest(); $servicedeskconfmodel = new Default_Model_Servicedeskconf(); $pendingRequestdata = $servicedeskconfmodel->getServiceReqDeptCount($id, 2); if (!empty($pendingRequestdata)) { $count = $pendingRequestdata[0]['count']; } if ($count < 1) { $servicedeskrequestdata = $servicedeskrequestmodel->getServiceDeskRequestbyID($id); $data = array('isactive' => 0, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $id); $Id = $servicedeskrequestmodel->SaveorUpdateServiceDeskRequestData($data, $where); if ($Id == 'update') { $menuID = SERVICEDESKREQUEST; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); $configmail = sapp_Global::send_configuration_mail('Request type', $servicedeskrequestdata[0]['service_request_name']); $messages['message'] = 'Request type deleted successfully.'; $messages['msgtype'] = 'success'; } else { $messages['message'] = 'Request type cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Request type cannot be deleted as requests are in pending state.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Request type cannot be deleted.'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); }