diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index d681a0926d9ed412559515cd841c291510435c59..b2ca347166cb77d3efb120df98e85abe584d7304 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -1425,6 +1425,7 @@ class Course_TimesroomsController extends AuthenticatedController private function deleteDate($termin, $cancel_comment) { $seminar_id = $termin->range_id; + $termin_id = $termin->id; $termin_room = $termin->getRoomName(); $termin_date = $termin->getFullname(); $has_topics = $termin->topics->count(); @@ -1440,6 +1441,12 @@ class Course_TimesroomsController extends AuthenticatedController } else { if ($termin->delete()) { StudipLog::log("SEM_DELETE_SINGLEDATE", $termin->id, $seminar_id, 'appointment cancelled'); + + // delete attached resource request appointments if they exist + ResourceRequestAppointment::deleteBySQL( + "appointment_id = ?", + [$termin_id] + ); } } diff --git a/db/migrations/5.2.10_biest_707.php b/db/migrations/5.2.10_biest_707.php new file mode 100644 index 0000000000000000000000000000000000000000..4b209d78772c3448b9921c5328c49ef7e6b121ce --- /dev/null +++ b/db/migrations/5.2.10_biest_707.php @@ -0,0 +1,14 @@ +<?php + +class Biest707 extends Migration +{ + public function description() + { + return 'Removes leftover entries of deleted course dates from resource request appointments'; + } + + public function up() + { + DBManager::get()->exec("DELETE FROM resource_request_appointments WHERE appointment_id NOT IN (SELECT termin_id FROM termine)"); + } +} diff --git a/lib/models/resources/ResourceRequest.class.php b/lib/models/resources/ResourceRequest.class.php index 648d83c9c6df69afda3fb67af6a39c772bfb9df5..6150cf4ed99c64877fcea563dd1539c68bda7398 100644 --- a/lib/models/resources/ResourceRequest.class.php +++ b/lib/models/resources/ResourceRequest.class.php @@ -1421,12 +1421,19 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen */ public function getTypeString($short = false) { - if (count($this->appointments)) { + if (count($this->appointments) > 1) { if ($short) { return _('Einzeltermine'); } else { return sprintf(_('Einzeltermine (%sx)'), count($this->appointments)); } + } elseif (count($this->appointments) == 1) { + if ($short) { + return _('Einzeltermin'); + } else { + return sprintf(_('Einzeltermin (%s)'), + $this->appointments[0]->appointment->getFullname()); + } } elseif ($this->date) { if ($short) { return _('Einzeltermin');