public function updateBalance() { $balance = $this->entitled + $this->adjustment - ($this->scheduled + $this->taken); $configService = new LeaveConfigurationService(); $includePending = $configService->includePendingLeaveInBalance(); if ($includePending) { $balance = $balance - $this->pending; } $this->balance = $balance; }
public function includePendingLeaveInBalance($forceReload = false) { $include = true; if ($forceReload || is_null(self::$includePendingLeaveInBalance)) { self::$includePendingLeaveInBalance = $this->_getConfigValue(self::KEY_INCLUDE_PENDING_LEAVE_IN_BALANCE); } if (self::$includePendingLeaveInBalance == 0) { $include = false; } return $include; }
protected function fixResultset($values) { $keep = array(); $configService = new LeaveConfigurationService(); $includePending = $configService->includePendingLeaveInBalance(); for ($i = 0; $i < count($this->resultsSet); $i++) { $total = isset($this->resultsSet[$i]['entitlement_total']) ? $this->resultsSet[$i]['entitlement_total'] : 0; $scheduled = isset($this->resultsSet[$i]['scheduled']) ? $this->resultsSet[$i]['scheduled'] : 0; $taken = isset($this->resultsSet[$i]['taken']) ? $this->resultsSet[$i]['taken'] : 0; $pending = isset($this->resultsSet[$i]['pending']) ? $this->resultsSet[$i]['pending'] : 0; $exclude = isset($this->resultsSet[$i]['exclude_if_no_entitlement']) ? $this->resultsSet[$i]['exclude_if_no_entitlement'] : 0; if ($total == 0 && $scheduled == 0 && $taken == 0 && $exclude == 1) { } else { $unused = $this->getValue($total) - $this->getValue($scheduled) - $this->getValue($taken); if ($includePending) { $unused = $unused - $this->getValue($pending); } $this->resultsSet[$i]['unused'] = number_format($unused, 2); if (isset($this->resultsSet[$i]['employeeName']) && isset($this->resultsSet[$i]['termination_id'])) { $this->resultsSet[$i]['employeeName'] = $this->resultsSet[$i]['employeeName'] . " (" . __("Past Employee") . ")"; } if (isset($this->resultsSet[$i]['leaveType']) && isset($this->resultsSet[$i]['leave_type_deleted']) && $this->resultsSet[$i]['leave_type_deleted'] == 1) { $this->resultsSet[$i]['leaveType'] = $this->resultsSet[$i]['leaveType'] . " (" . __("Deleted") . ")"; } $keep[] = $this->resultsSet[$i]; } } $this->resultsSet = $keep; }