mirror of https://github.com/itflow-org/itflow
Added Bulk Actions to Invoices Assign Income Category
This commit is contained in:
parent
46c4a62046
commit
f72b7763c1
|
|
@ -237,6 +237,7 @@ if (isset($_GET['invoice_id'])) {
|
|||
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-success" data-toggle="ajax-modal" data-ajax-url="ajax/ajax_invoice_pay.php" data-ajax-id="<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-credit-card mr-2"></i>Add Payment</button>
|
||||
<?php if ($config_stripe_enable) { ?>
|
||||
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="guest/guest_pay_invoice_stripe.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Enter Card Manually</a>
|
||||
|
|
@ -254,6 +255,7 @@ if (isset($_GET['invoice_id'])) {
|
|||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
<?php } // End Payment Provider Enable Check ?>
|
||||
</div>
|
||||
|
||||
<?php if ($invoice_status !== 'Partial' && $config_stripe_enable && $stripe_id && $stripe_pm) { ?>
|
||||
|
|
|
|||
255
invoices.php
255
invoices.php
|
|
@ -103,133 +103,153 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<!-- small box -->
|
||||
<a href="?<?php echo $url_query_strings_sort; ?>&status=Draft" class="small-box bg-secondary">
|
||||
<div class="inner">
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $total_draft_amount, $session_company_currency); ?></h3>
|
||||
<p><?php echo $draft_count; ?> Draft</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-pencil-ruler"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4">
|
||||
<!-- small box -->
|
||||
<a href="?<?php echo $url_query_strings_sort; ?>&status=Unpaid" class="small-box bg-info">
|
||||
<div class="inner text-white">
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $total_unpaid_amount, $session_company_currency); ?></h3>
|
||||
<p><?php echo $unpaid_count; ?> Unpaid</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-hand-holding-usd"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4">
|
||||
<!-- small box -->
|
||||
<a href="?<?php echo $url_query_strings_sort; ?>&status=Overdue" class="small-box bg-danger">
|
||||
<div class="inner">
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $real_overdue_amount, $session_company_currency); ?></h3>
|
||||
<p><?php echo $overdue_count; ?> Overdue</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-exclamation-triangle"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<!-- small box -->
|
||||
<a href="?<?php echo $url_query_strings_sort; ?>&status=Draft" class="small-box bg-secondary">
|
||||
<div class="inner">
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $total_draft_amount, $session_company_currency); ?></h3>
|
||||
<p><?php echo $draft_count; ?> Draft</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-pencil-ruler"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-file-invoice mr-2"></i>Invoices</h3>
|
||||
<div class="card-tools">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addInvoiceModal"><i class="fas fa-plus mr-2"></i>New Invoice</button>
|
||||
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportInvoicesModal">
|
||||
<i class="fa fa-fw fa-download mr-2"></i>Export
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<!-- small box -->
|
||||
<a href="?<?php echo $url_query_strings_sort; ?>&status=Unpaid" class="small-box bg-info">
|
||||
<div class="inner text-white">
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $total_unpaid_amount, $session_company_currency); ?></h3>
|
||||
<p><?php echo $unpaid_count; ?> Unpaid</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-hand-holding-usd"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4">
|
||||
<!-- small box -->
|
||||
<a href="?<?php echo $url_query_strings_sort; ?>&status=Overdue" class="small-box bg-danger">
|
||||
<div class="inner">
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $real_overdue_amount, $session_company_currency); ?></h3>
|
||||
<p><?php echo $overdue_count; ?> Overdue</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-exclamation-triangle"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-file-invoice mr-2"></i>Invoices</h3>
|
||||
<div class="card-tools">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addInvoiceModal"><i class="fas fa-plus mr-2"></i>New Invoice</button>
|
||||
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportInvoicesModal">
|
||||
<i class="fa fa-fw fa-download mr-2"></i>Export
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form class="mb-4" autocomplete="off">
|
||||
<input type="hidden" name="status" value="<?php if (isset($_GET['status'])) { echo nullable_htmlentities($_GET['status']); } ?>">
|
||||
<?php if ($client_url) { ?>
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<?php } ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group mb-3 mb-md-0">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) {echo stripslashes(nullable_htmlentities($q));} ?>" placeholder="Search Invoices">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="mb-4" autocomplete="off">
|
||||
<input type="hidden" name="status" value="<?php if (isset($_GET['status'])) { echo nullable_htmlentities($_GET['status']); } ?>">
|
||||
<?php if ($client_url) { ?>
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<?php } ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group mb-3 mb-md-0">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) {echo stripslashes(nullable_htmlentities($q));} ?>" placeholder="Search Invoices">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<?php if ($client_url) { ?>
|
||||
<div class="float-right">
|
||||
<div class="btn-group float-right">
|
||||
<?php if ($balance > 0) { ?>
|
||||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#addBulkPaymentModal"><i class="fa fa-credit-card mr-2"></i>Batch Payment</button>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="btn-group float-right">
|
||||
<a href="?<?php echo $client_url; ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
|
||||
class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>">
|
||||
<i class="fa fa-fw fa-archive mr-2"></i>Archived
|
||||
</a>
|
||||
<div class="dropdown ml-2" id="bulkActionButton" hidden>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if ($client_url && $balance > 0) { ?>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addBulkPaymentModal">
|
||||
<i class="fa fa-credit-card mr-2"></i>Batch Payment
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse mt-3 <?php if (!empty($_GET['dtf']) || $_GET['canned_date'] !== "custom" ) { echo "show"; } ?>" id="advancedFilter">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Canned Date</label>
|
||||
<select onchange="this.form.submit()" class="form-control select2" name="canned_date">
|
||||
<option <?php if ($_GET['canned_date'] == "custom") { echo "selected"; } ?> value="custom">Custom</option>
|
||||
<option <?php if ($_GET['canned_date'] == "today") { echo "selected"; } ?> value="today">Today</option>
|
||||
<option <?php if ($_GET['canned_date'] == "yesterday") { echo "selected"; } ?> value="yesterday">Yesterday</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thisweek") { echo "selected"; } ?> value="thisweek">This Week</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastweek") { echo "selected"; } ?> value="lastweek">Last Week</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thismonth") { echo "selected"; } ?> value="thismonth">This Month</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastmonth") { echo "selected"; } ?> value="lastmonth">Last Month</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thisyear") { echo "selected"; } ?> value="thisyear">This Year</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastyear") { echo "selected"; } ?> value="lastyear">Last Year</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Date From</label>
|
||||
<input onchange="this.form.submit()" type="date" class="form-control" name="dtf" max="2999-12-31" value="<?php echo $dtf; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Date To</label>
|
||||
<input onchange="this.form.submit()" type="date" class="form-control" name="dtt" max="2999-12-31" value="<?php echo $dtt; ?>">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditCategoryModal">
|
||||
<i class="fas fa-fw fa-list-ul mr-2"></i>Set Category
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="collapse mt-3 <?php if (!empty($_GET['dtf']) || $_GET['canned_date'] !== "custom" ) { echo "show"; } ?>" id="advancedFilter">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Canned Date</label>
|
||||
<select onchange="this.form.submit()" class="form-control select2" name="canned_date">
|
||||
<option <?php if ($_GET['canned_date'] == "custom") { echo "selected"; } ?> value="custom">Custom</option>
|
||||
<option <?php if ($_GET['canned_date'] == "today") { echo "selected"; } ?> value="today">Today</option>
|
||||
<option <?php if ($_GET['canned_date'] == "yesterday") { echo "selected"; } ?> value="yesterday">Yesterday</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thisweek") { echo "selected"; } ?> value="thisweek">This Week</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastweek") { echo "selected"; } ?> value="lastweek">Last Week</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thismonth") { echo "selected"; } ?> value="thismonth">This Month</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastmonth") { echo "selected"; } ?> value="lastmonth">Last Month</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thisyear") { echo "selected"; } ?> value="thisyear">This Year</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastyear") { echo "selected"; } ?> value="lastyear">Last Year</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Date From</label>
|
||||
<input onchange="this.form.submit()" type="date" class="form-control" name="dtf" max="2999-12-31" value="<?php echo $dtf; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Date To</label>
|
||||
<input onchange="this.form.submit()" type="date" class="form-control" name="dtt" max="2999-12-31" value="<?php echo $dtt; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<form id="bulkActions" action="post.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
|
||||
<div class="table-responsive-sm">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?> text-nowrap">
|
||||
<tr>
|
||||
<td class="bg-light pr-0">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
|
||||
</div>
|
||||
</td>
|
||||
<th>
|
||||
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=invoice_number&order=<?php echo $disp ?>">
|
||||
Number <?php if ($sort == 'invoice_number') { echo $order_icon; } ?>
|
||||
|
|
@ -318,6 +338,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
?>
|
||||
|
||||
<tr>
|
||||
<td class="pr-0 bg-light">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input bulk-select" type="checkbox" name="invoice_ids[]" value="<?php echo $invoice_id ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-bold">
|
||||
<a href="invoice.php?<?php echo $client_url; ?>invoice_id=<?php echo $invoice_id; ?>">
|
||||
<?php echo "$invoice_prefix$invoice_number"; ?>
|
||||
|
|
@ -402,10 +427,14 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php require_once "includes/filter_footer.php";
|
||||
?>
|
||||
</div>
|
||||
<?php require_once "modals/invoice_bulk_edit_category_modal.php"; ?>
|
||||
</form>
|
||||
<?php require_once "includes/filter_footer.php";
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/bulk_actions.js"></script>
|
||||
|
||||
<?php
|
||||
require_once "modals/invoice_add_modal.php";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<div class="modal" id="bulkEditCategoryModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-list mr-2"></i>Bulk Set Category</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Category <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="bulk_category_id">
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Income' AND category_archived_at IS NULL ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = nullable_htmlentities($row['category_name']);
|
||||
?>
|
||||
<option value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="submit" name="bulk_edit_invoice_category" class="btn btn-primary text-bold"><i class="fa fa-fw fa-check mr-2"></i>Set</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2082,4 +2082,46 @@ if (isset($_GET['export_invoice_pdf'])) {
|
|||
$pdf->Output("$filename.pdf", 'I');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['bulk_edit_invoice_category'])) {
|
||||
|
||||
$category_id = intval($_POST['bulk_category_id']);
|
||||
|
||||
// Get Category name for logging and Notification
|
||||
$sql = mysqli_query($mysqli,"SELECT category_name FROM categories WHERE category_id = $category_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$category_name = sanitizeInput($row['category_name']);
|
||||
|
||||
// Assign Income category to Selected Invoices
|
||||
if (isset($_POST['invoice_ids'])) {
|
||||
|
||||
// Get Selected Count
|
||||
$count = count($_POST['invoice_ids']);
|
||||
|
||||
foreach($_POST['invoice_ids'] as $invoice_id) {
|
||||
$invoice_id = intval($invoice_id);
|
||||
|
||||
// Get Invoice Details for Logging
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$invoice_prefix = sanitizeInput($row['invoice_prefix']);
|
||||
$invoice_number = intval($row['invoice_number']);
|
||||
$invoice_scope = sanitizeInput($row['invoice_scope']);
|
||||
$client_id = intval($row['invoice_client_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_category_id = $category_id WHERE invoice_id = $invoice_id");
|
||||
|
||||
// Logging
|
||||
logAction("Invoice", "Edit", "$session_name assigned Invoice $invoice_prefix$invoice_number to category $category_name", $client_id, $invoice_id);
|
||||
|
||||
} // End Assign Loop
|
||||
|
||||
// Logging
|
||||
logAction("Invoice", "Bulk Edit", "$session_name assigned $count invoices to category $category_name");
|
||||
|
||||
$_SESSION['alert_message'] = "Assigned income category <strong>$category_name</strong> to <strong>$count</strong> invoice(s)";
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
Loading…
Reference in New Issue