From 85e440339267859f9d3f70183c32f9443ca9a27a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sat, 7 Sep 2019 01:44:15 +0200 Subject: Rooms: Save times as Worklog and notify on room deletion --- includes/model/Shifts_model.php | 7 +++++-- includes/pages/admin_rooms.php | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'includes') diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 2408eb49..01295fbc 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -80,12 +80,15 @@ function Shifts_from_frab() } /** - * @param array $room + * @param array|int $room * @return array[] */ function Shifts_by_room($room) { - return DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]); + return DB::select( + 'SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', + [is_array($room) ? $room['RID'] : $room] + ); } /** diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index bc0eb651..c55eb227 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -179,9 +179,16 @@ function admin_rooms() ]); } elseif ($request->input('show') == 'delete') { if ($request->hasPostData('ack')) { + $shifts = Shifts_by_room($room_id); + foreach ($shifts as $shift) { + $shift = Shift($shift['SID']); + + UserWorkLog_from_shift($shift); + mail_shift_delete($shift); + } + Room_delete($room_id); - engelsystem_log('Room deleted: ' . $name); success(sprintf(__('Room %s deleted.'), $name)); redirect(page_link_to('admin_rooms')); } -- cgit v1.2.3-70-g09d2