Rooms: Save times as Worklog and notify on room deletion

This commit is contained in:
Igor Scheller 2019-09-07 01:44:15 +02:00
parent d71b27b78b
commit 85e4403392
2 changed files with 13 additions and 3 deletions

View File

@ -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]
);
}
/**

View File

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