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` DELETE FROM `GroupPrivileges`
WHERE WHERE
group_id = ? group_id = ?
AND privilege_id = ? AND privilege_id = ?
', ',
[ [
-40, // Shift Coordinator -40, // Shift Coordinator

@ -213,11 +213,11 @@ function user_controller()
); );
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) { foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
$needed_angeltype['users'] = DB::select(' $needed_angeltype['users'] = DB::select('
SELECT `ShiftEntry`.`freeloaded`, `users`.* SELECT `ShiftEntry`.`freeloaded`, `users`.*
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id` JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
WHERE `ShiftEntry`.`SID` = ? WHERE `ShiftEntry`.`SID` = ?
AND `ShiftEntry`.`TID` = ? AND `ShiftEntry`.`TID` = ?
', ',
[$shift['SID'], $needed_angeltype['id']] [$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> return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
var ctx = $(\'#' . $dom_id . '\').get(0).getContext(\'2d\'); var ctx = $(\'#' . $dom_id . '\').get(0).getContext(\'2d\');
var chart = new Chart(ctx, ' . json_encode([ var chart = new Chart(ctx, ' . json_encode([
'type' => 'bar', 'type' => 'bar',
'data' => [ 'data' => [
'labels' => $labels, 'labels' => $labels,
'datasets' => $datasets 'datasets' => $datasets
] ]
]) . '); ]) . ');
}); });
</script>'; </script>';
} }

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

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

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

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

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

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

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

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

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

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

