/** * Returns an instance of this class * * @return OrangeConfig */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public function execute($request) { $loggedInEmpNum = $this->getUser()->getEmployeeNumber(); //$this->isLeavePeriodDefined(); $personal = $request->getParameter('personal'); $empNumber = isset($personal['txtEmpID']) ? $personal['txtEmpID'] : $request->getParameter('empNumber'); $this->empNumber = $empNumber; // TODO: Improve $adminMode = $this->getUser()->hasCredential(Auth::ADMIN_ROLE); $this->personalInformationPermission = $this->getDataGroupPermissions('personal_information', $empNumber); $this->canEditSensitiveInformation = $empNumber != $loggedInEmpNum || $adminMode; $param = array('empNumber' => $empNumber, 'personalInformationPermission' => $this->personalInformationPermission, 'canEditSensitiveInformation' => $this->canEditSensitiveInformation); if (!$this->IsActionAccessible($empNumber)) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } $this->showDeprecatedFields = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_DEPRECATED); $this->showSSN = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_SSN); $this->showFPN = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_FPN); $this->showSIN = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_SIN); $this->setForm(new EmployeePersonalDetailsForm(array(), $param, true)); if ($this->personalInformationPermission->canUpdate()) { if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->_checkWhetherEmployeeIdExists($this->form->getValue('txtEmployeeId'), $empNumber); $employee = $this->form->getEmployee(); $this->getEmployeeService()->saveEmployee($employee); $this->getUser()->setFlash('personaldetails.success', __(TopLevelMessages::SAVE_SUCCESS)); $this->redirect('pim/viewPersonalDetails?empNumber=' . $empNumber); } } } }
/** * * @param type $post array of POST variables * @param type $postVar Post variable containing config value * @param type $configKey Key used in config table */ private function _saveConfigValue($post, $postVar, $configKey) { $value = false; if (isset($post[$postVar]) && $post[$postVar] == 'on') { $value = true; } OrangeConfig::getInstance()->setAppConfValue($configKey, $value); }
function isTaxMenuEnabled() { $sfUser = sfContext::getInstance()->getUser(); if (!$sfUser->hasAttribute('pim.leftMenu.isTaxMenuEnabled')) { $isTaxMenuEnabled = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_TAX_EXEMPTIONS); $sfUser->setAttribute('pim.leftMenu.isTaxMenuEnabled', $isTaxMenuEnabled); } return $sfUser->getAttribute('pim.leftMenu.isTaxMenuEnabled'); }
public function execute($request) { if (!Auth::instance()->hasRole(Auth::ADMIN_ROLE)) { $this->forward('leave', 'showLeavePeriodNotDefinedWarning'); } $this->setForm(new LeavePeriodForm(array(), array(), true)); $this->isLeavePeriodDefined = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_LEAVE_PERIOD_DEFINED); $this->currentLeavePeriod = $this->getLeavePeriodService()->getCurrentLeavePeriod(); if ($this->isLeavePeriodDefined) { $endDateElements = explode(' ', $this->currentLeavePeriod->getEndDateFormatted('F d')); $endDate = __($endDateElements[0]) . ' ' . $endDateElements[1]; $nextPeriodStartDateTimestamp = strtotime('+1 day', strtotime($this->currentLeavePeriod->getEndDate())); $startMonthValue = (int) date('m', $nextPeriodStartDateTimestamp); $startDateValue = (int) date('d', $nextPeriodStartDateTimestamp); } else { $endDate = '-'; $startMonthValue = 0; $startDateValue = 0; } $this->endDate = $endDate; $this->startMonthValue = $startMonthValue; $this->startDateValue = $startDateValue; if ($this->getUser()->hasFlash('templateMessage')) { list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage'); } // this section is for saving leave period if ($request->isMethod('post')) { $leavePeriodService = $this->getLeavePeriodService(); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->_setLeapYearLeavePeriodDetails($this->form); $leavePeriodDataHolder = $this->_getPopulatedLeavePeriodDataHolder(); $fullStartDate = $leavePeriodService->generateStartDate($leavePeriodDataHolder); $leavePeriodDataHolder->setLeavePeriodStartDate($fullStartDate); $fullEndDate = $leavePeriodService->generateEndDate($leavePeriodDataHolder); $currentLeavePeriod = $leavePeriodService->getCurrentLeavePeriod(); $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS))); if (!is_null($currentLeavePeriod)) { $leavePeriodService->adjustCurrentLeavePeriod($fullEndDate); } else { $leavePeriod = new LeavePeriod(); $leavePeriod->setStartDate($fullStartDate); $leavePeriod->setEndDate($fullEndDate); $leavePeriodService->saveLeavePeriod($leavePeriod); } $this->redirect('leave/defineLeavePeriod'); } } }
public function execute($request) { $this->leavePeriodPermissions = $this->getDataGroupPermissions('leave_period'); if (!Auth::instance()->hasRole(Auth::ADMIN_ROLE) && !$this->leavePeriodPermissions->canRead()) { $this->forward('leave', 'showLeavePeriodNotDefinedWarning'); } $values = array('leavePeriodPermissions' => $this->leavePeriodPermissions); $this->setForm(new LeavePeriodForm(array(), $values, true)); $this->isLeavePeriodDefined = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_LEAVE_PERIOD_DEFINED); $this->latestSatrtDate = $this->getLeavePeriodService()->getCurrentLeavePeriodStartDateAndMonth(); if ($this->isLeavePeriodDefined) { $this->currentLeavePeriod = $this->getLeavePeriodService()->getCurrentLeavePeriodByDate(date('Y-m-d')); $endDate = date('F d', strtotime($this->currentLeavePeriod[1])); $startMonthValue = $this->latestSatrtDate->getLeavePeriodStartMonth(); $startDateValue = $this->latestSatrtDate->getLeavePeriodStartDay(); } else { $endDate = '-'; $startMonthValue = 0; $startDateValue = 0; } $this->endDate = $endDate; $this->startMonthValue = $startMonthValue; $this->startDateValue = $startDateValue; if ($this->getUser()->hasFlash('templateMessage')) { list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage'); } // this section is for saving leave period if ($request->isMethod('post')) { if ($this->leavePeriodPermissions->canUpdate()) { $leavePeriodService = $this->getLeavePeriodService(); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $leavePeriodHistory = new LeavePeriodHistory(); $leavePeriodHistory->setLeavePeriodStartMonth($this->form->getValue('cmbStartMonth')); $leavePeriodHistory->setLeavePeriodStartDay($this->form->getValue('cmbStartDate')); $leavePeriodHistory->setCreatedAt(date('Y-m-d')); $this->getLeavePeriodService()->saveLeavePeriodHistory($leavePeriodHistory); // Enable leave module menu items the first time leave period is defined if (!$this->isLeavePeriodDefined) { $this->getMenuService()->enableModuleMenuItems('leave'); } $this->getUser()->getAttributeHolder()->remove(mainMenuComponent::MAIN_MENU_USER_ATTRIBUTE); $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS)); $this->redirect('leave/defineLeavePeriod'); } } } }
public function execute($request) { try { $loggedInEmpNum = $this->getUser()->getEmployeeNumber(); $this->showBackButton = true; $this->isLeavePeriodDefined(); $personal = $request->getParameter('personal'); $empNumber = isset($personal['txtEmpID']) ? $personal['txtEmpID'] : $request->getParameter('empNumber'); $this->empNumber = $empNumber; //hiding the back button if its self ESS view if ($loggedInEmpNum == $empNumber) { $this->showBackButton = false; } // TODO: Improve $adminMode = $this->getUser()->hasCredential(Auth::ADMIN_ROLE); if ($this->getUser()->hasFlash('templateMessage')) { list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage'); } $essMode = !$adminMode && !empty($loggedInEmpNum) && $empNumber == $loggedInEmpNum; $param = array('empNumber' => $empNumber, 'ESS' => $essMode); if (!$this->IsActionAccessible($empNumber)) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } $this->essMode = $essMode; $this->showDeprecatedFields = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_DEPRECATED); $this->showSSN = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_SSN); $this->showSIN = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_SIN); $this->setForm(new EmployeePersonalDetailsForm(array(), $param, true)); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->_checkWhetherEmployeeIdExists($this->form->getValue('txtEmployeeId'), $empNumber); $employee = $this->form->getEmployee(); $this->getEmployeeService()->savePersonalDetails($employee, $essMode); $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS))); $this->redirect('pim/viewPersonalDetails?empNumber=' . $empNumber); } else { echo "Form is inValid<br>" . $this->form->getErrorSchema(); die; } } } catch (Exception $e) { print $e->getMessage(); } }
protected function _getThemeName() { $sfUser = $this->getUser(); if (!$sfUser->hasAttribute('meta.themeName')) { $sfUser->setAttribute('meta.themeName', OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_THEME_NAME)); } return $sfUser->getAttribute('meta.themeName'); }
/** * Formats the employee number as expected by other components, by * left padding with zeros if needed. * * @param int $empNumber employee number * @return String $empNumber left padded with zeros */ function format_emp_number($empNumber) { $empIdLength = OrangeConfig::getInstance()->getSysConf()->getEmployeeIdLength(); $formattedNumber = str_pad($empNumber, $empIdLength, "0", STR_PAD_LEFT); return $formattedNumber; }
public static function setParameter($key, $value) { $key = self::_adjustKey($key); OrangeConfig::getInstance()->setAppConfValue($key, $value); }
function theme_path($path) { $sfUser = sfContext::getInstance()->getUser(); if (!$sfUser->hasAttribute('meta.themeName')) { $themeName = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_THEME_NAME); if (empty($themeName)) { $themeName = 'default'; } $sfUser->setAttribute('meta.themeName', $themeName); } $themeName = $sfUser->getAttribute('meta.themeName'); $resourceDir = sfConfig::get('ohrm_resource_dir'); $themePath = public_path($resourceDir . '/themes/' . $themeName . '/'); $themePath = empty($path) ? $themePath : $themePath . $path; return $themePath; }
/** * Private construct */ private function __construct() { $this->sysConf = OrangeConfig::getInstance()->getSysConf(); }
<li class="l2"> <?php $dataGroupPermission = $userRoleManager->getDataGroupPermissions(array('salary_details', 'salary_attachment', 'salary_custom_fields'), array(), array(), $self, $entities); if ($dataGroupPermission->canRead()) { ?> <a href="<?php echo url_for('pim/viewSalaryList?empNumber=' . $empNumber); ?> " id="paymentsLink" class="employment" accesskey="s" > <span><?php echo __("Salary"); ?> </span></a></li> <?php } $showTax = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_TAX_EXEMPTIONS); if ($showTax) { $dataGroupPermission = $userRoleManager->getDataGroupPermissions(array('tax_exemptions', 'tax_attachment', 'tax_custom_fields'), array(), array(), $self, $entities); if ($dataGroupPermission->canRead()) { ?> <li class="l2"> <a href="<?php echo url_for('pim/viewUsTaxExemptions?empNumber=' . $empNumber); ?> " id="taxLink" class="employment" accesskey="t" > <span><?php echo __("Tax Exemptions"); ?> </span></a></li> <?php
/** * Check if tax menu is enabled * * @return boolean true if enabled, false if not */ protected function isTaxMenuEnabled() { $sfUser = $this->getUser(); if (!$sfUser->hasAttribute(self::PIM_LEFTMENU_TAXMENU_ENABLED)) { $isTaxMenuEnabled = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_PIM_SHOW_TAX_EXEMPTIONS); $sfUser->setAttribute(self::PIM_LEFTMENU_TAXMENU_ENABLED, $isTaxMenuEnabled); } return $sfUser->getAttribute(self::PIM_LEFTMENU_TAXMENU_ENABLED); }
/** * Saves the leave period passed as the paramerter * * @param LeavePeriod $leavePeriod * @return bool Returns true if leave period is saved successfully */ public function saveLeavePeriod(LeavePeriod $leavePeriod) { $this->getLeavePeriodDao()->saveLeavePeriod($leavePeriod); OrangeConfig::getInstance()->setAppConfValue(ConfigService::KEY_LEAVE_PERIOD_DEFINED, 'Yes'); return true; }
public static function getLeavePeriodStatus($forceReload = false) { if ($forceReload || is_null(self::$leavePeriodStatus)) { self::$leavePeriodStatus = OrangeConfig::getInstance()->getAppConfValue(ConfigService::KEY_LEAVE_PERIOD_STATUS); } return self::$leavePeriodStatus; }