diff --git a/application/views/emails/appointment_details.php b/application/views/emails/appointment_details.php
index 229fff7b..b4f6594b 100644
--- a/application/views/emails/appointment_details.php
+++ b/application/views/emails/appointment_details.php
@@ -1,6 +1,6 @@
-
@@ -8,63 +8,63 @@
height: 45px; padding: 10px 15px;">
- $company_name
+ = $company_name ?>
@@ -8,63 +8,63 @@
height: 45px; padding: 10px 15px;">
- $company_name
+ = $company_name ?>
-
$email_title
-
$email_message
+
= lang('appointment_cancelled_title') ?>
+
= lang('appointment_removed_from_schedule') ?>
-
Appointment Details
+
= lang('appointment_details_title') ?>
- Service |
- $appointment_service |
+ = lang('service') ?> |
+ = $appointment_service ?> |
- Provider |
- $appointment_provider |
+ = lang('provider') ?> |
+ = $appointment_provider ?> |
- Date |
- $appointment_date |
+ = lang('start') ?> |
+ = $appointment_date ?> |
- Duration |
- $appointment_duration |
+ = lang('duration') ?> |
+ = $appointment_duration ?> |
-
Customer Details
+
= lang('customer_details_title') ?>
- Name |
- $customer_name |
+ = lang('name') ?> |
+ = $customer_name ?> |
- Email |
- $customer_email |
+ = lang('email') ?> |
+ = $customer_email ?> |
- Phone |
- $customer_phone |
+ = lang('phone_number') ?> |
+ = $customer_phone ?> |
- Address |
- $customer_address |
+ = lang('address') ?> |
+ = $customer_address ?> |
-
Reason
-
$reason
+
= lang('reason') ?>
+
= $reason ?>
diff --git a/engine/Notifications/Email.php b/engine/Notifications/Email.php
index c900363b..f2dc71b1 100755
--- a/engine/Notifications/Email.php
+++ b/engine/Notifications/Email.php
@@ -52,27 +52,6 @@ class Email {
$this->config = $config;
}
- /**
- * Replace the email template variables.
- *
- * This method finds and replaces the html variables of an email template. It is used to
- * generate dynamic HTML emails that are send as notifications to the system users.
- *
- * @param array $replaceArray Array that contains the variables to be replaced.
- * @param string $templateHtml The email template HTML.
- *
- * @return string Returns the new email html that contain the variables of the $replaceArray.
- */
- protected function _replaceTemplateVariables(array $replaceArray, $templateHtml)
- {
- foreach ($replaceArray as $name => $value)
- {
- $templateHtml = str_replace($name, $value, $templateHtml);
- }
-
- return $templateHtml;
- }
-
/**
* Send an email with the appointment details.
*
@@ -132,46 +111,30 @@ class Email {
}
// Prepare template replace array.
- $replaceArray = [
- '$email_title' => $title->get(),
- '$email_message' => $message->get(),
- '$appointment_service' => $service['name'],
- '$appointment_provider' => $provider['first_name'] . ' ' . $provider['last_name'],
- '$appointment_start_date' => date($date_format . ' ' . $timeFormat, strtotime($appointment['start_datetime'])),
- '$appointment_end_date' => date($date_format . ' ' . $timeFormat, strtotime($appointment['end_datetime'])),
- '$appointment_link' => $appointmentLink->get(),
- '$company_link' => $company['company_link'],
- '$company_name' => $company['company_name'],
- '$customer_name' => $customer['first_name'] . ' ' . $customer['last_name'],
- '$customer_email' => $customer['email'],
- '$customer_phone' => $customer['phone_number'],
- '$customer_address' => $customer['address'],
+ $email_title = $title->get();
+ $email_message = $message->get();
+ $appointment_service = $service['name'];
+ $appointment_provider = $provider['first_name'] . ' ' . $provider['last_name'];
+ $appointment_start_date = date($date_format . ' ' . $timeFormat, strtotime($appointment['start_datetime']));
+ $appointment_end_date = date($date_format . ' ' . $timeFormat, strtotime($appointment['end_datetime']));
+ $appointment_link = $appointmentLink->get();
+ $company_link = $company['company_link'];
+ $company_name = $company['company_name'];
+ $customer_name = $customer['first_name'] . ' ' . $customer['last_name'];
+ $customer_email = $customer['email'];
+ $customer_phone = $customer['phone_number'];
+ $customer_address = $customer['address'];
- // Translations
- 'Appointment Details' => $this->framework->lang->line('appointment_details_title'),
- 'Service' => $this->framework->lang->line('service'),
- 'Provider' => $this->framework->lang->line('provider'),
- 'Start' => $this->framework->lang->line('start'),
- 'End' => $this->framework->lang->line('end'),
- 'Customer Details' => $this->framework->lang->line('customer_details_title'),
- 'Name' => $this->framework->lang->line('name'),
- 'Email' => $this->framework->lang->line('email'),
- 'Phone' => $this->framework->lang->line('phone_number'),
- 'Address' => $this->framework->lang->line('address'),
- 'Appointment Link' => $this->framework->lang->line('appointment_link_title')
- ];
-
- $html = file_get_contents(__DIR__ . '/../../application/views/emails/appointment_details.php');
- $html = $this->_replaceTemplateVariables($replaceArray, $html);
+ ob_start();
+ require __DIR__ . '/../../application/views/emails/appointment_details.php';
+ $html = ob_get_clean();
$mailer = $this->_createMailer();
-
$mailer->From = $company['company_email'];
$mailer->FromName = $company['company_name'];
$mailer->AddAddress($recipientEmail->get());
$mailer->Subject = $title->get();
$mailer->Body = $html;
-
$mailer->addStringAttachment($icsStream->get(), 'invitation.ics');
if ( ! $mailer->Send())
@@ -236,37 +199,21 @@ class Email {
}
// Prepare email template data.
- $replaceArray = [
- '$email_title' => $this->framework->lang->line('appointment_cancelled_title'),
- '$email_message' => $this->framework->lang->line('appointment_removed_from_schedule'),
- '$appointment_service' => $service['name'],
- '$appointment_provider' => $provider['first_name'] . ' ' . $provider['last_name'],
- '$appointment_date' => date($date_format . ' ' . $timeFormat, strtotime($appointment['start_datetime'])),
- '$appointment_duration' => $service['duration'] . ' ' . $this->framework->lang->line('minutes'),
- '$company_link' => $company['company_link'],
- '$company_name' => $company['company_name'],
- '$customer_name' => $customer['first_name'] . ' ' . $customer['last_name'],
- '$customer_email' => $customer['email'],
- '$customer_phone' => $customer['phone_number'],
- '$customer_address' => $customer['address'],
- '$reason' => $reason->get(),
+ $appointment_service = $service['name'];
+ $appointment_provider = $provider['first_name'] . ' ' . $provider['last_name'];
+ $appointment_date = date($date_format . ' ' . $timeFormat, strtotime($appointment['start_datetime']));
+ $appointment_duration = $service['duration'] . ' ' . $this->framework->lang->line('minutes');
+ $company_link = $company['company_link'];
+ $company_name = $company['company_name'];
+ $customer_name = $customer['first_name'] . ' ' . $customer['last_name'];
+ $customer_email = $customer['email'];
+ $customer_phone = $customer['phone_number'];
+ $customer_address = $customer['address'];
+ $reason = $reason->get();
- // Translations
- 'Appointment Details' => $this->framework->lang->line('appointment_details_title'),
- 'Service' => $this->framework->lang->line('service'),
- 'Provider' => $this->framework->lang->line('provider'),
- 'Date' => $this->framework->lang->line('start'),
- 'Duration' => $this->framework->lang->line('duration'),
- 'Customer Details' => $this->framework->lang->line('customer_details_title'),
- 'Name' => $this->framework->lang->line('name'),
- 'Email' => $this->framework->lang->line('email'),
- 'Phone' => $this->framework->lang->line('phone_number'),
- 'Address' => $this->framework->lang->line('address'),
- 'Reason' => $this->framework->lang->line('reason')
- ];
-
- $html = file_get_contents(__DIR__ . '/../../application/views/emails/delete_appointment.php');
- $html = $this->_replaceTemplateVariables($replaceArray, $html);
+ ob_start();
+ require __DIR__ . '/../../application/views/emails/delete_appointment.php';
+ $html = ob_get_clean();
$mailer = $this->_createMailer();
@@ -293,17 +240,16 @@ class Email {
*/
public function sendPassword(NonEmptyText $password, EmailAddress $recipientEmail, array $company)
{
- $replaceArray = [
- '$email_title' => $this->framework->lang->line('new_account_password'),
- '$email_message' => $this->framework->lang->line('new_password_is'),
- '$company_name' => $company['company_name'],
- '$company_email' => $company['company_email'],
- '$company_link' => $company['company_link'],
- '$password' => '