diff --git a/src/application/controllers/Appointments.php b/src/application/controllers/Appointments.php index fbe3779f..82d4db83 100755 --- a/src/application/controllers/Appointments.php +++ b/src/application/controllers/Appointments.php @@ -518,11 +518,14 @@ class Appointments extends CI_Controller { $send_customer = filter_var($this->settings_model->get_setting('customer_notifications'), FILTER_VALIDATE_BOOLEAN); + $this->load->library('ics_file'); + $ics_stream = $this->ics_file->get_stream($appointment, $service, $provider, $customer); + if ($send_customer === TRUE) { $email->sendAppointmentDetails($appointment, $provider, $service, $customer, $company_settings, $customer_title, - $customer_message, $customer_link, new Email($customer['email'])); + $customer_message, $customer_link, new Email($customer['email']), new Text($ics_stream)); } $send_provider = filter_var($this->providers_model->get_setting('notifications', $provider['id']), @@ -532,7 +535,7 @@ class Appointments extends CI_Controller { { $email->sendAppointmentDetails($appointment, $provider, $service, $customer, $company_settings, $provider_title, - $provider_message, $provider_link, new Email($provider['email'])); + $provider_message, $provider_link, new Email($provider['email']), new Text($ics_stream)); } } catch (Exception $exc) diff --git a/src/application/controllers/Backend_api.php b/src/application/controllers/Backend_api.php index b0aa0baa..efa02893 100644 --- a/src/application/controllers/Backend_api.php +++ b/src/application/controllers/Backend_api.php @@ -368,18 +368,21 @@ class Backend_api extends CI_Controller { $send_customer = $this->settings_model->get_setting('customer_notifications'); + $this->load->library('ics_file'); + $ics_stream = $this->ics_file->get_stream($appointment, $service, $provider, $customer); + if ((bool)$send_customer === TRUE) { $email->sendAppointmentDetails($appointment, $provider, $service, $customer, $company_settings, $customer_title, - $customer_message, $customer_link, new Email($customer['email'])); + $customer_message, $customer_link, new Email($customer['email']), new Text($ics_stream)); } if ($send_provider == TRUE) { $email->sendAppointmentDetails($appointment, $provider, $service, $customer, $company_settings, $provider_title, - $provider_message, $provider_link, new Email($provider['email'])); + $provider_message, $provider_link, new Email($provider['email']), new Text($ics_stream)); } } diff --git a/src/application/libraries/Ics_file.php b/src/application/libraries/Ics_file.php index bf109fe4..cd5ab164 100644 --- a/src/application/libraries/Ics_file.php +++ b/src/application/libraries/Ics_file.php @@ -79,7 +79,7 @@ class Ics_file { $calendar ->setProdId('-//EasyAppointments//Open Source Web Scheduler//EN') - ->setTimezone(new DateTimeZone($provider['settings']['timezone'])) + ->setTimezone(new DateTimeZone(date_default_timezone_get())) ->addEvent($event); // Setup exporter. diff --git a/src/engine/Notifications/Email.php b/src/engine/Notifications/Email.php index 40e53ddb..f78288a4 100644 --- a/src/engine/Notifications/Email.php +++ b/src/engine/Notifications/Email.php @@ -90,6 +90,7 @@ class Email { * @param \EA\Engine\Types\Url $appointmentLink This link is going to enable the receiver to make changes * to the appointment record. * @param \EA\Engine\Types\Email $recipientEmail The recipient email address. + * @param \EA\Engine\Types\Text $icsStream Stream contents of the ICS file. */ public function sendAppointmentDetails( array $appointment, @@ -100,7 +101,8 @@ class Email { Text $title, Text $message, Url $appointmentLink, - EmailAddress $recipientEmail + EmailAddress $recipientEmail, + Text $icsStream ) { switch ($company['date_format']) { @@ -158,6 +160,8 @@ class Email { $mailer->Subject = $title->get(); $mailer->Body = $html; + $mailer->addStringAttachment($icsStream->get(), 'invitation.ics'); + if ( ! $mailer->Send()) { throw new \RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): '