Пример #1
0
    //when the staff member is trying to change the priority of a loan
    $reservation_idx = $request->id;
    $priority = $request->param('priority');
    $priority = filter_var($priority, FILTER_SANITIZE_STRING);
    ReserveDatabaseAPI::change_priority($reservation_idx, $priority);
    $response->redirect($GLOBALS['BASE_URL'] . '/admin/reservation/search/id/' . $reservation_idx);
});
//change priority
respond('/reservation/id/[i:id]/equipment', function ($request, $response, $app) {
    //when a piece of equipment is added to a loan
    $reservation_idx = $request->id;
    $glpi_id = $request->param('GLPI_ID');
    $glpi_id = filter_var($glpi_id, FILTER_SANITIZE_STRING);
    $glpi_id = ReserveDatabaseAPI::format_glpi($glpi_id);
    if (count($_SESSION['errors']) <= 0) {
        if (ReserveDatabaseAPI::check_glpi($glpi_id)) {
            //if the GLPI_ID is found then add it
            ReserveDatabaseAPI::add_equipment($reservation_idx, $glpi_id);
        } else {
            //otherwise show an error
            $_SESSION['errors'][] = "GLPI ID not found.";
        }
    }
    $response->redirect($GLOBALS['BASE_URL'] . '/admin/reservation/search/id/' . $reservation_idx);
});
//add equipment manually
respond('/reservation/equipment/[i:id]/remove/[i:key]', function ($request, $response, $app) {
    //when removing a piece of equipment from a loan
    //the key is used to delete the specific reservation_equipment field in the database where the
    //id is used as the reservation for redirecting
    $reservation_idx = $request->id;