| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Schedule_Html_View_NewOptions |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
SH4_New_Acl $newAcl, |
| 7 |
HC3_Hooks $hooks, |
| 8 |
HC3_Ui $ui, |
| 9 |
HC3_Request $request |
| 10 |
) |
| 11 |
{ |
| 12 |
$this->self = $hooks->wrap( $this ); |
| 13 |
$this->ui = $ui; |
| 14 |
$this->request = $request; |
| 15 |
$this->newAcl = $hooks->wrap( $newAcl ); |
| 16 |
|
| 17 |
$this->allCombosShift = $this->newAcl->findAllCombosShift(); |
| 18 |
$this->allCombosTimeoff = $this->newAcl->findAllCombosTimeoff(); |
| 19 |
} |
| 20 |
|
| 21 |
public function render() |
| 22 |
{ |
| 23 |
$out = NULL; |
| 24 |
|
| 25 |
$options = $this->self->options(); |
| 26 |
if( ! $options ){ |
| 27 |
return $out; |
| 28 |
} |
| 29 |
|
| 30 |
$out = $this->ui->makeListInline( $options ) |
| 31 |
->gutter(2) |
| 32 |
; |
| 33 |
|
| 34 |
return $out; |
| 35 |
} |
| 36 |
|
| 37 |
public function options() |
| 38 |
{ |
| 39 |
$out = array(); |
| 40 |
|
| 41 |
$params = $this->request->getParams(); |
| 42 |
|
| 43 |
$toParams = array(); |
| 44 |
if( array_key_exists('employee', $params) && (count($params['employee']) == 1) ){ |
| 45 |
$toParams['employee'] = $params['employee'][0]; |
| 46 |
} |
| 47 |
|
| 48 |
if( $this->allCombosShift ){ |
| 49 |
$label = '+' . ' ' . '__Shift__'; |
| 50 |
$to = 'new/shift'; |
| 51 |
$to = array( $to, $toParams ); |
| 52 |
$newShiftLink = $this->ui->makeAhref( $to, $label ) |
| 53 |
->tag('secondary') |
| 54 |
; |
| 55 |
$out[] = $newShiftLink; |
| 56 |
} |
| 57 |
|
| 58 |
if( $this->allCombosTimeoff ){ |
| 59 |
$label = '+' . ' ' . '__Time Off__'; |
| 60 |
$to = 'new/timeoff'; |
| 61 |
$to = array( $to, $toParams ); |
| 62 |
$newTimeoffLink = $this->ui->makeAhref( $to, $label ) |
| 63 |
->tag('secondary') |
| 64 |
; |
| 65 |
$out[] = $newTimeoffLink; |
| 66 |
} |
| 67 |
|
| 68 |
// $label = '+' . ' ' . '__Availability__'; |
| 69 |
// $to = 'new/availability'; |
| 70 |
// $to = array( $to, $toParams ); |
| 71 |
// $newAvailabilityLink = $this->ui->makeAhref( $to, $label ) |
| 72 |
// ->tag('secondary') |
| 73 |
// ; |
| 74 |
// $out[] = $newAvailabilityLink; |
| 75 |
|
| 76 |
return $out; |
| 77 |
} |
| 78 |
} |