Rooms: Save times as Worklog and notify on room deletion

main
Igor Scheller 5 years ago
parent d71b27b78b
commit 85e4403392

@ -80,12 +80,15 @@ function Shifts_from_frab()
} }
/** /**
* @param array $room * @param array|int $room
* @return array[] * @return array[]
*/ */
function Shifts_by_room($room) 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') { } elseif ($request->input('show') == 'delete') {
if ($request->hasPostData('ack')) { 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); Room_delete($room_id);
engelsystem_log('Room deleted: ' . $name);
success(sprintf(__('Room %s deleted.'), $name)); success(sprintf(__('Room %s deleted.'), $name));
redirect(page_link_to('admin_rooms')); redirect(page_link_to('admin_rooms'));
} }

Loading…
Cancel
Save