From 61c9c0c8b9639001a97ad6a29f13b51cfebba413 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 22 Sep 2023 15:19:05 -0400 Subject: [PATCH] Feature: Automatically calculate tickert to invoice based off time worked 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 --- account_add_modal.php | 2 +- budget_create_modal.php | 4 ++-- budget_edit_modal.php | 4 ++-- client_add_modal.php | 2 +- client_edit_modal.php | 2 +- client_network_add_modal.php | 2 +- client_network_edit_modal.php | 2 +- client_software_add_modal.php | 2 +- client_software_edit_modal.php | 2 +- client_trips.php | 2 +- expense_add_modal.php | 2 +- expense_copy_modal.php | 2 +- expense_edit_modal.php | 2 +- expense_refund_modal.php | 2 +- functions.php | 22 ++++++++++++++++++++++ invoice.php | 22 +++++++++++++++------- invoice_payment_add_modal.php | 4 ++-- item_edit_modal.php | 10 +++++----- post/profile.php | 2 +- product_add_modal.php | 2 +- product_edit_modal.php | 2 +- products.php | 2 +- quote.php | 21 ++++++++++++++------- recurring_expense_create_modal.php | 4 ++-- recurring_expense_edit_modal.php | 4 ++-- recurring_invoice.php | 20 ++++++++++++++------ revenue_add_modal.php | 4 ++-- revenue_edit_modal.php | 4 ++-- revenues.php | 2 +- ticket_invoice_add_modal.php | 6 +++--- transfer_add_modal.php | 2 +- transfer_edit_modal.php | 2 +- trip_add_modal.php | 2 +- trip_copy_modal.php | 2 +- trip_edit_modal.php | 2 +- trips.php | 2 +- user_profile.php | 2 +- 37 files changed, 111 insertions(+), 66 deletions(-) diff --git a/account_add_modal.php b/account_add_modal.php index 7663d926..ad06e7bc 100644 --- a/account_add_modal.php +++ b/account_add_modal.php @@ -26,7 +26,7 @@
- + diff --git a/budget_create_modal.php b/budget_create_modal.php index 4a97773e..75fddfee 100644 --- a/budget_create_modal.php +++ b/budget_create_modal.php @@ -42,7 +42,7 @@
- + @@ -65,7 +65,7 @@
- + diff --git a/budget_edit_modal.php b/budget_edit_modal.php index de635a39..913096bc 100644 --- a/budget_edit_modal.php +++ b/budget_edit_modal.php @@ -43,7 +43,7 @@
- + @@ -62,7 +62,7 @@
- + diff --git a/client_add_modal.php b/client_add_modal.php index 30723782..473949c7 100644 --- a/client_add_modal.php +++ b/client_add_modal.php @@ -232,7 +232,7 @@
- + diff --git a/client_edit_modal.php b/client_edit_modal.php index ba04a503..91b8dff3 100644 --- a/client_edit_modal.php +++ b/client_edit_modal.php @@ -93,7 +93,7 @@
- + diff --git a/client_network_add_modal.php b/client_network_add_modal.php index 3f55cad6..2d9f5cbf 100644 --- a/client_network_add_modal.php +++ b/client_network_add_modal.php @@ -27,7 +27,7 @@
- + diff --git a/client_network_edit_modal.php b/client_network_edit_modal.php index b8dacdb6..ec69d7b5 100644 --- a/client_network_edit_modal.php +++ b/client_network_edit_modal.php @@ -28,7 +28,7 @@
- + diff --git a/client_software_add_modal.php b/client_software_add_modal.php index 8dab4f9b..06ba8aad 100644 --- a/client_software_add_modal.php +++ b/client_software_add_modal.php @@ -91,7 +91,7 @@
- + diff --git a/client_software_edit_modal.php b/client_software_edit_modal.php index 842080bc..44d39ece 100644 --- a/client_software_edit_modal.php +++ b/client_software_edit_modal.php @@ -92,7 +92,7 @@
- + diff --git a/client_trips.php b/client_trips.php index 717a4feb..2a9b8313 100644 --- a/client_trips.php +++ b/client_trips.php @@ -74,7 +74,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $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']); diff --git a/expense_add_modal.php b/expense_add_modal.php index bf2cd6a4..e345e67d 100644 --- a/expense_add_modal.php +++ b/expense_add_modal.php @@ -27,7 +27,7 @@
- + diff --git a/expense_copy_modal.php b/expense_copy_modal.php index 3e1e2aef..ab69b03b 100644 --- a/expense_copy_modal.php +++ b/expense_copy_modal.php @@ -27,7 +27,7 @@
- + diff --git a/expense_edit_modal.php b/expense_edit_modal.php index 2df69cf7..4140254c 100644 --- a/expense_edit_modal.php +++ b/expense_edit_modal.php @@ -29,7 +29,7 @@
- + diff --git a/expense_refund_modal.php b/expense_refund_modal.php index c4bf5a89..c35cba77 100644 --- a/expense_refund_modal.php +++ b/expense_refund_modal.php @@ -31,7 +31,7 @@
- + diff --git a/functions.php b/functions.php index 9b3df3f1..6ba217cd 100644 --- a/functions.php +++ b/functions.php @@ -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); } \ No newline at end of file diff --git a/invoice.php b/invoice.php index 9ecc831b..ab1ac006 100644 --- a/invoice.php +++ b/invoice.php @@ -259,7 +259,7 @@ if (isset($_GET['invoice_id'])) { Item Description - Qty + Quantity Price Tax Total @@ -275,7 +275,7 @@ if (isset($_GET['invoice_id'])) { $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']); @@ -324,12 +324,20 @@ if (isset($_GET['invoice_id'])) {
- - - - - + + + + + + + + + + + + + @@ -113,7 +113,7 @@
- + diff --git a/item_edit_modal.php b/item_edit_modal.php index 140c61fe..b623e1b2 100644 --- a/item_edit_modal.php +++ b/item_edit_modal.php @@ -25,7 +25,7 @@
- + @@ -33,12 +33,12 @@
- +
- +
@@ -52,7 +52,7 @@
- +
@@ -63,7 +63,7 @@
- +
diff --git a/post/profile.php b/post/profile.php index 03b1fa2b..9995aa73 100644 --- a/post/profile.php +++ b/post/profile.php @@ -119,7 +119,7 @@ if (isset($_POST['edit_profile'])) { 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!"; diff --git a/product_add_modal.php b/product_add_modal.php index 0ec4ebab..07a38629 100644 --- a/product_add_modal.php +++ b/product_add_modal.php @@ -55,7 +55,7 @@
- + diff --git a/product_edit_modal.php b/product_edit_modal.php index d47f7c77..af9b20f8 100644 --- a/product_edit_modal.php +++ b/product_edit_modal.php @@ -55,7 +55,7 @@
- + diff --git a/products.php b/products.php index 3626fe06..df09a0c0 100644 --- a/products.php +++ b/products.php @@ -66,7 +66,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); } else { $product_description_display = "
$product_description
"; } - $product_price = floatval($row['product_price']); + $product_price = number_format(floatval($row['product_price']),2); $product_currency_code = nullable_htmlentities($row['product_currency_code']); $product_created_at = nullable_htmlentities($row['product_created_at']); $category_id = intval($row['category_id']); diff --git a/quote.php b/quote.php index 93f1047c..dc33d198 100644 --- a/quote.php +++ b/quote.php @@ -251,7 +251,7 @@ if (isset($_GET['quote_id'])) { Item Description - Qty + Quantity Price Tax Total @@ -267,7 +267,7 @@ if (isset($_GET['quote_id'])) { $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']); @@ -319,12 +319,19 @@ if (isset($_GET['quote_id'])) { - - - - - + + + + + + + + + + + + @@ -68,7 +68,7 @@
- + diff --git a/recurring_expense_edit_modal.php b/recurring_expense_edit_modal.php index dee36d93..8ec85ca5 100644 --- a/recurring_expense_edit_modal.php +++ b/recurring_expense_edit_modal.php @@ -56,7 +56,7 @@
- + @@ -70,7 +70,7 @@
- + diff --git a/recurring_invoice.php b/recurring_invoice.php index b0b30078..2f6c1647 100644 --- a/recurring_invoice.php +++ b/recurring_invoice.php @@ -191,7 +191,7 @@ if (isset($_GET['recurring_id'])) { Item Description - Qty + Quantity Price Tax Total @@ -207,7 +207,7 @@ if (isset($_GET['recurring_id'])) { $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']); @@ -251,10 +251,18 @@ if (isset($_GET['recurring_id'])) { - - - - + + + + + + + + + + + + + @@ -157,7 +157,7 @@
- + diff --git a/revenue_edit_modal.php b/revenue_edit_modal.php index a5a1ec87..d439d0e0 100644 --- a/revenue_edit_modal.php +++ b/revenue_edit_modal.php @@ -44,7 +44,7 @@
- + @@ -163,7 +163,7 @@
- + diff --git a/revenues.php b/revenues.php index fc427c48..5327a8ca 100644 --- a/revenues.php +++ b/revenues.php @@ -104,7 +104,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); } $revenue_date = nullable_htmlentities($row['revenue_date']); $revenue_payment_method = nullable_htmlentities($row['revenue_payment_method']); - $revenue_amount = floatval($row['revenue_amount']); + $revenue_amount = number_format(floatval($row['revenue_amount']),2); $revenue_currency_code = nullable_htmlentities($row['revenue_currency_code']); $revenue_created_at = nullable_htmlentities($row['revenue_created_at']); $account_id = intval($row['account_id']); diff --git a/ticket_invoice_add_modal.php b/ticket_invoice_add_modal.php index a4f4af56..22719d1b 100644 --- a/ticket_invoice_add_modal.php +++ b/ticket_invoice_add_modal.php @@ -121,7 +121,7 @@
- + @@ -141,7 +141,7 @@
- + @@ -155,7 +155,7 @@
- + diff --git a/transfer_add_modal.php b/transfer_add_modal.php index 3633413b..0aa94f8b 100644 --- a/transfer_add_modal.php +++ b/transfer_add_modal.php @@ -28,7 +28,7 @@
- + diff --git a/transfer_edit_modal.php b/transfer_edit_modal.php index b2736b69..524997c5 100644 --- a/transfer_edit_modal.php +++ b/transfer_edit_modal.php @@ -32,7 +32,7 @@
- + diff --git a/trip_add_modal.php b/trip_add_modal.php index 4ba31ff8..ee613ae3 100644 --- a/trip_add_modal.php +++ b/trip_add_modal.php @@ -28,7 +28,7 @@
- +
diff --git a/trip_copy_modal.php b/trip_copy_modal.php index 8e594fcd..6ffd8b6e 100644 --- a/trip_copy_modal.php +++ b/trip_copy_modal.php @@ -28,7 +28,7 @@
- +
> diff --git a/trip_edit_modal.php b/trip_edit_modal.php index 7fee31da..2a520c92 100644 --- a/trip_edit_modal.php +++ b/trip_edit_modal.php @@ -30,7 +30,7 @@
- +
> diff --git a/trips.php b/trips.php index 21a3f15c..22c48e9f 100644 --- a/trips.php +++ b/trips.php @@ -107,7 +107,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $trip_purpose = nullable_htmlentities($row['trip_purpose']); $trip_source = nullable_htmlentities($row['trip_source']); $trip_destination = nullable_htmlentities($row['trip_destination']); - $trip_miles = floatval($row['trip_miles']); + $trip_miles = number_format(floatval($row['trip_miles']),1); $trip_user_id = intval($row['trip_user_id']); $trip_created_at = nullable_htmlentities($row['trip_created_at']); $trip_archived_at = nullable_htmlentities($row['trip_archived_at']); diff --git a/user_profile.php b/user_profile.php index 9830e1c4..6b095323 100644 --- a/user_profile.php +++ b/user_profile.php @@ -132,7 +132,7 @@ $sql_recent_logs = mysqli_query($mysqli, "SELECT * FROM logs
- +