| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
interface SH4_Calendars_IModel |
| 3 |
{ |
| 4 |
public function isShift(); |
| 5 |
public function isAvailability(); |
| 6 |
public function isTimeoff(); |
| 7 |
public function getType(); |
| 8 |
} |
| 9 |
|
| 10 |
class SH4_Calendars_Model implements SH4_Calendars_IModel |
| 11 |
{ |
| 12 |
const STATUS_ACTIVE = 'publish'; |
| 13 |
const STATUS_ARCHIVE = 'trash'; |
| 14 |
|
| 15 |
const TYPE_SHIFT = 'shift'; |
| 16 |
const TYPE_TIMEOFF = 'timeoff'; |
| 17 |
const TYPE_AVAILABILITY = 'availability'; |
| 18 |
|
| 19 |
private $id = null; |
| 20 |
private $title = ''; |
| 21 |
private $status = self::STATUS_ACTIVE; |
| 22 |
private $color = ''; |
| 23 |
private $description = ''; |
| 24 |
private $type = 0; |
| 25 |
private $sortOrder = 1; |
| 26 |
|
| 27 |
public function __construct( $id, $title, $status = self::STATUS_ACTIVE, $color = '#cbe86b', $description = '', $type = self::TYPE_TIMEOFF, $sortOrder = 1 ) |
| 28 |
{ |
| 29 |
$this->id = $id; |
| 30 |
$this->title = $title; |
| 31 |
$this->color = $color; |
| 32 |
$this->status = $status; |
| 33 |
$this->description = $description; |
| 34 |
$this->type = $type; |
| 35 |
$this->sortOrder = $sortOrder; |
| 36 |
} |
| 37 |
|
| 38 |
public function getId() |
| 39 |
{ |
| 40 |
return $this->id; |
| 41 |
} |
| 42 |
|
| 43 |
public function getTitle() |
| 44 |
{ |
| 45 |
return $this->title; |
| 46 |
} |
| 47 |
|
| 48 |
public function getDescription() |
| 49 |
{ |
| 50 |
$ret = ( null === $this->description ) ? '' : $this->description; |
| 51 |
return $ret; |
| 52 |
} |
| 53 |
|
| 54 |
public function getColor() |
| 55 |
{ |
| 56 |
return $this->color; |
| 57 |
} |
| 58 |
|
| 59 |
public function getType() |
| 60 |
{ |
| 61 |
return $this->type; |
| 62 |
} |
| 63 |
|
| 64 |
public function isShift() |
| 65 |
{ |
| 66 |
return ( $this->type == self::TYPE_SHIFT ); |
| 67 |
} |
| 68 |
|
| 69 |
public function isAvailability() |
| 70 |
{ |
| 71 |
return ( $this->type == self::TYPE_AVAILABILITY ); |
| 72 |
} |
| 73 |
|
| 74 |
public function isTimeoff() |
| 75 |
{ |
| 76 |
return ( $this->type == self::TYPE_TIMEOFF ); |
| 77 |
} |
| 78 |
|
| 79 |
public function isActive() |
| 80 |
{ |
| 81 |
return ( $this->status == self::STATUS_ACTIVE ); |
| 82 |
} |
| 83 |
|
| 84 |
public function isArchived() |
| 85 |
{ |
| 86 |
return ( $this->status == self::STATUS_ARCHIVE ); |
| 87 |
} |
| 88 |
|
| 89 |
public function getSortOrder() |
| 90 |
{ |
| 91 |
return $this->sortOrder; |
| 92 |
} |
| 93 |
} |