| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Schedule_Html_View_MiscOptions |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Hooks $hooks, |
| 7 |
HC3_Ui $ui, |
| 8 |
HC3_Request $request, |
| 9 |
|
| 10 |
SH4_Shifts_Duration $shiftsDuration, |
| 11 |
SH4_Schedule_Html_View_Common $common |
| 12 |
) |
| 13 |
{ |
| 14 |
$this->self = $hooks->wrap( $this ); |
| 15 |
$this->ui = $ui; |
| 16 |
$this->request = $request; |
| 17 |
|
| 18 |
$this->shiftsDuration = $hooks->wrap( $shiftsDuration ); |
| 19 |
$this->common = $hooks->wrap( $common ); |
| 20 |
} |
| 21 |
|
| 22 |
public function render() |
| 23 |
{ |
| 24 |
$options = $this->self->options(); |
| 25 |
|
| 26 |
if( ! array_key_exists(1, $options) ){ |
| 27 |
$options[1] = NULL; |
| 28 |
} |
| 29 |
if( ! array_key_exists(2, $options) ){ |
| 30 |
$options[2] = NULL; |
| 31 |
} |
| 32 |
if( ! array_key_exists(3, $options) ){ |
| 33 |
$options[3] = NULL; |
| 34 |
} |
| 35 |
|
| 36 |
$out = $this->ui->makeGrid() |
| 37 |
->add( $options[1], 3, 12 ) |
| 38 |
->add( $options[2], 7, 12 ) |
| 39 |
->add( $options[3], 2, 12 ) |
| 40 |
; |
| 41 |
|
| 42 |
return $out; |
| 43 |
} |
| 44 |
|
| 45 |
public function options() |
| 46 |
{ |
| 47 |
$out = array(); |
| 48 |
|
| 49 |
$shifts = $this->common->getShifts(); |
| 50 |
$this->shiftsDuration->reset(); |
| 51 |
|
| 52 |
$counted = 0; |
| 53 |
|
| 54 |
foreach( $shifts as $shift ){ |
| 55 |
$shiftCalendar = $shift->getCalendar(); |
| 56 |
// if( ! $shiftCalendar->isShift() ){ |
| 57 |
// continue; |
| 58 |
// } |
| 59 |
$this->shiftsDuration->add( $shift ); |
| 60 |
$counted++; |
| 61 |
} |
| 62 |
|
| 63 |
if( $counted ){ |
| 64 |
$out[] = $this->common->renderReport( $this->shiftsDuration, FALSE ); |
| 65 |
} |
| 66 |
|
| 67 |
$out = $this->ui->makeListInline( $out ) |
| 68 |
->gutter(1) |
| 69 |
; |
| 70 |
|
| 71 |
$return = array(); |
| 72 |
$return[1] = $out; |
| 73 |
|
| 74 |
return $return; |
| 75 |
} |
| 76 |
} |