Merge pull request #2 from engelsystem/master
Merge Changes from esys Master to own Repo
This commit is contained in:
commit
e1cc80ec41
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Engelsystem\ShiftSignupState;
|
||||
|
||||
function shift_link($shift) {
|
||||
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ function shifts_json_export_all_controller() {
|
|||
* (Like iCal Export or shifts view)
|
||||
*/
|
||||
function shifts_json_export_controller() {
|
||||
global $ical_shifts, $user;
|
||||
global $user;
|
||||
|
||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||
engelsystem_error("Missing key.");
|
||||
|
@ -295,9 +295,6 @@ function shifts_json_export_controller() {
|
|||
$key = $_REQUEST['key'];
|
||||
|
||||
$user = User_by_api_key($key);
|
||||
if ($user === false) {
|
||||
engelsystem_error("Unable to find user.");
|
||||
}
|
||||
if ($user == null) {
|
||||
engelsystem_error("Key invalid.");
|
||||
}
|
||||
|
@ -305,25 +302,17 @@ function shifts_json_export_controller() {
|
|||
engelsystem_error("No privilege for shifts_json_export.");
|
||||
}
|
||||
|
||||
$ical_shifts = load_ical_shifts();
|
||||
$shifts = load_ical_shifts();
|
||||
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
raw_output(json_encode($ical_shifts));
|
||||
raw_output(json_encode($shifts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns shifts to export.
|
||||
* Users shifts or user_shifts filter based shifts if export=user_shifts is given as param.
|
||||
* Returns users shifts to export.
|
||||
*/
|
||||
function load_ical_shifts() {
|
||||
global $user, $ical_shifts;
|
||||
|
||||
if (isset($_REQUEST['export']) && $_REQUEST['export'] == 'user_shifts') {
|
||||
require_once realpath(__DIR__ . '/user_shifts.php');
|
||||
view_user_shifts();
|
||||
|
||||
return $ical_shifts;
|
||||
}
|
||||
global $user;
|
||||
|
||||
return Shifts_by_user($user);
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ function user_controller() {
|
|||
}
|
||||
}
|
||||
|
||||
$shifts = Shifts_by_user($user_source);
|
||||
$shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
|
||||
foreach ($shifts as &$shift) {
|
||||
// TODO: Move queries to model
|
||||
$shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`");
|
||||
|
|
|
@ -115,6 +115,7 @@ function ShiftEntries_finished_by_user($user) {
|
|||
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
|
||||
WHERE `ShiftEntry`.`UID`=" . sql_escape($user['UID']) . "
|
||||
AND `Shifts`.`end` < " . sql_escape(time()) . "
|
||||
AND `ShiftEntry`.`freeloaded` = 0
|
||||
ORDER BY `Shifts`.`end`
|
||||
");
|
||||
}
|
||||
|
|
|
@ -261,9 +261,12 @@ function Shift_create($shift) {
|
|||
/**
|
||||
* Return users shifts.
|
||||
*/
|
||||
function Shifts_by_user($user) {
|
||||
function Shifts_by_user($user, $include_freeload_comments = false) {
|
||||
$result = sql_select("
|
||||
SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, `ShiftEntry`.*, `Shifts`.*, `Room`.*
|
||||
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`.*, `Room`.*
|
||||
FROM `ShiftEntry`
|
||||
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
|
||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||
|
|
|
@ -284,7 +284,7 @@ function User($user_id) {
|
|||
function User_by_api_key($api_key) {
|
||||
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
|
||||
if ($user === false) {
|
||||
return false;
|
||||
engelsystem_error("Unable to find user by api key.");
|
||||
}
|
||||
if (count($user) == 0) {
|
||||
return null;
|
||||
|
|
|
@ -10,9 +10,6 @@ function user_atom() {
|
|||
$key = $_REQUEST['key'];
|
||||
|
||||
$user = User_by_api_key($key);
|
||||
if ($user === false) {
|
||||
engelsystem_error("Unable to find user.");
|
||||
}
|
||||
if ($user == null) {
|
||||
engelsystem_error("Key invalid.");
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@ function user_ical() {
|
|||
$key = $_REQUEST['key'];
|
||||
|
||||
$user = User_by_api_key($key);
|
||||
if ($user === false) {
|
||||
engelsystem_error("Unable to find user.");
|
||||
}
|
||||
if ($user == null) {
|
||||
engelsystem_error("Key invalid.");
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ function label($content, $class = 'default') {
|
|||
}
|
||||
|
||||
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '') {
|
||||
return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . (($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
|
||||
return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,8 +193,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
|
|||
*/
|
||||
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) {
|
||||
$page = [
|
||||
msg(),
|
||||
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
|
||||
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
|
||||
msg()
|
||||
];
|
||||
|
||||
$page[] = '<h3>' . _("Description") . '</h3>';
|
||||
|
|
|
@ -55,6 +55,7 @@ function ShiftType_view($shifttype, $angeltype) {
|
|||
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
|
||||
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete')
|
||||
]),
|
||||
heading(_("Description"), 2),
|
||||
$parsedown->parse($shifttype['description'])
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
|
|||
]),
|
||||
div('col-sm-3 col-xs-6', [
|
||||
'<h4>' . _('Location') . '</h4>',
|
||||
'<p class="lead">' . glyph('map-marker') . $room['Name'] . '</p>'
|
||||
'<p class="lead">' . Room_name_render($room) . '</p>'
|
||||
])
|
||||
]),
|
||||
div('row', [
|
||||
|
@ -113,7 +113,9 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
|
|||
$needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>';
|
||||
|
||||
$needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>';
|
||||
$needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
|
||||
$bar_max = max($needed_angeltype['count']*10, $needed_angeltype['taken']*10, 10);
|
||||
$bar_value = max(1, $needed_angeltype['taken'] * 10);
|
||||
$needed_angels .= progress_bar(0, $bar_max, $bar_value, $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
|
||||
|
||||
$angels = [];
|
||||
foreach ($shift['ShiftEntry'] as $shift_entry) {
|
||||
|
|
|
@ -7027,6 +7027,8 @@ a.thumbnail.active {
|
|||
color: #fff;
|
||||
}
|
||||
.label-warning,
|
||||
.label-success {
|
||||
.label-success,
|
||||
.progress-bar-warning,
|
||||
.progress-bar-success {
|
||||
color: #222222;
|
||||
}
|
||||
|
|
|
@ -1046,6 +1046,6 @@ a.thumbnail.active {
|
|||
}
|
||||
}
|
||||
|
||||
.label-warning, .label-success {
|
||||
.label-warning, .label-success, .progress-bar-warning, .progress-bar-success {
|
||||
color: @gray-darker;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue