summaryrefslogtreecommitdiff
path: root/includes/model/ShiftTypes_model.php
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-12-25 22:32:18 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-12-25 22:32:18 +0100
commite89acc0c1d1188662da7490e3a75a4a5c3950a75 (patch)
treef646260cc23195008f6ca5152426b17641fc4f69 /includes/model/ShiftTypes_model.php
parentbcd33c02c814a8d82c08c078c8fae287d1cd95a5 (diff)
parent544a51612f14c4f3cf7d1c4a6de26a99ea94b788 (diff)
merge feature-shift-types
Diffstat (limited to 'includes/model/ShiftTypes_model.php')
-rw-r--r--includes/model/ShiftTypes_model.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php
new file mode 100644
index 00000000..7b502585
--- /dev/null
+++ b/includes/model/ShiftTypes_model.php
@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * Delete a shift type.
+ * @param int $shifttype_id
+ */
+function ShiftType_delete($shifttype_id) {
+ return sql_query("DELETE FROM `ShiftTypes` WHERE `id`=" . sql_escape($shifttype_id));
+}
+
+/**
+ * Update a shift type.
+ *
+ * @param int $shifttype_id
+ * @param string $name
+ * @param int $angeltype_id
+ * @param string $description
+ */
+function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) {
+ return sql_query("UPDATE `ShiftTypes` SET
+ `name`='" . sql_escape($name) . "',
+ `angeltype_id`=" . sql_null($angeltype_id) . ",
+ `description`='" . sql_escape($description) . "'
+ WHERE `id`=" . sql_escape($shifttype_id));
+}
+
+/**
+ * Create a shift type.
+ *
+ * @param string $name
+ * @param int $angeltype_id
+ * @param string $description
+ * @return new shifttype id
+ */
+function ShiftType_create($name, $angeltype_id, $description) {
+ $result = sql_query("INSERT INTO `ShiftTypes` SET
+ `name`='" . sql_escape($name) . "',
+ `angeltype_id`=" . sql_null($angeltype_id) . ",
+ `description`='" . sql_escape($description) . "'");
+ if ($result === false)
+ return false;
+ return sql_id();
+}
+
+/**
+ * Get a shift type by id.
+ *
+ * @param int $shifttype_id
+ */
+function ShiftType($shifttype_id) {
+ $shifttype = sql_select("SELECT * FROM `ShiftTypes` WHERE `id`=" . sql_escape($shifttype_id));
+ if ($shifttype === false)
+ return false;
+ if ($shifttype == null)
+ return null;
+ return $shifttype[0];
+}
+
+/**
+ * Get all shift types.
+ */
+function ShiftTypes() {
+ return sql_select("SELECT * FROM `ShiftTypes` ORDER BY `name`");
+}
+
+?> \ No newline at end of file