| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
interface SH4_Employees_IPresenter |
| 3 |
{ |
| 4 |
public function presentTitle( SH4_Employees_Model $employee ); |
| 5 |
public function export( SH4_Employees_Model $model, $withContacts = true ); |
| 6 |
} |
| 7 |
|
| 8 |
class SH4_Employees_Presenter implements SH4_Employees_IPresenter |
| 9 |
{ |
| 10 |
public $self, $ui, $settings, $appQuery; |
| 11 |
|
| 12 |
public function __construct( |
| 13 |
HC3_Hooks $hooks, |
| 14 |
HC3_Settings $settings, |
| 15 |
SH4_App_Query $appQuery, |
| 16 |
HC3_Ui $ui |
| 17 |
) |
| 18 |
{ |
| 19 |
$this->ui = $ui; |
| 20 |
$this->settings = $hooks->wrap( $settings ); |
| 21 |
$this->appQuery = $hooks->wrap($appQuery); |
| 22 |
} |
| 23 |
|
| 24 |
public function export( SH4_Employees_Model $model, $withContacts = true ) |
| 25 |
{ |
| 26 |
$ret = array(); |
| 27 |
|
| 28 |
$ret['id'] = $model->getId(); |
| 29 |
$ret['title'] = $model->getTitle(); |
| 30 |
if( $withContacts ){ |
| 31 |
$user = $this->appQuery->findUserByEmployee( $model ); |
| 32 |
$ret['email'] = $user ? $user->getEmail() : null; |
| 33 |
$ret['username'] = $user ? $user->getUsername() : null; |
| 34 |
} |
| 35 |
|
| 36 |
return $ret; |
| 37 |
} |
| 38 |
|
| 39 |
public function presentDescription( SH4_Employees_Model $employee ) |
| 40 |
{ |
| 41 |
$return = $employee->getDescription(); |
| 42 |
|
| 43 |
// if( defined('WPINC') ){ |
| 44 |
// $return = do_shortcode( $return ); |
| 45 |
// } |
| 46 |
|
| 47 |
return $return; |
| 48 |
} |
| 49 |
|
| 50 |
public function presentTitle( SH4_Employees_Model $employee ) |
| 51 |
{ |
| 52 |
$ret = $employee->getTitle(); |
| 53 |
$ret = esc_html( $ret ); |
| 54 |
|
| 55 |
$showUserEmployee = $this->settings->get('shifts_show_employee_user'); |
| 56 |
if( $showUserEmployee ){ |
| 57 |
$user = $this->appQuery->findUserByEmployee( $employee ); |
| 58 |
if( $user ){ |
| 59 |
$userView = $user->getUsername(); |
| 60 |
$userView = esc_html( $userView ); |
| 61 |
$ret .= ' (' . $userView . ')'; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
if( $employee->isArchived() ){ |
| 66 |
$ret .= ' [' . '__Archived__' . ']'; |
| 67 |
} |
| 68 |
|
| 69 |
return $ret; |
| 70 |
} |
| 71 |
} |