@ -281,13 +281,11 @@ function User_get_shifts_sum_query()
return sprintf(' return sprintf('
COALESCE(SUM( COALESCE(SUM(
(1 + (1 + (
( (HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < %2$d)
(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`.`start`)) < %2$d) OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= %2$d)
OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= %2$d) ))
)
)
* (`Shifts`.`end` - `Shifts`.`start`) * (`Shifts`.`end` - `Shifts`.`start`)
* (1 - (%3$d + 1) * `ShiftEntry`.`freeloaded`) * (1 - (%3$d + 1) * `ShiftEntry`.`freeloaded`)
), 0) ), 0)

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

@ -362,16 +362,16 @@ function admin_shifts()
$needed_angel_types_info = []; $needed_angel_types_info = [];
foreach ($session->get('admin_shifts_types', []) as $type_id => $count) { foreach ($session->get('admin_shifts_types', []) as $type_id => $count) {
$angel_type_source = DB::selectOne(' $angel_type_source = DB::selectOne('
SELECT * SELECT *
FROM `AngelTypes` FROM `AngelTypes`
WHERE `id` = ? WHERE `id` = ?
LIMIT 1', [$type_id]); LIMIT 1', [$type_id]);
if (!empty($angel_type_source)) { if (!empty($angel_type_source)) {
DB::insert(' DB::insert('
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`) INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
VALUES (?, ?, ?) VALUES (?, ?, ?)
', ',
[ [
$shift_id, $shift_id,
$type_id, $type_id,

@ -551,19 +551,19 @@ class ImportSchedule extends BaseController
{ {
return $this->db->selectOne( return $this->db->selectOne(
' '
SELECT SELECT
s.SID AS id, s.SID AS id,
s.title, s.title,
s.start, s.start,
s.end, s.end,
s.shifttype_id AS shift_type_id, s.shifttype_id AS shift_type_id,
s.RID AS room_id, s.RID AS room_id,
r.Name AS room_name, r.Name AS room_name,
s.URL as url s.URL as url
FROM Shifts AS s FROM Shifts AS s
LEFT JOIN Room r on s.RID = r.RID LEFT JOIN Room r on s.RID = r.RID
WHERE SID = ? WHERE SID = ?
', ',
[$id] [$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'; $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"?> $html = '<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<title>' . config('app_name') . '</title> <title>' . config('app_name') . '</title>
<id>' . $request->getHttpHost() <id>' . $request->getHttpHost()
. htmlspecialchars(preg_replace( . htmlspecialchars(preg_replace(
'#[&?]key=[a-f\d]{32}#', '#[&?]key=[a-f\d]{32}#',
'', '',
$request->getRequestUri() $request->getRequestUri()
)) ))
. '</id> . '</id>
<updated>' . $updatedAt . '</updated>' . "\n"; <updated>' . $updatedAt . '</updated>' . "\n";
foreach ($news_entries as $news_entry) { foreach ($news_entries as $news_entry) {
$html .= make_atom_entry_from_news($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) function make_atom_entry_from_news(News $news)
{ {
return ' return '
<entry> <entry>
<title>' . htmlspecialchars($news->title) . '</title> <title>' . htmlspecialchars($news->title) . '</title>
<link href="' . page_link_to('news/' . $news->id) . '"/> <link href="' . page_link_to('news/' . $news->id) . '"/>
<id>' . preg_replace( <id>' . preg_replace(
@ -80,5 +80,5 @@ function make_atom_entry_from_news(News $news)
) . '</id> ) . '</id>
<updated>' . $news->updated_at->format('Y-m-d\TH:i:sP') . '</updated> <updated>' . $news->updated_at->format('Y-m-d\TH:i:sP') . '</updated>
<summary type="html">' . htmlspecialchars($news->text) . '</summary> <summary type="html">' . htmlspecialchars($news->text) . '</summary>
</entry>' . "\n"; </entry>' . "\n";
} }

@ -115,9 +115,9 @@ function load_rooms()
function load_days() function load_days()
{ {
$days = DB::select(' $days = DB::select('
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
FROM `Shifts` FROM `Shifts`
ORDER BY `id`, `name` ORDER BY `id`, `name`
'); ');
$days = array_map('array_shift', $days); $days = array_map('array_shift', $days);
@ -302,8 +302,8 @@ function ical_hint()
page_link_to('user_myshifts', ['reset' => 1]) 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"> . ' <button class="btn btn-xs btn-danger" data-toggle="collapse" data-target="#collapseApiKey" aria-expanded="false" aria-controls="collapseApiKey">
' . __('Show API Key') . ' ' . __('Show API Key') . '
</button>' </button>'
. '</p>' . '</p>'
. '<p id="collapseApiKey" class="collapse"><code>' . $user->api_key . '</code></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); $value = htmlspecialchars($value);
return form_element($label, ' return form_element($label, '
<div class="input-group"> <div class="input-group">
<input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . $value . '" /> <input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . $value . '" />
<div class="input-group-btn"> <div class="input-group-btn">
<button id="spinner-' . $name . '-down" class="btn btn-default" type="button"> <button id="spinner-' . $name . '-down" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-minus"></span> <span class="glyphicon glyphicon-minus"></span>
</button> </button>
<button id="spinner-' . $name . '-up" class="btn btn-default" type="button"> <button id="spinner-' . $name . '-up" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</button> </button>
</div>
</div> </div>
</div> <script type="text/javascript">
<script type="text/javascript"> $(\'#spinner-' . $name . '-down\').click(function() {
$(\'#spinner-' . $name . '-down\').click(function() { var spinner = $(\'#spinner-' . $name . '\');
var spinner = $(\'#spinner-' . $name . '\'); spinner.val(parseInt(spinner.val()) - 1);
spinner.val(parseInt(spinner.val()) - 1); });
}); $(\'#spinner-' . $name . '-up\').click(function() {
$(\'#spinner-' . $name . '-up\').click(function() { var spinner = $(\'#spinner-' . $name . '\');
var spinner = $(\'#spinner-' . $name . '\'); spinner.val(parseInt(spinner.val()) + 1);
spinner.val(parseInt(spinner.val()) + 1); });
}); </script>
</script> ');
');
} }
/** /**
@ -71,7 +71,7 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '')
return form_element($label, ' return form_element($label, '
<div class="input-group date" id="' . $dom_id . '" data-min-date="' . $start_date . '" data-max-date="' . $end_date . '"> <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> . '<span class="input-group-addon">' . glyph('th') . '</span>
</div> </div>
', $dom_id); ', $dom_id);

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

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

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

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

@ -1041,8 +1041,8 @@ a.thumbnail.active {
// Specials for cccamp19 design // Specials for cccamp19 design
.navbar-brand { .navbar-brand {
.icon-icon_angel { .icon-icon_angel {
background-color: @brand-primary; background-color: @brand-primary;
} }
strong { strong {

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

@ -41,11 +41,11 @@
@navbar-default-brand-hover-bg: #000; @navbar-default-brand-hover-bg: #000;
.navbar { .navbar {
.bg-info { .bg-info {
background-color: darken(@brand-info, 30%); background-color: darken(@brand-info, 30%);
} }
.bg-danger { .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, .label-warning, .label-success, .progress-bar-warning, .progress-bar-success,
.panel-warning .panel-heading, .panel-warning .panel-heading a, .panel-warning .panel-heading, .panel-warning .panel-heading a,
.panel-success .panel-heading, .panel-success .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; @state-danger-border: @brand-danger;
.label.label-warning { .label.label-warning {
color: #000; color: #000;
} }
@import "base.less"; @import "base.less";

@ -1060,7 +1060,7 @@ a.thumbnail.active {
} }
.btn-primary, .panel-info .panel-heading { .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 { .label-warning {

@ -1041,8 +1041,8 @@ a.thumbnail.active {
// Specials for cccamp19 design // Specials for cccamp19 design
.navbar-brand { .navbar-brand {
.icon-icon_angel { .icon-icon_angel {
background-color: @brand-primary; background-color: @brand-primary;
} }
strong { strong {
@ -1069,7 +1069,7 @@ h1 {
} }
.panel-title { .panel-title {
color: #fff; color: #fff;
} }
.input-group-addon { .input-group-addon {

@ -1041,8 +1041,8 @@ a.thumbnail.active {
// Specials for cccamp19 design // Specials for cccamp19 design
.navbar-brand { .navbar-brand {
.icon-icon_angel { .icon-icon_angel {
background-color: @brand-primary; background-color: @brand-primary;
} }
strong { strong {

Loading…
Cancel
Save