$hourLimit){
$additionalHours = $hoursUsed - $hourLimit;
$overHourLimitFee = $additionalHours * $overLimitFee;
}
$finalCharge = $monthlyFee + $overHourLimitFee;
//Using $nonProfit as a flag, if it's set take 20% off the final charges.
if(isset($nonProfit)){
$finalCharge = ($finalCharge * .2) - $finalCharge;
//Round the final charges up
$finalCharge = ceil($finalCharge);
}
//Writes the data to the log file, in append mode.
$logFile = fopen("log.txt","a");
fputs($logFile, $custFirst . ":" . $custLast . ":" . $packageType . ":" . number_format($finalCharge,2) . "\n");
fclose($logFile);
}
else
// display the log, do no calculations or writing to file
$logFile = fopen("log.txt","a");
$log = fgets($logFile, 1000);
list($custFirst, $custLast, $packageType, $finalCharge) = explode(":",$log);
print("
");
print("| " . $custFirst . " | ");
print("" . $custLast . " | ");
print("" . $finalCharge . " |
");
print("
");
?>