/** * * Validate organisation start date and organisation head joing date.... */ public function validateorgheadjoiningdateAction() { $result = 'yes'; $joiningdate = $this->_getParam('joiningdate', null); $joiningdate_obj = new DateTime($joiningdate); $joiningdate = $joiningdate_obj->format('Y-m-d'); $orginfomodel = new Default_Model_Organisationinfo(); $orgdetailsArr = $orginfomodel->getOrganisationInfo(); if (!empty($orgdetailsArr)) { if ($orgdetailsArr[0]['org_startdate'] > $joiningdate) { $result = 'no'; } } $this->_helper->_json(array('result' => $result)); }
public function configureorganisationAction() { $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(); $new_stateId = ''; if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'country'); } if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'state'); } if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'city'); } $msgarray = array(); $new_stateId = ''; $new_cityId = ''; $id = $this->getRequest()->getParam('id'); $form = new Default_Form_Organisationinfo(); $orgInfoModel = new Default_Model_Organisationinfo(); $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $wizard_model = new Default_Model_Wizard(); $wizardData = $wizard_model->getWizardData(); $orginfodata = $orgInfoModel->getOrganisationInfo(); $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray(); $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray(); $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray(); $form->setAttrib('action', DOMAIN . 'wizard/configureorganisation'); $flag = 'true'; if (empty($allCountriesData)) { $msgarray['country'] = 'Countries are not configured yet.'; $flag = 'false'; } if (empty($allStatesData)) { $msgarray['state'] = 'States are not configured yet.'; $flag = 'false'; } if (empty($allCitiesData)) { $msgarray['city'] = 'Cities are not configured yet.'; $flag = 'false'; } if (!empty($orginfodata)) { try { $data = $orginfodata[0]; $data['org_startdate'] = sapp_Global::change_date($data['org_startdate'], 'view'); $form->populate($data); $countryId = $data['country']; $stateId = $data['state']; $cityId = $data['city']; $actionpage = 'edit'; if (count($_POST) > 0) { $countryId = isset($_POST['country']) ? $_POST['country'] : ""; $stateId = isset($_POST['state']) ? $_POST['state'] : ""; $cityId = isset($_POST['city']) ? $_POST['city'] : ""; } if ($countryId != '') { $statesData = $statesmodel->getBasicStatesList((int) $countryId); foreach ($statesData as $res) { if ($stateId == $res['state_id_org']) { $new_stateId = $res['state_id_org'] . '!@#' . utf8_encode($res['state']); } $form->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state'])); } if (count($_POST) == 0) { $stateId = $new_stateId; } } if ($stateId != '') { $citiesData = $citiesmodel->getBasicCitiesList((int) $stateId); foreach ($citiesData as $res) { if ($cityId == $res['city_org_id']) { $new_cityId = $res['city_org_id'] . '!@#' . utf8_encode($res['city']); } $form->city->addMultiOption($res['city_org_id'] . '!@#' . utf8_encode($res['city']), utf8_encode($res['city'])); } if (count($_POST) == 0) { $cityId = $new_cityId; } } $form->setDefault('country', $countryId); $form->setDefault('state', $stateId); $form->setDefault('city', $cityId); $this->view->domainValue = $data['domain']; $this->view->org_image = $data['org_image']; $this->view->ermsg = ''; $this->view->datarr = $data; } catch (Exception $e) { $this->view->ermsg = 'nodata'; } } else { sapp_Global::buildlocations($form, $wizardData); } $this->view->form = $form; if (!empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData)) { $this->view->configuremsg = ''; } else { $this->view->configuremsg = 'notconfigurable'; } $this->view->wizarddata = $wizardData; $this->view->msgarray = $msgarray; $this->view->popConfigPermission = $popConfigPermission; $this->view->messages = $this->_helper->flashMessenger->getMessages(); if ($this->getRequest()->getPost()) { $result = $this->saveorginfo($form, $loginUserId, $wizardData); $this->view->msgarray = $result; if (isset($this->msgarray['domain'])) { $this->view->msMsg = 'multiselecterror'; } } }
public function savebusinessunitAction() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('savebusinessunit', 'json')->initContext(); $this->_helper->layout->disableLayout(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $businessunitsmodel = new Default_Model_Businessunits(); $orgInfoModel = new Default_Model_Organisationinfo(); $systempreferencemodel = new Default_Model_Sitepreference(); $organisationData = $orgInfoModel->getOrganisationInfo(); $sitePreferenceData = $systempreferencemodel->SitePreferanceData(); $result['result'] = ''; $result['id'] = ''; $result['unitname'] = ''; $result['address'] = ''; $date = new Zend_Date(); try { $unitname = trim($this->_request->getParam('bunit')); $address = $this->_request->getParam('streetAddress'); $isUnitExist = $businessunitsmodel->checkDuplicateUnitName($unitname); if (!empty($isUnitExist)) { if ($isUnitExist[0]['count'] > 0) { $result['msg'] = 'Name already exists.'; $result['id'] = ''; $result['unitname'] = ''; $result['address'] = ''; } else { $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; if (strlen(trim($unitname)) > 3) { $unitCode = strtoupper(substr(trim($unitname), 0, 4)); } else { $unitCode = strtoupper(trim($unitname)); } $data = array('unitname' => $unitname, 'unitcode' => $unitCode, 'startdate' => NULL, 'country' => !empty($organisationData) ? $organisationData[0]['country'] : NULL, 'state' => !empty($organisationData) ? $organisationData[0]['state'] : NULL, 'city' => !empty($organisationData) ? $organisationData[0]['city'] : NULL, 'address1' => $address, 'timezone' => !empty($sitePreferenceData) ? $sitePreferenceData[0]['timezoneid'] : NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss')); $where = ''; $actionflag = 1; $Id = $businessunitsmodel->SaveorUpdateBusinessUnits($data, $where); if ($Id) { $menuID = BUSINESSUNITS; $logresult = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id); $result['msg'] = 'success'; $result['id'] = $Id; $result['unitname'] = $unitname; $result['address'] = $address; } else { $result['msg'] = 'error'; $result['id'] = ''; $result['unitname'] = ''; $result['address'] = ''; } } } } catch (Exception $e) { $result['msg'] = $e->getMessage(); $result['id'] = ''; $result['unitname'] = ''; $result['address'] = ''; } $this->_helper->json($result); }