Пример #1
0
//chnage status
respond('/reservation/id/[i:id]/dropoff', function ($request, $response, $app) {
    //when the administrator is assigning a technician to dropoff the equipment
    $reservation_idx = $request->id;
    $user = $request->param('assigned_tech_dropoff');
    $user = filter_var($user, FILTER_SANITIZE_STRING);
    ReserveDatabaseAPI::change_dropoff($reservation_idx, $user);
    $response->redirect($GLOBALS['BASE_URL'] . '/admin/reservation/search/id/' . $reservation_idx);
});
//chnage status
respond('/reservation/id/[i:id]/priority', function ($request, $response, $app) {
    //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