You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.3 KiB
PHTML

<?php
namespace Engelsystem;
/**
* BO Class that stores all parameters used to filter shifts for users.
*
* @author msquare
*/
8 years ago
class ShiftsFilter
{
8 years ago
/**
* How long can the time interval be?
*/
const MAX_DURATION = 86400;
// one day
/**
* Shift is completely full.
*/
const FILLED_FILLED = 1;
/**
* Shift has some free slots.
*/
const FILLED_FREE = 0;
/**
* Has the user "user shifts admin" privilege?
*
* @var boolean
*/
private $userShiftsAdmin;
8 years ago
private $filled = [];
8 years ago
private $rooms = [];
8 years ago
private $types = [];
8 years ago
private $startTime = null;
8 years ago
private $endTime = null;
8 years ago
public function __construct($user_shifts_admin, $rooms, $types)
{
$this->user_shifts_admin = $user_shifts_admin;
$this->rooms = $rooms;
$this->types = $types;
8 years ago
8 years ago
$this->filled = [
8 years ago
ShiftsFilter::FILLED_FREE
];
8 years ago
if ($user_shifts_admin) {
$this->filled[] = ShiftsFilter::FILLED_FILLED;
}
}
8 years ago
public function getStartTime()
{
return $this->startTime;
}
8 years ago
public function setStartTime($startTime)
{
$this->startTime = $startTime;
}
8 years ago
public function getEndTime()
{
return $this->endTime;
}
8 years ago
public function setEndTime($endTime)
{
if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
$endTime = $this->startTime + ShiftsFilter::MAX_DURATION;
}
$this->endTime = $endTime;
}
8 years ago
public function getTypes()
{
if (count($this->types) == 0) {
8 years ago
return [0];
8 years ago
}
return $this->types;
}
8 years ago
public function setTypes($types)
{
$this->types = $types;
}
8 years ago
public function getRooms()
{
if (count($this->rooms) == 0) {
8 years ago
return [0];
8 years ago
}
return $this->rooms;
}
8 years ago
public function setRooms($rooms)
{
$this->rooms = $rooms;
}
8 years ago
public function isUserShiftsAdmin()
{
return $this->userShiftsAdmin;
}
8 years ago
public function setUserShiftsAdmin($userShiftsAdmin)
{
$this->userShiftsAdmin = $userShiftsAdmin;
}
8 years ago
public function getFilled()
{
return $this->filled;
}
8 years ago
public function setFilled($filled)
{
$this->filled = $filled;
}
}