Skip to content

Commit b3e8ee2

Browse files
authored
Update filter_header.php
Change to filters for better experience and address an issue where by default its difficult to see new stripe expenses since they are added as "tomorrow" date and many filters exclude tomorrow. This will also take into account the users preference on start of week.
1 parent 808fdf5 commit b3e8ee2

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

filter_header.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,19 @@
7171
// Date Handling
7272
if (empty($_GET['canned_date'])) {
7373
//Prevents lots of undefined variable errors.
74-
// $dtf and $dtt will be set by the below else to 0000-00-00 / 9999-00-00
74+
// $dtf and $dtt will be set by the below else to 0000-00-00 / end of the month
7575
$_GET['canned_date'] = 'custom';
7676
}
7777

7878
// Date Filter
79-
if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf'])) {
79+
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT user_config_calendar_first_day FROM user_settings WHERE user_id = $session_user_id"));
80+
if (intval($row['user_config_calendar_first_day']) == 1){
81+
$user_config_calendar_first_day = "monday";
82+
} else {
83+
$user_config_calendar_first_day = "sunday";
84+
}
85+
86+
if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf']) || !empty($_GET['dtt'])) {
8087
$dtf = sanitizeInput($_GET['dtf']);
8188
$dtt = sanitizeInput($_GET['dtt']);
8289
} elseif ($_GET['canned_date'] == "today") {
@@ -86,26 +93,26 @@
8693
$dtf = date('Y-m-d', strtotime("yesterday"));
8794
$dtt = date('Y-m-d', strtotime("yesterday"));
8895
} elseif ($_GET['canned_date'] == "thisweek") {
89-
$dtf = date('Y-m-d', strtotime("monday this week"));
90-
$dtt = date('Y-m-d');
96+
$dtf = date('Y-m-d', strtotime("last $user_config_calendar_first_day"));
97+
$dtt = date('Y-m-d', strtotime("last $user_config_calendar_first_day + 6 days"));
9198
} elseif ($_GET['canned_date'] == "lastweek") {
92-
$dtf = date('Y-m-d', strtotime("monday last week"));
93-
$dtt = date('Y-m-d', strtotime("sunday last week"));
99+
$dtf = date('Y-m-d', strtotime("last $user_config_calendar_first_day -7 days"));
100+
$dtt = date('Y-m-d', strtotime("last $user_config_calendar_first_day - 1 days"));
94101
} elseif ($_GET['canned_date'] == "thismonth") {
95102
$dtf = date('Y-m-01');
96-
$dtt = date('Y-m-d');
103+
$dtt = date('Y-m-d', strtotime("last day of this month"));
97104
} elseif ($_GET['canned_date'] == "lastmonth") {
98105
$dtf = date('Y-m-d', strtotime("first day of last month"));
99106
$dtt = date('Y-m-d', strtotime("last day of last month"));
100107
} elseif ($_GET['canned_date'] == "thisyear") {
101108
$dtf = date('Y-01-01');
102-
$dtt = date('Y-m-d');
109+
$dtt = date('Y-m-d', strtotime("last day of december this year"));
103110
} elseif ($_GET['canned_date'] == "lastyear") {
104111
$dtf = date('Y-m-d', strtotime("first day of january last year"));
105112
$dtt = date('Y-m-d', strtotime("last day of december last year"));
106113
} else {
107114
$dtf = "NULL";
108-
$dtt = date('Y-m-d');
115+
$dtt = date('Y-m-d', strtotime("last day of this month"));
109116
}
110117

111118
// Archived

0 commit comments

Comments
 (0)