mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Remove old item ordering logic for invoice, recurring invoice and quote
This commit is contained in:
@@ -1749,78 +1749,6 @@ if (isset($_POST['export_payments_csv'])) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isset($_POST['update_recurring_item_order'])) {
|
||||
|
||||
$item_id = intval($_POST['item_id']);
|
||||
$item_recurring_id = intval($_POST['item_recurring_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_id = $item_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$current_order = intval($row['item_order']);
|
||||
$update_direction = sanitizeInput($_POST['update_recurring_item_order']);
|
||||
|
||||
switch ($update_direction)
|
||||
{
|
||||
case 'up':
|
||||
$new_order = $current_order - 1;
|
||||
break;
|
||||
case 'down':
|
||||
$new_order = $current_order + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
//Find item_id of current item in $new_order
|
||||
$other_sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_recurring_id = $item_recurring_id AND item_order = $new_order");
|
||||
$other_row = mysqli_fetch_array($other_sql);
|
||||
$other_item_id = intval($other_row['item_id']);
|
||||
$other_row_str = strval($other_row['item_name']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $new_order WHERE item_id = $item_id");
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $current_order WHERE item_id = $other_item_id");
|
||||
|
||||
$_SESSION['alert_message'] = "recurring Item Order Updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_POST['update_invoice_item_order'])) {
|
||||
|
||||
$item_id = intval($_POST['item_id']);
|
||||
$item_invoice_id = intval($_POST['item_invoice_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_id = $item_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$current_order = intval($row['item_order']);
|
||||
$update_direction = sanitizeInput($_POST['update_invoice_item_order']);
|
||||
|
||||
switch ($update_direction)
|
||||
{
|
||||
case 'up':
|
||||
$new_order = $current_order - 1;
|
||||
break;
|
||||
case 'down':
|
||||
$new_order = $current_order + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
//Find item_id of current item in $new_order
|
||||
$other_sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $item_invoice_id AND item_order = $new_order");
|
||||
$other_row = mysqli_fetch_array($other_sql);
|
||||
$other_item_id = intval($other_row['item_id']);
|
||||
$other_row_str = strval($other_row['item_name']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $new_order WHERE item_id = $item_id");
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $current_order WHERE item_id = $other_item_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Invoice Item Order Updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_GET['recurring_invoice_email_notify'])) {
|
||||
$recurring_invoice_email_notify = intval($_GET['recurring_invoice_email_notify']);
|
||||
$recurring_id = intval($_GET['recurring_id']);
|
||||
|
||||
@@ -575,61 +575,3 @@ if(isset($_POST['export_quotes_csv'])){
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['update_quote_item_order'])) {
|
||||
|
||||
enforceUserPermission('module_sales', 2);
|
||||
|
||||
if ($_POST['update_quote_item_order'] == 'up') {
|
||||
$item_id = intval($_POST['item_id']);
|
||||
$item_quote_id = intval($_POST['item_quote_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_id = $item_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$item_order = intval($row['item_order']);
|
||||
|
||||
$new_item_order = $item_order - 1;
|
||||
|
||||
//Check if new item order is used
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_quote_id = $item_quote_id AND item_order = $new_item_order");
|
||||
|
||||
//Redo the entire order of list
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
$item_order = intval($row['item_order']);
|
||||
|
||||
$new_item_order = $item_order + 1;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $new_item_order WHERE item_id = $item_id");
|
||||
}
|
||||
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $item_order WHERE item_quote_id = $item_quote_id AND item_order = $new_item_order");
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $new_item_order WHERE item_id = $item_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Item moved up";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if ($_POST['update_quote_item_order'] == 'down') {
|
||||
$item_id = intval($_POST['item_id']);
|
||||
$item_quote_id = intval($_POST['item_quote_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_id = $item_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$item_order = intval($row['item_order']);
|
||||
|
||||
$new_item_order = $item_order + 1;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $item_order WHERE item_quote_id = $item_quote_id AND item_order = $new_item_order");
|
||||
mysqli_query($mysqli,"UPDATE invoice_items SET item_order = $new_item_order WHERE item_id = $item_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Item moved down";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user