Skip to content

Commit

Permalink
Feature: Automatically calculate tickert to invoice based off time wo…
Browse files Browse the repository at this point in the history
…rked rounded up to the near 15 min mark multiplied by Client Rate, Changed all Price, cost fields to use text field with numeric patterns instead of number fields, set pricing to always display 2 decimal spots
  • Loading branch information
johnnyq committed Sep 22, 2023
1 parent 1ccaa93 commit 61c9c0c
Show file tree
Hide file tree
Showing 37 changed files with 111 additions and 66 deletions.
2 changes: 1 addition & 1 deletion account_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" min="0" name="opening_balance" placeholder="Opening Balance" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="opening_balance" placeholder="0.00" required>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions budget_create_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="number" class="form-control" name="year" placeholder="Enter Year xxxx" required>
<input type="text" class="form-control" inputmode="numeric" pattern="^[0-9]{4}$" name="year" placeholder="2024" required>
</div>
</div>

Expand All @@ -65,7 +65,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="amount" placeholder="Enter an amount" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" placeholder="0.00" required>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions budget_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="number" class="form-control" name="year" placeholder="Enter a year xxxx" value="<?php echo $budget_year; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="^[0-9]{4}$" name="year" placeholder="2024" value="<?php echo $budget_year; ?>" required>
</div>
</div>

Expand All @@ -62,7 +62,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="amount" value="<?php echo $budget_amount; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" value="<?php echo number_format($budget_amount,2); ?>" required>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
</div>
<input type="number" step="0.01" min="0" class="form-control" name="rate" placeholder="Hourly rate">
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="rate" placeholder="0.00">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
</div>
<input type="number" step="0.01" min="0" class="form-control" name="rate" placeholder="Hourly rate" value="<?php echo $client_rate; ?>">
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="rate" placeholder="0.00" value="<?php echo $client_rate; ?>">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_network_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div>
<input type="number" class="form-control" name="vlan" placeholder="ex. 20" data-inputmask="'mask': '9999'">
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*" name="vlan" placeholder="ex. 20">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_network_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div>
<input type="number" class="form-control" id="editNetworkVlan" name="vlan" placeholder="ex. 20" data-inputmask="'mask': '9999'">
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*" id="editNetworkVlan" name="vlan" placeholder="ex. 20">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_software_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-chair"></i></span>
</div>
<input type="number" class="form-control" name="seats" placeholder="Number of seats">
<input type="text" inputmode="numeric" pattern="[0-9]*" class="form-control" name="seats" placeholder="Number of seats">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_software_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
</div>
<input type="number" class="form-control" name="seats" placeholder="Number of seats" value="<?php echo $software_seats; ?>">
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*" name="seats" placeholder="Number of seats" value="<?php echo $software_seats; ?>">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client_trips.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$trip_purpose = nullable_htmlentities($row['trip_purpose']);
$trip_source = nullable_htmlentities($row['trip_source']);
$trip_destination = nullable_htmlentities($row['trip_destination']);
$trip_miles = nullable_htmlentities($row['trip_miles']);
$trip_miles = number_format(floatval($row['trip_miles']),1);
$trip_user_id = intval($row['trip_user_id']);
$round_trip = nullable_htmlentities($row['round_trip']);
$client_id = intval($row['trip_client_id']);
Expand Down
2 changes: 1 addition & 1 deletion expense_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="amount" placeholder="Enter amount" autofocus required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" placeholder="0.00" required>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion expense_copy_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="amount" value="<?php echo $expense_amount; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" value="<?php echo number_format($expense_amount,2); ?>" placeholder="0.00" required>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion expense_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="amount" value="<?php echo $expense_amount; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="amount" value="<?php echo number_format($expense_amount,2); ?>" placeholder="0.00" required>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion expense_refund_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="amount" value="-<?php echo $expense_amount; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="amount" value="-<?php echo number_format($expense_amount,2); ?>" placeholder="-0.00" required>
</div>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,4 +743,26 @@ function shortenClient($client) {
}

return strtoupper(substr($shortened, 0, 3));
}

function roundUpToNearest15($time) {
// Extract hours, minutes, and seconds from the time string
list($hours, $minutes, $seconds) = explode(':', $time);

// Convert everything to seconds for easier calculation
$totalSeconds = ($hours * 3600) + ($minutes * 60) + $seconds;

// 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) {
$totalSeconds += (900 - $remainder);
}

// Convert total seconds to the decimal format
$decimalHours = $totalSeconds / 3600;

