summaryrefslogtreecommitdiff
path: root/includes/model
diff options
context:
space:
mode:
Diffstat (limited to 'includes/model')
-rw-r--r--includes/model/NeededAngelTypes_model.php10
-rw-r--r--includes/model/Shifts_model.php25
2 files changed, 26 insertions, 9 deletions
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 9bad22c8..81ce2d5f 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -3,14 +3,14 @@
/**
* Returns all needed angeltypes and already taken needs.
*
- * @param Shift $shift
+ * @param shiftID id of shift
*/
-function NeededAngelTypes_by_shift($shift) {
+function NeededAngelTypes_by_shift($shiftId) {
$needed_angeltypes_source = sql_select("
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
- WHERE `shift_id`=" . sql_escape($shift['SID']) . "
+ WHERE `shift_id`=" . sql_escape($shiftId) . "
AND `count` > 0
ORDER BY `room_id` DESC
");
@@ -23,7 +23,7 @@ function NeededAngelTypes_by_shift($shift) {
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
- WHERE `room_id`=" . sql_escape($shift['RID']) . "
+ WHERE `room_id`=" . sql_escape($shiftId) . "
AND `count` > 0
ORDER BY `room_id` DESC
");
@@ -33,7 +33,7 @@ function NeededAngelTypes_by_shift($shift) {
$needed_angeltypes = array();
foreach ($needed_angeltypes_source as $angeltype) {
- $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['angel_type_id']);
+ $shift_entries = ShiftEntries_by_shift_and_angeltype($shiftId, $angeltype['angel_type_id']);
if ($shift_entries === false)
return false;
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 224bfc0b..df47b967 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -41,7 +41,7 @@ function mShiftList() {
if (count($shifts_source) > 0) {
return $shifts_source;
}
-return null;
+ return null;
}
/**
@@ -51,10 +51,27 @@ return null;
*/
function mShift($id) {
$shifts_source = sql_select("SELECT * FROM `Shifts` WHERE `SID`=" . sql_escape($id) . " LIMIT 1");
+ $shiftsEntry_source = sql_select("SELECT `TID` , `UID` , `freeloaded` FROM `ShiftEntry` WHERE `SID`=" . sql_escape($id) );
+
if ($shifts_source === false)
return false;
- if (count($shifts_source) > 0)
- return $shifts_source[0];
+ if (count($shifts_source) > 0) {
+ $result = $shifts_source[0];
+
+ $result['ShiftEntry'] = $shiftsEntry_source;
+
+ $temp = NeededAngelTypes_by_shift($id);
+ foreach( $temp as $e)
+ {
+ $result['NeedAngels'][] = array (
+ 'TID' => $e['angel_type_id'],
+ 'count' => $e['count'],
+ 'restricted' => $e['restricted'],
+ 'taken' => $e['taken'] );
+ }
+
+ return $result;
+ }
return null;
}
@@ -71,7 +88,7 @@ function Shifts() {
return false;
foreach ($shifts_source as &$shift) {
- $needed_angeltypes = NeededAngelTypes_by_shift($shift);
+ $needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
if ($needed_angeltypes === false)
return false;