TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/gavafue/registroComponentesMultimedia/llms.txt
Use this file to discover all available pages before exploring further.
loans.php file is the core of the equipment registry. It handles the full lifecycle of a loan: creation with a checkout signature, public return with a return signature, and administrative operations such as status overrides, record edits, and reporting queries. Public endpoints require no session; admin endpoints check $_SESSION['user_id'] and return 401 if the session is missing.
Loan Object Schema
All admin GET endpoints return full loan records. The fields are:Auto-incremented primary key for the loan record.
Cédula de identidad (national ID) of the borrower.
Full name of the borrower.
Optional class or group identifier (e.g.,
"3°A").Free-text description of the borrowed equipment (e.g.,
"Ceibalita 003, Cable HDMI").ISO-8601-style datetime when the loan was created, set by
NOW() on the server (e.g., "2024-03-15 08:30:00").Base64 PNG data URL of the borrower’s checkout signature.
Datetime when the equipment was returned.
null while the loan is active.Base64 PNG data URL of the return signature.
null for admin-overridden returns.Optional freetext note recorded at return time.
Either
"active" (equipment not yet returned) or "returned" (equipment back).POST loans.php — Create a Loan
Records a new equipment checkout. Access is public — no admin session required. The checkout timestamp is set to NOW() by the server and the initial status is "active".
Request Body
Cédula de identidad of the borrower.
Full name of the borrower.
Description of the equipment being checked out.
Base64 PNG data URL of the borrower’s signature, obtained from
SignaturePad.getBase64().Optional class or group label for the borrower.
Responses
"Préstamo registrado correctamente" on success.The auto-incremented ID of the newly created loan record.
| Status | Body | Condition |
|---|---|---|
| 200 | { "message": "Préstamo registrado correctamente", "id": 42 } | Loan created |
| 400 | { "error": "Faltan campos obligatorios" } | One or more required fields missing |
| 500 | { "error": "Error al guardar: ..." } | Database write failed |
curl Example
JavaScript Client
GET loans.php?action=active_by_ci&ci={ci} — Active Loans by CI
Returns all loans with status = 'active' for the given cédula. Access is public. Used by the return form to look up what a person currently has checked out.
Query Parameters
Must be
active_by_ci.The cédula de identidad to look up.
Response
Returns a JSON array of active loan summaries ordered bycheckout_time DESC. Each item contains:
Loan record ID.
Description of the checked-out equipment.
Datetime when the equipment was checked out.
| Status | Body | Condition |
|---|---|---|
| 200 | Array of loan summary objects (may be empty) | Query successful |
| 400 | { "error": "Falta cédula" } | ci parameter missing |
curl Example
JavaScript Client
PUT loans.php — Return a Loan (Public)
Registers the return of a specific loan. The borrower provides their signature; no admin session is needed. Sets return_time = NOW() and flips status to "returned". Only loans currently in status = 'active' can be returned this way.
Request Body
ID of the loan to return.
Base64 PNG data URL of the return signature.
Optional freetext note (e.g., damage notes). Defaults to
null.Responses
"Devolución registrada correctamente" on success.| Status | Body | Condition |
|---|---|---|
| 200 | { "message": "Devolución registrada correctamente" } | Return recorded |
| 400 | { "error": "Falta el ID del préstamo" } | id field missing from request body |
| 400 | { "error": "Faltan campos obligatorios para la devolución" } | return_signature missing |
| 404 | { "error": "Préstamo no encontrado o ya devuelto" } | No active loan found with the given ID |
| 500 | { "error": "Error al guardar: ..." } | Database write failed |
curl Example
JavaScript Client
PUT loans.php — Update Loan Status (Admin)
Allows an authenticated admin to override the loan status without requiring a borrower signature. Useful for marking equipment as returned when the borrower is not present, or for reverting an accidental return.
Requires an active admin session.
Request Body
ID of the loan to update.
Target status. Accepted values:
"returned" or "active".Note to attach when marking as returned. Defaults to
"Marcado como devuelto desde administración" if omitted.Behaviour by Status Value
status: "returned" — Updates an active loan: sets return_time = NOW(), sets return_signature = NULL, sets return_observation to the provided value or the default admin note, and flips status to "returned". The WHERE clause requires status = 'active', so already-returned loans are untouched.
status: "active" — Reverts a returned loan: sets status = 'active', nulls out return_time, return_signature, and return_observation.
Responses
| Status | Body | Condition |
|---|---|---|
| 200 | { "message": "Registro marcado como devuelto" } | Successfully marked as returned |
| 200 | { "message": "Registro marcado como en préstamo" } | Successfully reverted to active |
| 401 | { "error": "No autorizado" } | No active admin session |
| 404 | { "error": "Préstamo no encontrado o ya devuelto" } | status: "returned" — loan not found or already returned |
| 404 | { "error": "Préstamo no encontrado o ya en préstamo" } | status: "active" — loan not found or already active |
| 500 | { "error": "Error al guardar: ..." } | Database write failed |
curl Example
JavaScript Client
PUT loans.php — Update Loan Details (Admin)
Edits one or more data fields of an existing loan record. Requires an active admin session. Any combination of the four updatable fields may be sent in a single request.
Request Body
ID of the loan record to edit.
New equipment description.
Corrected borrower name.
Corrected cédula de identidad.
Updated group or class label.
Responses
"Registro actualizado correctamente" on success.| Status | Body | Condition |
|---|---|---|
| 200 | { "message": "Registro actualizado correctamente" } | Record updated |
| 401 | { "error": "No autorizado" } | No active admin session |
| 404 | { "error": "Préstamo no encontrado o sin cambios" } | ID not found or supplied values are unchanged |
| 500 | { "error": "Error al guardar: ..." } | Database write failed |
The
PUT handler checks for status first, then for updatable fields. Both paths can coexist in one request body, but mixing status with field edits is not a documented or tested workflow — send them as separate requests.curl Example
JavaScript Client
GET loans.php?action=pending — Pending Loans (Admin)
Returns all loans with status = 'active', ordered by checkout_time ASC (oldest first). Requires an active admin session.
Response
An array of full loan objects ordered oldest-first. See the Loan Object Schema at the top of this page for field definitions.| Status | Body | Condition |
|---|---|---|
| 200 | Array of full loan objects (may be empty) | Query successful |
| 401 | { "error": "No autorizado" } | No active admin session |
curl Example
JavaScript Client
GET loans.php?action=all — Full Loan History (Admin)
Returns every loan record regardless of status, ordered by id DESC (most recent first). Requires an active admin session.
Response
An array of full loan objects. See the Loan Object Schema for field definitions.| Status | Body | Condition |
|---|---|---|
| 200 | Array of full loan objects | Query successful |
| 401 | { "error": "No autorizado" } | No active admin session |
curl Example
JavaScript Client
GET loans.php?action=stats — Dashboard KPIs (Admin)
Returns aggregated counts for the admin dashboard. All values are integers. Requires an active admin session.
Response Fields
Number of loans created today (based on
DATE(checkout_time) = ? where ? is the current date from PHP’s date('Y-m-d')).Number of loans currently in
status = 'active'.Number of loans returned today (based on
DATE(return_time) = ? where ? is the current date from PHP’s date('Y-m-d')).Number of active loans where
checkout_time < NOW() - INTERVAL 12 HOUR. These are overdue.Total number of loan records across all time.
| Status | Body | Condition |
|---|---|---|
| 200 | { "today": 5, "active": 3, "returned_today": 2, "delayed": 1, "total": 148 } | Query successful |
| 401 | { "error": "No autorizado" } | No active admin session |