shift type list

This commit is contained in:
Philip Häusler 2014-12-16 09:25:36 +01:00
parent a73e98a8e0
commit c8cc46886b
5 changed files with 63 additions and 28 deletions

View File

@ -5,7 +5,9 @@ CREATE TABLE IF NOT EXISTS `ShiftTypes` (
`angeltype_id` int(11) DEFAULT NULL,
`description` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
INSERT INTO `engelsystem`.`Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'shifttypes', 'Administrate shift types');
INSERT INTO `GroupPrivileges` SET `group_id`=-5, `privilege_id`=(SELECT `id` FROM `Privileges` WHERE `name`='shifttypes');
/* cleanup */
ALTER TABLE `User` DROP `ICQ` ;

View File

@ -10,6 +10,19 @@ function shifttype_controller() {
}
function shifttypes_list_controller() {
global $privileges, $user;
if (! in_array('shifttypes', $privileges))
redirect('?');
$shifttypes = ShiftTypes();
if ($shifttypes === false)
engelsystem_error("Unable to load shifttypes.");
return array(
shifttypes_title(),
ShiftTypes_list_view($shifttypes)
);
}
/**

View File

@ -113,6 +113,7 @@ function make_navigation() {
"admin_user" => admin_user_title(),
"admin_free" => admin_free_title(),
"admin_questions" => admin_questions_title(),
"shifttypes" => shifttypes_title(),
"admin_shifts" => admin_shifts_title(),
"admin_rooms" => admin_rooms_title(),
"admin_groups" => admin_groups_title(),

View File

@ -9,7 +9,24 @@ function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $s
function ShiftType_view($shifttype) {
}
function ShiftTypes_list_view() {
function ShiftTypes_list_view($shifttypes) {
foreach ($shifttypes as &$shifttype) {
$shifttype['actions'] = table_buttons([
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _("edit"), "btn-xs"),
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttypes['id'], _("delete"), "btn-xs")
]);
}
return page_with_title(shifttypes_title(), array(
msg(),
buttons(array(
button(page_link_to('shifttypes') . '&action=edit', _("New shifttype"), 'add')
)),
table(array(
'name' => _("Name"),
'actions' => ""
), $shifttypes)
));
}
?>

View File

@ -131,6 +131,8 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i
list($title, $content) = users_controller();
} elseif ($p == "user_angeltypes") {
list($title, $content) = user_angeltypes_controller();
} elseif ($p == "shifttypes") {
list($title, $content) = shifttypes_controller();
} elseif ($p == "news") {
$title = news_title();
$content = user_news();