From 554c4d99bb2b2ee359afdabd5cd1aad495906a48 Mon Sep 17 00:00:00 2001 From: ssteeltm Date: Fri, 21 Feb 2025 14:22:01 -0300 Subject: [PATCH] Drag and Drop Quote Items --- ajax.php | 19 +++++++++++++++++++ quote.php | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/ajax.php b/ajax.php index 9c0aa743..cdb4fda2 100644 --- a/ajax.php +++ b/ajax.php @@ -726,3 +726,22 @@ if (isset($_POST['update_task_templates_order'])) { exit; } +if (isset($_POST['update_quote_items_order'])) { + // Update multiple quote items order + enforceUserPermission('module_sales', 2); + + $positions = $_POST['positions']; + $quote_id = intval($_POST['quote_id']); + + foreach ($positions as $position) { + $id = intval($position['id']); + $order = intval($position['order']); + + mysqli_query($mysqli, "UPDATE invoice_items SET item_order = $order WHERE item_quote_id = $quote_id AND item_id = $id"); + } + + // return a response + echo json_encode(['status' => 'success']); + exit; +} + diff --git a/quote.php b/quote.php index 816ea672..1ce53962 100644 --- a/quote.php +++ b/quote.php @@ -109,6 +109,7 @@ if (isset($_GET['quote_id'])) { } ?> +