|
71 | 71 | // Date Handling |
72 | 72 | if (empty($_GET['canned_date'])) { |
73 | 73 | //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 |
75 | 75 | $_GET['canned_date'] = 'custom'; |
76 | 76 | } |
77 | 77 |
|
78 | 78 | // 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'])) { |
80 | 87 | $dtf = sanitizeInput($_GET['dtf']); |
81 | 88 | $dtt = sanitizeInput($_GET['dtt']); |
82 | 89 | } elseif ($_GET['canned_date'] == "today") { |
|
86 | 93 | $dtf = date('Y-m-d', strtotime("yesterday")); |
87 | 94 | $dtt = date('Y-m-d', strtotime("yesterday")); |
88 | 95 | } 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")); |
91 | 98 | } 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")); |
94 | 101 | } elseif ($_GET['canned_date'] == "thismonth") { |
95 | 102 | $dtf = date('Y-m-01'); |
96 | | - $dtt = date('Y-m-d'); |
| 103 | + $dtt = date('Y-m-d', strtotime("last day of this month")); |
97 | 104 | } elseif ($_GET['canned_date'] == "lastmonth") { |
98 | 105 | $dtf = date('Y-m-d', strtotime("first day of last month")); |
99 | 106 | $dtt = date('Y-m-d', strtotime("last day of last month")); |
100 | 107 | } elseif ($_GET['canned_date'] == "thisyear") { |
101 | 108 | $dtf = date('Y-01-01'); |
102 | | - $dtt = date('Y-m-d'); |
| 109 | + $dtt = date('Y-m-d', strtotime("last day of december this year")); |
103 | 110 | } elseif ($_GET['canned_date'] == "lastyear") { |
104 | 111 | $dtf = date('Y-m-d', strtotime("first day of january last year")); |
105 | 112 | $dtt = date('Y-m-d', strtotime("last day of december last year")); |
106 | 113 | } else { |
107 | 114 | $dtf = "NULL"; |
108 | | - $dtt = date('Y-m-d'); |
| 115 | + $dtt = date('Y-m-d', strtotime("last day of this month")); |
109 | 116 | } |
110 | 117 |
|
111 | 118 | // Archived |
|
0 commit comments