From 72e448e4f0df4354ab036edf3c75fd30ac4dac5f Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 9 Dec 2023 16:12:31 -0500 Subject: [PATCH] Item Ordering Fix for Copy Quote or Invoice, Recurring Invoice to Invoice Cron, Force Recurring, Invoice to Recurring. It was not carrying over the item order on these tasks causing item ordering to break --- cron.php | 3 ++- post/invoice.php | 9 ++++++--- post/quote.php | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cron.php b/cron.php index 8973ee8d..9df90de5 100644 --- a/cron.php +++ b/cron.php @@ -562,10 +562,11 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $item_subtotal = floatval($row['item_subtotal']); $item_tax = floatval($row['item_tax']); $item_total = floatval($row['item_total']); + $item_order = intval($row['item_order']); $tax_id = intval($row['item_tax_id']); //Insert Items into New Invoice - mysqli_query($mysqli, "INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_tax_id = $tax_id, item_invoice_id = $new_invoice_id"); + mysqli_query($mysqli, "INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_order = $item_order, item_tax_id = $tax_id, item_invoice_id = $new_invoice_id"); } diff --git a/post/invoice.php b/post/invoice.php index 4f4131aa..46983c13 100644 --- a/post/invoice.php +++ b/post/invoice.php @@ -109,9 +109,10 @@ if (isset($_POST['add_invoice_copy'])) { $item_subtotal = floatval($row['item_subtotal']); $item_tax = floatval($row['item_tax']); $item_total = floatval($row['item_total']); + $item_order = intval($row['item_order']); $tax_id = intval($row['item_tax_id']); - mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_tax_id = $tax_id, item_invoice_id = $new_invoice_id"); + mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_order = $item_order, item_tax_id = $tax_id, item_invoice_id = $new_invoice_id"); } //Logging @@ -159,9 +160,10 @@ if (isset($_POST['add_invoice_recurring'])) { $item_subtotal = floatval($row['item_subtotal']); $item_tax = floatval($row['item_tax']); $item_total = floatval($row['item_total']); + $item_order = intval($row['item_order']); $tax_id = intval($row['item_tax_id']); - mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_tax_id = $tax_id, item_recurring_id = $recurring_id"); + mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_order = $item_order, item_tax_id = $tax_id, item_recurring_id = $recurring_id"); } //Logging @@ -923,6 +925,7 @@ if (isset($_GET['force_recurring'])) { $item_quantity = floatval($row['item_quantity']); $item_price = floatval($row['item_price']); $item_subtotal = floatval($row['item_subtotal']); + $item_order = intval($row['item_order']); $tax_id = intval($row['item_tax_id']); //Recalculate Item Tax since Tax percents can change. @@ -938,7 +941,7 @@ if (isset($_GET['force_recurring'])) { $item_total = $item_subtotal + $item_tax_amount; //Update Recurring Items with new tax - mysqli_query($mysqli,"UPDATE invoice_items SET item_tax = $item_tax_amount, item_total = $item_total, item_tax_id = $tax_id WHERE item_id = $item_id"); + mysqli_query($mysqli,"UPDATE invoice_items SET item_tax = $item_tax_amount, item_total = $item_total, item_tax_id = $tax_id, item_order = $item_order WHERE item_id = $item_id"); mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax_amount, item_total = $item_total, item_tax_id = $tax_id, item_invoice_id = $new_invoice_id"); } diff --git a/post/quote.php b/post/quote.php index 0b30aae7..93060051 100644 --- a/post/quote.php +++ b/post/quote.php @@ -73,9 +73,10 @@ if (isset($_POST['add_quote_copy'])) { $item_subtotal = floatval($row['item_subtotal']); $item_tax = floatval($row['item_tax']); $item_total = floatval($row['item_total']); + $item_order = intval($row['item_order']); $tax_id = intval($row['item_tax_id']); - mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_tax_id = $tax_id, item_quote_id = $new_quote_id"); + mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_order = $item_order, item_tax_id = $tax_id, item_quote_id = $new_quote_id"); } //Logging