| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Employees_Html_Admin_View_Edit |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Hooks $hooks, |
| 7 |
HC3_Ui $ui, |
| 8 |
HC3_Ui_Layout1 $layout, |
| 9 |
SH4_Employees_Query $query |
| 10 |
) |
| 11 |
{ |
| 12 |
$this->ui = $ui; |
| 13 |
$this->layout = $layout; |
| 14 |
$this->query = $hooks->wrap($query); |
| 15 |
$this->self = $hooks->wrap($this); |
| 16 |
} |
| 17 |
|
| 18 |
public function render( $id ) |
| 19 |
{ |
| 20 |
$model = $this->query->findById($id); |
| 21 |
|
| 22 |
$form = $this->ui->makeForm( |
| 23 |
'admin/employees/' . $id, |
| 24 |
$this->self->form( $model ) |
| 25 |
); |
| 26 |
|
| 27 |
$this->layout |
| 28 |
->setContent( $form ) |
| 29 |
->setBreadcrumb( $this->self->breadcrumb($model) ) |
| 30 |
->setHeader( $this->self->header($model) ) |
| 31 |
->setMenu( $this->self->menu($model) ) |
| 32 |
; |
| 33 |
|
| 34 |
$out = $this->layout->render(); |
| 35 |
return $out; |
| 36 |
} |
| 37 |
|
| 38 |
public function menu( $model ) |
| 39 |
{ |
| 40 |
$ret = array(); |
| 41 |
return $ret; |
| 42 |
} |
| 43 |
|
| 44 |
public function header( $model ) |
| 45 |
{ |
| 46 |
$out = '__Edit__'; |
| 47 |
return $out; |
| 48 |
} |
| 49 |
|
| 50 |
public function breadcrumb( $model ) |
| 51 |
{ |
| 52 |
$return = array(); |
| 53 |
$return['admin'] = array( 'admin', '__Administration__' ); |
| 54 |
$return['employees'] = array( 'admin/employees', '__Employees__' ); |
| 55 |
return $return; |
| 56 |
} |
| 57 |
|
| 58 |
public function form( $model ) |
| 59 |
{ |
| 60 |
$inputs = array(); |
| 61 |
$idView = $model->getId(); |
| 62 |
|
| 63 |
$idLabel = $this->ui->makeBlock('id') |
| 64 |
->tag('mute') |
| 65 |
->tag('font-size', 2) |
| 66 |
; |
| 67 |
$idView = $this->ui->makeListInline( array($idLabel, $idView) ) |
| 68 |
->gutter(1) |
| 69 |
; |
| 70 |
|
| 71 |
$inputs['id'] = $idView; |
| 72 |
$inputs['title'] = $this->ui->makeInputText( 'title', '__Title__', $model->getTitle() )->bold(); |
| 73 |
$inputs['description'] = $this->ui->makeInputRichTextarea( 'description', '__Description__', $model->getDescription() )->setRows(6); |
| 74 |
|
| 75 |
$inputs = $this->ui->makeList( $inputs ); |
| 76 |
|
| 77 |
$buttons = $this->ui->makeInputSubmit( '__Save__' ) |
| 78 |
->tag('primary') |
| 79 |
; |
| 80 |
|
| 81 |
$out = $this->ui->makeList() |
| 82 |
->add( $inputs ) |
| 83 |
->add( $buttons ) |
| 84 |
; |
| 85 |
|
| 86 |
return $out; |
| 87 |
} |
| 88 |
} |
| 89 |
|