bring back session filter store
This commit is contained in:
parent
5e66007f06
commit
d59809d6d2
|
@ -34,13 +34,18 @@ function user_shifts() {
|
||||||
* @return the updated ShiftsFilter
|
* @return the updated ShiftsFilter
|
||||||
*/
|
*/
|
||||||
function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days) {
|
function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days) {
|
||||||
global $privileges;
|
|
||||||
|
|
||||||
$shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
|
$shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
|
||||||
|
if (isset($_REQUEST['filled'])) {
|
||||||
$shiftsFilter->setFilled(check_request_int_array('filled'));
|
$shiftsFilter->setFilled(check_request_int_array('filled'));
|
||||||
|
}
|
||||||
|
if (isset($_REQUEST['rooms'])) {
|
||||||
$shiftsFilter->setRooms(check_request_int_array('rooms'));
|
$shiftsFilter->setRooms(check_request_int_array('rooms'));
|
||||||
|
}
|
||||||
|
if (isset($_REQUEST['types'])) {
|
||||||
$shiftsFilter->setTypes(check_request_int_array('types'));
|
$shiftsFilter->setTypes(check_request_int_array('types'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isset($_REQUEST['start_time']) && isset($_REQUEST['start_day']) && isset($_REQUEST['end_time']) && isset($_REQUEST['end_day'])) || $shiftsFilter->getStartTime() == null || $shiftsFilter->getEndTime() == null) {
|
||||||
$day = date('Y-m-d', time());
|
$day = date('Y-m-d', time());
|
||||||
$start_day = in_array($day, $days) ? $day : min($days);
|
$start_day = in_array($day, $days) ? $day : min($days);
|
||||||
if (isset($_REQUEST['start_day']) && in_array($_REQUEST['start_day'], $days)) {
|
if (isset($_REQUEST['start_day']) && in_array($_REQUEST['start_day'], $days)) {
|
||||||
|
@ -75,6 +80,7 @@ function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $da
|
||||||
|
|
||||||
$enddatetime = DateTime::createFromFormat("Y-m-d H:i", $end_day . " " . $end_time);
|
$enddatetime = DateTime::createFromFormat("Y-m-d H:i", $end_day . " " . $end_time);
|
||||||
$shiftsFilter->setEndTime($enddatetime->getTimestamp());
|
$shiftsFilter->setEndTime($enddatetime->getTimestamp());
|
||||||
|
}
|
||||||
|
|
||||||
return $shiftsFilter;
|
return $shiftsFilter;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +125,7 @@ function view_user_shifts() {
|
||||||
$type_ids = array_map('get_ids_from_array', $types);
|
$type_ids = array_map('get_ids_from_array', $types);
|
||||||
$_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
|
$_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
|
||||||
}
|
}
|
||||||
$_SESSION['ShiftsFilter'] = update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
|
update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
|
||||||
$shiftsFilter = $_SESSION['ShiftsFilter'];
|
$shiftsFilter = $_SESSION['ShiftsFilter'];
|
||||||
|
|
||||||
$shifts = Shifts_by_ShiftsFilter($shiftsFilter, $user);
|
$shifts = Shifts_by_ShiftsFilter($shiftsFilter, $user);
|
||||||
|
|
Loading…
Reference in New Issue