File formatting fixes

main
Igor Scheller 5 years ago committed by msquare
parent a33298c3ce
commit 390db395a6

@ -54,8 +54,8 @@ class CleanupGroupPrivileges extends Migration
'
DELETE FROM `GroupPrivileges`
WHERE
group_id = ?
AND privilege_id = ?
group_id = ?
AND privilege_id = ?
',
[
-40, // Shift Coordinator

@ -61,7 +61,7 @@ class AddAngelSupporterPermissions extends Migration
return sprintf('
%s FROM GroupPrivileges
WHERE group_id = (SELECT UID FROM `Groups` WHERE `name` = ?)
AND privilege_id = (SELECT id FROM `Privileges` WHERE `name` = ?)
AND privilege_id = (SELECT id FROM `Privileges` WHERE `name` = ?)
', $type);
}
}

@ -213,11 +213,11 @@ function user_controller()
);
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
$needed_angeltype['users'] = DB::select('
SELECT `ShiftEntry`.`freeloaded`, `users`.*
FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
WHERE `ShiftEntry`.`SID` = ?
AND `ShiftEntry`.`TID` = ?
SELECT `ShiftEntry`.`freeloaded`, `users`.*
FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
WHERE `ShiftEntry`.`SID` = ?
AND `ShiftEntry`.`TID` = ?
',
[$shift['SID'], $needed_angeltype['id']]
);

@ -31,16 +31,16 @@ function bargraph($dom_id, $key, $row_names, $colors, $data)
}
return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
<script type="text/javascript">
$(function(){
var ctx = $(\'#' . $dom_id . '\').get(0).getContext(\'2d\');
var chart = new Chart(ctx, ' . json_encode([
'type' => 'bar',
'data' => [
'labels' => $labels,
'datasets' => $datasets
]
]) . ');
});
</script>';
<script type="text/javascript">
$(function(){
var ctx = $(\'#' . $dom_id . '\').get(0).getContext(\'2d\');
var chart = new Chart(ctx, ' . json_encode([
'type' => 'bar',
'data' => [
'labels' => $labels,
'datasets' => $datasets
]
]) . ');
});
</script>';
}

