Changed roundUpTo15 function to just round to the closest 15

This commit is contained in:
johnnyq 2023-09-26 17:59:11 -04:00
parent d82e6f99ab
commit 8ebe7eda03
2 changed files with 9 additions and 5 deletions

View File

@ -745,7 +745,7 @@ function shortenClient($client) {
return strtoupper(substr($shortened, 0, 3));
}
function roundUpToNearest15($time) {
function roundToNearest15($time) {
// Extract hours, minutes, and seconds from the time string
list($hours, $minutes, $seconds) = explode(':', $time);
@ -755,9 +755,13 @@ function roundUpToNearest15($time) {
// Calculate the remainder when divided by 900 seconds (15 minutes)
$remainder = $totalSeconds % 900;
// If there's any remainder, round up to the next 15 minutes
if ($remainder > 0) {
// If the total seconds is less than 15 minutes, round up to 15 minutes
if ($totalSeconds < 900) {
$totalSeconds = 900;
} else if ($remainder > 450) { // If remainder is more than 7.5 minutes (450 seconds), round up
$totalSeconds += (900 - $remainder);
} else { // Else round down
$totalSeconds -= $remainder;
}
// Convert total seconds to the decimal format

View File

@ -141,7 +141,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-balance-scale"></i></span>
</div>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="qty" value="<?php echo roundUpToNearest15($ticket_total_reply_time); ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="qty" value="<?php echo roundToNearest15($ticket_total_reply_time); ?>" required>
</div>
</div>
@ -155,7 +155,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="price" value="<?php echo number_format(roundUpToNearest15($ticket_total_reply_time) * $client_rate,2); ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="price" value="<?php echo number_format(roundToNearest15($ticket_total_reply_time) * $client_rate,2); ?>" required>
</div>
</div>