Skip to content

Commit

Permalink
add ics event to each approve email #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Philhil committed May 30, 2019
1 parent 1b7b62c commit d7936db
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion app/Mail/PositionAssigned.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,38 @@ public function __construct(Position $position, $authorizedby)
public function build()
{
$client = $this->position->service()->first()->client()->first();
$service = $this->position->service()->first();

define('ICAL_FORMAT', 'Ymd');

$icalObject = "BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:-//DLRG//Dienstplan//DE\n";

$icalObject .=
"BEGIN:VEVENT
DTSTART:" . date(ICAL_FORMAT, strtotime($service->toDateString())) . "
DTEND:" . date(ICAL_FORMAT, strtotime($service->date->toDateString())) . "
DTSTAMP:" . date(ICAL_FORMAT, strtotime($service->created_at)) . "
SUMMARY: DLRG Dienst $service->comment
UID:$service->id
STATUS:CONFIRMED
LAST-MODIFIED:" . date(ICAL_FORMAT, strtotime($service->updated_at)) . "
LOCATION:DLRG
END:VEVENT\n";

// close calendar
$icalObject .= "END:VCALENDAR";
$icalObject = str_replace(' ', '', $icalObject);

return $this->subject('DLRG DIENSTE: Dienst zugewiesen')->view('email.position')->with([
'position' => $this->position,
'servicepositions' => $this->servicepositions,
'authorizedby' => $this->authorizedby,
])->from($client->mailReplyAddress, $client->mailSenderName);
])->from($client->mailReplyAddress, $client->mailSenderName)
->attachData($icalObject, 'dienst.ics', [
'mime' => 'text/calendar;charset=UTF-8;method=REQUEST',
]);
}
}

0 comments on commit d7936db

Please sign in to comment.