public function savesitepreference($wizardpreferenceform, $wizardData) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } if ($wizardpreferenceform->isValid($this->_request->getPost())) { $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { $systempreferencemodel = new Default_Model_Sitepreference(); $currencymodel = new Default_Model_Currency(); $orgInfoModel = new Default_Model_Organisationinfo(); $wizard_model = new Default_Model_Wizard(); $IdentityCodesModel = new Default_Model_Identitycodes(); $employmentstatusmodel = new Default_Model_Employmentstatus(); $countriesmodel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $id = (int) $this->_request->getParam('id'); $currencyid = (int) $this->_request->getParam('currencyid'); $organisationid = (int) $this->_request->getParam('organisationid'); $empcodeid = (int) $this->_request->getParam('empcodeid'); $dateformatid = $this->_request->getParam('dateformatid'); $timeformatid = $this->_request->getParam('timeformatid'); $timezoneid = $this->_request->getParam('timezoneid'); $currencyname = $this->_request->getParam('currencyname'); $currencycode = $this->_request->getParam('currencycode'); $passwordid = $this->_request->getParam('passwordid'); $perm_country = $this->_request->getParam('perm_country'); $perm_stateparam = $this->_request->getParam('perm_state'); $perm_stateArr = explode("!@#", $this->_request->getParam('perm_state')); $perm_state = $perm_stateArr[0]; $perm_cityparam = $this->_request->getParam('perm_city'); $perm_cityArr = explode("!@#", $this->_request->getParam('perm_city')); $perm_city = $perm_cityArr[0]; $employee_code = $this->_request->getParam('employee_code'); $workcodename = $this->_request->getParam('workcodename'); $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); /* * Save or Update - Currency name in currency table based on currency ID */ $currency_data = array('currencyname' => trim($currencyname), 'currencycode' => trim($currencycode), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($currencyid != '') { $currencywhere = array('id=?' => $currencyid); } else { $currency_data['createdby'] = $loginUserId; $currency_data['createddate'] = gmdate("Y-m-d H:i:s"); $currency_data['isactive'] = 1; $currencywhere = ''; } $CurrencyId = $currencymodel->SaveorUpdateCurrencyData($currency_data, $currencywhere); /* * End */ /* * Start - Updating and Inserting Site Preference Data after fetching currency id */ $siteprference_data = array('dateformatid' => $dateformatid, 'timeformatid' => $timeformatid, 'timezoneid' => $timezoneid, 'currencyid' => $currencyid != '' ? $currencyid : $CurrencyId, 'passwordid' => $passwordid, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'isactive' => 1); $site_update_arr = array('isactive' => 0, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId); $systempreferencemodel->SaveorUpdateSystemPreferanceData($site_update_arr, 'isactive = 1'); $Id = $systempreferencemodel->SaveorUpdateSystemPreferanceData($siteprference_data, ''); /* * End */ /* * Updating Country,state and city based on organisation id */ // Inserting into main_countries if not added $countryExistsArr = $countriesmodel->getActiveCountryName($perm_country); if (empty($countryExistsArr)) { $countrynamearr = $countriesmodel->getCountryCode($perm_country); if (!empty($countrynamearr)) { $country_data = array('country' => trim($countrynamearr[0]['country_name']), 'countrycode' => trim($countrynamearr[0]['country_code']), 'citizenship' => NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'country_id_org' => $perm_country, 'isactive' => 1); $Country_Id = $countriesmodel->SaveorUpdateCountryData($country_data, ''); } } // Inserting into main_state if not added $State_Id = $statesmodel->SaveorUpdateStatesData($perm_country, $perm_stateArr[1], $perm_state, $loginUserId); // Inserting into main_cities if not added $City_Id = $citiesmodel->SaveorUpdateCitiesData($perm_country, $perm_state, $perm_cityArr[1], $perm_city, $loginUserId); $location_data = array('country' => $perm_country, 'state' => $perm_state, 'city' => $perm_city, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); if ($organisationid != '') { $locwhere = array('id=?' => $organisationid); $LocationId = $orgInfoModel->SaveorUpdateData($location_data, $orgwhere); } $LocationId = $wizard_model->SaveorUpdateWizardData($location_data, ''); /* * End */ /* * Start - Updating Employee Code */ $empcode_data = array('employee_code' => trim($employee_code), 'modifiedBy' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($empcodeid != '') { $empcodewhere = array('id=?' => $empcodeid); } else { $empcode_data['createdby'] = $loginUserId; $empcode_data['createddate'] = gmdate("Y-m-d H:i:s"); $empcodewhere = ''; } $EmpCodeId = $IdentityCodesModel->SaveorUpdateIdentitycodesData($empcode_data, $empcodewhere); /* * End */ /* * Start - Update employment status data */ if (!empty($workcodename)) { $empstat_update_arr = array('isactive' => 0, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId); $Empstat_update_Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($empstat_update_arr, 'isactive=1'); for ($j = 0; $j < sizeof($workcodename); $j++) { switch ($workcodename[$j]) { case 1: $workcode = 'FT'; break; case 2: $workcode = 'PT'; break; case 3: $workcode = 'PERM'; break; case 4: $workcode = 'TEMP'; break; case 5: $workcode = 'PROB'; break; case 6: $workcode = 'CONT'; break; case 7: $workcode = 'DEP'; break; case 8: $workcode = 'RES'; break; case 9: $workcode = 'LEFT'; break; case 10: $workcode = 'SUSP'; break; default: $workcode = 'FT'; } $empstatus_data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename[$j]), 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); $Empstat_Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($empstatus_data, ''); } } /* * End */ /* * Update Wizard Table */ $wizardarray = array('site_config' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($wizardData['org_details'] == 2) { $wizardarray['iscomplete'] = 2; } $wizard_model->SaveorUpdateWizardData($wizardarray, ''); $trDb->commit(); $this->_helper->getHelper("FlashMessenger")->addMessage("Site Preference updated successfully."); $this->_redirect('wizard/configuresite'); } catch (Exception $e) { $trDb->rollBack(); $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong,please try again later.")); $this->_redirect('wizard/configuresite'); } } else { $messages = $wizardpreferenceform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
public function viewpopupAction() { Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $id = $this->getRequest()->getParam('id'); if ($id == '') { $id = $loginUserId; } $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $objName = 'empadditionaldetails'; $empadditionaldetailsform = new Default_Form_empadditionaldetails(); $empadditionaldetailsModal = new Default_Model_Empadditionaldetails(); $countriesModel = new Default_Model_Countries(); $veteranstatusmodel = new Default_Model_Veteranstatus(); $militaryservicemodel = new Default_Model_Militaryservice(); $empadditionaldetailsform->removeElement("submit"); $elements = $empadditionaldetailsform->getElements(); if (count($elements) > 0) { foreach ($elements as $key => $element) { if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") { $element->setAttrib("disabled", "disabled"); } } } $data = $empadditionaldetailsModal->getEmpAdditionalDetailsData($id); if (!empty($data)) { $singleCountryArr = $countriesModel->getCountryCode($data[0]['countries_served']); $singleMilitaryServiceArr = $militaryservicemodel->getMilitaryServiceDataByID($data[0]['military_servicetype']); $singleVeteranStatusArr = $veteranstatusmodel->getVeteranStatusDataByID($data[0]['veteran_status']); if (!empty($singleCountryArr)) { $empadditionaldetailsform->countries_served->addMultiOption($singleCountryArr[0]['id'], $singleCountryArr[0]['country_name']); } if (!empty($singleMilitaryServiceArr)) { $empadditionaldetailsform->military_servicetype->addMultiOption($singleMilitaryServiceArr[0]['id'], $singleMilitaryServiceArr[0]['militaryservicetype']); } if (!empty($singleVeteranStatusArr)) { $empadditionaldetailsform->veteran_status->addMultiOption($singleVeteranStatusArr[0]['id'], $singleVeteranStatusArr[0]['veteranstatus']); } $empadditionaldetailsform->populate($data[0]); $empadditionaldetailsform->setDefault('countries_served', $data[0]['countries_served']); $empadditionaldetailsform->setDefault('military_servicetype', $data[0]['military_servicetype']); $empadditionaldetailsform->setDefault('veteran_status', $data[0]['veteran_status']); $from_date = sapp_Global::change_date($data[0]['from_date'], 'view'); $to_date = sapp_Global::change_date($data[0]['to_date'], 'view'); $empadditionaldetailsform->from_date->setValue($from_date); $empadditionaldetailsform->to_date->setValue($to_date); } $this->view->controllername = $objName; $this->view->id = $id; $this->view->form = $empadditionaldetailsform; }
public function comviewAction() { if (defined('EMPTABCONFIGS')) { $empOrganizationTabs = explode(",", EMPTABCONFIGS); if (in_array('empcommunicationdetails', $empOrganizationTabs)) { $auth = Zend_Auth::getInstance(); $empdata = array(); $empDeptdata = array(); $empDept = ''; if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->getRequest()->getParam('userid'); if ($id == '') { $id = $loginUserId; } $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $objName = 'empcommunicationdetails'; $empcommdetailsform = new Default_Form_empcommunicationdetails(); $empcommdetailsform->removeElement("submit"); $elements = $empcommdetailsform->getElements(); if (count($elements) > 0) { foreach ($elements as $key => $element) { if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") { $element->setAttrib("disabled", "disabled"); } } } try { if ($id) { $employeeModal = new Default_Model_Employee(); $empdata = $employeeModal->getsingleEmployeeData($id); if ($empdata == 'norows') { $this->view->rowexist = "norows"; $this->view->empdata = ""; } else { $this->view->rowexist = "rows"; if (!empty($empdata)) { $empDept = $empdata[0]['department_id']; $empcommdetailsModal = new Default_Model_Empcommunicationdetails(); $usersModel = new Default_Model_Users(); $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $orgInfoModel = new Default_Model_Organisationinfo(); $msgarray = array(); $deptModel = new Default_Model_Departments(); if ($empDept != '' && $empDept != 'NULL') { $departmentAddress = $usersModel->getDepartmentAddress($empDept); } else { $departmentAddress = $usersModel->getOrganizationAddress($empDept); } $data = $empcommdetailsModal->getsingleEmpCommDetailsData($id); if (!empty($data)) { if ($data[0]['perm_country'] != '') { $countrieslistArr = $countriesModel->getCountryCode($data[0]['perm_country']); if (sizeof($countrieslistArr) > 0) { $empcommdetailsform->perm_country->addMultiOption('', 'Select Country'); foreach ($countrieslistArr as $countrieslistres) { $empcommdetailsform->perm_country->addMultiOption($countrieslistres['id'], $countrieslistres['country_name']); } } } if ($data[0]['perm_country'] != '') { $statePermlistArr = $statesmodel->getStatesList($data[0]['perm_country']); if (sizeof($statePermlistArr) > 0) { $empcommdetailsform->perm_state->addMultiOption('', 'Select State'); foreach ($statePermlistArr as $statelistres) { $empcommdetailsform->perm_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']); } } } if ($data[0]['perm_state'] != '') { $cityPermlistArr = $citiesmodel->getCitiesList($data[0]['perm_state']); if (sizeof($cityPermlistArr) > 0) { $empcommdetailsform->perm_city->addMultiOption('', 'Select City'); foreach ($cityPermlistArr as $cityPermlistres) { $empcommdetailsform->perm_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']); } } } if ($data[0]['current_country'] != '' && $data[0]['current_state'] != '') { $countriesArr = $countriesModel->getCountryCode($data[0]['current_country']); if (sizeof($countriesArr) > 0) { $empcommdetailsform->current_country->addMultiOption('', 'Select Country'); foreach ($countriesArr as $countrieslistres) { $empcommdetailsform->current_country->addMultiOption($countrieslistres['id'], $countrieslistres['country_name']); } } $statecurrlistArr = $statesmodel->getStatesList($data[0]['current_country']); if (sizeof($statecurrlistArr) > 0) { $empcommdetailsform->current_state->addMultiOption('', 'Select State'); foreach ($statecurrlistArr as $statecurrlistres) { $empcommdetailsform->current_state->addMultiOption($statecurrlistres['id'] . '!@#' . $statecurrlistres['state_name'], $statecurrlistres['state_name']); } } $currstateNameArr = $statesmodel->getStateName($data[0]['current_state']); } if ($data[0]['current_country'] != '' && $data[0]['current_state'] != '' && $data[0]['current_city'] != '') { $cityCurrlistArr = $citiesmodel->getCitiesList($data[0]['current_state']); if (sizeof($cityCurrlistArr) > 0) { $empcommdetailsform->current_city->addMultiOption('', 'Select State'); foreach ($cityCurrlistArr as $cityCurrlistres) { $empcommdetailsform->current_city->addMultiOption($cityCurrlistres['id'] . '!@#' . $cityCurrlistres['city_name'], $cityCurrlistres['city_name']); } } $currcityNameArr = $citiesmodel->getCityName($data[0]['current_city']); } $empcommdetailsform->populate($data[0]); if ($data[0]['perm_state'] != '') { $permstateNameArr = $statesmodel->getStateName($data[0]['perm_state']); $empcommdetailsform->setDefault('perm_state', $permstateNameArr[0]['id'] . '!@#' . $permstateNameArr[0]['statename']); } if ($data[0]['perm_city'] != '') { $permcityNameArr = $citiesmodel->getCityName($data[0]['perm_city']); $empcommdetailsform->setDefault('perm_city', $permcityNameArr[0]['id'] . '!@#' . $permcityNameArr[0]['cityname']); } if ($data[0]['perm_country'] != '') { $empcommdetailsform->setDefault('perm_country', $data[0]['perm_country']); } if ($data[0]['current_country'] != '') { $empcommdetailsform->setDefault('current_country', $data[0]['current_country']); } if ($data[0]['current_state'] != '') { $empcommdetailsform->setDefault('current_state', $currstateNameArr[0]['id'] . '!@#' . $currstateNameArr[0]['statename']); } if ($data[0]['current_city'] != '') { $empcommdetailsform->setDefault('current_city', $currcityNameArr[0]['id'] . '!@#' . $currcityNameArr[0]['cityname']); } } $this->view->controllername = $objName; $this->view->data = $data; $this->view->dataArray = $departmentAddress; $this->view->id = $id; $this->view->employeedata = $empdata[0]; $this->view->form = $empcommdetailsform; } $this->view->empdata = $empdata; } } } catch (Exception $e) { $this->view->rowexist = "norows"; } } else { $this->_redirect('error'); } } else { $this->_redirect('error'); } }
public function addpopupAction() { 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'); $callval = $this->getRequest()->getParam('call'); $countriesform = new Default_Form_countries(); $countriesmodel = new Default_Model_Countries(); $countriesform->setAction(BASE_URL . 'countries/addpopup'); $controllername = 'countries'; if ($this->getRequest()->getPost()) { $id = $this->_request->getParam('id'); $errorflag = "true"; $msgarray = array(); $dbcountry = ''; $dbcountryid = ''; $country = $this->_request->getParam('country'); $othercountry = $this->_request->getParam('othercountry'); $countrycode = $this->_request->getParam('countrycode'); $citizenship = $this->_request->getParam('citizenship'); if ($country == 'other') { if ($othercountry == '') { $msgarray['othercountry'] = "Please enter other country"; $errorflag = "false"; } else { $isduplicatecountrynameArr = $countriesmodel->getDuplicateCountryName($othercountry); if ($isduplicatecountrynameArr[0]['count'] > 0) { $errorflag = "false"; $msgarray['othercountry'] = "Country already exists"; $msgarray['othercountryname'] = $othercountry; } else { if (!preg_match('/^[^ ][a-z0-9 ]*$/i', $othercountry)) { $errorflag = "false"; $msgarray['othercountry'] = "Please enter valid country name."; $msgarray['othercountryname'] = $othercountry; } else { $dbcountry = $othercountry; $errorflag = "true"; } } } } else { $countrynamearr = $countriesmodel->getCountryCode($country); if (!empty($countrynamearr)) { $dbcountry = $countrynamearr[0]['country_name']; $dbcountryid = $countrynamearr[0]['id']; $errorflag = "true"; } else { $msgarray['country'] = $dbcountry . " already added"; $errorflag = "false"; } } if ($countriesform->isValid($this->_request->getPost()) && $errorflag == "true") { $date = new Zend_Date(); $actionflag = ''; $tableid = ''; if ($country == 'other') { if ($othercountry != '' && $countrycode != '') { $countryID = $countriesmodel->SaveMainCountryData($othercountry, $countrycode); } } $data = array('country' => trim($dbcountry), 'countrycode' => trim($countrycode), 'citizenship' => NULL, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'country_id_org' => $dbcountryid != '' ? $dbcountryid : $countryID); 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 = $countriesmodel->SaveorUpdateCountryData($data, $where); $tableid = $Id; $menuID = COUNTRIES; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $countryData = $countriesmodel->fetchAll('isactive = 1', 'country')->toArray(); $opt = ''; foreach ($countryData as $record) { $opt .= sapp_Global::selectOptionBuilder($record['country_id_org'], $record['country']); } $this->view->countryData = $opt; $this->view->eventact = 'added'; $close = 'close'; $this->view->popup = $close; } else { $messages = $countriesform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $this->view->msgarray = $msgarray; } } $this->view->ermsg = ''; $this->view->form = $countriesform; $this->view->controllername = $controllername; }