| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Reminders_Html_Admin |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_UriAction $uriAction, |
| 7 |
HC3_Uri $uri, |
| 8 |
HC3_Post $post, |
| 9 |
SH4_Reminders_Sms $sms, |
| 10 |
|
| 11 |
HC3_Settings $settings, |
| 12 |
HC3_Request $request, |
| 13 |
HC3_Ui_Layout1 $layout, |
| 14 |
HC3_Hooks $hooks |
| 15 |
) |
| 16 |
{ |
| 17 |
$this->sms = $hooks->wrap( $sms ); |
| 18 |
$this->settings = $hooks->wrap( $settings ); |
| 19 |
$this->post = $hooks->wrap( $post ); |
| 20 |
$this->uriAction = $uriAction; |
| 21 |
$this->uri = $uri; |
| 22 |
$this->layout = $layout; |
| 23 |
$this->request = $request; |
| 24 |
$this->self = $hooks->wrap( $this ); |
| 25 |
} |
| 26 |
|
| 27 |
public function breadcrumbs() |
| 28 |
{ |
| 29 |
$ret = array(); |
| 30 |
$ret['admin'] = array( 'admin', '__Administration__' ); |
| 31 |
return $ret; |
| 32 |
} |
| 33 |
|
| 34 |
public function header() |
| 35 |
{ |
| 36 |
$ret = '__Reminders__'; |
| 37 |
return $ret; |
| 38 |
} |
| 39 |
|
| 40 |
public function menu() |
| 41 |
{ |
| 42 |
$ret = array(); |
| 43 |
|
| 44 |
$ret['templates'] = array( 'admin/reminders/templates', '__Edit Templates__' ); |
| 45 |
$ret['review'] = array( 'admin/reminders/review', '__Review Reminders__' ); |
| 46 |
$ret['sms'] = array( 'admin/reminders/sms', '__SMS__' ); |
| 47 |
|
| 48 |
return $ret; |
| 49 |
} |
| 50 |
|
| 51 |
public function post() |
| 52 |
{ |
| 53 |
$take = array( |
| 54 |
'reminders_setup', 'reminders_daily', 'reminders_weekly', 'reminders_monthly', 'reminders_include', |
| 55 |
); |
| 56 |
|
| 57 |
if( $this->sms->isEnabled() ){ |
| 58 |
$take[] = 'reminders_daily_sms'; |
| 59 |
} |
| 60 |
|
| 61 |
foreach( $take as $k ){ |
| 62 |
$v = $this->post->get($k); |
| 63 |
$this->settings->set( $k, $v ); |
| 64 |
} |
| 65 |
|
| 66 |
$return = array( 'admin/reminders', '__Settings Updated__' ); |
| 67 |
return $return; |
| 68 |
} |
| 69 |
|
| 70 |
public function render() |
| 71 |
{ |
| 72 |
$values = array(); |
| 73 |
$pnames = array( |
| 74 |
'reminders_setup', 'reminders_daily', 'reminders_weekly', 'reminders_monthly', 'reminders_include', |
| 75 |
); |
| 76 |
|
| 77 |
if( $this->sms->isEnabled() ){ |
| 78 |
$pnames[] = 'reminders_daily_sms'; |
| 79 |
} |
| 80 |
|
| 81 |
foreach( $pnames as $pname ){ |
| 82 |
$values[$pname] = $this->settings->get($pname); |
| 83 |
} |
| 84 |
|
| 85 |
// cron link |
| 86 |
$cronParams = array(); |
| 87 |
$cronSlug = 'cron'; |
| 88 |
// $cronLink = $this->uriAction->makeUrl( array($cronSlug, $cronParams) ); |
| 89 |
$cronLink = site_url( '/?hcs=sh4&hca=' . $cronSlug ); |
| 90 |
|
| 91 |
// post to |
| 92 |
$slug = $this->request->getSlug(); |
| 93 |
$to = $this->uri->makeUrl( $slug ); |
| 94 |
|
| 95 |
ob_start(); |
| 96 |
?> |
| 97 |
|
| 98 |
<form action="<?php echo $to; ?>" method="post" accept-charset="utf-8"> |
| 99 |
|
| 100 |
<?php if( 1 OR ! $values['reminders_setup'] ) : ?> |
| 101 |
<p> |
| 102 |
<mark class="hc-p1">__Please Note__</mark> |
| 103 |
</p> |
| 104 |
|
| 105 |
<p> |
| 106 |
For shifts reminders to work, you'll need to set up a cron job. Cron job is a process that runs periodically at your web server. |
| 107 |
Log in to your web hosting control panel and go to Cron Jobs. Add a cron job that will be pulling the following command every day once a day. |
| 108 |
</p> |
| 109 |
|
| 110 |
<p> |
| 111 |
<code> |
| 112 |
wget -O /dev/null '<?php echo $cronLink; ?>' |
| 113 |
</code> |
| 114 |
</p> |
| 115 |
|
| 116 |
<p> |
| 117 |
Alternatively, you can make use of a web cron service (search the web for <i>web cron</i>) and make them pull the following link every day once a day. |
| 118 |
</p> |
| 119 |
|
| 120 |
<p> |
| 121 |
<code> |
| 122 |
<?php echo $cronLink; ?> |
| 123 |
</code> |
| 124 |
</p> |
| 125 |
|
| 126 |
<?php endif; ?> |
| 127 |
|
| 128 |
<p> |
| 129 |
<label> |
| 130 |
<input type="checkbox" name="hc-reminders_setup" value="1"<?php if( $values['reminders_setup'] ) : ?> checked<?php endif; ?>/> |
| 131 |
__Yes, I've set up the cron job__ |
| 132 |
</label> |
| 133 |
</p> |
| 134 |
|
| 135 |
<?php if( $values['reminders_setup'] ) : ?> |
| 136 |
<p> |
| 137 |
<label> |
| 138 |
<input type="checkbox" name="hc-reminders_daily" value="1"<?php if( $values['reminders_daily'] ) : ?> checked<?php endif; ?>/> |
| 139 |
__Tomorrow Active Shift Reminder__ |
| 140 |
</label> |
| 141 |
</p> |
| 142 |
|
| 143 |
<?php if( $this->sms->isEnabled() ) : ?> |
| 144 |
<p> |
| 145 |
<label> |
| 146 |
<input type="checkbox" name="hc-reminders_daily_sms" value="1"<?php if( $values['reminders_daily_sms'] ) : ?> checked<?php endif; ?>/> |
| 147 |
__Tomorrow Active Shift Reminder SMS Text__ |
| 148 |
</label> |
| 149 |
</p> |
| 150 |
<?php endif; ?> |
| 151 |
|
| 152 |
<p> |
| 153 |
<label> |
| 154 |
<input type="checkbox" name="hc-reminders_weekly" value="1"<?php if( $values['reminders_weekly'] ) : ?> checked<?php endif; ?>/> |
| 155 |
__Next Week Active Shift Reminder__ |
| 156 |
</label> |
| 157 |
</p> |
| 158 |
|
| 159 |
<p> |
| 160 |
<label> |
| 161 |
<input type="checkbox" name="hc-reminders_monthly" value="1"<?php if( $values['reminders_monthly'] ) : ?> checked<?php endif; ?>/> |
| 162 |
__Next Month Active Shift Reminder__ |
| 163 |
</label> |
| 164 |
</p> |
| 165 |
|
| 166 |
<p> |
| 167 |
<span class="pw-inline-list"> |
| 168 |
<label> |
| 169 |
<input type="radio" name="hc-reminders_include" value="all"<?php if( 'all' == $values['reminders_include'] ) : ?> checked<?php endif; ?>/> |
| 170 |
__Shift__ & __Time Off__ |
| 171 |
</label> |
| 172 |
|
| 173 |
<label> |
| 174 |
<input type="radio" name="hc-reminders_include" value="shift"<?php if( 'shift' == $values['reminders_include'] ) : ?> checked<?php endif; ?>/> |
| 175 |
__Shift__ |
| 176 |
</label> |
| 177 |
|
| 178 |
<label> |
| 179 |
<input type="radio" name="hc-reminders_include" value="timeoff"<?php if( 'timeoff' == $values['reminders_include'] ) : ?> checked<?php endif; ?>/> |
| 180 |
__Time Off__ |
| 181 |
</label> |
| 182 |
</span> |
| 183 |
</p> |
| 184 |
|
| 185 |
<?php endif; ?> |
| 186 |
|
| 187 |
<p> |
| 188 |
<?php if( $values['reminders_setup'] ) : ?> |
| 189 |
<button type="submit" class="button button-primary button-large hc-xs-block">__Save__</button> |
| 190 |
<?php else: ?> |
| 191 |
<button type="submit" class="button button-primary button-large hc-xs-block">__Continue__</button> |
| 192 |
<?php endif; ?> |
| 193 |
</p> |
| 194 |
|
| 195 |
</form> |
| 196 |
|
| 197 |
<?php |
| 198 |
$ret = trim( ob_get_clean() ); |
| 199 |
|
| 200 |
$this->layout |
| 201 |
->setContent( $ret ) |
| 202 |
->setHeader( $this->self->header() ) |
| 203 |
->setMenu( $this->self->menu() ) |
| 204 |
->setBreadcrumb( $this->self->breadcrumbs() ) |
| 205 |
; |
| 206 |
|
| 207 |
$ret = $this->layout->render(); |
| 208 |
return $ret; |
| 209 |
} |
| 210 |
} |