Skip to content
Snippets Groups Projects
Commit f50ce7db authored by Moritz Strohm's avatar Moritz Strohm
Browse files

SingleCalendar::deleteEventWithConsultation: count other consultation events...

SingleCalendar::deleteEventWithConsultation: count other consultation events before cancelling all bookings
parent 6581c801
No related branches found
No related tags found
No related merge requests found
...@@ -579,7 +579,15 @@ class SingleCalendar ...@@ -579,7 +579,15 @@ class SingleCalendar
if ($consultation_event) { if ($consultation_event) {
//Check if the slot is empty and delete it, if so. //Check if the slot is empty and delete it, if so.
if ($consultation_event->slot) { if ($consultation_event->slot) {
if (empty($consultation_event->slot->events)) { //Count other consultation events:
$other_event_c = ConsultationEvent::countBySql(
'slot_id = :slot_id AND event_id <> :event_id',
[
'slot_id' => $consultation_event->slot->id,
'event_id' => $consultation_event->event_id
]
);
if ($other_event_c == 0) {
foreach ($consultation_event->slot->bookings as $booking) { foreach ($consultation_event->slot->bookings as $booking) {
$booking->cancel(); $booking->cancel();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment