mirror of
https://github.com/itflow-org/itflow
synced 2026-03-09 15:24:51 +00:00
Remove old item ordering logic for invoice, recurring invoice and quote
This commit is contained in:
@@ -99,7 +99,6 @@ $sql_task_templates = mysqli_query($mysqli, "SELECT * FROM task_templates WHERE
|
|||||||
while($row = mysqli_fetch_array($sql_task_templates)){
|
while($row = mysqli_fetch_array($sql_task_templates)){
|
||||||
$task_id = intval($row['task_template_id']);
|
$task_id = intval($row['task_template_id']);
|
||||||
$task_name = nullable_htmlentities($row['task_template_name']);
|
$task_name = nullable_htmlentities($row['task_template_name']);
|
||||||
$task_order = intval($row['task_template_order']);
|
|
||||||
$task_completion_estimate = intval($row['task_template_completion_estimate']);
|
$task_completion_estimate = intval($row['task_template_completion_estimate']);
|
||||||
$task_description = nullable_htmlentities($row['task_template_description']);
|
$task_description = nullable_htmlentities($row['task_template_description']);
|
||||||
?>
|
?>
|
||||||
|
|||||||
21
invoice.php
21
invoice.php
@@ -369,18 +369,6 @@ if (isset($_GET['invoice_id'])) {
|
|||||||
$tax_id = intval($row['item_tax_id']);
|
$tax_id = intval($row['item_tax_id']);
|
||||||
$total_tax = $item_tax + $total_tax;
|
$total_tax = $item_tax + $total_tax;
|
||||||
$sub_total = $item_price * $item_quantity + $sub_total;
|
$sub_total = $item_price * $item_quantity + $sub_total;
|
||||||
$item_order = intval($row['item_order']);
|
|
||||||
// Logic to check if top or bottom arrow should be hidden
|
|
||||||
if ($item_order == 1) {
|
|
||||||
$up_hidden = "hidden";
|
|
||||||
} else {
|
|
||||||
$up_hidden = "";
|
|
||||||
}
|
|
||||||
if ($item_order == mysqli_num_rows($sql_invoice_items)) {
|
|
||||||
$down_hidden = "hidden";
|
|
||||||
} else {
|
|
||||||
$down_hidden = "";
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<tr data-item-id="<?php echo $item_id; ?>">
|
<tr data-item-id="<?php echo $item_id; ?>">
|
||||||
<td class="d-print-none">
|
<td class="d-print-none">
|
||||||
@@ -390,15 +378,6 @@ if (isset($_GET['invoice_id'])) {
|
|||||||
<i class="fas fa-ellipsis-v"></i>
|
<i class="fas fa-ellipsis-v"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<form action="post.php" method="post">
|
|
||||||
<input type="hidden" name="item_invoice_id" value="<?php echo $invoice_id; ?>">
|
|
||||||
<input type="hidden" name="item_id" value="<?php echo $item_id; ?>">
|
|
||||||
<input type="hidden" name="item_order" value="<?php echo $item_order; ?>">
|
|
||||||
<button class="dropdown-item" type="submit" name="update_invoice_item_order" value="up" <?php echo $up_hidden; ?>><i class="fas fa-fw fa-arrow-up mr-2"></i>Move Up</button>
|
|
||||||
<?php if ($up_hidden == "" && $down_hidden == "") { echo '<div class="dropdown-divider"></div>'; }?>
|
|
||||||
<button class="dropdown-item" type="submit" name="update_invoice_item_order" value="down" <?php echo $down_hidden; ?>><i class="fas fa-fw fa-arrow-down mr-2"></i>Move down</button>
|
|
||||||
</form>
|
|
||||||
<div class="dropdown-divider"></div>
|
|
||||||
<a class="dropdown-item" href="#"
|
<a class="dropdown-item" href="#"
|
||||||
data-toggle="ajax-modal"
|
data-toggle="ajax-modal"
|
||||||
data-ajax-url="ajax/ajax_item_edit.php"
|
data-ajax-url="ajax/ajax_item_edit.php"
|
||||||
|
|||||||
@@ -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'])) {
|
if (isset($_GET['recurring_invoice_email_notify'])) {
|
||||||
$recurring_invoice_email_notify = intval($_GET['recurring_invoice_email_notify']);
|
$recurring_invoice_email_notify = intval($_GET['recurring_invoice_email_notify']);
|
||||||
$recurring_id = intval($_GET['recurring_id']);
|
$recurring_id = intval($_GET['recurring_id']);
|
||||||
|
|||||||
@@ -575,61 +575,3 @@ if(isset($_POST['export_quotes_csv'])){
|
|||||||
exit;
|
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"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
34
quote.php
34
quote.php
@@ -305,7 +305,6 @@ if (isset($_GET['quote_id'])) {
|
|||||||
$item_id = intval($row['item_id']);
|
$item_id = intval($row['item_id']);
|
||||||
$item_name = nullable_htmlentities($row['item_name']);
|
$item_name = nullable_htmlentities($row['item_name']);
|
||||||
$item_description = nullable_htmlentities($row['item_description']);
|
$item_description = nullable_htmlentities($row['item_description']);
|
||||||
$item_order = intval($row['item_order']);
|
|
||||||
$item_quantity = floatval($row['item_quantity']);
|
$item_quantity = floatval($row['item_quantity']);
|
||||||
$item_price = floatval($row['item_price']);
|
$item_price = floatval($row['item_price']);
|
||||||
$item_tax = floatval($row['item_tax']);
|
$item_tax = floatval($row['item_tax']);
|
||||||
@@ -314,27 +313,7 @@ if (isset($_GET['quote_id'])) {
|
|||||||
$tax_id = intval($row['item_tax_id']);
|
$tax_id = intval($row['item_tax_id']);
|
||||||
$total_tax = $item_tax + $total_tax;
|
$total_tax = $item_tax + $total_tax;
|
||||||
$sub_total = $item_price * $item_quantity + $sub_total;
|
$sub_total = $item_price * $item_quantity + $sub_total;
|
||||||
|
?>
|
||||||
// Logic to check if top or bottom arrow should be hidden by looking at max and min of item_order
|
|
||||||
$sql = mysqli_query($mysqli, "SELECT MAX(item_order) AS item_order FROM invoice_items WHERE item_quote_id = $quote_id");
|
|
||||||
$row = mysqli_fetch_array($sql);
|
|
||||||
$max_item_order = intval($row['item_order']);
|
|
||||||
|
|
||||||
$sql = mysqli_query($mysqli, "SELECT MIN(item_order) AS item_order FROM invoice_items WHERE item_quote_id = $quote_id");
|
|
||||||
$row = mysqli_fetch_array($sql);
|
|
||||||
$min_item_order = intval($row['item_order']);
|
|
||||||
|
|
||||||
if ($item_order == $max_item_order) {
|
|
||||||
$down_hidden = "hidden";
|
|
||||||
} else {
|
|
||||||
$down_hidden = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item_order == $min_item_order) {
|
|
||||||
$up_hidden = "hidden";
|
|
||||||
} else {
|
|
||||||
$up_hidden = "";
|
|
||||||
} ?>
|
|
||||||
|
|
||||||
<tr data-item-id="<?php echo $item_id; ?>">
|
<tr data-item-id="<?php echo $item_id; ?>">
|
||||||
<td class="d-print-none">
|
<td class="d-print-none">
|
||||||
@@ -344,17 +323,6 @@ if (isset($_GET['quote_id'])) {
|
|||||||
<i class="fas fa-ellipsis-v"></i>
|
<i class="fas fa-ellipsis-v"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<form action="post.php" method="post">
|
|
||||||
<input type="hidden" name="item_quote_id" value="<?php echo $quote_id; ?>">
|
|
||||||
<input type="hidden" name="item_id" value="<?php echo $item_id; ?>">
|
|
||||||
<input type="hidden" name="item_order" value="<?php echo $item_order; ?>">
|
|
||||||
<button class="dropdown-item" type="submit" name="update_quote_item_order" value="up" <?php echo $up_hidden; ?>><i class="fa fa-fw fa-arrow-up mr-2"></i>Move Up</button>
|
|
||||||
<?php if ($up_hidden == "" && $down_hidden == "") {
|
|
||||||
echo '<div class="dropdown-divider"></div>';
|
|
||||||
} ?>
|
|
||||||
<button class="dropdown-item" type="submit" name="update_quote_item_order" value="down" <?php echo $down_hidden; ?>><i class="fa fa-fw fa-arrow-down mr-2"></i>Move Down</button>
|
|
||||||
</form>
|
|
||||||
<div class="dropdown-divider"></div>
|
|
||||||
<a class="dropdown-item" href="#"
|
<a class="dropdown-item" href="#"
|
||||||
data-toggle="ajax-modal"
|
data-toggle="ajax-modal"
|
||||||
data-ajax-url="ajax/ajax_item_edit.php"
|
data-ajax-url="ajax/ajax_item_edit.php"
|
||||||
|
|||||||
@@ -265,28 +265,6 @@ if (isset($_GET['recurring_id'])) {
|
|||||||
$tax_id = intval($row['item_tax_id']);
|
$tax_id = intval($row['item_tax_id']);
|
||||||
$total_tax = $item_tax + $total_tax;
|
$total_tax = $item_tax + $total_tax;
|
||||||
$sub_total = $item_price * $item_quantity + $sub_total;
|
$sub_total = $item_price * $item_quantity + $sub_total;
|
||||||
$item_order = intval($row['item_order']);
|
|
||||||
|
|
||||||
// Logic to check if top or bottom arrow should be hidden by looking at max and min of item_order
|
|
||||||
$sql = mysqli_query($mysqli, "SELECT MAX(item_order) AS item_order FROM invoice_items WHERE item_recurring_id = $recurring_id");
|
|
||||||
$row = mysqli_fetch_array($sql);
|
|
||||||
$max_item_order = intval($row['item_order']);
|
|
||||||
|
|
||||||
$sql = mysqli_query($mysqli, "SELECT MIN(item_order) AS item_order FROM invoice_items WHERE item_recurring_id = $recurring_id");
|
|
||||||
$row = mysqli_fetch_array($sql);
|
|
||||||
$min_item_order = intval($row['item_order']);
|
|
||||||
|
|
||||||
if ($item_order == $max_item_order) {
|
|
||||||
$down_hidden = "hidden";
|
|
||||||
} else {
|
|
||||||
$down_hidden = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item_order == $min_item_order) {
|
|
||||||
$up_hidden = "hidden";
|
|
||||||
} else {
|
|
||||||
$up_hidden = "";
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr data-item-id="<?php echo $item_id; ?>">
|
<tr data-item-id="<?php echo $item_id; ?>">
|
||||||
@@ -296,15 +274,6 @@ if (isset($_GET['recurring_id'])) {
|
|||||||
<i class="fas fa-ellipsis-v"></i>
|
<i class="fas fa-ellipsis-v"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<form action="post.php" method="post">
|
|
||||||
<input type="hidden" name="item_recurring_id" value="<?php echo $recurring_id; ?>">
|
|
||||||
<input type="hidden" name="item_id" value="<?php echo $item_id; ?>">
|
|
||||||
<input type="hidden" name="item_order" value="<?php echo $item_order; ?>">
|
|
||||||
<button class="dropdown-item" type="submit" name="update_recurring_item_order" value="up" <?php echo $up_hidden; ?>><i class="fa fa-fw fa-arrow-up mr-2"></i> Move Up</button>
|
|
||||||
<?php if ($up_hidden == "" && $down_hidden == "") { echo '<div class="dropdown-divider"></div>'; }?>
|
|
||||||
<button class="dropdown-item" type="submit" name="update_recurring_item_order" value="down" <?php echo $down_hidden; ?>><i class="fa fa-fw fa-arrow-down mr-2"></i> Move Down</button>
|
|
||||||
</form>
|
|
||||||
<div class="dropdown-divider"></div>
|
|
||||||
<a class="dropdown-item" href="#"
|
<a class="dropdown-item" href="#"
|
||||||
data-toggle="ajax-modal"
|
data-toggle="ajax-modal"
|
||||||
data-ajax-url="ajax/ajax_item_edit.php"
|
data-ajax-url="ajax/ajax_item_edit.php"
|
||||||
|
|||||||
Reference in New Issue
Block a user