fix different bugs with shift types
This commit is contained in:
parent
702047de53
commit
2d587478a1
|
@ -11,7 +11,12 @@ function mail_shift_change($old_shift, $new_shift) {
|
||||||
$message .= "\n";
|
$message .= "\n";
|
||||||
|
|
||||||
if ($old_shift["name"] != $new_shift["name"]) {
|
if ($old_shift["name"] != $new_shift["name"]) {
|
||||||
$message .= sprintf(_("* Shift Name changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
$message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
||||||
|
$noticable_changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($old_shift["title"] != $new_shift["title"]) {
|
||||||
|
$message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
|
||||||
$noticable_changes = true;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +44,7 @@ function mail_shift_change($old_shift, $new_shift) {
|
||||||
$message .= _("The updated Shift:") . "\n";
|
$message .= _("The updated Shift:") . "\n";
|
||||||
|
|
||||||
$message .= $new_shift["name"] . "\n";
|
$message .= $new_shift["name"] . "\n";
|
||||||
|
$message .= $new_shift["title"] . "\n";
|
||||||
$message .= date("y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
||||||
$message .= $new_room["Name"] . "\n";
|
$message .= $new_room["Name"] . "\n";
|
||||||
|
|
||||||
|
@ -54,6 +60,7 @@ function mail_shift_delete($shift) {
|
||||||
$message = _("A Shift you are registered on was deleted:") . "\n";
|
$message = _("A Shift you are registered on was deleted:") . "\n";
|
||||||
|
|
||||||
$message .= $shift["name"] . "\n";
|
$message .= $shift["name"] . "\n";
|
||||||
|
$message .= $new_shift["title"] . "\n";
|
||||||
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
|
@ -68,6 +75,7 @@ function mail_shift_assign($user, $shift) {
|
||||||
|
|
||||||
$message = _("You have been assigned to a Shift:") . "\n";
|
$message = _("You have been assigned to a Shift:") . "\n";
|
||||||
$message .= $shift["name"] . "\n";
|
$message .= $shift["name"] . "\n";
|
||||||
|
$message .= $shift["title"] . "\n";
|
||||||
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
|
@ -81,6 +89,7 @@ function mail_shift_removed($user, $shift) {
|
||||||
|
|
||||||
$message = _("You have been removed from a Shift:") . "\n";
|
$message = _("You have been removed from a Shift:") . "\n";
|
||||||
$message .= $shift["name"] . "\n";
|
$message .= $shift["name"] . "\n";
|
||||||
|
$message .= $shift["title"] . "\n";
|
||||||
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ function Shift_delete($shift_id) {
|
||||||
* Update a shift.
|
* Update a shift.
|
||||||
*/
|
*/
|
||||||
function Shift_update($shift) {
|
function Shift_update($shift) {
|
||||||
$old_shift = Shift($shift['SID']);
|
$shift['name'] = ShiftType($shift['shifttype_id'])['name'];
|
||||||
mail_shift_change(Shift($shift['SID']), $shift);
|
mail_shift_change(Shift($shift['SID']), $shift);
|
||||||
|
|
||||||
return sql_query("UPDATE `Shifts` SET
|
return sql_query("UPDATE `Shifts` SET
|
||||||
|
@ -43,7 +43,7 @@ function Shift_update_by_psid($shift) {
|
||||||
return false;
|
return false;
|
||||||
if (count($shift_source) == 0)
|
if (count($shift_source) == 0)
|
||||||
return null;
|
return null;
|
||||||
$shift['SID'] = $shift_source['SID'];
|
$shift['SID'] = $shift_source[0]['SID'];
|
||||||
return Shift_update($shift);
|
return Shift_update($shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,7 @@ function Shift($id) {
|
||||||
$result = $shifts_source[0];
|
$result = $shifts_source[0];
|
||||||
|
|
||||||
$result['ShiftEntry'] = $shiftsEntry_source;
|
$result['ShiftEntry'] = $shiftsEntry_source;
|
||||||
|
$result['NeedAngels'] = [];
|
||||||
|
|
||||||
$temp = NeededAngelTypes_by_shift($id);
|
$temp = NeededAngelTypes_by_shift($id);
|
||||||
foreach ($temp as $e) {
|
foreach ($temp as $e) {
|
||||||
|
|
|
@ -10,104 +10,154 @@ function admin_import() {
|
||||||
$html = "";
|
$html = "";
|
||||||
|
|
||||||
$step = "input";
|
$step = "input";
|
||||||
if (isset($_REQUEST['step']))
|
if (isset($_REQUEST['step']) && in_array($step, [
|
||||||
|
'input',
|
||||||
|
'check',
|
||||||
|
'import'
|
||||||
|
]))
|
||||||
$step = $_REQUEST['step'];
|
$step = $_REQUEST['step'];
|
||||||
|
|
||||||
$html .= '<p>';
|
if ($test_handle = fopen('../import/tmp', 'w')) {
|
||||||
$html .= $step == "input" ? '<b>1. Input</b>' : '1. Input';
|
fclose($test_handle);
|
||||||
$html .= ' » ';
|
unlink('../import/tmp');
|
||||||
$html .= $step == "check" ? '<b>2. Validate</b>' : '2. Validate';
|
} else {
|
||||||
$html .= ' » ';
|
error(_('Webserver has no write-permission on import directory.'));
|
||||||
$html .= $step == "import" ? '<b>3. Import</b>' : '3. Import';
|
}
|
||||||
$html .= '</p>';
|
|
||||||
|
|
||||||
$import_file = '../import/import_' . $user['UID'] . '.xml';
|
$import_file = '../import/import_' . $user['UID'] . '.xml';
|
||||||
|
$shifttype_id = null;
|
||||||
|
|
||||||
|
$shifttypes_source = ShiftTypes();
|
||||||
|
if ($shifttypes_source === false)
|
||||||
|
engelsystem_error('Unable to load shifttypes.');
|
||||||
|
$shifttypes = [];
|
||||||
|
foreach ($shifttypes_source as $shifttype)
|
||||||
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
|
|
||||||
switch ($step) {
|
switch ($step) {
|
||||||
case "input":
|
case 'input':
|
||||||
$ok = false;
|
$ok = false;
|
||||||
if ($test_handle = fopen('../import/tmp', 'w')) {
|
|
||||||
fclose($test_handle);
|
|
||||||
unlink('../import/tmp');
|
|
||||||
} else {
|
|
||||||
error("Webserver has no write-permission on import directory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
|
||||||
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']]))
|
||||||
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
|
else {
|
||||||
|
$ok = false;
|
||||||
|
error(_('Please select a shift type.'));
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_FILES['xcal_file']) && ($_FILES['xcal_file']['error'] == 0)) {
|
if (isset($_FILES['xcal_file']) && ($_FILES['xcal_file']['error'] == 0)) {
|
||||||
if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
|
if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
if (simplexml_load_file($import_file) === false) {
|
if (simplexml_load_file($import_file) === false) {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
error("No valid xml/xcal file provided.");
|
error(_('No valid xml/xcal file provided.'));
|
||||||
unlink($import_file);
|
unlink($import_file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
error("File upload went wrong.");
|
error(_('File upload went wrong.'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ok = false;
|
$ok = false;
|
||||||
error("Please provide some data.");
|
error(_('Please provide some data.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ok)
|
if ($ok) {
|
||||||
redirect(page_link_to('admin_import') . "&step=check");
|
redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id);
|
||||||
else {
|
} else {
|
||||||
$html .= form(array(
|
$html .= div('well well-sm text-center', [
|
||||||
form_info('', _("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")),
|
_('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import'))
|
||||||
form_file('xcal_file', _("xcal-File (.xcal)")),
|
]) . div('row', [
|
||||||
form_submit('submit', _("Import"))
|
div('col-md-offset-3 col-md-6', [
|
||||||
));
|
form(array(
|
||||||
|
form_info('', _("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")),
|
||||||
|
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
|
||||||
|
form_file('xcal_file', _("xcal-File (.xcal)")),
|
||||||
|
form_submit('submit', _("Import"))
|
||||||
|
))
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "check":
|
case 'check':
|
||||||
if (! file_exists($import_file))
|
if (! file_exists($import_file)) {
|
||||||
|
error(_('Missing import file.'));
|
||||||
redirect(page_link_to('admin_import'));
|
redirect(page_link_to('admin_import'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']]))
|
||||||
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
|
else {
|
||||||
|
error(_('Please select a shift type.'));
|
||||||
|
redirect(page_link_to('admin_import'));
|
||||||
|
}
|
||||||
|
|
||||||
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
||||||
list($events_new, $events_updated, $events_deleted) = prepare_events($import_file);
|
list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id);
|
||||||
|
|
||||||
$html .= form(array(
|
$html .= form([
|
||||||
'<h3>' . _("Rooms to create") . '</h3>',
|
div('row', [
|
||||||
table(_("Name"), $rooms_new),
|
div('col-sm-6', [
|
||||||
'<h3>' . _("Rooms to delete") . '</h3>',
|
'<h3>' . _("Rooms to create") . '</h3>',
|
||||||
table(_("Name"), $rooms_deleted),
|
table(_("Name"), $rooms_new)
|
||||||
|
]),
|
||||||
|
div('col-sm-6', [
|
||||||
|
'<h3>' . _("Rooms to delete") . '</h3>',
|
||||||
|
table(_("Name"), $rooms_deleted)
|
||||||
|
])
|
||||||
|
]),
|
||||||
'<h3>' . _("Shifts to create") . '</h3>',
|
'<h3>' . _("Shifts to create") . '</h3>',
|
||||||
table(array(
|
table(array(
|
||||||
'day' => _("Day"),
|
'day' => _("Day"),
|
||||||
'start' => _("Start"),
|
'start' => _("Start"),
|
||||||
'end' => _("End"),
|
'end' => _("End"),
|
||||||
'name' => _("Name"),
|
'shifttype' => _('Shift type'),
|
||||||
|
'title' => _("Title"),
|
||||||
'room' => _("Room")
|
'room' => _("Room")
|
||||||
), shifts_printable($events_new)),
|
), shifts_printable($events_new, $shifttypes)),
|
||||||
'<h3>' . _("Shifts to update") . '</h3>',
|
'<h3>' . _("Shifts to update") . '</h3>',
|
||||||
table(array(
|
table(array(
|
||||||
'day' => _("Day"),
|
'day' => _("Day"),
|
||||||
'start' => _("Start"),
|
'start' => _("Start"),
|
||||||
'end' => _("End"),
|
'end' => _("End"),
|
||||||
'name' => _("Name"),
|
'shifttype' => _('Shift type'),
|
||||||
|
'title' => _("Title"),
|
||||||
'room' => _("Room")
|
'room' => _("Room")
|
||||||
), shifts_printable($events_updated)),
|
), shifts_printable($events_updated, $shifttypes)),
|
||||||
'<h3>' . _("Shifts to delete") . '</h3>',
|
'<h3>' . _("Shifts to delete") . '</h3>',
|
||||||
table(array(
|
table(array(
|
||||||
'day' => _("Day"),
|
'day' => _("Day"),
|
||||||
'start' => _("Start"),
|
'start' => _("Start"),
|
||||||
'end' => _("End"),
|
'end' => _("End"),
|
||||||
'name' => _("Name"),
|
'shifttype' => _('Shift type'),
|
||||||
|
'title' => _("Title"),
|
||||||
'room' => _("Room")
|
'room' => _("Room")
|
||||||
), shifts_printable($events_deleted)),
|
), shifts_printable($events_deleted, $shifttypes)),
|
||||||
form_submit('submit', _("Import"))
|
form_submit('submit', _("Import"))
|
||||||
), page_link_to('admin_import') . '&step=import');
|
], page_link_to('admin_import') . '&step=import&shifttype_id=' . $shifttype_id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "import":
|
case 'import':
|
||||||
|
if (! file_exists($import_file)) {
|
||||||
|
error(_('Missing import file.'));
|
||||||
|
redirect(page_link_to('admin_import'));
|
||||||
|
}
|
||||||
|
|
||||||
if (! file_exists($import_file))
|
if (! file_exists($import_file))
|
||||||
redirect(page_link_to('admin_import'));
|
redirect(page_link_to('admin_import'));
|
||||||
|
|
||||||
|
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']]))
|
||||||
|
$shifttype_id = $_REQUEST['shifttype_id'];
|
||||||
|
else {
|
||||||
|
error(_('Please select a shift type.'));
|
||||||
|
redirect(page_link_to('admin_import'));
|
||||||
|
}
|
||||||
|
|
||||||
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
||||||
foreach ($rooms_new as $room) {
|
foreach ($rooms_new as $room) {
|
||||||
sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($room) . "', `FromPentabarf`='Y', `Show`='Y'");
|
sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($room) . "', `FromPentabarf`='Y', `Show`='Y'");
|
||||||
|
@ -116,7 +166,7 @@ function admin_import() {
|
||||||
foreach ($rooms_deleted as $room)
|
foreach ($rooms_deleted as $room)
|
||||||
sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1");
|
sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1");
|
||||||
|
|
||||||
list($events_new, $events_updated, $events_deleted) = prepare_events($import_file);
|
list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id);
|
||||||
foreach ($events_new as $event) {
|
foreach ($events_new as $event) {
|
||||||
$result = Shift_create($event);
|
$result = Shift_create($event);
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
|
@ -145,7 +195,10 @@ function admin_import() {
|
||||||
redirect(page_link_to('admin_import'));
|
redirect(page_link_to('admin_import'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return page_with_title(admin_import_title(), [
|
||||||
|
msg(),
|
||||||
|
$html
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_rooms($file) {
|
function prepare_rooms($file) {
|
||||||
|
@ -179,7 +232,7 @@ function prepare_rooms($file) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_events($file) {
|
function prepare_events($file, $shifttype_id) {
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
|
@ -195,10 +248,11 @@ function prepare_events($file) {
|
||||||
$event_id = trim($event_pb->{
|
$event_id = trim($event_pb->{
|
||||||
'event-id' });
|
'event-id' });
|
||||||
$shifts_pb[$event_id] = array(
|
$shifts_pb[$event_id] = array(
|
||||||
|
'shifttype_id' => $shifttype_id,
|
||||||
'start' => DateTime::createFromFormat("Ymd\THis", $event->dtstart)->getTimestamp(),
|
'start' => DateTime::createFromFormat("Ymd\THis", $event->dtstart)->getTimestamp(),
|
||||||
'end' => DateTime::createFromFormat("Ymd\THis", $event->dtend)->getTimestamp(),
|
'end' => DateTime::createFromFormat("Ymd\THis", $event->dtend)->getTimestamp(),
|
||||||
'RID' => $rooms_import[trim($event->location)],
|
'RID' => $rooms_import[trim($event->location)],
|
||||||
'name' => trim($event->summary),
|
'title' => trim($event->summary),
|
||||||
'URL' => trim($event->url),
|
'URL' => trim($event->url),
|
||||||
'PSID' => $event_id
|
'PSID' => $event_id
|
||||||
);
|
);
|
||||||
|
@ -209,14 +263,14 @@ function prepare_events($file) {
|
||||||
foreach ($shifts as $shift)
|
foreach ($shifts as $shift)
|
||||||
$shifts_db[$shift['PSID']] = $shift;
|
$shifts_db[$shift['PSID']] = $shift;
|
||||||
|
|
||||||
$shifts_new = array();
|
$shifts_new = [];
|
||||||
$shifts_updated = array();
|
$shifts_updated = [];
|
||||||
foreach ($shifts_pb as $shift)
|
foreach ($shifts_pb as $shift)
|
||||||
if (! isset($shifts_db[$shift['PSID']]))
|
if (! isset($shifts_db[$shift['PSID']]))
|
||||||
$shifts_new[] = $shift;
|
$shifts_new[] = $shift;
|
||||||
else {
|
else {
|
||||||
$tmp = $shifts_db[$shift['PSID']];
|
$tmp = $shifts_db[$shift['PSID']];
|
||||||
if ($shift['name'] != $tmp['name'] || $shift['start'] != $tmp['start'] || $shift['end'] != $tmp['end'] || $shift['RID'] != $tmp['RID'] || $shift['URL'] != $tmp['URL'])
|
if ($shift['shifttype_id'] != $tmp['shifttype_id'] || $shift['title'] != $tmp['title'] || $shift['start'] != $tmp['start'] || $shift['end'] != $tmp['end'] || $shift['RID'] != $tmp['RID'] || $shift['URL'] != $tmp['URL'])
|
||||||
$shifts_updated[] = $shift;
|
$shifts_updated[] = $shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +293,7 @@ function read_xml($file) {
|
||||||
return $xml_import;
|
return $xml_import;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shifts_printable($shifts) {
|
function shifts_printable($shifts, $shifttypes) {
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$rooms = array_flip($rooms_import);
|
$rooms = array_flip($rooms_import);
|
||||||
|
|
||||||
|
@ -250,7 +304,11 @@ function shifts_printable($shifts) {
|
||||||
$shifts_printable[] = array(
|
$shifts_printable[] = array(
|
||||||
'day' => date("l, Y-m-d", $shift['start']),
|
'day' => date("l, Y-m-d", $shift['start']),
|
||||||
'start' => date("H:i", $shift['start']),
|
'start' => date("H:i", $shift['start']),
|
||||||
'name' => shorten($shift['name']),
|
'shifttype' => ShiftType_name_render([
|
||||||
|
'id' => $shift['shifttype_id'],
|
||||||
|
'name' => $shifttypes[$shift['shifttype_id']]
|
||||||
|
]),
|
||||||
|
'title' => shorten($shift['title']),
|
||||||
'end' => date("H:i", $shift['end']),
|
'end' => date("H:i", $shift['end']),
|
||||||
'room' => $rooms[$shift['RID']]
|
'room' => $rooms[$shift['RID']]
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,6 +9,12 @@ function user_shifts() {
|
||||||
|
|
||||||
if (User_is_freeloader($user))
|
if (User_is_freeloader($user))
|
||||||
redirect(page_link_to('user_myshifts'));
|
redirect(page_link_to('user_myshifts'));
|
||||||
|
|
||||||
|
// Locations laden
|
||||||
|
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
||||||
|
$room_array = array();
|
||||||
|
foreach ($rooms as $room)
|
||||||
|
$room_array[$room['RID']] = $room['Name'];
|
||||||
|
|
||||||
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
|
// Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
|
||||||
if (isset($_REQUEST['entry_id']) && in_array('user_shifts_admin', $privileges)) {
|
if (isset($_REQUEST['entry_id']) && in_array('user_shifts_admin', $privileges)) {
|
||||||
|
@ -56,12 +62,6 @@ function user_shifts() {
|
||||||
if (count($shift) == 0)
|
if (count($shift) == 0)
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
$shift = $shift[0];
|
$shift = $shift[0];
|
||||||
|
|
||||||
// Locations laden
|
|
||||||
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
|
||||||
$room_array = array();
|
|
||||||
foreach ($rooms as $room)
|
|
||||||
$room_array[$room['RID']] = $room['Name'];
|
|
||||||
|
|
||||||
// Engeltypen laden
|
// Engeltypen laden
|
||||||
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
|
@ -179,17 +179,13 @@ function user_shifts() {
|
||||||
else
|
else
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
|
|
||||||
$shift = sql_select("
|
$shift = Shift($shift_id);
|
||||||
SELECT `Shifts`.*, `ShiftTypes`.`name`, `Room`.*
|
if ($shift === false)
|
||||||
FROM `Shifts`
|
engelsystem_error('Unable to load shift.');
|
||||||
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
|
if ($shift == null)
|
||||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
|
||||||
WHERE `SID`=" . sql_escape($shift_id));
|
|
||||||
if (count($shift) == 0)
|
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
$shift = $shift[0];
|
|
||||||
|
// Schicht löschen bestätigt
|
||||||
// Schicht löschen bestätigt
|
|
||||||
if (isset($_REQUEST['delete'])) {
|
if (isset($_REQUEST['delete'])) {
|
||||||
$result = Shift_delete($shift_id);
|
$result = Shift_delete($shift_id);
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
|
@ -210,15 +206,13 @@ function user_shifts() {
|
||||||
else
|
else
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
|
|
||||||
$shift = sql_select("
|
$shift = Shift($shift_id);
|
||||||
SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.*
|
$room;
|
||||||
FROM `Shifts`
|
$shift['Name'] = $room_array[$shift['RID']];
|
||||||
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
|
if ($shift === false)
|
||||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
engelsystem_error('Unable to load shift.');
|
||||||
WHERE `SID`=" . sql_escape($shift_id));
|
if ($shift == null)
|
||||||
if (count($shift) == 0)
|
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
$shift = $shift[0];
|
|
||||||
|
|
||||||
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id']))
|
if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id']))
|
||||||
$type_id = $_REQUEST['type_id'];
|
$type_id = $_REQUEST['type_id'];
|
||||||
|
@ -434,7 +428,7 @@ function view_user_shifts() {
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
$SQL = "SELECT DISTINCT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`Name` as `room_name`, nat2.`special_needs` > 0 AS 'has_special_needs'
|
$SQL = "SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`, nat2.`special_needs` > 0 AS 'has_special_needs'
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
INNER JOIN `Room` USING (`RID`)
|
INNER JOIN `Room` USING (`RID`)
|
||||||
INNER JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
INNER JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||||
|
@ -454,7 +448,9 @@ function view_user_shifts() {
|
||||||
}
|
}
|
||||||
$SQL .= "
|
$SQL .= "
|
||||||
ORDER BY `start`";
|
ORDER BY `start`";
|
||||||
|
|
||||||
$shifts = sql_select($SQL);
|
$shifts = sql_select($SQL);
|
||||||
|
|
||||||
$ownshifts_source = sql_select("
|
$ownshifts_source = sql_select("
|
||||||
SELECT `ShiftTypes`.`name`, `Shifts`.*
|
SELECT `ShiftTypes`.`name`, `Shifts`.*
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
|
|
|
@ -9,6 +9,15 @@ $themes = array(
|
||||||
"2" => "Engelsystem 31c3"
|
"2" => "Engelsystem 31c3"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display muted (grey) text.
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
*/
|
||||||
|
function mute($text) {
|
||||||
|
return '<span class="text-muted">' . $text . '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '') {
|
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: ' . (($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
|
||||||
}
|
}
|
||||||
|
@ -195,7 +204,7 @@ function form_radio($name, $label, $selected, $value) {
|
||||||
*/
|
*/
|
||||||
function form_info($label, $text = "") {
|
function form_info($label, $text = "") {
|
||||||
if ($label == "")
|
if ($label == "")
|
||||||
return '<span class="help-block">' . $text . '</span>';
|
return '<span class="help-block">' . glyph('info-sign') . $text . '</span>';
|
||||||
if ($text == "")
|
if ($text == "")
|
||||||
return '<h4>' . $label . '</h4>';
|
return '<h4>' . $label . '</h4>';
|
||||||
return form_element($label, '<p class="form-control-static">' . $text . '</p>', '');
|
return form_element($label, '<p class="form-control-static">' . $text . '</p>', '');
|
||||||
|
|
Loading…
Reference in New Issue