require_once $GLOBALS['BASE_DIR'] . '/includes/CTSDatabaseAPI.class.php'; require_once $GLOBALS['BASE_DIR'] . '/includes/ReserveDatabaseAPI.class.php'; respond(function ($request, $response, $app) { //this checks every admin page and makes sure the user is a manager, cts staff or helpdesk staff if (ReserveDatabaseAPI::user_level() > 3) { die('You do not have permission to view this page.'); } }); respond('/admincp', function ($request, $response, $app) { //page with the admin control panel links on it $app->tpl->display('admin-control-panel.tpl'); }); //admin cp respond('/admincp/equipment', function ($request, $response, $app) { //page with the equipment form options $app->tpl->assign('categories', ReserveDatabaseAPI::get_form_options()); $app->tpl->display('admin-form-options.tpl'); }); //admincp equipment page respond('/admincp/subitems', function ($request, $response, $app) { //page with the subitem form options $app->tpl->assign('subitems', ReserveDatabaseAPI::get_subitems()); $app->tpl->display('admin-subitems.tpl'); }); //admincp equipment page respond('POST', '/admincp/subitems/add', function ($request, $response, $app) { //when the administrator is trying to create a new subitem $name = $request->param('new_subitem'); $name = filter_var($name, FILTER_SANITIZE_STRING); ReserveDatabaseAPI::insert_subitem($name); $response->redirect($GLOBALS['BASE_URL'] . '/admin/admincp/subitems');