forked from mirrors/easyappointments
Improve the structure of the email notifications
This commit is contained in:
parent
c3aca37591
commit
4d79e1d3cf
4 changed files with 96 additions and 165 deletions
|
@ -53,7 +53,7 @@ class Email_messages {
|
|||
* @param array $settings App settings.
|
||||
* @param string $subject Email subject.
|
||||
* @param string $message Email message.
|
||||
* @param string $appointment_link_address Appointment unique URL.
|
||||
* @param string $appointment_link Appointment unique URL.
|
||||
* @param string $recipient_email Recipient email address.
|
||||
* @param string $ics_stream ICS file contents.
|
||||
* @param string|null $timezone Custom timezone.
|
||||
|
@ -68,41 +68,12 @@ class Email_messages {
|
|||
array $settings,
|
||||
string $subject,
|
||||
string $message,
|
||||
string $appointment_link_address,
|
||||
string $appointment_link,
|
||||
string $recipient_email,
|
||||
string $ics_stream,
|
||||
string $timezone = NULL
|
||||
)
|
||||
): void
|
||||
{
|
||||
$timezones = $this->CI->timezones->to_array();
|
||||
|
||||
switch ($settings['date_format'])
|
||||
{
|
||||
case 'DMY':
|
||||
$date_format = 'd/m/Y';
|
||||
break;
|
||||
case 'MDY':
|
||||
$date_format = 'm/d/Y';
|
||||
break;
|
||||
case 'YMD':
|
||||
$date_format = 'Y/m/d';
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException('Invalid date_format value: ' . $settings['date_format']);
|
||||
}
|
||||
|
||||
switch ($settings['time_format'])
|
||||
{
|
||||
case 'military':
|
||||
$time_format = 'H:i';
|
||||
break;
|
||||
case 'regular':
|
||||
$time_format = 'g:i a';
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException('Invalid time_format value: ' . $settings['time_format']);
|
||||
}
|
||||
|
||||
$appointment_timezone = new DateTimeZone($provider['timezone']);
|
||||
|
||||
$appointment_start = new DateTime($appointment['start_datetime'], $appointment_timezone);
|
||||
|
@ -119,20 +90,15 @@ class Email_messages {
|
|||
}
|
||||
|
||||
$html = $this->CI->load->view('emails/appointment_saved_email', [
|
||||
'email_title' => $subject,
|
||||
'email_message' => $message,
|
||||
'appointment_service' => $service['name'],
|
||||
'appointment_provider' => $provider['first_name'] . ' ' . $provider['last_name'],
|
||||
'appointment_start_date' => $appointment_start->format($date_format . ' ' . $time_format),
|
||||
'appointment_end_date' => $appointment_end->format($date_format . ' ' . $time_format),
|
||||
'appointment_timezone' => $timezones[empty($timezone) ? $provider['timezone'] : $timezone],
|
||||
'appointment_link' => $appointment_link_address,
|
||||
'company_link' => $settings['company_link'],
|
||||
'company_name' => $settings['company_name'],
|
||||
'customer_name' => $customer['first_name'] . ' ' . $customer['last_name'],
|
||||
'customer_email' => $customer['email'],
|
||||
'customer_phone' => $customer['phone_number'],
|
||||
'customer_address' => $customer['address'],
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'appointment' => $appointment,
|
||||
'service' => $service,
|
||||
'provider' => $provider,
|
||||
'customer' => $customer,
|
||||
'settings' => $settings,
|
||||
'timezone' => $timezone,
|
||||
'appointment_link' => $appointment_link,
|
||||
], TRUE);
|
||||
|
||||
$this->CI->email->from($settings['company_email'], $settings['company_email']);
|
||||
|
@ -174,37 +140,8 @@ class Email_messages {
|
|||
string $recipient_email,
|
||||
string $reason = NULL,
|
||||
string $timezone = NULL
|
||||
)
|
||||
): void
|
||||
{
|
||||
$timezones = $this->CI->timezones->to_array();
|
||||
|
||||
switch ($settings['date_format'])
|
||||
{
|
||||
case 'DMY':
|
||||
$date_format = 'd/m/Y';
|
||||
break;
|
||||
case 'MDY':
|
||||
$date_format = 'm/d/Y';
|
||||
break;
|
||||
case 'YMD':
|
||||
$date_format = 'Y/m/d';
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException('Invalid date_format value: ' . $settings['date_format']);
|
||||
}
|
||||
|
||||
switch ($settings['time_format'])
|
||||
{
|
||||
case 'military':
|
||||
$time_format = 'H:i';
|
||||
break;
|
||||
case 'regular':
|
||||
$time_format = 'g:i a';
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException('Invalid time_format value: ' . $settings['time_format']);
|
||||
}
|
||||
|
||||
$appointment_timezone = new DateTimeZone($provider['timezone']);
|
||||
|
||||
$appointment_start = new DateTime($appointment['start_datetime'], $appointment_timezone);
|
||||
|
@ -217,17 +154,12 @@ class Email_messages {
|
|||
}
|
||||
|
||||
$html = $this->CI->load->view('emails/appointment_deleted_email', [
|
||||
'appointment_service' => $service['name'],
|
||||
'appointment_provider' => $provider['first_name'] . ' ' . $provider['last_name'],
|
||||
'appointment_date' => $appointment_start->format($date_format . ' ' . $time_format),
|
||||
'appointment_duration' => $service['duration'] . ' ' . lang('minutes'),
|
||||
'appointment_timezone' => $timezones[empty($timezone) ? $provider['timezone'] : $timezone],
|
||||
'company_link' => $settings['company_link'],
|
||||
'company_name' => $settings['company_name'],
|
||||
'customer_name' => $customer['first_name'] . ' ' . $customer['last_name'],
|
||||
'customer_email' => $customer['email'],
|
||||
'customer_phone' => $customer['phone_number'],
|
||||
'customer_address' => $customer['address'],
|
||||
'appointment' => $appointment,
|
||||
'service' => $service,
|
||||
'provider' => $provider,
|
||||
'customer' => $customer,
|
||||
'settings' => $settings,
|
||||
'timezone' => $timezone,
|
||||
'reason' => $reason,
|
||||
], TRUE);
|
||||
|
||||
|
@ -256,14 +188,12 @@ class Email_messages {
|
|||
string $password,
|
||||
string $recipient_email,
|
||||
array $settings
|
||||
)
|
||||
): void
|
||||
{
|
||||
$html = $this->CI->load->view('emails/account_recovery_email', [
|
||||
'email_title' => lang('new_account_password'),
|
||||
'email_message' => str_replace('$password', '<strong>' . $password . '</strong>', lang('new_password_is')),
|
||||
'company_name' => $settings['company_name'],
|
||||
'company_email' => $settings['company_email'],
|
||||
'company_link' => $settings['company_link'],
|
||||
'subject' => lang('new_account_password'),
|
||||
'message' => str_replace('$password', '<strong>' . $password . '</strong>', lang('new_password_is')),
|
||||
'settings' => $settings,
|
||||
], TRUE);
|
||||
|
||||
$this->CI->email->from($settings['company_email'], $settings['company_email']);
|
||||
|
|
|
@ -2,30 +2,30 @@
|
|||
/**
|
||||
* Local variables.
|
||||
*
|
||||
* @var string $company_name
|
||||
* @var string $email_title
|
||||
* @var string $email_message
|
||||
* @var string $company_link
|
||||
* @var string $subject
|
||||
* @var string $message
|
||||
* @var array $settings
|
||||
*/
|
||||
?>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>New Password | Easy!Appointments</title>
|
||||
<title><?= $subject ?> | Easy!Appointments</title>
|
||||
</head>
|
||||
<body style="font: 13px arial, helvetica, tahoma;">
|
||||
|
||||
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
||||
<div id="header" style="background-color: #429a82; height: 45px; padding: 10px 15px;">
|
||||
<strong id="logo" style="color: white; font-size: 20px; margin-top: 10px; display: inline-block">
|
||||
<?= $company_name ?>
|
||||
<?= $settings['company_name'] ?>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div id="content" style="padding: 10px 15px;">
|
||||
<h2>
|
||||
<?= $email_title ?>
|
||||
<?= $subject ?>
|
||||
</h2>
|
||||
<p>
|
||||
<?= $email_message ?>
|
||||
<?= $message ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -36,10 +36,11 @@
|
|||
Easy!Appointments
|
||||
</a>
|
||||
|
|
||||
<a href="<?= $company_link ?>" style="text-decoration: none;">
|
||||
<?= $company_name ?>
|
||||
<a href="<?= $settings['company_link'] ?>" style="text-decoration: none;">
|
||||
<?= $settings['company_name'] ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -2,17 +2,13 @@
|
|||
/**
|
||||
* Local variables.
|
||||
*
|
||||
* @var string $company_name
|
||||
* @var string $appointment_service
|
||||
* @var string $appointment_provider
|
||||
* @var string $appointment_duration
|
||||
* @var string $appointment_timezone
|
||||
* @var string $customer_name
|
||||
* @var string $customer_email
|
||||
* @var string $customer_phone
|
||||
* @var string $customer_address
|
||||
* @var array $appointment
|
||||
* @var array $service
|
||||
* @var array $provider
|
||||
* @var array $customer
|
||||
* @var array $settings
|
||||
* @var array $timezone
|
||||
* @var string $reason
|
||||
* @var string $company_link
|
||||
*/
|
||||
?>
|
||||
|
||||
|
@ -21,10 +17,11 @@
|
|||
<title><?= lang('appointment_cancelled_title') ?> | Easy!Appointments</title>
|
||||
</head>
|
||||
<body style="font: 13px arial, helvetica, tahoma;">
|
||||
|
||||
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
||||
<div id="header" style="background-color: #429a82; height: 45px; padding: 10px 15px;">
|
||||
<strong id="logo" style="color: white; font-size: 20px; margin-top: 10px; display: inline-block">
|
||||
<?= $company_name ?>
|
||||
<?= $settings['company_name'] ?>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
|
@ -47,7 +44,7 @@
|
|||
<?= lang('service') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_service ?>
|
||||
<?= $service['name'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -55,7 +52,7 @@
|
|||
<?= lang('provider') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_provider ?>
|
||||
<?= $provider['first_name'] . ' ' . $provider['last_name'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -63,15 +60,16 @@
|
|||
<?= lang('start') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_date ?>
|
||||
<?= format_date_time($appointment['start_datetime']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" style="padding: 3px;font-weight: bold;">
|
||||
<?= lang('duration') ?>
|
||||
<?= lang('end') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_duration ?>
|
||||
<?= format_date_time($appointment['end_datetime']) ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -79,19 +77,22 @@
|
|||
<?= lang('timezone') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_timezone ?>
|
||||
<?= format_timezone($timezone) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2><?= lang('customer_details_title') ?></h2>
|
||||
<h2>
|
||||
<?= lang('customer_details_title') ?>
|
||||
</h2>
|
||||
|
||||
<table id="customer-details">
|
||||
<tr>
|
||||
<td class="label" style="padding: 3px;font-weight: bold;">
|
||||
<?= lang('name') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_name ?>
|
||||
<?= $customer['first_name'] . ' ' . $customer['last_name'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -99,7 +100,7 @@
|
|||
<?= lang('email') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_email ?>
|
||||
<?= $customer['email'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -107,7 +108,7 @@
|
|||
<?= lang('phone_number') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_phone ?>
|
||||
<?= $customer['phone_number'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -115,7 +116,7 @@
|
|||
<?= lang('address') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_address ?>
|
||||
<?= $customer['address'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -136,10 +137,11 @@
|
|||
Easy!Appointments
|
||||
</a>
|
||||
|
|
||||
<a href="<?= $company_link ?>" style="text-decoration: none;">
|
||||
<?= $company_name ?>
|
||||
<a href="<?= $settings['company_link'] ?>" style="text-decoration: none;">
|
||||
<?= $settings['company_name'] ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -2,42 +2,40 @@
|
|||
/**
|
||||
* Local variables.
|
||||
*
|
||||
* @var string $company_name
|
||||
* @var string $email_title
|
||||
* @var string $email_message
|
||||
* @var array $appointment_service
|
||||
* @var string $appointment_provider
|
||||
* @var string $appointment_start_date
|
||||
* @var string $appointment_end_date
|
||||
* @var string $appointment_timezone
|
||||
* @var string $customer_name
|
||||
* @var string $customer_email
|
||||
* @var string $customer_phone
|
||||
* @var string $customer_address
|
||||
* @var string $subject
|
||||
* @var string $message
|
||||
* @var array $appointment
|
||||
* @var array $service
|
||||
* @var array $provider
|
||||
* @var array $customer
|
||||
* @var array $settings
|
||||
* @var array $timezone
|
||||
* @var string $appointment_link
|
||||
* @var string $company_link
|
||||
*/
|
||||
?>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title><?= lang('appointment_details_title') ?> | Easy!Appointments</title>
|
||||
<title>
|
||||
<?= lang('appointment_details_title') ?> | Easy!Appointments
|
||||
</title>
|
||||
</head>
|
||||
<body style="font: 13px arial, helvetica, tahoma;">
|
||||
|
||||
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
||||
<div id="header" style="background-color: #429a82; height: 45px; padding: 10px 15px;">
|
||||
<strong id="logo" style="color: white; font-size: 20px; margin-top: 10px; display: inline-block">
|
||||
<?= $company_name ?>
|
||||
<?= $settings['company_name'] ?>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div id="content" style="padding: 10px 15px;">
|
||||
<h2>
|
||||
<?= $email_title ?>
|
||||
<?= $subject ?>
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
<?= $email_message ?>
|
||||
<?= $message ?>
|
||||
</p>
|
||||
|
||||
<h2>
|
||||
|
@ -50,7 +48,7 @@
|
|||
<?= lang('service') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_service ?>
|
||||
<?= $service['name'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -58,8 +56,7 @@
|
|||
<?= lang('provider') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_provider ?>
|
||||
|
||||
<?= $provider['first_name'] . ' ' . $provider['last_name'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -67,7 +64,7 @@
|
|||
<?= lang('start') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_start_date ?>
|
||||
<?= format_date_time($appointment['start_datetime']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -75,7 +72,7 @@
|
|||
<?= lang('end') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_end_date ?>
|
||||
<?= format_date_time($appointment['end_datetime']) ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -84,7 +81,7 @@
|
|||
<?= lang('timezone') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $appointment_timezone ?>
|
||||
<?= format_timezone($timezone) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -99,7 +96,7 @@
|
|||
<?= lang('name') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_name ?>
|
||||
<?= $customer['first_name'] . ' ' . $customer['last_name'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -107,7 +104,7 @@
|
|||
<?= lang('email') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_email ?>
|
||||
<?= $customer['email'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -115,7 +112,7 @@
|
|||
<?= lang('phone_number') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_phone ?>
|
||||
<?= $customer['phone_number'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -123,7 +120,7 @@
|
|||
<?= lang('address') ?>
|
||||
</td>
|
||||
<td style="padding: 3px;">
|
||||
<?= $customer_address ?>
|
||||
<?= $customer['address'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -144,10 +141,11 @@
|
|||
Easy!Appointments
|
||||
</a>
|
||||
|
|
||||
<a href="<?= $company_link ?>" style="text-decoration: none;">
|
||||
<?= $company_name ?>
|
||||
<a href="<?= $settings['company_link'] ?>" style="text-decoration: none;">
|
||||
<?= $settings['company_name'] ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue