@ -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]
);
@ -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'));