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 7663d926a..ad06e7bc2 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 4a97773e0..75fddfee9 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 de635a393..913096bc9 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 307237821..473949c74 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 ba04a5034..91b8dff32 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 3f55cad6f..2d9f5cbf3 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 b8dacdb60..ec69d7b5d 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 8dab4f9b3..06ba8aad3 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 842080bce..44d39ece3 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 717a4feb1..2a9b83136 100644 --- a/client_trips.php +++ b/client_trips.php @@ -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']); diff --git a/expense_add_modal.php b/expense_add_modal.php index bf2cd6a41..e345e67df 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 3e1e2aef6..ab69b03b5 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 2df69cf74..4140254cd 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 c4bf5a896..c35cba776 100644 --- a/expense_refund_modal.php +++ b/expense_refund_modal.php @@ -31,7 +31,7 @@
- + diff --git a/functions.php b/functions.php index 9b3df3f12..6ba217cde 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 9ecc831b2..ab1ac0064 100644 --- a/invoice.php +++ b/invoice.php @@ -259,7 +259,7 @@ Item Description - Qty + Quantity Price Tax Total @@ -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']); @@ -324,12 +324,20 @@
- - - - - + + + + + + + + + + + + + @@ -113,7 +113,7 @@
- + diff --git a/item_edit_modal.php b/item_edit_modal.php index 140c61fea..b623e1b2a 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 03b1fa2bd..9995aa732 100644 --- a/post/profile.php +++ b/post/profile.php @@ -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!"; diff --git a/product_add_modal.php b/product_add_modal.php index 0ec4ebabd..07a38629e 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 d47f7c771..af9b20f80 100644 --- a/product_edit_modal.php +++ b/product_edit_modal.php @@ -55,7 +55,7 @@
- + diff --git a/products.php b/products.php index 3626fe06a..df09a0c05 100644 --- a/products.php +++ b/products.php @@ -66,7 +66,7 @@ } 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 93f1047c8..dc33d1982 100644 --- a/quote.php +++ b/quote.php @@ -251,7 +251,7 @@ Item Description - Qty + Quantity Price Tax Total @@ -267,7 +267,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']); @@ -319,12 +319,19 @@ - - - - - + + + + + + + + + + + + @@ -68,7 +68,7 @@
- + diff --git a/recurring_expense_edit_modal.php b/recurring_expense_edit_modal.php index dee36d93a..8ec85ca5f 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 b0b30078f..2f6c16479 100644 --- a/recurring_invoice.php +++ b/recurring_invoice.php @@ -191,7 +191,7 @@ Item Description - Qty + Quantity Price Tax Total @@ -207,7 +207,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']); @@ -251,10 +251,18 @@ - - - - + + + + + + + + + + + + + @@ -157,7 +157,7 @@
- + diff --git a/revenue_edit_modal.php b/revenue_edit_modal.php index a5a1ec871..d439d0e02 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 fc427c48d..5327a8ca8 100644 --- a/revenues.php +++ b/revenues.php @@ -104,7 +104,7 @@ } $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 a4f4af562..22719d1bb 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 3633413bc..0aa94f8b5 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 b2736b695..524997c54 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 4ba31ff85..ee613ae37 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 8e594fcd2..6ffd8b6ea 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 7fee31da9..2a520c926 100644 --- a/trip_edit_modal.php +++ b/trip_edit_modal.php @@ -30,7 +30,7 @@
- +
> diff --git a/trips.php b/trips.php index 21a3f15c1..22c48e9f9 100644 --- a/trips.php +++ b/trips.php @@ -107,7 +107,7 @@ $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 9830e1c4e..6b0953235 100644 --- a/user_profile.php +++ b/user_profile.php @@ -132,7 +132,7 @@
- +