diff --git a/application/controllers/api/frontend/v1/Ort.php b/application/controllers/api/frontend/v1/Ort.php index 81ae8d810..e936686be 100644 --- a/application/controllers/api/frontend/v1/Ort.php +++ b/application/controllers/api/frontend/v1/Ort.php @@ -454,7 +454,7 @@ class Ort extends FHCAPI_Controller $reservationsCount = hasData($reservationsResult) ? getData($reservationsResult)[0]->count : 0; if ($reservationsCount > 0) { - $this->terminateWithError("Cannot delete room with shortcode $ort_kurzbz because there are existing reservations for this room", self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('ui', 'error_existingReservationsForRoomsUponDeletion'), self::ERROR_TYPE_GENERAL); } $softwareImageOrtQuery = "SELECT COUNT(*) FROM extension.tbl_softwareimage_ort WHERE ort_kurzbz = ?"; @@ -465,7 +465,14 @@ class Ort extends FHCAPI_Controller $softwareImageOrtCount = $softwareImageOrtResult->row()->count; if ($softwareImageOrtCount > 0) { - $this->terminateWithError($this->p->t('ui', 'error_existingReservationsForRoomsUponDeletion'), self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('ui', 'error_existingSoftwareImageForRoomTypeUponDeletion'), self::ERROR_TYPE_GENERAL); + } + + $subRoomsCountQuery = "SELECT COUNT(*) FROM public.tbl_ort WHERE parent_ort_kurzbz = ?"; + $subRoomsCountQuery = $this->OrtModel->execReadOnlyQuery($subRoomsCountQuery, [$ort_kurzbz]); + $subRoomsCount = hasData($subRoomsCountQuery) ? getData($subRoomsCountQuery)[0]->count : 0; + if ($subRoomsCount > 0) { + $this->terminateWithError($this->p->t('ui', 'error_existingSubRoomsForRoomUponDeletion'), self::ERROR_TYPE_GENERAL); } $result = $this->OrtModel->delete([ diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 323126d1c..b00ddf347 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -58877,6 +58877,26 @@ I have been informed that I am under no obligation to consent to the transmissio ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'error_existingSubRoomsForRoomUponDeletion', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Es gibt bestehende Unterräume für diesen Raum. Bitte entfernen Sie die Unterräume, bevor Sie den Raum löschen.', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'There are existing sub-rooms for this room. Please remove the sub-rooms before deleting the room.', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'core', 'category' => 'ui',