summaryrefslogtreecommitdiff
path: root/includes/model
diff options
context:
space:
mode:
Diffstat (limited to 'includes/model')
-rw-r--r--includes/model/NeededAngelTypes_model.php52
-rw-r--r--includes/model/Room_model.php11
2 files changed, 61 insertions, 2 deletions
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 96ceca83..77a23c3d 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -1,9 +1,59 @@
<?php
/**
+ * Entity needed angeltypes describes how many angels of given type are needed for a shift or in a room.
+ */
+
+/**
+ * Insert a new needed angel type.
+ *
+ * @param int $shift_id
+ * The shift. Can be null, but then a room_id must be given.
+ * @param int $angeltype_id
+ * The angeltype
+ * @param int $room_id
+ * The room. Can be null, but then a shift_id must be given.
+ * @param int $count
+ * How many angels are needed?
+ */
+function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) {
+ $result = sql_query("
+ INSERT INTO `NeededAngelTypes` SET
+ `shift_id`=" . sql_null($shift_id) . ",
+ `angel_type_id`='" . sql_escape($angeltype_id) . "',
+ `room_id`=" . sql_null($room_id) . ",
+ `count`='" . sql_escape($count) . "'");
+ if ($result === false) {
+ return false;
+ }
+ return sql_id();
+}
+
+/**
+ * Deletes all needed angel types from given shift.
+ *
+ * @param int $shift_id
+ * id of the shift
+ */
+function NeededAngelTypes_delete_by_shift($shift_id) {
+ return sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`='" . sql_escape($shift_id) . "'");
+}
+
+/**
+ * Deletes all needed angel types from given room.
+ *
+ * @param int $room_id
+ * id of the room
+ */
+function NeededAngelTypes_delete_by_room($room_id) {
+ return sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
+}
+
+/**
* Returns all needed angeltypes and already taken needs.
*
- * @param shiftID id of shift
+ * @param int $shiftID
+ * id of shift
*/
function NeededAngelTypes_by_shift($shiftId) {
$needed_angeltypes_source = sql_select("
diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php
index 4d03260a..6b6e269e 100644
--- a/includes/model/Room_model.php
+++ b/includes/model/Room_model.php
@@ -1,8 +1,17 @@
<?php
/**
+ * returns a list of rooms.
+ * @param boolean $show_all returns also hidden rooms when true
+ */
+function Rooms($show_all = false) {
+ return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
+}
+
+/**
* Delete a room
- * @param int $room_id
+ *
+ * @param int $room_id
*/
function Room_delete($room_id) {
return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));