The application is displaying hours worked and leave accrual information based on a database of submitted time reports. There is a method that calculates how much vacation was earned based on employee hire date and hours worked and another that calculates what the maximum vacation accrual for the employee is. Here is the relevant code:
Code: Select all
// $rates - the current monthly accrual rates, based on years of service
// $allocRatio - the ratio of hours worked to the monthly number of hours, for vacation allocation purposes
// $yos - years of service
function vacEarned($rates, $allocRatio, $yos) {
$rate = $rates['vacation5'];
if ($yos>=15)
$rate = $rates['vacation20'];
else if ($yos>=10)
$rate = $rates['vacation15'];
else if ($yos>=5)
$rate = $rates['vacation10'];
return round($allocRatio * $rate, 2);
}
...
$maxedVac = false;
...
$maxVac = maxVacation($currentRates, $hireDate, $tlrDates[$dateID], $currentPctTime);
$vacEarned = vacEarned($currentRates, $allocRatio, $yos);
$vacUsed = $usage[$idx]['vacUsed'];
$currentVac += $vacEarned - $vacUsed;
if ($currentVac>$maxVac) {
$maxedVac = true;
$vacEarned = $vacEarned + $maxVac - $currentVac;
$currentVac = $maxVac;
}I can usually find a kludge to fix this by echoing the variable to the page once first and then doing it for real. The lines that display the value look like this:
[text]
<!-- the following line is my kludge to get around the problem -->
<!-- <?php echo $vacEarned; ?> -->
<td class="formField" align="center"><?php echo $vacEarned; ?><?php echo ($maxedVac ? " *" : ""); ?></td>
[/text]
(Note that the code prints an asterisk next to the value if the accrual has maxed out - not the case in this example) Any suggestions?