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 updatewizardcompletionAction() { $this->_helper->layout->disableLayout(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $result['result'] = ''; $wizard_model = new Default_Model_Wizard(); $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $Completion_data = array('iscomplete' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $CompleteId = $wizard_model->SaveorUpdateWizardData($Completion_data, ''); $db->commit(); $result['result'] = 'success'; } catch (Exception $e) { $db->rollBack(); $result['result'] = 'fail'; } $this->_helper->json($result); }
public function saveorginfo($form, $loginUserId) { $orgInfoModel = new Default_Model_Organisationinfo(); $wizard_model = new Default_Model_Wizard(); $id = $this->getRequest()->getParam('id'); $imagerror = $this->_request->getParam('imgerr'); $imagepath = $this->_request->getParam('org_image_value'); $imgerrmsg = $this->_request->getParam('imgerrmsg'); $pphnumber = $this->_request->getParam('phonenumber'); $sphnumber = $this->_request->getParam('secondaryphone'); $org_startdate = sapp_Global::change_date($this->_request->getParam('org_startdate'), 'database'); $flag = 'true'; if (isset($imagepath) && $imagepath != '') { $imageArr = explode('.', $imagepath); if (sizeof($imageArr) > 1) { $imagename = $imageArr[0]; $imageext = $imageArr[1]; $extArr = array('gif', 'jpg', 'jpeg', 'png'); if (!in_array($imageext, $extArr)) { $msgarray['org_image_value'] = 'Please upload an appropriate image file.'; $flag = 'false'; } } else { $msgarray['org_image_value'] = 'Please upload an appropriate image file.'; $flag = 'false'; } } if ($imagerror == 'error') { if ($imgerrmsg != '' && $imgerrmsg != 'undefined') { $msgarray['org_image_value'] = $imgerrmsg; } else { $msgarray['org_image_value'] = 'Please upload an appropriate image file.'; } $flag = 'false'; } if ($pphnumber == $sphnumber && $sphnumber != '' && $pphnumber != '') { $msgarray['secondaryphone'] = 'Please enter different phone number.'; $flag = 'false'; } if ($form->isValid($this->_request->getPost()) && $flag != 'false') { $domain = $this->_request->getParam('domain'); if (!empty($domain)) { $domain = implode(',', $domain); } $date = new Zend_Date(); $data = array('organisationname' => trim($this->_request->getParam('organisationname')), 'domain' => trim($domain), 'website' => trim($this->_request->getParam('website')), 'org_image' => $imagepath, 'orgdescription' => trim($this->_request->getParam('orgdescription')), 'totalemployees' => trim($this->_request->getParam('totalemployees')), 'org_startdate' => $org_startdate != '' ? $org_startdate : NULL, 'phonenumber' => trim($this->_request->getParam('phonenumber')), 'secondaryphone' => trim($this->_request->getParam('secondaryphone')), 'faxnumber' => trim($this->_request->getParam('faxnumber')), 'country' => trim((int) $this->_request->getParam('country')), 'state' => trim(intval($this->_request->getParam('state'))), 'city' => trim(intval($this->_request->getParam('city'))), 'address1' => trim($this->_request->getParam('address1')), 'address2' => trim($this->_request->getParam('address2')), 'address3' => trim($this->_request->getParam('address3')), 'description' => trim($this->_request->getParam('description')), 'designation' => trim($this->_request->getParam('jobtitle_id', null)), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $path = IMAGE_UPLOAD_PATH; $imagepath = $this->_request->getParam('org_image_value'); $filecopy = 'success'; if ($imagepath != '') { $filecopy = 'error'; if (file_exists(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath)) { try { if (copy(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath, $path . '//' . $imagepath)) { $filecopy = 'success'; } unlink(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath); } catch (Exception $e) { echo $msgarray['org_image_value'] = $e->getMessage(); exit; } } } $where = array('id=?' => $id); if ($imagepath == '') { unset($data['org_image']); } else { if ($filecopy == 'error') { unset($data['org_image']); } } 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 = $orgInfoModel->SaveorUpdateData($data, $where); $location_data = array('country' => trim((int) $this->_request->getParam('country')), 'state' => trim(intval($this->_request->getParam('state'))), 'city' => trim(intval($this->_request->getParam('city'))), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $LocationId = $wizard_model->SaveorUpdateWizardData($location_data, ''); if ($filecopy == 'success') { $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information saved successfully."); } else { $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information saved successfully but failed to upload the logo."); } $menuID = ORGANISATIONINFO; try { if ($Id != '' && $Id != 'update') { $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id); } else { $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); } } catch (Exception $e) { echo $e->getMessage(); } $db->commit(); $this->_redirect('organisationinfo'); } catch (Exception $e) { $db->rollBack(); return 'failed'; } } else { $messages = $form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }