3
<!-- Modal Popup for Tracking Status -->
<div id="trackingModal" class="modal">
<div class="modal-content">
<span class="close-btn">×</span>
<h3>Parcel Tracking Status</h3>
<p id="modalTrackingStatus"></p>
</div>
</div>
</div>
<script src="officer-tracking.js"></script>
</body>
</html>
/* General Page Styling */
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #1f2937, #111827);
color: white;
text-align: center;
margin: 0;
padding: 0;
}
/* Tracking Container */
.tracking-container {
background: rgba(255, 255, 255, 0.1);
padding: 30px;
border-radius: 12px;
width: 50%;
margin: 50px auto;
box-shadow: 0px 5px 20px rgba(255, 255, 255, 0.1);
text-align: center;
backdrop-filter: blur(10px);
}
/* Search Box */
.search-box {
display: flex;
justify-content: center;
gap: 10px;
margin-bottom: 20px;
}
input {
width: 40%;
padding: 12px;
border: 2px solid #4f46e5;
border-radius: 8px;
background: rgba(255, 255, 255, 0.2);
color: white;
text-align: center;
font-size: 16px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.6);
}
button {
background: #4f46e5;
color: white;
border: none;
padding: 12px 18px;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
transition: 0.3s;
}
button:hover {
background: #6366f1;
transform: scale(1.05);
}
/* Package List */
#packageList {
margin-top: 20px;
text-align: left;
color: white;
}
.package {
background: rgba(255, 255, 255, 0.1);
padding: 15px;
border-radius: 8px;
margin-bottom: 10px;
transition: all 0.3s ease;
}
.package:hover {
transform: scale(1.03);
}
/* Modal Popup */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
justify-content: center;
align-items: center;
}
.modal-content {
background: white;
padding: 20px;
border-radius: 10px;
width: 350px;
text-align: center;
color: black;
animation: fadeIn 0.4s;
}
.close-btn {
float: right;
font-size: 24px;
cursor: pointer;
}
.close-btn:hover {
color: red;
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; transform: scale(0.9); }
to { opacity: 1; transform: scale(1); }
}
// Check if officer is logged in
function checkAuth() {
if (localStorage.getItem("isOfficerLoggedIn") !== "true") {
alert("Unauthorized access! Redirecting to login...");
window.location.href = "officer-login.html";
}
}
// Sample package data (replace with API call in real project)
const shippedPackages = [
{ customerId: "CUST001", bookingId: "123456789012", status: "In Transit" },
{ customerId: "CUST002", bookingId: "987654321098", status: "Delivered" },
{ customerId: "CUST003", bookingId: "567890123456", status: "Pending" }
];
// Search function for officers
function searchPackage() {
const customerId = document.getElementById("customerId").value.trim();
const bookingId = document.getElementById("bookingId").value.trim();
let packageList = document.getElementById("packageList");
packageList.innerHTML = "<h3>🔍 Search Results</h3>";
let found = false;
shippedPackages.forEach(pkg => {
if ((customerId && pkg.customerId === customerId) || (bookingId && pkg.bookingId === bookingId)) {
packageList.innerHTML += `
<div class="package">
<strong>Customer ID:</strong> ${pkg.customerId} <br>
<strong>Booking ID:</strong> ${pkg.bookingId} <br>
<strong>Status:</strong> <span class="status">${pkg.status}</span> <br>
<button onclick="openTrackingPopup('${pkg.status}')">📋 View Status</button>
</div>
`;
found = true;
}
});
if (!found) {
packageList.innerHTML += "<p>No matching records found.</p>";
}
}
// Open Tracking Status Popup
function openTrackingPopup(status) {
const modal = document.getElementById("trackingModal");
const modalText = document.getElementById("modalTrackingStatus");
modalText.innerHTML = `<strong>Current Status:</strong> <span class="status">${status}</span>`;
modal.style.display = "flex";
document.querySelector(".close-btn").onclick = function () {
modal.style.display = "none";
};
window.onclick = function (event) {
if (event.target === modal) {
modal.style.display = "none";
}
};
}