mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-21 23:42:21 +03:00
Added more information to the ICS file, sent with the email confirmation.
This commit is contained in:
parent
cfc6167d4f
commit
abe6de3ab5
1 changed files with 78 additions and 4 deletions
|
@ -15,7 +15,9 @@ use Jsvrcek\ICS\CalendarExport;
|
|||
use Jsvrcek\ICS\CalendarStream;
|
||||
use Jsvrcek\ICS\Exception\CalendarEventException;
|
||||
use Jsvrcek\ICS\Model\Calendar;
|
||||
use Jsvrcek\ICS\Model\CalendarAlarm;
|
||||
use Jsvrcek\ICS\Model\CalendarEvent;
|
||||
use Jsvrcek\ICS\Model\Description\Location;
|
||||
use Jsvrcek\ICS\Model\Relationship\Attendee;
|
||||
use Jsvrcek\ICS\Model\Relationship\Organizer;
|
||||
use Jsvrcek\ICS\Utility\Formatter;
|
||||
|
@ -44,8 +46,10 @@ class Ics_file {
|
|||
*/
|
||||
public function get_stream($appointment, $service, $provider, $customer)
|
||||
{
|
||||
$appointment_start = new DateTime($appointment['start_datetime']);
|
||||
$appointment_end = new DateTime($appointment['end_datetime']);
|
||||
$appointment_timezone = new DateTimeZone($provider['timezone']);
|
||||
|
||||
$appointment_start = new DateTime($appointment['start_datetime'], $appointment_timezone);
|
||||
$appointment_end = new DateTime($appointment['end_datetime'], $appointment_timezone);
|
||||
|
||||
// Setup the event.
|
||||
$event = new CalendarEvent();
|
||||
|
@ -53,10 +57,44 @@ class Ics_file {
|
|||
$event
|
||||
->setStart($appointment_start)
|
||||
->setEnd($appointment_end)
|
||||
->setStatus('CONFIRMED')
|
||||
->setSummary($service['name'])
|
||||
->setUid($appointment['id']);
|
||||
|
||||
// Add the customer attendee.
|
||||
if (!empty($service['location']))
|
||||
{
|
||||
$location = new Location();
|
||||
$location->setName((string)$service['location']);
|
||||
$event->addLocation($location);
|
||||
}
|
||||
|
||||
$description = [
|
||||
'',
|
||||
lang('provider'),
|
||||
'',
|
||||
lang('name') . ': ' . $provider['first_name'] . ' ' . $provider['last_name'],
|
||||
lang('email') .': ' . $provider['email'],
|
||||
lang('phone_number') . ': ' . $provider['phone_number'],
|
||||
lang('address') . ': ' . $provider['address'],
|
||||
lang('city') . ': ' . $provider['city'],
|
||||
lang('zip_code') . ': ' . $provider['zip_code'],
|
||||
'',
|
||||
lang('customer'),
|
||||
'',
|
||||
lang('name') . ': ' . $customer['first_name'] . ' ' . $customer['last_name'],
|
||||
lang('email') .': ' . $customer['email'],
|
||||
lang('phone_number') . ': ' . $customer['phone_number'],
|
||||
lang('address') . ': ' . $customer['address'],
|
||||
lang('city') . ': ' . $customer['city'],
|
||||
lang('zip_code') . ': ' . $customer['zip_code'],
|
||||
'',
|
||||
lang('notes'),
|
||||
'',
|
||||
$appointment['notes'],
|
||||
];
|
||||
|
||||
$event->setDescription(implode("\\n", $description));
|
||||
|
||||
$attendee = new Attendee(new Formatter());
|
||||
|
||||
if (isset($customer['email']) && ! empty($customer['email']))
|
||||
|
@ -64,8 +102,44 @@ class Ics_file {
|
|||
$attendee->setValue($customer['email']);
|
||||
}
|
||||
|
||||
|
||||
// Add the event attendees.
|
||||
$attendee->setName($customer['first_name'] . ' ' . $customer['last_name']);
|
||||
$attendee->setCalendarUserType('INDIVIDUAL')
|
||||
->setRole('REQ-PARTICIPANT')
|
||||
->setParticipationStatus('NEEDS-ACTION')
|
||||
->setRsvp('TRUE');
|
||||
$event->addAttendee($attendee);
|
||||
|
||||
$alarm = new CalendarAlarm();
|
||||
$alarm_datetime = clone $appointment_start;
|
||||
$alarm->setTrigger($alarm_datetime->modify('-15 minutes'));
|
||||
$alarm->setSummary('Alarm notification');
|
||||
$alarm->setDescription('This is an event reminder');
|
||||
$alarm->setAction('EMAIL');
|
||||
$alarm->addAttendee($attendee);
|
||||
$event->addAlarm($alarm);
|
||||
|
||||
$alarm = new CalendarAlarm();
|
||||
$alarm_datetime = clone $appointment_start;
|
||||
$alarm->setTrigger($alarm_datetime->modify('-60 minutes'));
|
||||
$alarm->setSummary('Alarm notification');
|
||||
$alarm->setDescription('This is an event reminder');
|
||||
$alarm->setAction('EMAIL');
|
||||
$alarm->addAttendee($attendee);
|
||||
$event->addAlarm($alarm);
|
||||
|
||||
$attendee = new Attendee(new Formatter());
|
||||
|
||||
if (isset($provider['email']) && ! empty($provider['email']))
|
||||
{
|
||||
$attendee->setValue($provider['email']);
|
||||
}
|
||||
|
||||
$attendee->setName($provider['first_name'] . ' ' . $provider['last_name']);
|
||||
$attendee->setCalendarUserType('INDIVIDUAL')
|
||||
->setRole('REQ-PARTICIPANT')
|
||||
->setParticipationStatus('ACCEPTED')
|
||||
->setRsvp('FALSE');
|
||||
$event->addAttendee($attendee);
|
||||
|
||||
// Set the organizer.
|
||||
|
|
Loading…
Reference in a new issue