| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Reminders_Html_Admin_Templates |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Ui $ui, |
| 7 |
HC3_Time $t, |
| 8 |
HC3_Uri $uri, |
| 9 |
HC3_Post $post, |
| 10 |
|
| 11 |
HC3_Settings $settings, |
| 12 |
SH4_Reminders_Sms $sms, |
| 13 |
SH4_Notifications_Template $notificationsTemplate, |
| 14 |
|
| 15 |
HC3_Request $request, |
| 16 |
HC3_Ui_Layout1 $layout, |
| 17 |
HC3_Hooks $hooks |
| 18 |
) |
| 19 |
{ |
| 20 |
$this->ui = $ui; |
| 21 |
$this->t = $t; |
| 22 |
$this->post = $hooks->wrap( $post ); |
| 23 |
$this->settings = $hooks->wrap( $settings ); |
| 24 |
$this->sms = $hooks->wrap( $sms ); |
| 25 |
|
| 26 |
$this->notificationsTemplate = $hooks->wrap( $notificationsTemplate ); |
| 27 |
|
| 28 |
$this->uri = $uri; |
| 29 |
$this->layout = $layout; |
| 30 |
$this->request = $request; |
| 31 |
$this->self = $hooks->wrap( $this ); |
| 32 |
} |
| 33 |
|
| 34 |
public function breadcrumbs() |
| 35 |
{ |
| 36 |
$ret = array(); |
| 37 |
$ret['admin'] = array( 'admin', '__Administration__' ); |
| 38 |
$ret['admin/reminders'] = array( 'admin/reminders', '__Reminders__' ); |
| 39 |
return $ret; |
| 40 |
} |
| 41 |
|
| 42 |
public function header() |
| 43 |
{ |
| 44 |
$ret = '__Edit Templates__'; |
| 45 |
return $ret; |
| 46 |
} |
| 47 |
|
| 48 |
public function pnames() |
| 49 |
{ |
| 50 |
$ret = [ |
| 51 |
'reminders_template_subject_daily', |
| 52 |
'reminders_template_subject_weekly', |
| 53 |
'reminders_template_subject_monthly' |
| 54 |
]; |
| 55 |
|
| 56 |
$smsEnabled = $this->sms->isEnabled(); |
| 57 |
if( $smsEnabled ){ |
| 58 |
$ret[] = 'reminders_template_subject_dailysms'; |
| 59 |
$ret[] = 'reminders_template_body_dailysms'; |
| 60 |
} |
| 61 |
|
| 62 |
return $ret; |
| 63 |
} |
| 64 |
|
| 65 |
public function post() |
| 66 |
{ |
| 67 |
$pnames = $this->self->pnames(); |
| 68 |
foreach( $pnames as $pname ){ |
| 69 |
$this->settings->set( $pname, $this->post->get($pname) ); |
| 70 |
} |
| 71 |
|
| 72 |
$to = 'admin/reminders/templates'; |
| 73 |
$msg = '__Settings Updated__'; |
| 74 |
$ret = array( $to, $msg ); |
| 75 |
|
| 76 |
return $ret; |
| 77 |
} |
| 78 |
|
| 79 |
public function postReset() |
| 80 |
{ |
| 81 |
$pnames = $this->self->pnames(); |
| 82 |
foreach( $pnames as $pname ){ |
| 83 |
$this->settings->reset( $pname ); |
| 84 |
} |
| 85 |
|
| 86 |
$to = 'admin/reminders/templates'; |
| 87 |
$msg = '__Settings Updated__'; |
| 88 |
$ret = array( $to, $msg ); |
| 89 |
|
| 90 |
return $ret; |
| 91 |
} |
| 92 |
|
| 93 |
public function render() |
| 94 |
{ |
| 95 |
$pnames = $this->self->pnames(); |
| 96 |
|
| 97 |
$v = array(); |
| 98 |
foreach( $pnames as $pname ){ |
| 99 |
$v[ $pname ] = $this->settings->get( $pname ); |
| 100 |
} |
| 101 |
|
| 102 |
// post to |
| 103 |
$slug = $this->request->getSlug(); |
| 104 |
$to = $this->uri->makeUrl( $slug ); |
| 105 |
$toReset = $this->uri->makeUrl( $slug . '/reset' ); |
| 106 |
|
| 107 |
$smsEnabled = $this->sms->isEnabled(); |
| 108 |
|
| 109 |
// $tags = $this->notificationsTemplate->getTags( $calendar ); |
| 110 |
// $tags = $this->notificationsTemplate->getTags( ); |
| 111 |
|
| 112 |
ob_start(); |
| 113 |
?> |
| 114 |
|
| 115 |
<form action="<?php echo $to; ?>" method="post" accept-charset="utf-8"> |
| 116 |
|
| 117 |
<div class="hc-clearfix hc-mxn2"> |
| 118 |
<div class="hc-col hc-col-9 hc-px2"> |
| 119 |
<div class="hc-mb2"> |
| 120 |
<b><u>__Email__</u></b> |
| 121 |
</div> |
| 122 |
|
| 123 |
<div class="hc-mb2"> |
| 124 |
<label> |
| 125 |
<b>__Subject__: __Tomorrow Active Shift Reminder__</b> |
| 126 |
<input type="text" class="hc-block" name="hc-reminders_template_subject_daily" value="<?php echo esc_attr($v['reminders_template_subject_daily']); ?>"> |
| 127 |
</label> |
| 128 |
</div> |
| 129 |
|
| 130 |
<div class="hc-mb2"> |
| 131 |
<label> |
| 132 |
<b>__Subject__: __Next Week Active Shift Reminder__</b> |
| 133 |
<input type="text" class="hc-block" name="hc-reminders_template_subject_weekly" value="<?php echo esc_attr($v['reminders_template_subject_weekly']); ?>"> |
| 134 |
</label> |
| 135 |
</div> |
| 136 |
|
| 137 |
<div class="hc-mb2"> |
| 138 |
<label> |
| 139 |
<b>__Subject__: __Next Month Active Shift Reminder__</b> |
| 140 |
<input type="text" class="hc-block" name="hc-reminders_template_subject_monthly" value="<?php echo esc_attr($v['reminders_template_subject_monthly']); ?>"> |
| 141 |
</label> |
| 142 |
</div> |
| 143 |
|
| 144 |
<div class="hc-mb2"> |
| 145 |
<b>__Each Shift Details__</b> |
| 146 |
<br/> |
| 147 |
__It depends on the shift calendar, the following notification template is used__: <strong>__Email__: __Shift Published__ (__Employee__)</strong> |
| 148 |
</div> |
| 149 |
|
| 150 |
<?php if( $smsEnabled ) : ?> |
| 151 |
<div class="hc-mb2"> |
| 152 |
<b><u>__SMS__</u></b> |
| 153 |
</div> |
| 154 |
|
| 155 |
<div class="hc-mb2"> |
| 156 |
<label> |
| 157 |
<b>__Tomorrow Active Shift Reminder__</b> |
| 158 |
<input type="text" class="hc-block" name="hc-reminders_template_subject_dailysms" value="<?php echo esc_attr($v['reminders_template_subject_dailysms']); ?>"> |
| 159 |
</label> |
| 160 |
</div> |
| 161 |
<?php endif; ?> |
| 162 |
</div> |
| 163 |
|
| 164 |
<div class="hc-col hc-col-3 hc-px2"> |
| 165 |
<ul> |
| 166 |
<li> |
| 167 |
<strong>__Template Tags__</strong> |
| 168 |
</li> |
| 169 |
<li>{DATELABEL}</li> |
| 170 |
<li>{EMPLOYEE_ID}</li> |
| 171 |
<li>{EMPLOYEE_NAME}</li> |
| 172 |
</ul> |
| 173 |
</div> |
| 174 |
</div> |
| 175 |
|
| 176 |
<p> |
| 177 |
<button type="submit" class="button button-primary hc-xs-block">__Save__</button> |
| 178 |
</p> |
| 179 |
|
| 180 |
</form> |
| 181 |
|
| 182 |
<form action="<?php echo $toReset; ?>" method="post" accept-charset="utf-8"> |
| 183 |
|
| 184 |
<p> |
| 185 |
<button type="submit" class="button button-secondary hc-xs-block">× __Reset To Defaults__</button> |
| 186 |
</p> |
| 187 |
|
| 188 |
</form> |
| 189 |
|
| 190 |
<?php |
| 191 |
$ret = trim( ob_get_clean() ); |
| 192 |
|
| 193 |
$this->layout |
| 194 |
->setContent( $ret ) |
| 195 |
->setHeader( $this->self->header() ) |
| 196 |
->setBreadcrumb( $this->self->breadcrumbs() ) |
| 197 |
; |
| 198 |
|
| 199 |
$ret = $this->layout->render(); |
| 200 |
return $ret; |
| 201 |
} |
| 202 |
} |