412 lines
18 KiB
HTML
412 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Gastauftrag Status-Abfrage - Mercedes-Benz TBA Marienfelde</title>
|
|
<link href="{{ url_for('static', filename='css/output.css') }}" rel="stylesheet">
|
|
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
|
|
|
<style>
|
|
.status-card {
|
|
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
|
|
border: 1px solid #e2e8f0;
|
|
border-radius: 16px;
|
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.dark .status-card {
|
|
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
|
|
border-color: #334155;
|
|
}
|
|
|
|
.otp-input {
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 1.5rem;
|
|
text-align: center;
|
|
letter-spacing: 0.5rem;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.status-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 9999px;
|
|
font-weight: 500;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.status-pending { background-color: #fef3c7; color: #92400e; }
|
|
.status-approved { background-color: #d1fae5; color: #065f46; }
|
|
.status-rejected { background-color: #fee2e2; color: #991b1b; }
|
|
|
|
.loading-spinner {
|
|
border: 2px solid #f3f4f6;
|
|
border-top: 2px solid #0073ce;
|
|
border-radius: 50%;
|
|
width: 1rem;
|
|
height: 1rem;
|
|
animation: spin 1s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="bg-gray-50 font-mercedes">
|
|
<div class="min-h-screen flex items-center justify-center p-4">
|
|
<div class="max-w-md w-full space-y-8">
|
|
<!-- Header -->
|
|
<div class="text-center">
|
|
<div class="mx-auto h-12 w-12 bg-mercedes-blue rounded-full flex items-center justify-center">
|
|
<svg class="h-6 w-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
|
</svg>
|
|
</div>
|
|
<h2 class="mt-6 text-3xl font-bold text-gray-900">
|
|
Auftragsstatus prüfen
|
|
</h2>
|
|
<p class="mt-2 text-sm text-gray-600">
|
|
Geben Sie Ihren Statuscode ein, um Informationen über Ihren Gastauftrag zu erhalten
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Status-Abfrage-Formular -->
|
|
<div class="status-card p-6" id="query-form">
|
|
<form id="status-form" class="space-y-6">
|
|
<div>
|
|
<label for="otp_code" class="block text-sm font-medium text-gray-700">
|
|
Statuscode (16 Zeichen)
|
|
</label>
|
|
<input type="text"
|
|
id="otp_code"
|
|
name="otp_code"
|
|
maxlength="16"
|
|
class="otp-input mt-1 appearance-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-md focus:outline-none focus:ring-mercedes-blue focus:border-mercedes-blue focus:z-10 sm:text-sm"
|
|
placeholder="XXXXXXXXXXXXXXXX"
|
|
required>
|
|
<p class="mt-1 text-xs text-gray-500">
|
|
Der Code wurde Ihnen bei der Antragsstellung mitgeteilt
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="email" class="block text-sm font-medium text-gray-700">
|
|
E-Mail-Adresse (optional)
|
|
</label>
|
|
<input type="email"
|
|
id="email"
|
|
name="email"
|
|
class="mt-1 appearance-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-md focus:outline-none focus:ring-mercedes-blue focus:border-mercedes-blue focus:z-10 sm:text-sm"
|
|
placeholder="ihre.email@example.com">
|
|
<p class="mt-1 text-xs text-gray-500">
|
|
Zusätzliche Sicherheit (empfohlen)
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<button type="submit"
|
|
class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-mercedes-blue hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
<span id="submit-text">Status prüfen</span>
|
|
<span id="loading-spinner" class="loading-spinner ml-2 hidden"></span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Status-Ergebnis -->
|
|
<div id="status-result" class="hidden">
|
|
<div class="status-card p-6">
|
|
<div id="status-content">
|
|
<!-- Wird per JavaScript gefüllt -->
|
|
</div>
|
|
|
|
<div class="mt-6 flex gap-3">
|
|
<button onclick="resetForm()"
|
|
class="flex-1 py-2 px-4 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Neue Abfrage
|
|
</button>
|
|
<button onclick="refreshStatus()"
|
|
class="flex-1 py-2 px-4 border border-transparent rounded-md text-sm font-medium text-white bg-mercedes-blue hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Aktualisieren
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Fehleranzeige -->
|
|
<div id="error-message" class="hidden">
|
|
<div class="status-card p-6 border-l-4 border-red-500">
|
|
<div class="flex">
|
|
<div class="flex-shrink-0">
|
|
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
|
|
</svg>
|
|
</div>
|
|
<div class="ml-3">
|
|
<h3 class="text-sm font-medium text-red-800">Fehler</h3>
|
|
<div class="mt-2 text-sm text-red-700" id="error-text">
|
|
<!-- Wird per JavaScript gefüllt -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4">
|
|
<button onclick="resetForm()"
|
|
class="py-2 px-4 border border-transparent rounded-md text-sm font-medium text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
|
|
Erneut versuchen
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div class="text-center">
|
|
<p class="text-xs text-gray-500">
|
|
Mercedes-Benz Technische Berufsausbildung Marienfelde<br>
|
|
<a href="/guest/request" class="text-mercedes-blue hover:underline">Neuen Antrag stellen</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let currentRequestData = null;
|
|
|
|
// Formular-Submit-Handler
|
|
document.getElementById('status-form').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const otpCode = document.getElementById('otp_code').value.trim();
|
|
const email = document.getElementById('email').value.trim();
|
|
|
|
if (!otpCode) {
|
|
showError('Bitte geben Sie Ihren Statuscode ein.');
|
|
return;
|
|
}
|
|
|
|
if (otpCode.length !== 16) {
|
|
showError('Der Statuscode muss genau 16 Zeichen lang sein.');
|
|
return;
|
|
}
|
|
|
|
setLoading(true);
|
|
hideAll();
|
|
|
|
try {
|
|
const response = await fetch('/guest/api/guest/status', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
otp_code: otpCode,
|
|
email: email || undefined
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
currentRequestData = data.request;
|
|
showStatus(data.request);
|
|
} else {
|
|
showError(data.message || 'Ungültiger Code oder E-Mail-Adresse');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Fehler bei Status-Abfrage:', error);
|
|
showError('Verbindungsfehler. Bitte versuchen Sie es später erneut.');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
});
|
|
|
|
// Status anzeigen
|
|
function showStatus(request) {
|
|
const statusContent = document.getElementById('status-content');
|
|
|
|
// Status-Badge
|
|
let statusBadge = '';
|
|
let statusIcon = '';
|
|
|
|
switch (request.status) {
|
|
case 'pending':
|
|
statusBadge = '<span class="status-badge status-pending">🕒 In Bearbeitung</span>';
|
|
statusIcon = '🕒';
|
|
break;
|
|
case 'approved':
|
|
statusBadge = '<span class="status-badge status-approved">✅ Genehmigt</span>';
|
|
statusIcon = '✅';
|
|
break;
|
|
case 'rejected':
|
|
statusBadge = '<span class="status-badge status-rejected">❌ Abgelehnt</span>';
|
|
statusIcon = '❌';
|
|
break;
|
|
default:
|
|
statusBadge = '<span class="status-badge">❓ Unbekannt</span>';
|
|
statusIcon = '❓';
|
|
}
|
|
|
|
let html = `
|
|
<div class="text-center mb-6">
|
|
<div class="text-4xl mb-2">${statusIcon}</div>
|
|
<h3 class="text-xl font-semibold text-gray-900 mb-2">
|
|
Antrag von ${request.name}
|
|
</h3>
|
|
${statusBadge}
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
<div class="bg-gray-50 p-4 rounded-lg">
|
|
<h4 class="font-medium text-gray-900 mb-2">Antragsdetails</h4>
|
|
<dl class="space-y-1 text-sm">
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-600">Erstellt am:</dt>
|
|
<dd class="text-gray-900">${formatDate(request.created_at)}</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-600">Dauer:</dt>
|
|
<dd class="text-gray-900">${request.duration_min} Minuten</dd>
|
|
</div>
|
|
${request.file_name ? `
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-600">Datei:</dt>
|
|
<dd class="text-gray-900">${request.file_name}</dd>
|
|
</div>
|
|
` : ''}
|
|
</dl>
|
|
</div>
|
|
|
|
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
|
<p class="text-sm text-blue-800">
|
|
${request.message}
|
|
</p>
|
|
</div>
|
|
|
|
${request.status === 'approved' && request.can_start_job ? `
|
|
<div class="bg-green-50 border border-green-200 rounded-lg p-4">
|
|
<h4 class="font-medium text-green-800 mb-2">🎯 Bereit zum Drucken!</h4>
|
|
<p class="text-sm text-green-700 mb-3">
|
|
Ihr Auftrag wurde genehmigt. Sie können mit dem 3D-Druck beginnen.
|
|
</p>
|
|
<a href="/guest/start-job"
|
|
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700">
|
|
🚀 Jetzt drucken
|
|
</a>
|
|
</div>
|
|
` : ''}
|
|
|
|
${request.status === 'rejected' && request.rejection_reason ? `
|
|
<div class="bg-red-50 border border-red-200 rounded-lg p-4">
|
|
<h4 class="font-medium text-red-800 mb-2">Ablehnungsgrund:</h4>
|
|
<p class="text-sm text-red-700">${request.rejection_reason}</p>
|
|
</div>
|
|
` : ''}
|
|
|
|
${request.job ? `
|
|
<div class="bg-indigo-50 border border-indigo-200 rounded-lg p-4">
|
|
<h4 class="font-medium text-indigo-800 mb-2">📋 Job-Informationen</h4>
|
|
<dl class="space-y-1 text-sm">
|
|
<div class="flex justify-between">
|
|
<dt class="text-indigo-600">Job-Name:</dt>
|
|
<dd class="text-indigo-900">${request.job.name}</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-indigo-600">Status:</dt>
|
|
<dd class="text-indigo-900">${request.job.status}</dd>
|
|
</div>
|
|
${request.job.printer_name ? `
|
|
<div class="flex justify-between">
|
|
<dt class="text-indigo-600">Drucker:</dt>
|
|
<dd class="text-indigo-900">${request.job.printer_name}</dd>
|
|
</div>
|
|
` : ''}
|
|
</dl>
|
|
</div>
|
|
` : ''}
|
|
</div>
|
|
`;
|
|
|
|
statusContent.innerHTML = html;
|
|
document.getElementById('status-result').classList.remove('hidden');
|
|
}
|
|
|
|
// Fehler anzeigen
|
|
function showError(message) {
|
|
document.getElementById('error-text').textContent = message;
|
|
document.getElementById('error-message').classList.remove('hidden');
|
|
}
|
|
|
|
// Loading-Zustand setzen
|
|
function setLoading(loading) {
|
|
const submitText = document.getElementById('submit-text');
|
|
const loadingSpinner = document.getElementById('loading-spinner');
|
|
const submitButton = document.querySelector('button[type="submit"]');
|
|
|
|
if (loading) {
|
|
submitText.textContent = 'Prüfe...';
|
|
loadingSpinner.classList.remove('hidden');
|
|
submitButton.disabled = true;
|
|
} else {
|
|
submitText.textContent = 'Status prüfen';
|
|
loadingSpinner.classList.add('hidden');
|
|
submitButton.disabled = false;
|
|
}
|
|
}
|
|
|
|
// Alle Anzeigen ausblenden
|
|
function hideAll() {
|
|
document.getElementById('status-result').classList.add('hidden');
|
|
document.getElementById('error-message').classList.add('hidden');
|
|
}
|
|
|
|
// Formular zurücksetzen
|
|
function resetForm() {
|
|
document.getElementById('status-form').reset();
|
|
hideAll();
|
|
document.getElementById('query-form').classList.remove('hidden');
|
|
currentRequestData = null;
|
|
}
|
|
|
|
// Status aktualisieren
|
|
function refreshStatus() {
|
|
if (currentRequestData) {
|
|
const otpCode = document.getElementById('otp_code').value;
|
|
const email = document.getElementById('email').value;
|
|
|
|
// Formular erneut abschicken
|
|
document.getElementById('status-form').dispatchEvent(new Event('submit'));
|
|
}
|
|
}
|
|
|
|
// Datum formatieren
|
|
function formatDate(dateString) {
|
|
if (!dateString) return 'Unbekannt';
|
|
|
|
try {
|
|
const date = new Date(dateString);
|
|
return date.toLocaleDateString('de-DE', {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit'
|
|
});
|
|
} catch (error) {
|
|
return dateString;
|
|
}
|
|
}
|
|
|
|
// OTP-Input Formatierung
|
|
document.getElementById('otp_code').addEventListener('input', function(e) {
|
|
// Nur alphanumerische Zeichen erlauben
|
|
e.target.value = e.target.value.replace(/[^A-Fa-f0-9]/g, '').toUpperCase();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |