From 4d79e1d3cf78671571f0bc9a90a627bc2b223813 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 21 Feb 2023 07:58:21 +0100 Subject: [PATCH] Improve the structure of the email notifications --- application/libraries/Email_messages.php | 116 ++++-------------- .../views/emails/account_recovery_email.php | 23 ++-- .../emails/appointment_deleted_email.php | 54 ++++---- .../views/emails/appointment_saved_email.php | 68 +++++----- 4 files changed, 96 insertions(+), 165 deletions(-) diff --git a/application/libraries/Email_messages.php b/application/libraries/Email_messages.php index fd655722..af4d5376 100644 --- a/application/libraries/Email_messages.php +++ b/application/libraries/Email_messages.php @@ -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', '' . $password . '', 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', '' . $password . '', lang('new_password_is')), + 'settings' => $settings, ], TRUE); $this->CI->email->from($settings['company_email'], $settings['company_email']); diff --git a/application/views/emails/account_recovery_email.php b/application/views/emails/account_recovery_email.php index dc717624..3166ab85 100644 --- a/application/views/emails/account_recovery_email.php +++ b/application/views/emails/account_recovery_email.php @@ -1,31 +1,31 @@ - New Password | Easy!Appointments + <?= $subject ?> | Easy!Appointments +

- +

- +

@@ -36,10 +36,11 @@ Easy!Appointments | - - + +
+ diff --git a/application/views/emails/appointment_deleted_email.php b/application/views/emails/appointment_deleted_email.php index ee3dc292..6402391b 100644 --- a/application/views/emails/appointment_deleted_email.php +++ b/application/views/emails/appointment_deleted_email.php @@ -1,18 +1,14 @@ @@ -21,10 +17,11 @@ <?= lang('appointment_cancelled_title') ?> | Easy!Appointments +
@@ -40,14 +37,14 @@

- + @@ -55,7 +52,7 @@ @@ -63,15 +60,16 @@ @@ -79,19 +77,22 @@
- +
- +
- +
- + - + +
- +
-

+

+ +

+ @@ -99,7 +100,7 @@ @@ -107,7 +108,7 @@ @@ -115,7 +116,7 @@
- +
- +
- +
- +
@@ -136,10 +137,11 @@ Easy!Appointments | - - + +
+ diff --git a/application/views/emails/appointment_saved_email.php b/application/views/emails/appointment_saved_email.php index b3039e9c..cf28811f 100644 --- a/application/views/emails/appointment_saved_email.php +++ b/application/views/emails/appointment_saved_email.php @@ -1,56 +1,54 @@ - <?= lang('appointment_details_title') ?> | Easy!Appointments + + <?= lang('appointment_details_title') ?> | Easy!Appointments + +

- +

- +

- +

- + @@ -58,8 +56,7 @@ @@ -67,7 +64,7 @@ @@ -75,8 +72,8 @@ @@ -84,7 +81,7 @@
- +
- - +
- +
- - + +
- +
@@ -92,14 +89,14 @@

- + @@ -107,7 +104,7 @@ @@ -115,7 +112,7 @@ @@ -123,7 +120,7 @@
- +
- +
- +
- +
@@ -131,7 +128,7 @@

- + @@ -144,10 +141,11 @@ Easy!Appointments | - - + +
+