mirror of
https://github.com/itflow-org/itflow
synced 2026-08-05 15:17:17 +00:00
Feature: On all export modals added Filter Tab and Selectable Columns tab with default selected, also you can now export to a PDF
This commit is contained in:
@@ -2,21 +2,61 @@
|
||||
|
||||
require_once '../../../includes/modal_header.php';
|
||||
|
||||
enforceUserPermission('module_financial');
|
||||
|
||||
// Pre-filled from the expenses page's current filters. Everything here is editable -
|
||||
// the export runs whatever this form posts, not whatever the page happened to show.
|
||||
$client_id = intval($_GET['client_id'] ?? 0);
|
||||
if ($client_id) {
|
||||
enforceClientAccess();
|
||||
}
|
||||
|
||||
// Search Filter
|
||||
$q_filter = $_GET['q'] ?? '';
|
||||
|
||||
// Account Filter
|
||||
$account_filter = intval($_GET['account'] ?? 0);
|
||||
|
||||
// Vendor Filter
|
||||
$vendor_filter = intval($_GET['vendor'] ?? 0);
|
||||
|
||||
// Category Filter
|
||||
$category_filter = intval($_GET['category'] ?? 0);
|
||||
|
||||
// Date Filter - the all-time sentinels from filter_header.php leave the fields blank
|
||||
$date_from_filter = (!empty($_GET['dtf']) && $_GET['dtf'] !== '1970-01-01') ? escapeHtml($_GET['dtf']) : '';
|
||||
$date_to_filter = (!empty($_GET['dtt']) && $_GET['dtt'] !== '2099-12-31') ? escapeHtml($_GET['dtt']) : '';
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-download mr-2"></i>Exporting Expenses to CSV</h5>
|
||||
<h5 class="modal-title"><i class="fas fa-fw fa-download mr-2"></i>Export Expenses</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php exportTabsNav(); ?>
|
||||
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<?php exportTabsFiltersOpen(); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Search</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-search"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="q" value="<?= stripslashes(escapeHtml($q_filter)) ?>" placeholder="Vendor, client, category, description">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Account</label>
|
||||
<div class="input-group">
|
||||
@@ -25,18 +65,16 @@ ob_start();
|
||||
</div>
|
||||
<select class="form-control select2" name="account">
|
||||
<option value="">- All Accounts -</option>
|
||||
|
||||
<?php
|
||||
$sql_accounts_filter = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_accounts_filter)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']);
|
||||
$sql_account_filter = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_account_filter)) {
|
||||
$filter_option_id = intval($row['account_id']);
|
||||
$filter_option_name = escapeHtml($row['account_name']);
|
||||
?>
|
||||
<option <?php if ($account_filter == $account_id) { echo "selected"; } ?> value="<?= $account_id ?>"><?= $account_name ?></option>
|
||||
<option <?php if ($account_filter == $filter_option_id) { echo "selected"; } ?> value="<?= $filter_option_id ?>"><?= $filter_option_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,18 +87,16 @@ ob_start();
|
||||
</div>
|
||||
<select class="form-control select2" name="vendor">
|
||||
<option value="">- All Vendors -</option>
|
||||
|
||||
<?php
|
||||
$sql_vendors_filter = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_client_id = 0 ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_vendors_filter)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = escapeHtml($row['vendor_name']);
|
||||
$sql_vendor_filter = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE EXISTS (SELECT 1 FROM expenses WHERE expense_vendor_id = vendor_id) ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_vendor_filter)) {
|
||||
$filter_option_id = intval($row['vendor_id']);
|
||||
$filter_option_name = escapeHtml($row['vendor_name']);
|
||||
?>
|
||||
<option <?php if ($vendor_filter == $vendor_id) { echo "selected"; } ?> value="<?= $vendor_id ?>"><?= $vendor_name ?></option>
|
||||
<option <?php if ($vendor_filter == $filter_option_id) { echo "selected"; } ?> value="<?= $filter_option_id ?>"><?= $filter_option_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,46 +109,45 @@ ob_start();
|
||||
</div>
|
||||
<select class="form-control select2" name="category">
|
||||
<option value="">- All Categories -</option>
|
||||
|
||||
<?php
|
||||
$sql_categories_filter = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Expense' ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_filter)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = escapeHtml($row['category_name']);
|
||||
$sql_category_filter = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Expense' ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_category_filter)) {
|
||||
$filter_option_id = intval($row['category_id']);
|
||||
$filter_option_name = escapeHtml($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($category_filter == $category_id) { echo "selected"; } ?> value="<?= $category_id ?>"><?= $category_name ?></option>
|
||||
<option <?php if ($category_filter == $filter_option_id) { echo "selected"; } ?> value="<?= $filter_option_id ?>"><?= $filter_option_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Date From</label>
|
||||
<label>Dated From</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="date" class="form-control" name="date_from" max="2999-12-31">
|
||||
<input type="date" class="form-control" name="dtf" value="<?= $date_from_filter ?>" max="2999-12-31">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Date To</label>
|
||||
<label>Dated To</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="date" class="form-control" name="date_to" max="2999-12-31">
|
||||
<input type="date" class="form-control" name="dtt" value="<?= $date_to_filter ?>" max="2999-12-31">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php exportTabsColumns('expenses'); ?>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" name="export_expenses_csv" class="btn btn-primary text-bold"><i class="fas fa-fw fa-download mr-2"></i>Download CSV</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||
<?php renderExportButtons('export_expenses'); ?>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user