|
|
@ -73,8 +73,21 @@ function stats_angels_needed_three_hours()
|
|
|
|
$result = Db::selectOne("
|
|
|
|
$result = Db::selectOne("
|
|
|
|
SELECT SUM(`count`) AS `count` FROM (
|
|
|
|
SELECT SUM(`count`) AS `count` FROM (
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
|
|
|
|
GREATEST(0,
|
|
|
|
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
|
|
|
(
|
|
|
|
|
|
|
|
SELECT SUM(`count`)
|
|
|
|
|
|
|
|
FROM `NeededAngelTypes`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
|
|
|
|
|
|
|
) - (
|
|
|
|
|
|
|
|
SELECT COUNT(*) FROM `ShiftEntry`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
|
|
|
|
|
|
|
AND `freeloaded`=0
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
AS `count`
|
|
|
|
AS `count`
|
|
|
|
FROM `Shifts`
|
|
|
|
FROM `Shifts`
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
@ -83,8 +96,21 @@ function stats_angels_needed_three_hours()
|
|
|
|
UNION ALL
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
|
|
|
|
GREATEST(0,
|
|
|
|
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
|
|
|
(
|
|
|
|
|
|
|
|
SELECT SUM(`count`)
|
|
|
|
|
|
|
|
FROM `NeededAngelTypes`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
|
|
|
|
|
|
|
) - (
|
|
|
|
|
|
|
|
SELECT COUNT(*) FROM `ShiftEntry`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
|
|
|
|
|
|
|
AND `freeloaded`=0
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
AS `count`
|
|
|
|
AS `count`
|
|
|
|
FROM `Shifts`
|
|
|
|
FROM `Shifts`
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
@ -116,8 +142,21 @@ function stats_angels_needed_for_nightshifts()
|
|
|
|
$result = Db::selectOne("
|
|
|
|
$result = Db::selectOne("
|
|
|
|
SELECT SUM(`count`) AS `count` FROM (
|
|
|
|
SELECT SUM(`count`) AS `count` FROM (
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
|
|
|
|
GREATEST(0,
|
|
|
|
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
|
|
|
(
|
|
|
|
|
|
|
|
SELECT SUM(`count`)
|
|
|
|
|
|
|
|
FROM `NeededAngelTypes`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
|
|
|
|
|
|
|
) - (
|
|
|
|
|
|
|
|
SELECT COUNT(*) FROM `ShiftEntry`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
|
|
|
|
|
|
|
AND `freeloaded`=0
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
AS `count`
|
|
|
|
AS `count`
|
|
|
|
FROM `Shifts`
|
|
|
|
FROM `Shifts`
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
@ -126,8 +165,21 @@ function stats_angels_needed_for_nightshifts()
|
|
|
|
UNION ALL
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
|
|
|
|
GREATEST(0,
|
|
|
|
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
|
|
|
(
|
|
|
|
|
|
|
|
SELECT SUM(`count`)
|
|
|
|
|
|
|
|
FROM `NeededAngelTypes`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
|
|
|
|
|
|
|
) - (
|
|
|
|
|
|
|
|
SELECT COUNT(*) FROM `ShiftEntry`
|
|
|
|
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
|
|
|
|
|
|
|
WHERE `AngelTypes`.`show_on_dashboard`=FALSE
|
|
|
|
|
|
|
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
|
|
|
|
|
|
|
AND `freeloaded`=0
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
AS `count`
|
|
|
|
AS `count`
|
|
|
|
FROM `Shifts`
|
|
|
|
FROM `Shifts`
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
|
WHERE `end` > ? AND `start` < ?
|
|
|
|