mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Dedup More Pagination code you now only have to define Sortby column and its order, also fixed issue when searching by date it would close on the first query
This commit is contained in:
@@ -1,57 +1,11 @@
|
||||
<?php
|
||||
|
||||
// Default Column Sortby/Order Filter
|
||||
$sb = "recurring_next_date";
|
||||
$o = "DESC";
|
||||
|
||||
require_once("inc_all.php");
|
||||
|
||||
if (!empty($_GET['sb'])) {
|
||||
$sb = sanitizeInput($_GET['sb']);
|
||||
} else {
|
||||
$sb = "recurring_next_date";
|
||||
}
|
||||
|
||||
if (empty($_GET['canned_date'])) {
|
||||
//Prevents lots of undefined variable errors.
|
||||
// $dtf and $dtt will be set by the below else to 0000-00-00 / 9999-00-00
|
||||
$_GET['canned_date'] = 'custom';
|
||||
}
|
||||
|
||||
//Date Filter
|
||||
if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf'])) {
|
||||
$dtf = sanitizeInput($_GET['dtf']);
|
||||
$dtt = sanitizeInput($_GET['dtt']);
|
||||
} elseif ($_GET['canned_date'] == "today") {
|
||||
$dtf = date('Y-m-d');
|
||||
$dtt = date('Y-m-d');
|
||||
} elseif ($_GET['canned_date'] == "yesterday") {
|
||||
$dtf = date('Y-m-d', strtotime("yesterday"));
|
||||
$dtt = date('Y-m-d', strtotime("yesterday"));
|
||||
} elseif ($_GET['canned_date'] == "thisweek") {
|
||||
$dtf = date('Y-m-d', strtotime("monday this week"));
|
||||
$dtt = date('Y-m-d');
|
||||
} elseif ($_GET['canned_date'] == "lastweek") {
|
||||
$dtf = date('Y-m-d', strtotime("monday last week"));
|
||||
$dtt = date('Y-m-d', strtotime("sunday last week"));
|
||||
} elseif ($_GET['canned_date'] == "thismonth") {
|
||||
$dtf = date('Y-m-01');
|
||||
$dtt = date('Y-m-d');
|
||||
} elseif ($_GET['canned_date'] == "lastmonth") {
|
||||
$dtf = date('Y-m-d', strtotime("first day of last month"));
|
||||
$dtt = date('Y-m-d', strtotime("last day of last month"));
|
||||
} elseif ($_GET['canned_date'] == "thisyear") {
|
||||
$dtf = date('Y-01-01');
|
||||
$dtt = date('Y-m-d');
|
||||
} elseif ($_GET['canned_date'] == "lastyear") {
|
||||
$dtf = date('Y-m-d', strtotime("first day of january last year"));
|
||||
$dtt = date('Y-m-d', strtotime("last day of december last year"));
|
||||
} else {
|
||||
$dtf = "0000-00-00";
|
||||
$dtt = "9999-00-00";
|
||||
}
|
||||
|
||||
if (empty($_GET['canned_date'])) {
|
||||
//Prevents lots of undefined variable errors.
|
||||
// $dtf and $dtt will be set by the below else to 0000-00-00 / 9999-00-00
|
||||
$_GET['canned_date'] = 'custom';
|
||||
}
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
@@ -62,7 +16,7 @@ $sql = mysqli_query(
|
||||
LEFT JOIN categories ON recurring_category_id = category_id
|
||||
WHERE recurring.company_id = $session_company_id
|
||||
AND (CONCAT(recurring_prefix,recurring_number) LIKE '%$q%' OR recurring_frequency LIKE '%$q%' OR recurring_scope LIKE '%$q%' OR client_name LIKE '%$q%' OR category_name LIKE '%$q%')
|
||||
AND DATE(recurring_next_date) BETWEEN '$dtf' AND '$dtt'
|
||||
AND DATE(recurring_last_sent) BETWEEN '$dtf' AND '$dtt'
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
@@ -90,7 +44,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse mt-3 <?php if (!empty($_GET['dtf'])) { echo "show"; } ?>" id="advancedFilter">
|
||||
<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">
|
||||
|
||||
Reference in New Issue
Block a user