| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class SH4_Notifications_Email_Manager_Delete implements SH4_Notifications_INotification |
| 3 |
{ |
| 4 |
public $self, $notificationsTemplate, $notificator, $appQuery; |
| 5 |
|
| 6 |
public function __construct( |
| 7 |
HC3_Hooks $hooks, |
| 8 |
HC3_Notificator $notificator, |
| 9 |
SH4_Notifications_Template $notificationsTemplate, |
| 10 |
SH4_App_Query $appQuery |
| 11 |
) |
| 12 |
{ |
| 13 |
$this->self = $hooks->wrap( $this ); |
| 14 |
|
| 15 |
$this->notificationsTemplate = $hooks->wrap( $notificationsTemplate ); |
| 16 |
$this->notificator = $hooks->wrap( $notificator ); |
| 17 |
$this->appQuery = $hooks->wrap( $appQuery ); |
| 18 |
} |
| 19 |
|
| 20 |
public function getTitle() |
| 21 |
{ |
| 22 |
$return = '__Email__' . ': ' . '__Shift Deleted__' . ' ('. '__Manager__' . ')'; |
| 23 |
return $return; |
| 24 |
} |
| 25 |
|
| 26 |
public function execute( SH4_Shifts_Model $shift, $template ) |
| 27 |
{ |
| 28 |
$msg = $this->notificationsTemplate->parse( $template, $shift ); |
| 29 |
|
| 30 |
$calendar = $shift->getCalendar(); |
| 31 |
$managers = $this->appQuery->findManagersForCalendar( $calendar ); |
| 32 |
|
| 33 |
foreach( $managers as $user ){ |
| 34 |
$this->notificator |
| 35 |
->queue( $user, 'email_manager_delete', $msg ) |
| 36 |
; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
public function getDefaultTemplate() |
| 41 |
{ |
| 42 |
$return = array(); |
| 43 |
$return[] = '__Shift Deleted__' . ' (#{ID})'; |
| 44 |
|
| 45 |
$return[] = '{CALENDAR}'; |
| 46 |
$return[] = '{DATETIME}'; |
| 47 |
$return[] = '{EMPLOYEE}'; |
| 48 |
|
| 49 |
$return = join("\n", $return); |
| 50 |
return $return; |
| 51 |
} |
| 52 |
} |