Commit 20d6b4ed authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt

modify ALL the things

* update translations Rooms (Räume) are now Places (Orte)
* Rooms/Places have addresses now
* Roomes/Places have colors now (visibile in shift view)
parent 4dd440f1
......@@ -567,4 +567,10 @@ SET FOREIGN_KEY_CHECKS=1;
-- CUSTOM FORK UPDATES
ALTER TABLE Shifts
ADD COLUMN `bulk_id` varchar(255) DEFAULT NULL;
ADD COLUMN `bulk_id` VARCHAR(255) DEFAULT NULL;
ALTER TABLE Room
ADD COLUMN `address` VARCHAR(600) DEFAULT NULL;
ALTER TABLE Room
ADD COLUMN `color` VARCHAR(7) DEFAULT NULL;
......@@ -17,14 +17,20 @@ function Room_delete($room_id) {
* Is this a frab imported room?
* @param boolean $public
* Is the room visible for angels?
* @param int $number room number
* @param string $address room address
*
* @return int
*/
function Room_create($name, $from_frab, $public) {
function Room_create($name, $from_frab, $public, $number = 0, $address = null, $color = null) {
$result = sql_query("
INSERT INTO `Room` SET
`Name`='" . sql_escape($name) . "',
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : 'N') . "',
`show`='" . sql_escape($public ? 'Y' : 'N') . "',
`Number`=0");
`show`='" . sql_escape($public ? 'Y' : 'N') . "',
`address`='" . sql_escape($address) . "',
`color`='" . sql_escape($color) . "',
`Number`='" . sql_escape(intval($number)) . "'");
if ($result === false)
return false;
return sql_id();
......
......@@ -26,6 +26,8 @@ function admin_rooms() {
$from_pentabarf = "";
$public = 'Y';
$number = "";
$address = "";
$color = "#E5F2DE";
$angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angeltypes = array();
......@@ -40,6 +42,8 @@ function admin_rooms() {
if (count($room) > 0) {
$id = $_REQUEST['id'];
$name = $room[0]['Name'];
$address = $room[0]['address'];
$color = $room[0]['color'];
$from_pentabarf = $room[0]['FromPentabarf'];
$public = $room[0]['show'];
$needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
......@@ -59,7 +63,7 @@ function admin_rooms() {
$ok = false;
$msg .= error(_("Please enter a name."), true);
}
if (isset($_REQUEST['from_pentabarf']))
$from_pentabarf = 'Y';
else
......@@ -74,7 +78,15 @@ function admin_rooms() {
$number = strip_request_item('number');
else
$ok = false;
if (isset($_REQUEST['address'])) {
$address = strip_request_item('address');
}
if (isset($_REQUEST['color'])) {
$color = strip_request_item('color');
}
foreach ($angeltypes as $angeltype_id => $angeltype) {
if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id]))
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
......@@ -86,13 +98,13 @@ function admin_rooms() {
if ($ok) {
if (isset($id)) {
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "', `address`='" . sql_escape($address) . "', `color`='" . sql_escape($color) . "' WHERE `RID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number . ", address: " . $address . ", color: " . $color);
} else {
$id = Room_create($name, $from_pentabarf, $public, $number);
$id = Room_create($name, $from_pentabarf, $public, $number, $address);
if ($id === false)
engelsystem_error("Unable to create room.");
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number . ", address: " . $address . ", color: " . $color);
}
sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($id) . "'");
......@@ -129,7 +141,9 @@ function admin_rooms() {
form_text('name', _("Name"), $name),
form_checkbox('from_pentabarf', _("Frab import"), $from_pentabarf),
form_checkbox('public', _("Public"), $public),
form_text('number', _("Room number"), $number)
form_text('number', _("Room number"), $number),
form_textarea('address', _('Address'), $address),
form_color('color', _("Signal Color"), $color)
)),
div('col-md-6', array(
div('row', array(
......
......@@ -370,7 +370,7 @@ function view_user_shifts() {
redirect('?');
}
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name`, `color` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
if (count($rooms) == 0) {
error(_("The administration has not configured any rooms yet."));
......@@ -700,7 +700,16 @@ function view_user_shifts() {
$class = 'free';
else
$class = 'occupied';
$shifts_table .= '<td rowspan="' . $blocks . '" class="' . $class . '">';
if($is_free) {
$color = $room["color"] ?: "#f0f0f0";
} else {
$color = "#f0f0f0";
}
$borderColor = color_darken($color, 15);
$shifts_table .= '<td rowspan="' . $blocks . '" class="' . $class . '" style="background-color: ' . $color . '; border-color: ' . $borderColor . ';">';
$shifts_table .= $shifts_row;
$shifts_table .= "</td>";
for ($j = 0; $j < $blocks && $i + $j < $maxshow; $j ++) {
......
......@@ -269,6 +269,11 @@ function form_text($name, $label, $value, $disabled = false, $placeholder = "")
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . $placeholder . '/>', 'form_' . $name);
}
function form_color($name, $label, $value, $disabled = false) {
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="color" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
}
/**
* Rendert ein Formular-Emailfeld
*/
......@@ -333,6 +338,15 @@ function page($elements) {
return join($elements);
}
function color_darken($color, $percentage) {
$percentage = 1 - $percentage / 100;
preg_match("/^#([\\da-f]{2})([\\da-f]{2})([\\da-f]{2})$/", $color, $colorValues);
$newColor = array_map(function($channel) use($percentage) {
return dechex(hexdec($channel) * $percentage);
}, array($colorValues[1], $colorValues[2], $colorValues[3]));
return vsprintf("#%s%s%s", $newColor);
}
/**
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
* Fügt dazu die übergebenen Elemente zusammen.
......
......@@ -28,13 +28,11 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null,
function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) {
$parsedown = new Parsedown();
$angeltypes = [];
foreach ($angeltypes_source as $angeltype)
$angeltypes[$angeltype['id']] = $angeltype;
$angeltypes = array_column($angeltypes_source, null, 'id');
$needed_angels = '';
foreach ($shift['NeedAngels'] as $needed_angeltype) {
$angelType = $angeltypes[$needed_angeltype['TID']];
$class = 'progress-bar-warning';
if ($needed_angeltype['taken'] == 0)
$class = 'progress-bar-danger';
......@@ -44,7 +42,8 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
$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 .= '<h3>' . AngelType_name_render($angelType) . '</h3>';
$needed_angels .= '<div>' . $parsedown->parse($angelType['description']) . '</div>';
$needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
$angels = [];
......@@ -102,7 +101,8 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
]),
div('col-sm-3 col-xs-6', [
'<h4>' . _('Location') . '</h4>',
'<p class="lead">' . glyph('map-marker') . $room['Name'] . '</p>'
'<p class="lead" style="margin-bottom: 0">' . glyph('map-marker') . $room['Name'] . '</p>',
'<p class="lead">' . nl2br($room['address']) . '</p>'
])
]),
div('row', [
......@@ -112,7 +112,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
]),
div('col-sm-6', [
'<h2>' . _('Description') . '</h2>',
$parsedown->parse($shifttype['description'])
$parsedown->parse($shifttype['description'])
])
]),
$shift_admin ? Shift_editor_info_render($shift) : ''
......
......@@ -4,8 +4,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Engelsystem 2.0\n"
"POT-Creation-Date: 2015-08-15 23:36+0100\n"
"PO-Revision-Date: 2015-09-24 07:31+0200\n"
"Last-Translator: phil <>\n"
"PO-Revision-Date: 2015-09-24 22:19+0200\n"
"Last-Translator: Konrad Mohrfeldt <konrad.mohrfeldt@farbdev.org>\n"
"Language-Team: hack-hro\n"
"Language: de\n"
"MIME-Version: 1.0\n"
......@@ -869,7 +869,7 @@ msgid ""
"This import will create/update/delete rooms and shifts by given FRAB-export "
"file. The needed file format is xcal."
msgstr ""
"Dieser Import erzeugt, ändert und löscht Räume und Schichten anhand einer "
"Dieser Import erzeugt, ändert und löscht Orte und Schichten anhand einer "
"FRAB-Export Datei. Das benötigte Format ist xcal."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:78
......@@ -889,11 +889,11 @@ msgstr "Import-Datei nicht vorhanden."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:108
msgid "Rooms to create"
msgstr "Anzulegende Räume"
msgstr "Anzulegende Orte"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:112
msgid "Rooms to delete"
msgstr "Zu löschende Räume"
msgstr "Zu löschende Orte"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:116
msgid "Shifts to create"
......@@ -943,7 +943,7 @@ msgstr "Titel"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:303
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:803
msgid "Room"
msgstr "Raum"
msgstr "Ort"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:125
msgid "Shifts to update"
......@@ -1042,7 +1042,7 @@ msgstr "Antwort von"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:4
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:816
msgid "Rooms"
msgstr "Räume"
msgstr "Orte"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:83
#, php-format
......@@ -1051,7 +1051,7 @@ msgstr "Bitte gib die Anzahl der benötigten Helfer_innen vom Typ %s an."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:111
msgid "Room saved."
msgstr "Raum gespeichert."
msgstr "Ort gespeichert."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:131
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:176
......@@ -1069,12 +1069,12 @@ msgstr "Benötigte Helfer_innen:"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:152
#, php-format
msgid "Room %s deleted."
msgstr "Raum %s gelöscht."
msgstr "Ort %s gelöscht."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:160
#, php-format
msgid "Do you want to delete room %s?"
msgstr "Möchest Du den Raum %s wirklich löschen?"
msgstr "Möchest Du den Ort %s wirklich löschen?"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:170
msgid "add"
......@@ -1166,7 +1166,7 @@ msgstr "Schichtwechsel-Stunden"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:317
msgid "Take needed angels from room settings"
msgstr "Übernehme benötigte Helfer_innen von den Raum-Einstellungen"
msgstr "Übernehme benötigte Helfer_innen von den Einstellungen des Orts"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:318
msgid "The following angels are needed"
......@@ -1615,7 +1615,7 @@ msgstr "Eintrag nicht gefunden."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:110
msgid "Please select a room."
msgstr "Bitte einen Raum auswählen."
msgstr "Bitte einen Ort auswählen."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:117
msgid "Please select a shifttype."
......@@ -1648,7 +1648,7 @@ msgstr "Diese Seite ist mit JavaScript viel komfortabler."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:186
msgid "Room:"
msgstr "Raum:"
msgstr "Ort:"
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:187
msgid "Start:"
......@@ -1690,7 +1690,7 @@ msgstr "Die Administratoren haben noch keine Schichten angelegt."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:344
msgid "The administration has not configured any rooms yet."
msgstr "Die Administratoren habe noch keine Räume eingerichtet."
msgstr "Die Administratoren habe noch keine Orte eingerichtet."
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:357
msgid "occupied"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment