Beispiel #1
0
 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 addpopupAction()
 {
     $screenFlag = "";
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     if ($this->getRequest()->getParam('screenflag')) {
         $screenFlag = $this->getRequest()->getParam('screenflag');
     }
     $boxid = $this->_getParam('boxid', null);
     $fromcontroller = $this->_getParam('fromcontroller', null);
     $msgarray = array();
     $controllername = 'employmentstatus';
     $employmentstatusform = new Default_Form_employmentstatus();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $employmentstatusform->setAction(BASE_URL . 'employmentstatus/addpopup');
     $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
     $newarr = array();
     $empstatusstr = '';
     if (!empty($activeEmploymentStatusArr)) {
         for ($i = 0; $i < sizeof($activeEmploymentStatusArr); $i++) {
             $newarr1[] = $activeEmploymentStatusArr[$i]['workcodename'];
         }
         if ($screenFlag == 'add') {
             array_push($newarr1, 8, 9, 10);
         }
         $empstatusstr = implode(",", $newarr1);
     }
     if ($empstatusstr != '') {
         $statusArr = $employmentstatusmodel->getStatuslist($empstatusstr);
     } else {
         $statusArr = $employmentstatusmodel->getCompleteStatuslist();
     }
     if (!empty($statusArr)) {
         $employmentstatusform->workcodename->addMultiOption('', 'Select Work Code');
         for ($i = 0; $i < sizeof($statusArr); $i++) {
             if ($fromcontroller == 'requisition') {
                 if (!in_array($statusArr[$i]['id'], array(5, 7, 8, 9, 10))) {
                     $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
                 }
             } else {
                 $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
             }
         }
     }
     $this->view->statusArr = $statusArr;
     $this->view->ermsg = '';
     if ($this->getRequest()->getPost()) {
         if ($employmentstatusform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $workcode = $this->_request->getParam('workcode');
             $workcodename = $this->_request->getParam('workcodename');
             $default_leaves = $this->_request->getParam('default_leaves');
             $description = $this->_request->getParam('description');
             $screenFlag = $this->getRequest()->getParam('screenflag');
             $date = new Zend_Date();
             $actionflag = '';
             $tableid = '';
             $data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             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 = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($data, $where);
             $tableid = $Id;
             $menuID = EMPLOYMENTSTATUS;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
             if (isset($_POST['fromcontroller']) && $_POST['fromcontroller'] != '') {
                 $fromcontroller = $_POST['fromcontroller'];
             }
             if (isset($_POST['boxid']) && $_POST['boxid'] != '') {
                 $boxid = $_POST['boxid'];
             }
         } else {
             $messages = $employmentstatusform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $opt = '';
     if ($fromcontroller == '') {
         if ($screenFlag == 'edit') {
             $empstatusData = $employmentstatusmodel->getempstatuslist();
         }
         if ($screenFlag == 'add') {
             $empstatusData = $employmentstatusmodel->getempstatusActivelist();
         }
         if (!empty($empstatusData)) {
             foreach ($empstatusData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['workcodename'], $record['statusname']);
             }
         }
     } else {
         if ($fromcontroller == 'requisition') {
             $requi_model = new Default_Model_Requisition();
             $empstatusData = $requi_model->getStatusOptionsForRequi();
             foreach ($empstatusData as $stat_id => $stat_name) {
                 $opt .= sapp_Global::selectOptionBuilder($stat_id, $stat_name);
             }
         }
     }
     $this->view->empstatusData = $opt;
     $this->view->screenFlag = $screenFlag;
     $this->view->controllername = $controllername;
     $this->view->form = $employmentstatusform;
     $this->view->ermsg = '';
     $this->view->boxid = $boxid;
     $this->view->fromcontroller = $fromcontroller;
 }