summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-11-14 17:58:15 +0100
committermsquare <msquare@notrademark.de>2016-11-14 17:58:15 +0100
commitf5681411642b7da1b175fa153d3c234ba97b472a (patch)
tree3d474aff97498c834706024b6e0d88be1540c275 /includes
parent0ab9f4f9886ca61fe0711ba1ee551394ceda877a (diff)
add shift legend and fix dark theme
Diffstat (limited to 'includes')
-rw-r--r--includes/model/Shifts_model.php35
-rw-r--r--includes/sys_template.php12
-rw-r--r--includes/view/ShiftCalendarRenderer.php19
3 files changed, 46 insertions, 20 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 3d3fa356..2db0a3d3 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -133,6 +133,24 @@ function Shift_signup_allowed($user, $shift, $angeltype, $user_angeltype = null,
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
}
+
+ if ($user_shifts == null) {
+ $user_shifts = Shifts_by_user($user);
+ }
+
+ $signed_up = false;
+ foreach ($user_shifts as $user_shift) {
+ if ($user_shift['SID'] == $shift['SID']) {
+ $signed_up = true;
+ break;
+ }
+ }
+
+ if ($signed_up) {
+ // you cannot join if you already singed up for this shift
+ return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
+ }
+
if (time() > $shift['start']) {
// you can only join if the shift is in future
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
@@ -152,28 +170,11 @@ function Shift_signup_allowed($user, $shift, $angeltype, $user_angeltype = null,
return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
}
- if ($user_shifts == null) {
- $user_shifts = Shifts_by_user($user);
- }
-
if (Shift_collides($shift, $user_shifts)) {
// you cannot join if user alread joined a parallel or this shift
return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
}
- $signed_up = false;
- foreach ($user_shifts as $user_shift) {
- if ($user_shift['SID'] == $shift['SID']) {
- $signed_up = true;
- break;
- }
- }
-
- if ($signed_up) {
- // you cannot join if you already singed up for this shift
- return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
- }
-
// Hooray, shift is free for you!
return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
}
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 5d450493..bd53ecaa 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -19,6 +19,18 @@ function mute($text) {
return '<span class="text-muted">' . $text . '</span>';
}
+/**
+ * Renders a bootstrap label with given content and class.
+ *
+ * @param string $content
+ * The text
+ * @param string $class
+ * default, primary, info, success, warning, danger
+ */
+function label($content, $class = 'default') {
+ return '<span class="label label-' . $class . '">' . $content . '</span>';
+}
+
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>';
}
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 989bd890..89c1be4c 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -25,7 +25,7 @@ class ShiftCalendarRenderer {
private $shiftsFilter;
private $firstBlockStartTime = null;
-
+
private $lastBlockEndTime = null;
private $blocksPerSlot = null;
@@ -85,7 +85,7 @@ class ShiftCalendarRenderer {
public function getFirstBlockStartTime() {
return $this->firstBlockStartTime;
}
-
+
public function getLastBlockEndTime() {
return $this->lastBlockEndTime;
}
@@ -106,7 +106,7 @@ class ShiftCalendarRenderer {
return div('shift-calendar', [
$this->renderTimeLane(),
$this->renderShiftLanes()
- ]);
+ ]) . $this->renderLegend();
}
/**
@@ -222,6 +222,19 @@ class ShiftCalendarRenderer {
private function calcBlocksPerSlot() {
return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
+
+ /**
+ * Renders a legend explaining the shift coloring
+ */
+ private function renderLegend() {
+ return div('legend', [
+ label(_('Your shift'), 'primary'),
+ label(_('Help needed'), 'danger'),
+ label(_('Other angeltype needed / collides with my shifts'), 'warning'),
+ label(_('Shift is full'), 'success'),
+ label(_('Shift running/ended'), 'default')
+ ]);
+ }
}
?> \ No newline at end of file