Skip to content

Commit 0ee4698

Browse files
committed
new
1 parent 6f2fcdb commit 0ee4698

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

public/app.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ function updateAdminDashboard() {
285285
<td>${visitor.id || ''}</td>
286286
<td>${visitor.name || ''}</td>
287287
<td>${visitor.mobile || ''}</td>
288+
<td>${visitor.cardNumber || 'Not Issued'}</td>
288289
<td>${visitor.purpose || 'N/A'}</td>
289290
<td>${visitor.scheduledDate || 'N/A'}</td>
290291
<td>${formatDateTime(visitor.checkInTime)}</td>
@@ -300,8 +301,7 @@ function updateAdminDashboard() {
300301

301302
function updateDeskDashboard() {
302303
const currentVisitors = visitors.filter(v =>
303-
v.status === 'checked-in' || v.status === 'scheduled'
304-
);
304+
v.status === 'checked-in');
305305
const deskCountEl = document.getElementById("deskCurrentCount");
306306
if (deskCountEl) deskCountEl.textContent = currentVisitors.length;
307307

@@ -321,6 +321,7 @@ function updateDeskDashboard() {
321321
row.innerHTML = `
322322
<td>${visitor.name}</td>
323323
<td>${visitor.mobile}</td>
324+
<td>${visitor.cardNumber || "-"}</td>
324325
<td>${formatDateTime(visitor.checkInTime)}</td>
325326
<td>${visitor.purpose || 'N/A'}</td>
326327
<td><button class="btn-secondary" onclick="checkoutVisitor('${visitor.id}')">Check-Out</button></td>
@@ -631,11 +632,20 @@ function initializeDeskScanner() {
631632
return;
632633
}
633634

634-
qrScanner.start(
635-
cameras[0].id,
636-
{ fps: 10, qrbox: 250 },
637-
qrData => handleQRScan(qrData)
638-
);
635+
// Prefer back camera if exists
636+
const backCam = cameras.find(cam =>
637+
cam.label.toLowerCase().includes("back") ||
638+
cam.label.toLowerCase().includes("environment")
639+
);
640+
641+
const selectedCam = backCam || cameras[0]; // fallback to first if no back cam
642+
643+
qrScanner.start(
644+
selectedCam.id,
645+
{ fps: 10, qrbox: 250 },
646+
qrData => handleQRScan(qrData)
647+
);
648+
639649

640650
qrScannerInitialized = true;
641651
})
@@ -710,11 +720,22 @@ async function processQRCheckIn(qrData) {
710720
return;
711721
}
712722

713-
// ---- CHECK-IN ----
714-
await updateDoc(docRef, {
715-
status: "checked-in",
716-
checkInTime: now.toISOString()
717-
});
723+
// Ask desk person to assign card number
724+
const cardNumber = prompt("Enter issued card number (RFID):");
725+
726+
if (!cardNumber || cardNumber.trim() === "") {
727+
alert("❌ Card number is required for check-in.");
728+
return;
729+
}
730+
731+
await updateDoc(docRef, {
732+
status: "checked-in",
733+
cardNumber,
734+
checkInTime: now.toISOString()
735+
});
736+
737+
alert(`✅ Check-in successful\nAssigned Card: ${cardNumber}`);
738+
718739

719740
alert("✅ Check-in successful");
720741
}

public/css/styles.css

Whitespace-only changes.

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ <h1 class="text-2xl font-bold" style="color: var(--primary-brown);">Admin Dashbo
431431
<th>ID</th>
432432
<th>Name</th>
433433
<th>Mobile</th>
434+
<th>Card No.</th>
434435
<th>Purpose</th>
435436
<th>Scheduled Date</th>
436437
<th>Check-in Time</th>

0 commit comments

Comments
 (0)