function updateData($index, $id, $object, $noRedirect = false) { try { $extraParams = ""; switch ($index) { case 'EST': $empstat = new EmploymentStatus(); $empstat = $object; $res = $empstat->updateEmpStat(); break; case 'JOB': $jobtit = new JobTitle(); $jobtit = $object; $res = $jobtit->updateJobTitles(); break; case 'SPC': $jobSpec = $object; try { $res = $jobSpec->save(); } catch (JobSpecException $e) { $res = false; } break; case 'CST': $compstruct = new CompStruct(); $compstruct = $object; $res = $compstruct->updateCompStruct(); break; case 'BNK': $bankinfo = new BankInfo(); $bankinfo = $object; $res = $bankinfo->updateBankInfo(); break; case 'TAX': $taxinfo = new TaxInfo(); $taxinfo = $object; $res = $taxinfo->updateTaxInfo(); break; case 'CCB': $cashben = new CashBen(); $cashben = $object; $res = $cashben->updateCashBenefits(); break; case 'COS': $cost = new CostCenter(); $cost = $object; $res = $cost->updateCostCenter(); break; case 'COU': $country = new CountryInfo(); $country = $object; $res = $country->updateCountryInfo(); break; case 'CUR': $currency = new CurrencyTypes(); $currency = $object; $res = $currency->updateCurrencyTypes(); break; case 'DWT': $dwinfo = new DwellingType(); $dwinfo = $object; $res = $dwinfo->updateDwellingType(); break; case 'ELE': $eleinfo = new ElectorateInfo(); $eleinfo = $object; $res = $eleinfo->updateElectorateInfo(); break; case 'EMC': $empcatinfo = new EmployeeCat(); $empcatinfo = $object; $res = $empcatinfo->updateEmployeeCat(); break; case 'EMG': $empgrpinfo = new EmployeeGroup(); $empgrpinfo = $object; $res = $empgrpinfo->updateEmployeeGroup(); break; case 'ETY': $emptype = new EmployeeType(); $emptype = $object; $res = $emptype->updateEmployeeType(); break; case 'EXC': $exccat = new ExtraCurrActCat(); $exccat = $object; $res = $exccat->updateExtraCurrActCat(); break; case 'DEF': $hicode = new HierarchyDefInfo(); $hicode = $object; $res = $hicode->updateHierarchyDefInfo(); break; case 'JDC': $jdcat = new JDCategory(); $jdcat = $object; $res = $jdcat->updateJDCategory(); break; case 'LOC': $loc = new models_eimadmin_Location(); $loc = $object; $res = $loc->updateLocation(); break; case 'MEM': $memtype = new MembershipType(); $memtype = $object; $res = $memtype->updateMembershipType(); break; case 'NAT': $natinfo = new NationalityInfo(); $natinfo = $object; $res = $natinfo->updateNationalityInfo(); break; case 'NCB': $noncashben = new NonCashBen(); $noncashben = $object; $res = $noncashben->updateNonCashBenefits(); break; case 'QLF': $qualtype = new QualificationType(); $qualtype = $object; $res = $qualtype->updateQualificationType(); break; case 'RTM': $rattype = new RatingTypes(); $rattype = $object; $res = $rattype->updateRatingTypes(); break; case 'RTE': $rouinfo = new RouteInfo(); $rouinfo = $object; $res = $rouinfo->updateRouteInfo(); break; case 'SGR': $salgread = new SalaryGrades(); $salgread = $object; $res = $salgread->updateSalaryGrades(); break; case 'SKI': $skill = new Skills(); $skill = $object; $res = $skill->updateSkills(); break; case 'ETH': $ethnicrace = new EthnicRace(); $ethnicrace = $object; $res = $ethnicrace->updateEthnicRace(); break; case 'EXA': $extcainfo = new ExtraCurActInfo(); $extcainfo = $object; $res = $extcainfo->updateExtraCurActInfo(); break; case 'MME': $membinfo = new MembershipInfo(); $membinfo = $object; $res = $membinfo->updateMembershipInfo(); break; case 'JDK': $jdkr = new JDKra(); $jdkr = $object; $res = $jdkr->updateJDKra(); break; case 'LAN': $laninfo = new LanguageInfo(); $laninfo = $object; $res = $laninfo->updateLanguageInfo(); break; case 'RLG': $relinfo = new ReligionInfo(); $relinfo = $object; $res = $relinfo->updateReligionInfo(); break; case 'SAT': $satinfo = new SatutoryInfo(); $satinfo = $object; $res = $satinfo->updateSatutoryInfo(); break; case 'UNI': $unitype = new UniformType(); $unitype = $object; $res = $unitype->updateUniformType(); break; case 'EXA': $excurac = new ExtraCurActInfo(); $excurac = $object; $res = $excurac->updateExtraCurActInfo(); break; case 'EDU': $edu = new Education(); $edu = $object; $res = $edu->updateEducation(); break; case 'JDT': $jdt = new JDType(); $jdt = $object; $res = $jdt->updateJDType(); break; case 'SBJ': $subin = new SubjectInfo(); $subin = $object; $res = $subin->updateSubjectInfo(); break; case 'SSK': $subsk = new SubSkillInfo(); $subsk = $object; $res = $subsk->updateSubSkillInfo(); break; case 'BCH': $brch = new Branches(); $brch = $object; $res = $brch->updateBranches(); break; case 'CHI': $cmphier = new CompHierachy(); $cmphier = $object; $res = $cmphier->updateCompHierachy(); break; case 'CTT': $corptit = new CorpTitle(); $corptit = $object; $res = $corptit->updateCorpTitles(); break; case 'DSG': $desig = new Designations(); $desig = $object; $res = $desig->updateDesignations(); break; case 'DIS': $disinfo = new DistrictInfo(); $disinfo = $object; $res = $disinfo->updateDistrictInfo(); break; case 'EEC': $eeojobcat = new EEOJobCat(); $eeojobcat = $object; $res = $eeojobcat->updateEEOJobCat(); break; case 'LIC': $licenses = new Licenses(); $licenses = $object; $res = $licenses->updateLicenses(); break; case 'CUS': $customers = new Customer(); $customers = $object; $res = $customers->updateCustomer(); break; case 'CTM': $customField = $object; try { $customField->updateCustomField(); $res = true; } catch (CustomFieldsException $e) { $res = false; } break; case 'CHD': // Fall through to 'CEX' below // Fall through to 'CEX' below case 'CEX': $customExport = $object; try { $customExport->save(); $res = true; } catch (CustomExportException $e) { if ($e->getCode() == CustomExportException::DUPLICATE_EXPORT_NAME) { $showMsg = "DUPLICATE_NAME_FAILURE"; } $res = false; } break; case 'CIM': $customImport = $object; try { $customImport->save(); $res = true; } catch (CustomImportException $e) { if ($e->getCode() == CustomImportException::DUPLICATE_IMPORT_NAME) { $showMsg = "DUPLICATE_NAME_FAILURE"; } if ($e->getCode() == CustomImportException::COMPULSARY_FIELDS_NOT_ASSIGNED) { $showMsg = "COMPULSARY_FIELDS_NOT_ASSIGNED_FAILURE"; } $res = false; } break; case 'PRJ': $projects = new Projects(); $projects = $object; $res = $projects->updateProject(); break; case 'TCP': $property = new CompProperty(); $property = $object; if ($property->getEditPropFlag() == false) { $res = $property->editPropertyList(); } else { $res = $property->editProperty($id); } break; case 'PAC': $projectActivity = $object; $authorizeObj = new authorize($_SESSION['empID'], $_SESSION['isAdmin']); $projectId = $projectActivity->getProjectId(); $res = true; if ($authorizeObj->isAdmin() || $authorizeObj->isProjectAdminOf($projectId)) { try { $projectActivity->save(); $extraParams = "&projectId={$projectId}"; } catch (ProjectActivityException $e) { $res = false; } } break; case 'USR': $users = new Users(); $users = $object; $res = $users->updateUsers(); break; case 'USG': $usergroups = new UserGroups(); $usergroups = $object; $res = $usergroups->updateUserGroups(); break; case 'EMX': $emailConfig = new EmailConfiguration(); $emailConfig = $object; $res = (bool) $emailConfig->reWriteConf(); $testEmail = $emailConfig->getTestEmail(); $testEmailType = $emailConfig->getTestEmailType(); break; case 'ENS': $emailNotifacationConfigs = new EmailNotificationConfiguration($_SESSION['user']); $emailNotifacationConfigs = $object; $res = true; foreach ($emailNotifacationConfigs as $emailNotifacationConfig) { $resp = $emailNotifacationConfig->updateNotificationStatus(); if (!$resp) { $res = $resp; } } break; case 'LDAP': if ($_SESSION['ldap'] == "enabled") { $ldapDetails = new LdapDetails(); $ldapDetails = $object; $res = $ldapDetails->updateLdapDetails(); } break; } } catch (Exception $e) { if ($e->getCode() == 1) { $res = false; $showMsg = "DUPLICATE_NAME_FAILURE"; } } // Checking whether the $message Value returned is 1 or 0 if ($res) { switch ($index) { case 'CEX': // Go to CSV heading Define page header("Location: ./CentralController.php?uniqcode=CHD&id={$id}"); break; case 'CHD': $showMsg = "UPDATE_SUCCESS"; $esp = isset($_GET['isAdmin']) ? '&isAdmin=' . $_GET['isAdmin'] : ''; header("Location: ./CentralController.php?message={$showMsg}&uniqcode=CEX&VIEW=MAIN{$esp}{$extraParams}"); break; case 'CST': break; case 'EMX': $emailConfig = new EmailConfiguration(); $showMsg = ""; /* * $testEmail and $testEmail should be initialized when writing the mailConfig file * Getting the value for $testEmail should not be from the newlt created EmailConfiguration * object, since test mail value is not written to the physical file */ if (isset($testEmail) && !empty($testEmail) && isset($testEmailType) && !empty($testEmailType)) { $emailConfig->setTestEmail($testEmail); $emailConfig->setTestEmailType($testEmailType); if ($emailConfig->sendTestEmail()) { $showMsg = "TEST_EMAIL_SUCCESS"; } else { $showMsg = "TEST_EMAIL_FAILIURE"; } } header("Location:./CentralController.php?uniqcode=EMX&VIEW=MAIN&msg={$showMsg}"); break; case 'SGR': $showMsg = "UPDATE_SUCCESS"; header("Location:" . $_POST['referer'] . "&msg={$showMsg}"); break; case 'EST': case 'CUR': if ($noRedirect) { break; } default: $showMsg = "UPDATE_SUCCESS"; //If $message is 1 setting up the $pageNoQueryString = isset($_REQUEST['pageNo']) ? '&pageNo=' . $_REQUEST['pageNo'] : ''; $uniqcode = $index; $esp = isset($_GET['isAdmin']) ? '&isAdmin=' . $_GET['isAdmin'] : ''; header("Location: ./CentralController.php?message={$showMsg}&uniqcode={$uniqcode}&VIEW=MAIN{$esp}{$extraParams}{$pageNoQueryString}"); } } else { if (!isset($showMsg) || empty($showMsg)) { $showMsg = "UPDATE_FAILURE"; } $uniqcode = $index; $esp = isset($_GET['isAdmin']) ? '&isAdmin=' . $_GET['isAdmin'] : ''; header("Location: ./CentralController.php?msg={$showMsg}&id={$id}&capturemode=updatemode&uniqcode={$uniqcode}{$esp}{$extraParams}"); } }