2024-09-06 23:26:30 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2024-09-10 17:29:16 +00:00
|
|
|
<title>Credential Printer</title>
|
|
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
2024-09-06 23:26:30 +00:00
|
|
|
</head>
|
2024-09-10 17:29:16 +00:00
|
|
|
<body class="bg-gray-100 font-sans leading-normal tracking-normal">
|
|
|
|
<div class="max-w-lg mx-auto mt-10 bg-white p-8 rounded-lg shadow-lg">
|
2024-09-10 17:40:47 +00:00
|
|
|
<div class="flex justify-center mb-6">
|
|
|
|
<img src="./itslogo_color.png" alt="ITS Logo" class="h-24 w-auto">
|
|
|
|
</div>
|
|
|
|
<h1 class="text-2xl font-bold text-center mb-4" style="color: #1F3C70;">ITS Credential Printer</h1>
|
2024-09-10 17:29:16 +00:00
|
|
|
<p class="text-center text-gray-600 mb-6">
|
|
|
|
Provide the username and student ID in the fields below, then click the Print button.
|
|
|
|
A pre-formatted receipt will print with the information from the thermal printer.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<form id="printForm" class="space-y-4">
|
|
|
|
<div>
|
|
|
|
<label for="username" class="block text-sm font-medium text-gray-700">Username:</label>
|
|
|
|
<input type="text" id="username" name="username" required
|
|
|
|
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
|
|
|
</div>
|
2024-09-09 20:27:51 +00:00
|
|
|
|
2024-09-10 17:29:16 +00:00
|
|
|
<div>
|
|
|
|
<label for="studentId" class="block text-sm font-medium text-gray-700">Student ID:</label>
|
|
|
|
<input type="text" id="studentId" name="studentId" required
|
|
|
|
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
|
|
|
</div>
|
2024-09-09 20:27:51 +00:00
|
|
|
|
2024-09-10 17:29:16 +00:00
|
|
|
<div class="text-center">
|
|
|
|
<button type="submit"
|
2024-09-10 17:40:47 +00:00
|
|
|
style="background-color: #1F3C70;"
|
|
|
|
class="w-full text-white py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50">
|
2024-09-10 17:29:16 +00:00
|
|
|
Print
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2024-09-06 23:26:30 +00:00
|
|
|
|
|
|
|
<script>
|
2024-09-09 20:27:51 +00:00
|
|
|
document.getElementById('printForm').addEventListener('submit', (event) => {
|
|
|
|
event.preventDefault(); // Prevent the form from submitting normally
|
|
|
|
|
|
|
|
// Get the form data
|
|
|
|
const formData = new FormData(event.target);
|
|
|
|
const username = formData.get('username');
|
|
|
|
const studentId = formData.get('studentId');
|
|
|
|
|
|
|
|
// Send a POST request with the form data to the server
|
2024-09-10 17:29:16 +00:00
|
|
|
fetch('/print', {
|
2024-09-09 20:27:51 +00:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: username,
|
|
|
|
studentId: studentId,
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.text(); // or .json() if your server returns JSON
|
|
|
|
} else {
|
|
|
|
throw new Error('Failed to send print request');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(message => alert(message))
|
|
|
|
.catch(error => alert('Error: ' + error));
|
2024-09-06 23:26:30 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
2024-09-09 20:27:51 +00:00
|
|
|
</html>
|