Added ICS invitation files in notifications as attachments.

This commit is contained in:
alext 2017-11-02 14:09:15 +01:00
parent 5c00bd9c82
commit 35d812a550
4 changed files with 16 additions and 6 deletions

View file

@ -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)

View file

@ -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));
}
}

View file

@ -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.

View file

@ -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__ . '): '