Skip to content

Add locked classroom reservations with admin-only booking#90

Merged
marpisco merged 9 commits intomainfrom
copilot/add-lock-classroom-reservations
Dec 2, 2025
Merged

Add locked classroom reservations with admin-only booking#90
marpisco merged 9 commits intomainfrom
copilot/add-lock-classroom-reservations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 2, 2025

Adds ability to lock classrooms so only admins can create reservations. Locked rooms remain visible with existing reservations, but non-admins see a blocked notice instead of booking controls. Admins gain the ability to create reservations on behalf of any user.

Database Schema

  • Added bloqueado column to salas table (0=unlocked, 1=locked)
  • Migration handles existing installations

Admin Panel (admin/salas.php)

  • New "Estado" dropdown in room edit form to toggle lock status
  • Lock status badge in rooms list (red=locked, green=unlocked)

Reservation UI (reservar/index.php)

  • Locked room notice: warning for admins, danger alert for non-admins
  • Non-admins on locked rooms see "Livre" text without checkboxes/links
  • Modal-based user lookup for admins in bulk reservation form with search/filter functionality

Reservation Logic (reservar/manage.php)

  • Blocks non-admin reservation attempts on locked rooms (returns 403)
  • Modal-based user selection for single and bulk reservations with search/filter by name or email
  • Validates requisitor_id exists in database before use

User Selection Modal

  • Searchable modal replaces dropdown to prevent UI clutter with many users
  • Filter users by name or email in real-time
  • Scrollable list with user name and email displayed
  • "Procurar" (Search) button opens the modal, "Limpar" (Clear) button resets selection
// Check if room is locked and user is not admin
if ($salaInfo['bloqueado'] == 1 && !$_SESSION['admin']) {
    http_response_code(403);
    die("Esta sala está bloqueada. Apenas os administradores podem criar reservas.");
}

// Validate requisitor_id for admin reservations on behalf of users
if ($_SESSION['admin'] && isset($_POST['requisitor_id']) && !empty($_POST['requisitor_id'])) {
    $userCheckStmt = $db->prepare("SELECT id FROM cache WHERE id = ?");
    $userCheckStmt->bind_param("s", $_POST['requisitor_id']);
    // ...
}
Original prompt

Add a feature to lock classroom reservations. They'll show up on the reservation list, and people can see reservations, but only admins can create reservations. With this, add a "create reservations for user" option for admins. Locked classrooms will have a notice on the reserve classroom page saying that the classroom is locked.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 2, 2025 11:42
Co-authored-by: marpisco <162377105+marpisco@users.noreply.github.com>
Co-authored-by: marpisco <162377105+marpisco@users.noreply.github.com>
Copilot AI changed the title [WIP] Add feature to lock classroom reservations for admins Add locked classroom reservations with admin-only booking Dec 2, 2025
Copilot AI requested a review from marpisco December 2, 2025 11:49
@marpisco
Copy link
Copy Markdown
Owner

marpisco commented Dec 2, 2025

@copilot Everything seems great except the reservation tactic. Change the way that you are putting up users, since that might become hogged up over time. Add some sort of modal for looking up.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 2, 2025

@copilot Everything seems great except the reservation tactic. Change the way that you are putting up users, since that might become hogged up over time. Add some sort of modal for looking up.

Replaced the dropdown with a modal-based user lookup in commit 537c72d. The new UI includes:

  • A search/filter input to quickly find users by name or email
  • A scrollable list of users in a Bootstrap modal
  • "Procurar" (Search) button to open the modal
  • "Limpar" (Clear) button to reset selection

This change applies to both bulk reservations (reservar/index.php) and single reservations (reservar/manage.php).

@marpisco
Copy link
Copy Markdown
Owner

marpisco commented Dec 2, 2025

Aproveitei esta PR para poder adicionar outras funções e QOL.

@marpisco marpisco marked this pull request as ready for review December 2, 2025 14:15
@marpisco marpisco merged commit 43e351b into main Dec 2, 2025
5 checks passed
@marpisco marpisco deleted the copilot/add-lock-classroom-reservations branch December 2, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants