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; } $popConfigPermission = array(); $msgarray = array(); $id = $this->getRequest()->getParam('id'); $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $systempreferenceform = new Default_Form_systempreference(); $dateformatidmodel = new Default_Model_Dateformat(); $timeformatidmodel = new Default_Model_Timeformat(); $currencyidmodel = new Default_Model_Currency(); $systempreferencemodel = new Default_Model_Sitepreference(); $date_formats_arr = array(); $time_formats_arr = array(); $passworddataArr = array(); $timezonemodel = new Default_Model_Timezone(); $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray(); if (sapp_Global::_checkprivileges(CURRENCY, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'currency'); } if (sapp_Global::_checkprivileges(TIMEZONE, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'timezone'); } if ($id && $id > 0 && is_numeric($id)) { try { $data = $systempreferencemodel->getsingleSystemPreferanceData($id); $date_formats_arr = $dateformatidmodel->getAllDateFormats(); $time_formats_arr = $timeformatidmodel->fetchAll()->toArray(); $currencyidmodeldata = $currencyidmodel->getCurrencyList(); $systempreferenceform->currencyid->addMultiOption('', 'Select Currency'); if (sizeof($currencyidmodeldata) > 0) { foreach ($currencyidmodeldata as $currencyidres) { $systempreferenceform->currencyid->addMultiOption($currencyidres['id'], utf8_encode($currencyidres['currencytext'])); } } $systempreferenceform->passwordid->addMultiOption('', 'Select Password Preference'); $passworddataArr = $systempreferencemodel->getPasswordData(); foreach ($passworddataArr as $passwordres) { $systempreferenceform->passwordid->addMultiOption($passwordres['id'], utf8_encode($passwordres['passwordtype'])); } if (sizeof($allTimezoneData) > 0) { foreach ($allTimezoneData as $timezoneidres) { $systempreferenceform->timezoneid->addMultiOption($timezoneidres['id'], utf8_encode($timezoneidres['timezone'] . ' [' . $timezoneidres['timezone_abbr'] . ']')); } } else { $msgarray['timezoneid'] = 'Time Zone is not configured yet.'; } $systempreferenceform->populate($data); $systempreferenceform->setDefault('dateformatid', $data['dateformatid']); $systempreferenceform->setDefault('timeformatid', $data['timeformatid']); $systempreferenceform->setDefault('currencyid', $data['currencyid']); $systempreferenceform->setDefault('passwordid', $data['passwordid']); $systempreferenceform->setAttrib('action', DOMAIN . 'sitepreference/edit/id/' . $id); $this->view->msgarray = $msgarray; } catch (Exception $e) { $this->view->nodata = "nodata"; } } else { $this->view->nodata = "nodata"; } $this->view->form = $systempreferenceform; $this->view->date_formats_arr = $date_formats_arr; $this->view->time_formats_arr = $time_formats_arr; $this->view->passworddata = $passworddataArr; if ($this->getRequest()->getPost()) { $result = $this->save($systempreferenceform); $this->view->msgarray = $result; } $this->view->popConfigPermission = $popConfigPermission; }
public function configuresiteAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $popConfigPermission = array(); $msgarray = array(); $wizardpreferenceform = new Default_Form_wizardpreference(); $dateformatidmodel = new Default_Model_Dateformat(); $timeformatidmodel = new Default_Model_Timeformat(); $currencyidmodel = new Default_Model_Currency(); $systempreferencemodel = new Default_Model_Sitepreference(); $orginfomodel = new Default_Model_Organisationinfo(); $identitycodesmodel = new Default_Model_Identitycodes(); $employmentstatusmodel = new Default_Model_Employmentstatus(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $date_formats_arr = array(); $time_formats_arr = array(); $passworddataArr = array(); $currencynameArr = array(); $countryId = ''; $stateId = ''; $cityId = ''; $new_stateId = ''; $new_cityId = ''; $empstatusids = ''; $timezonemodel = new Default_Model_Timezone(); $wizard_model = new Default_Model_Wizard(); $wizardData = $wizard_model->getWizardData(); /* START * Queries to check whether the configuration are already set. * If set then prepopulate the fields */ $sitepreferencedata = $systempreferencemodel->SitePreferanceData(); $orginfodata = $orginfomodel->getOrganisationInfo(); $empstatusdata = $employmentstatusmodel->getEmploymentStatuslist(); $identitycodedata = $identitycodesmodel->getIdentitycodesRecord(); /* * END - Checking configuration is set or not. */ $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray(); if (sapp_Global::_checkprivileges(CURRENCY, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'currency'); } if (sapp_Global::_checkprivileges(TIMEZONE, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'timezone'); } try { if (!empty($orginfodata)) { $countryId = isset($orginfodata[0]['country']) ? $orginfodata[0]['country'] : ""; $stateId = isset($orginfodata[0]['state']) ? $orginfodata[0]['state'] : ""; $cityId = isset($orginfodata[0]['city']) ? $orginfodata[0]['city'] : ""; $wizardpreferenceform->organisationid->setValue($orginfodata[0]['id']); } else { if (isset($wizardData['country']) && $wizardData['country'] != 'null') { $countryId = $wizardData['country']; } if (isset($wizardData['state']) && $wizardData['state'] != 'null') { $stateId = $wizardData['state']; } if (isset($wizardData['city']) && $wizardData['city'] != 'null') { $cityId = $wizardData['city']; } } if (count($_POST) > 0) { $countryId = isset($_POST['perm_country']) ? $_POST['perm_country'] : ""; $stateId = isset($_POST['perm_state']) ? $_POST['perm_state'] : ""; $cityId = isset($_POST['perm_city']) ? $_POST['perm_city'] : ""; } $date_formats_arr = $dateformatidmodel->getAllDateFormats(); $time_formats_arr = $timeformatidmodel->fetchAll()->toArray(); $defaultempstatusdata = $employmentstatusmodel->getCompleteStatuslist(); $wizardpreferenceform->passwordid->addMultiOption('', 'Select Password Preference'); $passworddataArr = $systempreferencemodel->getPasswordData(); foreach ($passworddataArr as $passwordres) { $wizardpreferenceform->passwordid->addMultiOption($passwordres['id'], utf8_encode($passwordres['passwordtype'])); } if (sizeof($allTimezoneData) > 0) { foreach ($allTimezoneData as $timezoneidres) { $wizardpreferenceform->timezoneid->addMultiOption($timezoneidres['id'], utf8_encode($timezoneidres['timezone'] . ' [' . $timezoneidres['timezone_abbr'] . ']')); } } else { $msgarray['timezoneid'] = 'Time Zone is not configured yet.'; } if (sizeof($defaultempstatusdata) > 0) { foreach ($defaultempstatusdata as $empstatusres) { $wizardpreferenceform->workcodename->addMultiOption($empstatusres['id'], utf8_encode($empstatusres['employemnt_status'])); } } /* Start * To prepopulate the form if already configured */ if (!empty($sitepreferencedata)) { if (isset($sitepreferencedata[0]['dateformatid'])) { $wizardpreferenceform->setDefault('dateformatid', $sitepreferencedata[0]['dateformatid']); } if (isset($sitepreferencedata[0]['timeformatid'])) { $wizardpreferenceform->setDefault('timeformatid', $sitepreferencedata[0]['timeformatid']); } if (isset($sitepreferencedata[0]['timezoneid'])) { $wizardpreferenceform->setDefault('timezoneid', $sitepreferencedata[0]['timezoneid']); } if (isset($sitepreferencedata[0]['passwordid'])) { $wizardpreferenceform->setDefault('passwordid', $sitepreferencedata[0]['passwordid']); } if (isset($sitepreferencedata[0]['currencyid'])) { $wizardpreferenceform->currencyid->setValue($sitepreferencedata[0]['currencyid']); $currencynameArr = $currencyidmodel->getCurrencyDataByID($sitepreferencedata[0]['currencyid']); } if (!empty($currencynameArr)) { $wizardpreferenceform->currencyname->setValue($currencynameArr[0]['currencyname']); $wizardpreferenceform->currencycode->setValue($currencynameArr[0]['currencycode']); } } if ($countryId != '') { $wizardpreferenceform->setDefault('perm_country', $countryId); $statesData = $statesmodel->getStatesList((int) $countryId); if (!empty($statesData)) { foreach ($statesData as $res) { if ($stateId == $res['id']) { $new_stateId = $res['id'] . '!@#' . utf8_encode($res['state_name']); } $wizardpreferenceform->perm_state->addMultiOption($res['id'] . '!@#' . utf8_encode($res['state_name']), utf8_encode($res['state_name'])); } if (count($_POST) == 0) { $stateId = $new_stateId; } } } if ($stateId != '') { $wizardpreferenceform->setDefault('perm_state', $stateId); $citiesData = $citiesmodel->getCitiesList((int) $stateId); foreach ($citiesData as $res) { if ($cityId == $res['id']) { $new_cityId = $res['id'] . '!@#' . utf8_encode($res['city_name']); } $wizardpreferenceform->perm_city->addMultiOption($res['id'] . '!@#' . utf8_encode($res['city_name']), utf8_encode($res['city_name'])); } if (count($_POST) == 0) { $cityId = $new_cityId; } } if ($cityId != '') { $wizardpreferenceform->setDefault('perm_city', $cityId); } if (!empty($identitycodedata)) { $wizardpreferenceform->empcodeid->setValue($identitycodedata[0]['id']); $wizardpreferenceform->employee_code->setValue($identitycodedata[0]['employee_code']); } if (sizeof($empstatusdata) > 0) { foreach ($empstatusdata as $empstats) { $empstatusids .= $empstats['workcodename'] . ','; } $empstatusids = rtrim($empstatusids, ','); } /* * End - Prepopulating data */ $wizardpreferenceform->setAttrib('action', DOMAIN . 'wizard/configuresite'); $this->view->msgarray = $msgarray; } catch (Exception $e) { $this->view->nodata = "nodata"; } $this->view->form = $wizardpreferenceform; $this->view->date_formats_arr = $date_formats_arr; $this->view->time_formats_arr = $time_formats_arr; $this->view->passworddata = $passworddataArr; $this->view->empstatusids = $empstatusids; if ($this->getRequest()->getPost()) { $result = $this->savesitepreference($wizardpreferenceform, $wizardData); $this->view->msgarray = $result; } $this->view->popConfigPermission = $popConfigPermission; $this->view->wizarddata = $wizardData; $this->view->messages = $this->_helper->flashMessenger->getMessages(); }
public function deleteAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->_request->getParam('objid'); $messages['message'] = ''; $messages['msgtype'] = ''; $messages['flagtype'] = ''; $actionflag = 3; if ($id) { $dateformatmodel = new Default_Model_Dateformat(); $menumodel = new Default_Model_Menu(); $data = array('isactive' => 0); $where = array('id=?' => $id); $Id = $dateformatmodel->SaveorUpdateDateFormatData($data, $where); if ($Id == 'update') { $menuidArr = $menumodel->getMenuObjID('/dateformat'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); $messages['message'] = 'Date format deleted successfully'; $messages['msgtype'] = 'success'; } else { $messages['message'] = 'Date format cannot be deleted'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Date format cannot be deleted'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); }