summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-09-07 01:44:15 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2019-09-18 04:27:59 +0200
commit85e440339267859f9d3f70183c32f9443ca9a27a (patch)
tree7f269276fcf8b7e5c6a600ae59f66482a667fa0f /includes
parentd71b27b78b29a2ed725a6e631bf8085bde257f18 (diff)
Rooms: Save times as Worklog and notify on room deletion
Diffstat (limited to 'includes')
-rw-r--r--includes/model/Shifts_model.php7
-rw-r--r--includes/pages/admin_rooms.php9
2 files changed, 13 insertions, 3 deletions
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'));
}