engelsystem/includes/model/ShiftsFilter.php

168 lines
2.9 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
{
2017-01-02 15:43:36 +01:00
/**
* 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-03 03:22:48 +01:00
/** @var int[] */
2017-01-02 03:57:23 +01:00
private $filled = [];
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/** @var int[] */
2017-01-02 03:57:23 +01:00
private $rooms = [];
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/** @var int[] */
2017-01-02 03:57:23 +01:00
private $types = [];
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/** @var int unix timestamp */
2017-01-02 03:57:23 +01:00
private $startTime = null;
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/** @var int unix timestamp */
2017-01-02 03:57:23 +01:00
private $endTime = null;
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/**
* ShiftsFilter constructor.
*
* @param bool $user_shifts_admin
* @param int[] $rooms
* @param int[] $types
*/
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-03 03:22:48 +01:00
/**
* @return int unix timestamp
*/
2017-01-02 03:57:23 +01:00
public function getStartTime()
{
return $this->startTime;
}
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/**
* @param int $startTime unix timestamp
*/
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-03 03:22:48 +01:00
/**
* @return int unix timestamp
*/
2017-01-02 03:57:23 +01:00
public function getEndTime()
{
return $this->endTime;
}
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/**
* @param int $endTime unix timestamp
*/
2017-01-02 03:57:23 +01:00
public function setEndTime($endTime)
{
$this->endTime = $endTime;
}
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/**
* @return int[]
*/
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-03 03:22:48 +01:00
/**
* @param int[] $types
*/
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-03 03:22:48 +01:00
/**
* @return int[]
*/
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-03 03:22:48 +01:00
/**
* @param int[] $rooms
*/
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-03 03:22:48 +01:00
/**
* @return bool
*/
2017-01-02 03:57:23 +01:00
public function isUserShiftsAdmin()
{
return $this->userShiftsAdmin;
}
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/**
* @param bool $userShiftsAdmin
*/
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-03 03:22:48 +01:00
/**
* @return int[]
*/
2017-01-02 03:57:23 +01:00
public function getFilled()
{
return $this->filled;
}
2016-10-03 17:41:14 +02:00
2017-01-03 03:22:48 +01:00
/**
* @param int[] $filled
*/
2017-01-02 03:57:23 +01:00
public function setFilled($filled)
{
$this->filled = $filled;
}
2016-10-03 17:41:14 +02:00
}