From b3e8ee26bb580a61945acd245c4720c5d490a0ef Mon Sep 17 00:00:00 2001 From: ThaMunsta Date: Wed, 23 Oct 2024 13:56:31 -0400 Subject: [PATCH] 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. --- filter_header.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/filter_header.php b/filter_header.php index 1b9e33944..1f11e9b4e 100644 --- a/filter_header.php +++ b/filter_header.php @@ -71,12 +71,19 @@ // Date Handling 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 + // $dtf and $dtt will be set by the below else to 0000-00-00 / end of the month $_GET['canned_date'] = 'custom'; } // Date Filter -if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf'])) { +$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT user_config_calendar_first_day FROM user_settings WHERE user_id = $session_user_id")); +if (intval($row['user_config_calendar_first_day']) == 1){ + $user_config_calendar_first_day = "monday"; +} else { + $user_config_calendar_first_day = "sunday"; +} + +if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf']) || !empty($_GET['dtt'])) { $dtf = sanitizeInput($_GET['dtf']); $dtt = sanitizeInput($_GET['dtt']); } elseif ($_GET['canned_date'] == "today") { @@ -86,26 +93,26 @@ $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'); + $dtf = date('Y-m-d', strtotime("last $user_config_calendar_first_day")); + $dtt = date('Y-m-d', strtotime("last $user_config_calendar_first_day + 6 days")); } elseif ($_GET['canned_date'] == "lastweek") { - $dtf = date('Y-m-d', strtotime("monday last week")); - $dtt = date('Y-m-d', strtotime("sunday last week")); + $dtf = date('Y-m-d', strtotime("last $user_config_calendar_first_day -7 days")); + $dtt = date('Y-m-d', strtotime("last $user_config_calendar_first_day - 1 days")); } elseif ($_GET['canned_date'] == "thismonth") { $dtf = date('Y-m-01'); - $dtt = date('Y-m-d'); + $dtt = date('Y-m-d', strtotime("last day of this month")); } 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'); + $dtt = date('Y-m-d', strtotime("last day of december this year")); } 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 = "NULL"; - $dtt = date('Y-m-d'); + $dtt = date('Y-m-d', strtotime("last day of this month")); } // Archived