api export for all shifts completed

This commit is contained in:
Philip Häusler 2013-12-09 17:17:23 +01:00
parent ad5899f028
commit 4aa85a3ff2
4 changed files with 12 additions and 7 deletions

View File

@ -14,19 +14,21 @@ function NeededAngelTypes_by_shift($shift) {
OR `room_id`=" . sql_escape($shift['RID']) . " OR `room_id`=" . sql_escape($shift['RID']) . "
ORDER BY `room_id` DESC ORDER BY `room_id` DESC
"); ");
if ($needed_angeltypes === false) if ($needed_angeltypes_source === false)
return false; return false;
$needed_angeltypes = array(); $needed_angeltypes_merged = array();
foreach ($needed_angeltypes_source as $angeltype) foreach ($needed_angeltypes_source as $angeltype)
$needed_angeltypes[$angeltype['id']] = $angeltype; $needed_angeltypes_merged[$angeltype['id']] = $angeltype;
foreach ($needed_angeltypes as &$angeltype) { $needed_angeltypes = array();
foreach ($needed_angeltypes_merged as $angeltype) {
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']); $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
if ($shift_entries === false) if ($shift_entries === false)
return false; return false;
$angeltype['taken'] = count($shift_entries); $angeltype['taken'] = count($shift_entries);
$needed_angeltypes[] = $angeltype;
} }
return $needed_angeltypes; return $needed_angeltypes;

View File

@ -8,7 +8,7 @@
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) { function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) {
return sql_select(" return sql_select("
SELECT * SELECT *
FROM `ShiftEntries` FROM `ShiftEntry`
WHERE `SID`=" . sql_escape($shift_id) . " WHERE `SID`=" . sql_escape($shift_id) . "
AND `TID`=" . sql_escape($angeltype_id) . " AND `TID`=" . sql_escape($angeltype_id) . "
"); ");

View File

@ -16,9 +16,11 @@ function Shifts() {
$needed_angeltypes = NeededAngelTypes_by_shift($shift); $needed_angeltypes = NeededAngelTypes_by_shift($shift);
if ($needed_angeltypes === false) if ($needed_angeltypes === false)
return false; return false;
$shift['angeltypes'] = $needed_angeltypes; $shift['angeltypes'] = $needed_angeltypes;
} }
return $shifts_source;
} }
?> ?>

View File

@ -12,6 +12,7 @@ require_once ('includes/sys_template.php');
require_once ('includes/model/LogEntries_model.php'); require_once ('includes/model/LogEntries_model.php');
require_once ('includes/model/NeededAngelTypes_model.php'); require_once ('includes/model/NeededAngelTypes_model.php');
require_once ('includes/model/ShiftEntry_model.php');
require_once ('includes/model/Shifts_model.php'); require_once ('includes/model/Shifts_model.php');
require_once ('includes/model/User_model.php'); require_once ('includes/model/User_model.php');
@ -25,7 +26,7 @@ require_once ('includes/helper/message_helper.php');
require_once ('includes/helper/error_helper.php'); require_once ('includes/helper/error_helper.php');
require_once ('config/config.default.php'); require_once ('config/config.default.php');
if (file_exists('config/config.php')) if (file_exists('../config/config.php'))
require_once ('config/config.php'); require_once ('config/config.php');
require_once ('includes/pages/admin_active.php'); require_once ('includes/pages/admin_active.php');