@ -44,9 +44,9 @@ function AngelType_has_contact_info($angeltype)
function AngelType_delete($angeltype)
{
DB::delete('
DELETE FROM `AngelTypes`
WHERE `id`=?
LIMIT 1
DELETE FROM `AngelTypes`
WHERE `id`=?
LIMIT 1
', [$angeltype['id']]);
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype, true));
}
@ -59,17 +59,18 @@ function AngelType_delete($angeltype)
function AngelType_update($angeltype)
{
DB::update('
UPDATE `AngelTypes` SET
`name` = ?,
`restricted` = ?,
`description` = ?,
`requires_driver_license` = ?,
`no_self_signup` = ?,
`contact_name` = ?,
`contact_dect` = ?,
`contact_email` = ?,
`show_on_dashboard` = ?
WHERE `id` = ?',
UPDATE `AngelTypes` SET
`name` = ?,
`restricted` = ?,
`description` = ?,
`requires_driver_license` = ?,
`no_self_signup` = ?,
`contact_name` = ?,
`contact_dect` = ?,
`contact_email` = ?,
`show_on_dashboard` = ?
WHERE `id` = ?
',
[
$angeltype['name'],
(int)$angeltype['restricted'],
@ -104,18 +105,18 @@ function AngelType_update($angeltype)
function AngelType_create($angeltype)
{
DB::insert('
INSERT INTO `AngelTypes` (
`name`,
`restricted`,
`description`,
`requires_driver_license`,
`no_self_signup`,
`contact_name`,
`contact_dect`,
`contact_email`,
`show_on_dashboard`
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO `AngelTypes` (
`name`,
`restricted`,
`description`,
`requires_driver_license`,
`no_self_signup`,
`contact_name`,
`contact_dect`,
`contact_email`,
`show_on_dashboard`
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
',
[
$angeltype['name'],
@ -187,14 +188,14 @@ function AngelType_validate_name($name, $angeltype)
function AngelTypes_with_user($userId)
{
return DB::select('
SELECT `AngelTypes`.*,
`UserAngelTypes`.`id` AS `user_angeltype_id`,
`UserAngelTypes`.`confirm_user_id`,
`UserAngelTypes`.`supporter`
FROM `AngelTypes`
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
AND `UserAngelTypes`.`user_id` = ?
ORDER BY `name`', [$userId]);
SELECT `AngelTypes`.*,
`UserAngelTypes`.`id` AS `user_angeltype_id`,
`UserAngelTypes`.`confirm_user_id`,
`UserAngelTypes`.`supporter`
FROM `AngelTypes`
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
AND `UserAngelTypes`.`user_id` = ?
ORDER BY `name`', [$userId]);
}
/**
@ -205,9 +206,10 @@ function AngelTypes_with_user($userId)
function AngelTypes()
{
return DB::select('
SELECT *
FROM `AngelTypes`
ORDER BY `name`');
SELECT *
FROM `AngelTypes`
ORDER BY `name`
');
}
/**

@ -18,8 +18,8 @@ use Engelsystem\Database\DB;
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
{
DB::insert('
INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`)
VALUES (?, ?, ?, ?)
INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`)
VALUES (?, ?, ?, ?)
',
[
$shift_id,

@ -72,8 +72,8 @@ function Room_delete($room_id)
function Room_create($name, $map_url, $description)
{
DB::insert('
INSERT INTO `Room` (`Name`, `map_url`, `description`)
VALUES (?, ?, ?)
INSERT INTO `Room` (`Name`, `map_url`, `description`)
VALUES (?, ?, ?)
', [
$name,
$map_url,

@ -48,18 +48,19 @@ function ShiftEntries_freeloaded_count()
function ShiftEntries_by_shift($shift_id)
{
return DB::select('
SELECT
`users`.*,
`ShiftEntry`.`UID`,
`ShiftEntry`.`TID`,
`ShiftEntry`.`SID`,
`AngelTypes`.`name` AS `angel_type_name`,
`ShiftEntry`.`Comment`,
`ShiftEntry`.`freeloaded`
FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
WHERE `ShiftEntry`.`SID` = ?',
SELECT
`users`.*,
`ShiftEntry`.`UID`,
`ShiftEntry`.`TID`,
`ShiftEntry`.`SID`,
`AngelTypes`.`name` AS `angel_type_name`,
`ShiftEntry`.`Comment`,
`ShiftEntry`.`freeloaded`
FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
WHERE `ShiftEntry`.`SID` = ?
',
[$shift_id]
);
}
@ -78,15 +79,15 @@ function ShiftEntry_create($shift_entry)
$room = Room($shift['RID']);
$angeltype = AngelType($shift_entry['TID']);
$result = DB::insert('
INSERT INTO `ShiftEntry` (
`SID`,
`TID`,
`UID`,
`Comment`,
`freeload_comment`,
`freeloaded`
)
VALUES(?, ?, ?, ?, ?, ?)
INSERT INTO `ShiftEntry` (
`SID`,
`TID`,
`UID`,
`Comment`,
`freeload_comment`,
`freeloaded`
)
VALUES(?, ?, ?, ?, ?, ?)
',
[
$shift_entry['SID'],
@ -119,12 +120,13 @@ function ShiftEntry_create($shift_entry)
function ShiftEntry_update($shift_entry)
{
DB::update('
UPDATE `ShiftEntry`
SET
`Comment` = ?,
`freeload_comment` = ?,
`freeloaded` = ?
WHERE `id` = ?',
UPDATE `ShiftEntry`
SET
`Comment` = ?,
`freeload_comment` = ?,
`freeloaded` = ?
WHERE `id` = ?
',
[
$shift_entry['Comment'],
$shift_entry['freeload_comment'],
@ -191,7 +193,7 @@ function ShiftEntries_upcoming_for_user($userId)
WHERE `ShiftEntry`.`UID` = ?
AND `Shifts`.`end` > ?
ORDER BY `Shifts`.`end`
',
',
[
$userId,
time(),
@ -209,16 +211,16 @@ function ShiftEntries_upcoming_for_user($userId)
function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null)
{
return DB::select('
SELECT *
FROM `ShiftEntry`
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
WHERE `ShiftEntry`.`UID` = ?
AND `Shifts`.`end` < ?
AND `ShiftEntry`.`freeloaded` = 0
' . ($sinceTime ? 'AND Shifts.start >= ' . $sinceTime->getTimestamp() : '') . '
ORDER BY `Shifts`.`end` desc
',
SELECT *
FROM `ShiftEntry`
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
WHERE `ShiftEntry`.`UID` = ?
AND `Shifts`.`end` < ?
AND `ShiftEntry`.`freeloaded` = 0
' . ($sinceTime ? 'AND Shifts.start >= ' . $sinceTime->getTimestamp() : '') . '
ORDER BY `Shifts`.`end` desc
',
[
$userId,
time(),
@ -257,11 +259,11 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
function ShiftEntries_freeloaded_by_user($userId)
{
return DB::select('
SELECT *
FROM `ShiftEntry`
WHERE `freeloaded` = 1
AND `UID` = ?
',
SELECT *
FROM `ShiftEntry`
WHERE `freeloaded` = 1
AND `UID` = ?
',
[
$userId
]

@ -23,11 +23,11 @@ function ShiftType_delete($shifttype_id)
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
{
DB::update('
UPDATE `ShiftTypes` SET
`name`=?,
`angeltype_id`=?,
`description`=?
WHERE `id`=?
UPDATE `ShiftTypes` SET
`name`=?,
`angeltype_id`=?,
`description`=?
WHERE `id`=?
',
[
$name,

@ -18,9 +18,9 @@ function Shifts_by_angeltype($angeltype)
WHERE `NeededAngelTypes`.`angel_type_id` = ?
AND `NeededAngelTypes`.`count` > 0
AND s.shift_id IS NULL
UNION
SELECT DISTINCT `Shifts`.* FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id` = `Shifts`.`RID`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
@ -48,9 +48,9 @@ function Shifts_free($start, $end)
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
AND s.shift_id IS NULL
UNION
SELECT *
FROM `Shifts`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
@ -91,34 +91,37 @@ function Shifts_by_room($room)
*/
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
$sql = 'SELECT * FROM (
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts`
JOIN `Room` USING (`RID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0
AND s.shift_id IS NULL
UNION
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts`
JOIN `Room` USING (`RID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0
AND NOT s.shift_id IS NULL) AS tmp_shifts
ORDER BY `room_name`, `start`';
$sql = '
SELECT * FROM (
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts`
JOIN `Room` USING (`RID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0
AND s.shift_id IS NULL
UNION
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts`
JOIN `Room` USING (`RID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0
AND NOT s.shift_id IS NULL
) AS tmp_shifts
ORDER BY `room_name`, `start`
';
return DB::select(
$sql,
@ -138,37 +141,38 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
$sql = '
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
`AngelTypes`.`id`,
`AngelTypes`.`name`,
`AngelTypes`.`restricted`,
`AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND s.shift_id IS NULL
UNION
SELECT
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
`AngelTypes`.`id`,
`AngelTypes`.`name`,
`AngelTypes`.`restricted`,
`AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND NOT s.shift_id IS NULL';
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND s.shift_id IS NULL
UNION
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
`AngelTypes`.`id`,
`AngelTypes`.`name`,
`AngelTypes`.`restricted`,
`AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ? AND ?
AND NOT s.shift_id IS NULL
';
return DB::select(
$sql,
@ -189,38 +193,38 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
{
return DB::selectOne('
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
`AngelTypes`.`id`,
`AngelTypes`.`name`,
`AngelTypes`.`restricted`,
`AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`SID`=?
AND `AngelTypes`.`id`=?
AND s.shift_id IS NULL
UNION
SELECT
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
`AngelTypes`.`id`,
`AngelTypes`.`name`,
`AngelTypes`.`restricted`,
`AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`SID`=?
AND `AngelTypes`.`id`=?
AND NOT s.shift_id IS NULL
',
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`SID`=?
AND `AngelTypes`.`id`=?
AND s.shift_id IS NULL
UNION
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
`AngelTypes`.`id`,
`AngelTypes`.`name`,
`AngelTypes`.`restricted`,
`AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `Shifts`.`SID`=?
AND `AngelTypes`.`id`=?
AND NOT s.shift_id IS NULL
',
[
$shift['SID'],
$angeltype['id'],
@ -237,19 +241,19 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
$sql = sprintf('
SELECT
users.*,
`ShiftEntry`.`UID`,
`ShiftEntry`.`TID`,
`ShiftEntry`.`SID`,
`ShiftEntry`.`Comment`,
`ShiftEntry`.`freeloaded`
FROM `Shifts`
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
WHERE `Shifts`.`RID` IN (%s)
AND `start` BETWEEN ? AND ?
ORDER BY `Shifts`.`start`
SELECT
users.*,
`ShiftEntry`.`UID`,
`ShiftEntry`.`TID`,
`ShiftEntry`.`SID`,
`ShiftEntry`.`Comment`,
`ShiftEntry`.`freeloaded`
FROM `Shifts`
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
WHERE `Shifts`.`RID` IN (%s)
AND `start` BETWEEN ? AND ?
ORDER BY `Shifts`.`start`
',
implode(',', $shiftsFilter->getRooms())
);
@ -518,16 +522,16 @@ function Shift_update($shift)
mail_shift_change(Shift($shift['SID']), $shift);
return DB::update('
UPDATE `Shifts` SET
`shifttype_id` = ?,
`start` = ?,
`end` = ?,
`RID` = ?,
`title` = ?,
`URL` = ?,
`edited_by_user_id` = ?,
`edited_at_timestamp` = ?
WHERE `SID` = ?
UPDATE `Shifts` SET
`shifttype_id` = ?,
`start` = ?,
`end` = ?,
`RID` = ?,
`title` = ?,
`URL` = ?,
`edited_by_user_id` = ?,
`edited_at_timestamp` = ?
WHERE `SID` = ?
',
[
$shift['shifttype_id'],
@ -552,18 +556,18 @@ function Shift_update($shift)
function Shift_create($shift)
{
DB::insert('
INSERT INTO `Shifts` (
`shifttype_id`,
`start`,
`end`,
`RID`,
`title`,
`URL`,
`created_by_user_id`,
`edited_at_timestamp`,
`created_at_timestamp`
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO `Shifts` (
`shifttype_id`,
`start`,
`end`,
`RID`,
`title`,
`URL`,
`created_by_user_id`,
`edited_at_timestamp`,
`created_at_timestamp`
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
',
[
$shift['shifttype_id'],
@ -591,26 +595,26 @@ function Shift_create($shift)
function Shifts_by_user($userId, $include_freeload_comments = false)
{
return DB::select('
SELECT
`ShiftTypes`.`id` AS `shifttype_id`,
`ShiftTypes`.`name`,
`ShiftEntry`.`id`,
`ShiftEntry`.`SID`,
`ShiftEntry`.`TID`,
`ShiftEntry`.`UID`,
`ShiftEntry`.`freeloaded`,
`ShiftEntry`.`Comment`,
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
`Shifts`.*,
@@session.time_zone AS timezone,
`Room`.*
FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
WHERE `UID` = ?
ORDER BY `start`
',
SELECT
`ShiftTypes`.`id` AS `shifttype_id`,
`ShiftTypes`.`name`,
`ShiftEntry`.`id`,
`ShiftEntry`.`SID`,
`ShiftEntry`.`TID`,
`ShiftEntry`.`UID`,
`ShiftEntry`.`freeloaded`,
`ShiftEntry`.`Comment`,
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
`Shifts`.*,
@@session.time_zone AS timezone,
`Room`.*
FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
WHERE `UID` = ?
ORDER BY `start`
',
[
$userId
]
@ -626,10 +630,10 @@ function Shifts_by_user($userId, $include_freeload_comments = false)
function Shift($shift_id)
{
$result = DB::selectOne('
SELECT `Shifts`.*, `ShiftTypes`.`name`
FROM `Shifts`
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
WHERE `SID`=?', [$shift_id]);
SELECT `Shifts`.*, `ShiftTypes`.`name`
FROM `Shifts`
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
WHERE `SID`=?', [$shift_id]);
if (empty($result)) {
return null;

@ -35,16 +35,16 @@ function stats_hours_to_work()
{
$result = Db::selectOne("
SELECT ROUND(SUM(`count`)) AS `count` FROM (
SELECT
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
* (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
FROM `Shifts`
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` >= ?
AND s.shift_id IS NULL
UNION ALL
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
* (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
@ -77,16 +77,16 @@ function stats_angels_needed_three_hours()
SELECT
GREATEST(0,
(
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
) - (
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
AND `freeloaded`=0
)
)
@ -95,22 +95,22 @@ function stats_angels_needed_three_hours()
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` > ? AND `start` < ?
AND s.shift_id IS NULL
UNION ALL
SELECT
GREATEST(0,
(
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
) - (
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
AND `freeloaded`=0
)
)
@ -152,16 +152,16 @@ function stats_angels_needed_for_nightshifts()
SELECT
GREATEST(0,
(
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
) - (
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
AND `freeloaded`=0
)
)
@ -170,22 +170,22 @@ function stats_angels_needed_for_nightshifts()
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` > ? AND `start` < ?
AND s.shift_id IS NULL
UNION ALL
SELECT
GREATEST(0,
(
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
SELECT SUM(`count`)
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
) - (
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
SELECT COUNT(*) FROM `ShiftEntry`
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
AND `freeloaded`=0
)
)

@ -17,11 +17,11 @@ use Engelsystem\Models\User\User;
function UserAngelType_exists($userId, $angeltype)
{
return count(DB::select('
SELECT `id`
FROM `UserAngelTypes`
WHERE `UserAngelTypes`.`user_id`=?
AND `angeltype_id`=?
', [$userId, $angeltype['id']])) > 0;
SELECT `id`
FROM `UserAngelTypes`
WHERE `UserAngelTypes`.`user_id`=?
AND `angeltype_id`=?
', [$userId, $angeltype['id']])) > 0;
}
/**
@ -33,11 +33,11 @@ function UserAngelType_exists($userId, $angeltype)
function User_angeltypes($userId)
{
return DB::select('
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
FROM `UserAngelTypes`
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
WHERE `UserAngelTypes`.`user_id`=?
', [$userId]);
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
FROM `UserAngelTypes`
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
WHERE `UserAngelTypes`.`user_id`=?
', [$userId]);
}
/**
@ -50,16 +50,16 @@ function User_unconfirmed_AngelTypes($userId)
{
return DB::select('
SELECT
`UserAngelTypes`.*,
`AngelTypes`.`name`,
count(`UnconfirmedMembers`.`user_id`) AS `count`
`UserAngelTypes`.*,
`AngelTypes`.`name`,
count(`UnconfirmedMembers`.`user_id`) AS `count`
FROM `UserAngelTypes`
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
JOIN `UserAngelTypes` AS `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id`
WHERE `UserAngelTypes`.`user_id`=?
AND `UserAngelTypes`.`supporter`=TRUE
AND `AngelTypes`.`restricted`=TRUE
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
AND `UserAngelTypes`.`supporter`=TRUE
AND `AngelTypes`.`restricted`=TRUE
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
GROUP BY `UserAngelTypes`.`angeltype_id`, `UserAngelTypes`.`id`
ORDER BY `AngelTypes`.`name`
', [$userId]);
@ -77,12 +77,12 @@ function User_is_AngelType_supporter($user, $angeltype)
$privileges = privileges_for_user($user->id);
return (count(DB::select('
SELECT `id`
FROM `UserAngelTypes`
WHERE `user_id`=?
AND `angeltype_id`=?
AND `supporter`=TRUE
LIMIT 1
SELECT `id`
FROM `UserAngelTypes`
WHERE `user_id`=?
AND `angeltype_id`=?
AND `supporter`=TRUE
LIMIT 1
',
[
$user->id,
@ -101,10 +101,10 @@ function User_is_AngelType_supporter($user, $angeltype)
function UserAngelType_update($user_angeltype_id, $supporter)
{
DB::update('
UPDATE `UserAngelTypes`
SET `supporter`=?
WHERE `id`=?
LIMIT 1
UPDATE `UserAngelTypes`
SET `supporter`=?
WHERE `id`=?
LIMIT 1
', [(int)$supporter, $user_angeltype_id]);
}
@ -116,9 +116,9 @@ function UserAngelType_update($user_angeltype_id, $supporter)
function UserAngelTypes_delete_all($angeltype_id)
{
DB::delete('
DELETE FROM `UserAngelTypes`
WHERE `angeltype_id`=?
AND `confirm_user_id` IS NULL
DELETE FROM `UserAngelTypes`
WHERE `angeltype_id`=?
AND `confirm_user_id` IS NULL
', [$angeltype_id]);
}
@ -131,10 +131,10 @@ function UserAngelTypes_delete_all($angeltype_id)
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
{
DB::update('
UPDATE `UserAngelTypes`
SET `confirm_user_id`=?
WHERE `angeltype_id`=?
AND `confirm_user_id` IS NULL
UPDATE `UserAngelTypes`
SET `confirm_user_id`=?
WHERE `angeltype_id`=?
AND `confirm_user_id` IS NULL
', [$confirm_user_id, $angeltype_id]);
}
@ -147,10 +147,10 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user_id)
function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
{
DB::update('
UPDATE `UserAngelTypes`
SET `confirm_user_id`=?
WHERE `id`=?
LIMIT 1', [$confirm_user_id, $user_angeltype_id]);
UPDATE `UserAngelTypes`
SET `confirm_user_id`=?
WHERE `id`=?
LIMIT 1', [$confirm_user_id, $user_angeltype_id]);
}
/**
@ -161,9 +161,9 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user_id)
function UserAngelType_delete($user_angeltype)
{
DB::delete('
DELETE FROM `UserAngelTypes`
WHERE `id`=?
LIMIT 1', [$user_angeltype['id']]);
DELETE FROM `UserAngelTypes`
WHERE `id`=?
LIMIT 1', [$user_angeltype['id']]);
}
/**
@ -197,10 +197,10 @@ function UserAngelType_create($userId, $angeltype)
function UserAngelType($user_angeltype_id)
{
$angelType = DB::selectOne('
SELECT *
FROM `UserAngelTypes`
WHERE `id`=?
LIMIT 1', [$user_angeltype_id]);
SELECT *
FROM `UserAngelTypes`
WHERE `id`=?
LIMIT 1', [$user_angeltype_id]);
return empty($angelType) ? null : $angelType;
}
@ -215,11 +215,11 @@ function UserAngelType($user_angeltype_id)
function UserAngelType_by_User_and_AngelType($userId, $angeltype)
{
$angelType = DB::selectOne('
SELECT *
FROM `UserAngelTypes`
WHERE `user_id`=?
AND `angeltype_id`=?
LIMIT 1
SELECT *
FROM `UserAngelTypes`
WHERE `user_id`=?
AND `angeltype_id`=?
LIMIT 1
',
[
$userId,
@ -239,9 +239,9 @@ function UserAngelType_by_User_and_AngelType($userId, $angeltype)
function UserAngelTypes_by_User($userId)
{
return DB::select('
SELECT *
FROM `UserAngelTypes`
WHERE `user_id`=?
SELECT *
FROM `UserAngelTypes`
WHERE `user_id`=?
',
[$userId]
);

@ -64,16 +64,16 @@ function UserDriverLicenses_create($user_driver_license, $userId)
{
$user_driver_license['user_id'] = $userId;
DB::insert('
INSERT INTO `UserDriverLicenses` (
`user_id`,
`has_car`,
`has_license_car`,
`has_license_3_5t_transporter`,
`has_license_7_5t_truck`,
`has_license_12_5t_truck`,
`has_license_forklift`
)
VALUES (?, ?, ?, ?, ?, ?, ?)
INSERT INTO `UserDriverLicenses` (
`user_id`,
`has_car`,
`has_license_car`,
`has_license_3_5t_transporter`,
`has_license_7_5t_truck`,
`has_license_12_5t_truck`,
`has_license_forklift`
)
VALUES (?, ?, ?, ?, ?, ?, ?)
',
[
$user_driver_license['user_id'],
@ -97,16 +97,16 @@ function UserDriverLicenses_create($user_driver_license, $userId)
function UserDriverLicenses_update($user_driver_license)
{
DB::update('
UPDATE `UserDriverLicenses`
SET
`has_car`=?,
`has_license_car`=?,
`has_license_3_5t_transporter`=?,
`has_license_7_5t_truck`=?,
`has_license_12_5t_truck`=?,
`has_license_forklift`=?
WHERE `user_id`=?
',
UPDATE `UserDriverLicenses`
SET
`has_car`=?,
`has_license_car`=?,
`has_license_3_5t_transporter`=?,
`has_license_7_5t_truck`=?,
`has_license_12_5t_truck`=?,
`has_license_forklift`=?
WHERE `user_id`=?
',
[
(int)$user_driver_license['has_car'],
(int)$user_driver_license['has_license_car'],

@ -11,12 +11,12 @@ use Engelsystem\Database\DB;
function User_groups($userId)
{
return DB::select('
SELECT `Groups`.*
FROM `UserGroups`
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
WHERE `UserGroups`.`uid`=?
ORDER BY `UserGroups`.`group_id`
',
SELECT `Groups`.*
FROM `UserGroups`
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
WHERE `UserGroups`.`uid`=?
ORDER BY `UserGroups`.`group_id`
',
[$userId]
);
}

@ -30,12 +30,12 @@ function UserWorkLogsForUser($userId, Carbon $sinceTime = null)
{
return Db::select(
'
SELECT *
FROM `UserWorkLog`
WHERE `user_id`=?
' . ($sinceTime ? 'AND work_timestamp >= ' . $sinceTime->getTimestamp() : '') . '
ORDER BY `created_timestamp`
',
SELECT *
FROM `UserWorkLog`
WHERE `user_id`=?
' . ($sinceTime ? 'AND work_timestamp >= ' . $sinceTime->getTimestamp() : '') . '
ORDER BY `created_timestamp`
',
[
$userId
]

@ -23,7 +23,7 @@ function User_tshirt_score($userId)
$result_shifts = DB::selectOne(sprintf('
SELECT ROUND((%s) / 3600, 2) AS `tshirt_score`
FROM `users` LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
WHERE `users`.`id` = ?
AND `Shifts`.`end` < ?
GROUP BY `users`.`id`
@ -37,7 +37,7 @@ function User_tshirt_score($userId)
$result_worklog = DB::selectOne('
SELECT SUM(`work_hours`) AS `tshirt_score`
FROM `users`
FROM `users`
LEFT JOIN `UserWorkLog` ON `users`.`id` = `UserWorkLog`.`user_id`
WHERE `users`.`id` = ?
AND `UserWorkLog`.`work_timestamp` < ?
@ -281,13 +281,11 @@ function User_get_shifts_sum_query()
return sprintf('
COALESCE(SUM(
(1 +
(
(HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < %2$d)
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`start`)) < %2$d)
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= %2$d)
)
)
(1 + (
(HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < %2$d)
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`start`)) < %2$d)
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= %2$d)
))
* (`Shifts`.`end` - `Shifts`.`start`)
* (1 - (%3$d + 1) * `ShiftEntry`.`freeloaded`)
), 0)

@ -62,8 +62,8 @@ function admin_active()
users.*,
COUNT(ShiftEntry.id) AS shift_count,
(%s + (
SELECT COALESCE(SUM(`work_hours`) * 3600, 0) FROM `UserWorkLog` WHERE `user_id`=`users`.`id`
AND `work_timestamp` < ?
SELECT COALESCE(SUM(`work_hours`) * 3600, 0) FROM `UserWorkLog` WHERE `user_id`=`users`.`id`
AND `work_timestamp` < ?
)) AS `shift_length`
',
$shift_sum_formula
@ -156,8 +156,8 @@ function admin_active()
users.*,
COUNT(ShiftEntry.id) AS shift_count,
(%s + (
SELECT COALESCE(SUM(`work_hours`) * 3600, 0) FROM `UserWorkLog` WHERE `user_id`=`users`.`id`
AND `work_timestamp` < ?
SELECT COALESCE(SUM(`work_hours`) * 3600, 0) FROM `UserWorkLog` WHERE `user_id`=`users`.`id`
AND `work_timestamp` < ?
)) AS `shift_length`
',
$shift_sum_formula

@ -129,7 +129,7 @@ function admin_shifts()
$valid = false;
error(__('Please split the shift-change hours by colons.'));
}
$shift_over_midnight = $request->has('shift_over_midnight')
$shift_over_midnight = $request->has('shift_over_midnight')
&& $request->input('shift_over_midnight') != 'false';
}
} else {
@ -362,16 +362,16 @@ function admin_shifts()
$needed_angel_types_info = [];
foreach ($session->get('admin_shifts_types', []) as $type_id => $count) {
$angel_type_source = DB::selectOne('
SELECT *
FROM `AngelTypes`
WHERE `id` = ?
LIMIT 1', [$type_id]);
SELECT *
FROM `AngelTypes`
WHERE `id` = ?
LIMIT 1', [$type_id]);
if (!empty($angel_type_source)) {
DB::insert('
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
VALUES (?, ?, ?)
',
',
[
$shift_id,
$type_id,
@ -442,8 +442,8 @@ function admin_shifts()
: '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
),
form_checkbox(
'shift_over_midnight',
__('Create a shift over midnight.'),
'shift_over_midnight',
__('Create a shift over midnight.'),
$shift_over_midnight
)
]),

@ -551,19 +551,19 @@ class ImportSchedule extends BaseController
{
return $this->db->selectOne(
'
SELECT
s.SID AS id,
s.title,
s.start,
s.end,
s.shifttype_id AS shift_type_id,
s.RID AS room_id,
r.Name AS room_name,
s.URL as url
FROM Shifts AS s
LEFT JOIN Room r on s.RID = r.RID
WHERE SID = ?
',
SELECT
s.SID AS id,
s.title,
s.start,
s.end,
s.shifttype_id AS shift_type_id,
s.RID AS room_id,
r.Name AS room_name,
s.URL as url
FROM Shifts AS s
LEFT JOIN Room r on s.RID = r.RID
WHERE SID = ?
',
[$id]
);
}

@ -46,16 +46,16 @@ function make_atom_entries_from_news($news_entries)
$updatedAt = isset($news_entries[0]) ? $news_entries[0]->updated_at->format('Y-m-d\TH:i:sP') : '0000:00:00T00:00:00+00:00';
$html = '<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>' . config('app_name') . '</title>
<id>' . $request->getHttpHost()
. htmlspecialchars(preg_replace(
'#[&?]key=[a-f\d]{32}#',
'',
$request->getRequestUri()
))
. '</id>
<updated>' . $updatedAt . '</updated>' . "\n";
<feed xmlns="http://www.w3.org/2005/Atom">
<title>' . config('app_name') . '</title>
<id>' . $request->getHttpHost()
. htmlspecialchars(preg_replace(
'#[&?]key=[a-f\d]{32}#',
'',
$request->getRequestUri()
))
. '</id>
<updated>' . $updatedAt . '</updated>' . "\n";
foreach ($news_entries as $news_entry) {
$html .= make_atom_entry_from_news($news_entry);
}
@ -70,7 +70,7 @@ function make_atom_entries_from_news($news_entries)
function make_atom_entry_from_news(News $news)
{
return '
<entry>
<entry>
<title>' . htmlspecialchars($news->title) . '</title>
<link href="' . page_link_to('news/' . $news->id) . '"/>
<id>' . preg_replace(
@ -80,5 +80,5 @@ function make_atom_entry_from_news(News $news)
) . '</id>
<updated>' . $news->updated_at->format('Y-m-d\TH:i:sP') . '</updated>
<summary type="html">' . htmlspecialchars($news->text) . '</summary>
</entry>' . "\n";
</entry>' . "\n";
}

@ -115,9 +115,9 @@ function load_rooms()
function load_days()
{
$days = DB::select('
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
FROM `Shifts`
ORDER BY `id`, `name`
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
FROM `Shifts`
ORDER BY `id`, `name`
');
$days = array_map('array_shift', $days);
@ -302,8 +302,8 @@ function ical_hint()
page_link_to('user_myshifts', ['reset' => 1])
)
. ' <button class="btn btn-xs btn-danger" data-toggle="collapse" data-target="#collapseApiKey" aria-expanded="false" aria-controls="collapseApiKey">
' . __('Show API Key') . '
</button>'
' . __('Show API Key') . '
</button>'
. '</p>'
. '<p id="collapseApiKey" class="collapse"><code>' . $user->api_key . '</code></p>';
}

@ -27,28 +27,28 @@ function form_spinner($name, $label, $value)
$value = htmlspecialchars($value);
return form_element($label, '
<div class="input-group">
<input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . $value . '" />
<div class="input-group-btn">
<button id="spinner-' . $name . '-down" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-minus"></span>
</button>
<button id="spinner-' . $name . '-up" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-plus"></span>
</button>
<div class="input-group">
<input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . $value . '" />
<div class="input-group-btn">
<button id="spinner-' . $name . '-down" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-minus"></span>
</button>
<button id="spinner-' . $name . '-up" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-plus"></span>
</button>
</div>
</div>
</div>
<script type="text/javascript">
$(\'#spinner-' . $name . '-down\').click(function() {
var spinner = $(\'#spinner-' . $name . '\');
spinner.val(parseInt(spinner.val()) - 1);
});
$(\'#spinner-' . $name . '-up\').click(function() {
var spinner = $(\'#spinner-' . $name . '\');
spinner.val(parseInt(spinner.val()) + 1);
});
</script>
');
<script type="text/javascript">
$(\'#spinner-' . $name . '-down\').click(function() {
var spinner = $(\'#spinner-' . $name . '\');
spinner.val(parseInt(spinner.val()) - 1);
});
$(\'#spinner-' . $name . '-up\').click(function() {
var spinner = $(\'#spinner-' . $name . '\');
spinner.val(parseInt(spinner.val()) + 1);
});
</script>
');
}
/**
@ -71,7 +71,7 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '')
return form_element($label, '
<div class="input-group date" id="' . $dom_id . '" data-min-date="' . $start_date . '" data-max-date="' . $end_date . '">
<input type="date" placeholder="YYYY-MM-DD" name="' . $name . '" class="form-control" value="' . htmlspecialchars($value) . '">'
<input type="date" placeholder="YYYY-MM-DD" name="' . $name . '" class="form-control" value="' . htmlspecialchars($value) . '">'
. '<span class="input-group-addon">' . glyph('th') . '</span>
</div>
', $dom_id);

@ -1,7 +1,5 @@
<?php
use Engelsystem\Renderer\Twig\Extensions\Assets;
/**
* Render a stat for dashborad (big number with label).
* If no style given, style is danger if number > 0, and success if number == 0.
@ -194,12 +192,12 @@ function toolbar_item_divider()
*/
function toolbar_dropdown($glyphicon, $label, $submenu, $class = '')
{
return '<li class="dropdown ' . $class . '">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">'
return '<li class="dropdown ' . $class . '">'
. '<a href="#" class="dropdown-toggle" data-toggle="dropdown">'
. ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
. $label
. ' <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">'
. '<span class="caret"></span></a>'
. '<ul class="dropdown-menu" role="menu">'
. join("\n", $submenu)
. '</ul></li>';
}
@ -214,22 +212,22 @@ function toolbar_dropdown($glyphicon, $label, $submenu, $class = '')
function toolbar_popover($glyphicon, $label, $content, $class = '')
{
$dom_id = md5(microtime() . $glyphicon . $label);
return '<li class="dropdown messages ' . $class . '">
<a id="' . $dom_id . '" href="#" tabindex="0">'
return '<li class="dropdown messages ' . $class . '">'
. '<a id="' . $dom_id . '" href="#" tabindex="0">'
. ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
. $label
. ' <span class="caret"></span></a>
<script type="text/javascript">
$(function(){
$(\'#' . $dom_id . '\').popover({
trigger: \'click\',
html: true,
content: \'' . addslashes(join('', $content)) . '\',
placement: \'bottom\',
container: \'#navbar-offcanvas\'
})
});
</script></li>';
. ' <span class="caret"></span></a>'
. '<script type="text/javascript">
$(function(){
$(\'#' . $dom_id . '\').popover({
trigger: \'click\',
html: true,
content: \'' . addslashes(join('', $content)) . '\',
placement: \'bottom\',
container: \'#navbar-offcanvas\'
})
});
</script></li>';
}

@ -53,23 +53,23 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
], 'driving_license'),
form_submit('submit', __('Save'))
]),
'<script type="text/javascript">
$(function() {
var checkbox = $(\'#wants_to_drive\');
if(checkbox.is(\':checked\'))
$(\'#driving_license\').show();
else
$(\'#driving_license\').hide();
'
<script type="text/javascript">
$(function() {
var checkbox = $(\'#wants_to_drive\');
if(checkbox.is(\':checked\'))
$(\'#driving_license\').show();
else
$(\'#driving_license\').hide();
checkbox.click(
function() {
if($(\'#wants_to_drive\').is(\':checked\'))
$(\'#driving_license\').show();
else
$(\'#driving_license\').hide();
}
);
});
</script>'
checkbox.click(function() {
if($(\'#wants_to_drive\').is(\':checked\'))
$(\'#driving_license\').show();
else
$(\'#driving_license\').hide();
});
});
</script>
'
]);
}

@ -589,7 +589,7 @@ function User_view(
(config('enable_pronoun') && $user_source->personalData->pronoun)
? '<small>' . htmlspecialchars($user_source->personalData->pronoun) . '</small> '
: ''
)
)
. htmlspecialchars($user_source->name)
. (config('enable_user_name') ? ' <small>' . $user_name . '</small>' : ''),
[

@ -1,6 +1,6 @@
/* =============================================================
Error page
============================================================= */
/* =============================================================
Error page
============================================================= */
.error-big {
text-align: center;

@ -1,2 +1,2 @@
// light
@import "base.less";
@import "base.less";

@ -1041,13 +1041,13 @@ a.thumbnail.active {
// Specials for cccamp19 design
.navbar-brand {
.icon-icon_angel {
background-color: @brand-primary;
.icon-icon_angel {
background-color: @brand-primary;
}
strong {
font-weight: lighter;
color: @brand-primary;
color: @brand-primary;
text-shadow:
0 0 10px @brand-primary,
0 0 20px @brand-primary,
@ -1062,7 +1062,7 @@ h1 {
font-weight: lighter;
color: @brand-primary;
text-shadow: 0 0 10px @brand-primary;
.icon-icon_angel {
background-color: @brand-primary;
}

@ -1046,5 +1046,5 @@ a.thumbnail.active {
}
.panel-info .panel-title {
color: #000;
color: #000;
}

@ -41,11 +41,11 @@
@navbar-default-brand-hover-bg: #000;
.navbar {
.bg-info {
.bg-info {
background-color: darken(@brand-info, 30%);
}
}
.bg-danger {
background-color: darken(@brand-danger, 30%);
background-color: darken(@brand-danger, 30%);
}
}

@ -1044,5 +1044,5 @@ a.thumbnail.active {
.label-warning, .label-success, .progress-bar-warning, .progress-bar-success,
.panel-warning .panel-heading, .panel-warning .panel-heading a,
.panel-success .panel-heading, .panel-success .panel-heading a {
color: @gray-darker;
color: @gray-darker;
}

@ -26,7 +26,7 @@
@state-danger-border: @brand-danger;
.label.label-warning {
color: #000;
color: #000;
}
@import "base.less";

@ -1060,7 +1060,7 @@ a.thumbnail.active {
}
.btn-primary, .panel-info .panel-heading {
background-image: linear-gradient(to right, rgb(0, 132, 176) , rgb(0, 163, 86));
background-image: linear-gradient(to right, rgb(0, 132, 176) , rgb(0, 163, 86));
}
.label-warning {

@ -1041,13 +1041,13 @@ a.thumbnail.active {
// Specials for cccamp19 design
.navbar-brand {
.icon-icon_angel {
background-color: @brand-primary;
.icon-icon_angel {
background-color: @brand-primary;
}
strong {
font-weight: lighter;
color: @brand-primary;
color: @brand-primary;
text-shadow:
0 0 10px @brand-primary,
0 0 20px @brand-primary,
@ -1062,14 +1062,14 @@ h1 {
font-weight: lighter;
color: @brand-primary;
text-shadow: 0 0 10px @brand-primary;
.icon-icon_angel {
background-color: @brand-primary;
}
}
.panel-title {
color: #fff;
color: #fff;
}
.input-group-addon {
@ -1078,4 +1078,4 @@ h1 {
.icon-icon_angel {
background-color: #000;
}
}
}

@ -1041,13 +1041,13 @@ a.thumbnail.active {
// Specials for cccamp19 design
.navbar-brand {
.icon-icon_angel {
background-color: @brand-primary;
.icon-icon_angel {
background-color: @brand-primary;
}
strong {
font-weight: lighter;
color: @brand-primary;
color: @brand-primary;
text-shadow:
0 0 10px @brand-primary,
0 0 20px @brand-primary,
@ -1062,7 +1062,7 @@ h1 {
font-weight: lighter;
color: @brand-primary;
text-shadow: 0 0 10px @brand-primary;
.icon-icon_angel {
background-color: @brand-primary;
}

@ -80,4 +80,4 @@
<div class="hidden-print">
%ical_text%
</div>
</div>

Loading…
Cancel
Save