// Return the formatted string
return number_format($decimalHours, 2);
}
22 changes: 15 additions & 7 deletions invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
<th class="d-print-none"></th>
<th>Item</th>
<th>Description</th>
<th class="text-center">Qty</th>
<th class="text-center">Quantity</th>
<th class="text-right">Price</th>
<th class="text-right">Tax</th>
<th class="text-right">Total</th>
Expand All @@ -275,7 +275,7 @@
$item_id = intval($row['item_id']);
$item_name = nullable_htmlentities($row['item_name']);
$item_description = nullable_htmlentities($row['item_description']);
$item_quantity = floatval($row['item_quantity']);
$item_quantity = number_format(floatval($row['item_quantity']),2);
$item_price = floatval($row['item_price']);
$item_tax = floatval($row['item_tax']);
$item_total = floatval($row['item_total']);
Expand Down Expand Up @@ -324,12 +324,20 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<td></td>
<td><input type="text" class="form-control" id="name" name="name" placeholder="Item" required></td>
<td><textarea class="form-control" rows="2" id="desc" name="description" placeholder="Description"></textarea></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" id="qty" name="qty" placeholder="QTY"></td>
<td><input type="number" step="0.01" class="form-control" style="text-align: right;" id="price" name="price" placeholder="Price (<?php echo $invoice_currency_code; ?>)"></td>
<td>
<select class="form-control" name="tax_id" required>
<input type="text" class="form-control" id="name" name="name" placeholder="Item" required>
</td>
<td>
<textarea class="form-control" rows="2" id="desc" name="description" placeholder="Enter a Description"></textarea>
</td>
<td>
<input type="text" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" class="form-control" style="text-align: center;" id="qty" name="qty" placeholder="Quantity">
</td>
<td>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" style="text-align: right;" id="price" name="price" placeholder="Price (<?php echo $invoice_currency_code; ?>)">
</td>
<td>
<select class="form-control select2" name="tax_id" required>
<option value="0">No Tax</option>
<?php

Expand Down
4 changes: 2 additions & 2 deletions invoice_payment_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" min="0" name="amount" value="<?php echo $balance; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" value="<?php echo number_format($balance,2); ?>" placeholder="0.00" required>
</div>
</div>

Expand Down Expand Up @@ -113,7 +113,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-file-alt"></i></span>
</div>
<input type="text" class="form-control" name="reference" placeholder="Enter a reference">
<input type="text" class="form-control" name="reference" placeholder="Check #, Trans #, etc">
</div>
</div>

Expand Down
10 changes: 5 additions & 5 deletions item_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-box"></i></span>
</div>
<input type="text" class="form-control" name="name" value="<?php echo $item_name; ?>" required>
<input type="text" class="form-control" name="name" value="<?php echo $item_name; ?>" placeholder="Enter item name" required>
</div>
</div>

<div class="form-row">
<div class="col-sm">

<div class="form-group">
<label>QTY <strong class="text-danger">*</strong></label>
<label>Quantity <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-balance-scale"></i></span>
</div>
<input type="number" class="form-control" step="0.01" min="0" name="qty" value="<?php echo $item_quantity; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="qty" value="<?php echo number_format($item_quantity,2); ?>" placeholder="0.00" required>
</div>
</div>

Expand All @@ -52,7 +52,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" class="form-control" step="0.01" name="price" value="<?php echo $item_price; ?>" required>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="price" value="<?php echo number_format($item_price,2); ?>" placeholder="0.00" required>
</div>
</div>

Expand All @@ -63,7 +63,7 @@
<div class="form-group">
<label>Description</label>
<div class="input-group">
<textarea class="form-control" rows="5" name="description"><?php echo $item_description; ?></textarea>
<textarea class="form-control" rows="5" name="description" placeholder="Enter a description"><?php echo $item_description; ?></textarea>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion post/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
if (isset($_POST['verify'])) {

require_once("rfc6238.php");
$currentcode = sanitizeInput($_POST['code']); //code to validate, for example received from device
$currentcode = intval($_POST['code']); //code to validate, for example received from device

if (TokenAuth6238::verify($session_token, $currentcode)) {
$_SESSION['alert_message'] = "VALID!";
Expand Down
2 changes: 1 addition & 1 deletion product_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" step="0.01" min="0" class="form-control" name="price" placeholder="Price" required>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="price" placeholder="0.00" required>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion product_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="number" step="0.01" min="0" class="form-control" name="price" value="<?php echo $product_price; ?>" required>
<input type="text" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" class="form-control" name="price" value="<?php echo $product_price; ?>" placeholder="0.00" required>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 61c9c0c

Please sign in to comment.