engelsystem/includes/model/ShiftsFilter.php

130 lines
2.3 KiB
PHP
Raw Normal View History

2016-10-03 17:41:14 +02:00
<?php
namespace Engelsystem;
/**
* BO Class that stores all parameters used to filter shifts for users.
*
* @author msquare
*/
2017-01-02 03:57:23 +01:00
class ShiftsFilter
{
2016-10-03 17:41:14 +02:00
2017-01-02 15:43:36 +01:00
/**
* 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;
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
private $filled = [];
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
private $rooms = [];
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
private $types = [];
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
private $startTime = null;
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
private $endTime = null;
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function __construct($user_shifts_admin, $rooms, $types)
{
$this->user_shifts_admin = $user_shifts_admin;
$this->rooms = $rooms;
$this->types = $types;
2017-01-02 15:43:36 +01:00
2017-01-02 03:57:23 +01:00
$this->filled = [
2017-01-02 15:43:36 +01:00
ShiftsFilter::FILLED_FREE
];
2017-01-02 03:57:23 +01:00
if ($user_shifts_admin) {
$this->filled[] = ShiftsFilter::FILLED_FILLED;
}
2016-10-03 17:41:14 +02:00
}
2017-01-02 03:57:23 +01:00
public function getStartTime()
{
return $this->startTime;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function setStartTime($startTime)
{
$this->startTime = $startTime;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function getEndTime()
{
return $this->endTime;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function setEndTime($endTime)
{
if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
$endTime = $this->startTime + ShiftsFilter::MAX_DURATION;
}
$this->endTime = $endTime;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function getTypes()
{
if (count($this->types) == 0) {
2017-01-02 15:43:36 +01:00
return [0];
2017-01-02 03:57:23 +01:00
}
return $this->types;
2016-10-03 17:41:14 +02:00
}
2017-01-02 03:57:23 +01:00
public function setTypes($types)
{
$this->types = $types;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function getRooms()
{
if (count($this->rooms) == 0) {
2017-01-02 15:43:36 +01:00
return [0];
2017-01-02 03:57:23 +01:00
}
return $this->rooms;
2016-10-03 17:41:14 +02:00
}
2017-01-02 03:57:23 +01:00
public function setRooms($rooms)
{
$this->rooms = $rooms;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function isUserShiftsAdmin()
{
return $this->userShiftsAdmin;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function setUserShiftsAdmin($userShiftsAdmin)
{
$this->userShiftsAdmin = $userShiftsAdmin;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function getFilled()
{
return $this->filled;
}
2016-10-03 17:41:14 +02:00
2017-01-02 03:57:23 +01:00
public function setFilled($filled)
{
$this->filled = $filled;
}
2016-10-03 17:41:14 +02:00
}