694 lines
28 KiB
HTML
694 lines
28 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Swansea PPR Request</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background-color: #f5f5f5;
|
|
color: #333;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.container {
|
|
max-width: 800px;
|
|
margin: 2rem auto;
|
|
padding: 2rem;
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.header {
|
|
text-align: center;
|
|
margin-bottom: 2rem;
|
|
padding-bottom: 1rem;
|
|
border-bottom: 2px solid #3498db;
|
|
}
|
|
|
|
.header h1 {
|
|
color: #2c3e50;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.header p {
|
|
color: #666;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.form-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.form-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.form-group.full-width {
|
|
grid-column: 1 / -1;
|
|
}
|
|
|
|
.form-group label {
|
|
font-weight: 600;
|
|
margin-bottom: 0.3rem;
|
|
color: #555;
|
|
}
|
|
|
|
.form-group input, .form-group select, .form-group textarea {
|
|
padding: 0.6rem;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
|
|
outline: none;
|
|
border-color: #3498db;
|
|
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
|
|
}
|
|
|
|
.required::after {
|
|
content: " *";
|
|
color: #e74c3c;
|
|
}
|
|
|
|
.form-actions {
|
|
display: flex;
|
|
gap: 1rem;
|
|
justify-content: center;
|
|
padding-top: 1rem;
|
|
border-top: 1px solid #eee;
|
|
margin-top: 2rem;
|
|
}
|
|
|
|
.btn {
|
|
padding: 0.8rem 2rem;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 1rem;
|
|
font-weight: 500;
|
|
transition: all 0.3s ease;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: #3498db;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: #2980b9;
|
|
}
|
|
|
|
.btn-success {
|
|
background-color: #27ae60;
|
|
color: white;
|
|
}
|
|
|
|
.btn-success:hover {
|
|
background-color: #229954;
|
|
}
|
|
|
|
.notification {
|
|
position: fixed;
|
|
top: 20px;
|
|
right: 20px;
|
|
background-color: #27ae60;
|
|
color: white;
|
|
padding: 12px 20px;
|
|
border-radius: 5px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
|
z-index: 10000;
|
|
opacity: 0;
|
|
transform: translateY(-20px);
|
|
transition: all 0.3s ease;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.notification.show {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.notification.error {
|
|
background-color: #e74c3c;
|
|
}
|
|
|
|
.loading {
|
|
display: none;
|
|
text-align: center;
|
|
margin-top: 1rem;
|
|
}
|
|
|
|
.spinner {
|
|
border: 3px solid #f3f3f3;
|
|
border-top: 3px solid #3498db;
|
|
border-radius: 50%;
|
|
width: 30px;
|
|
height: 30px;
|
|
animation: spin 1s linear infinite;
|
|
margin: 0 auto 1rem;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
.success-message {
|
|
display: none;
|
|
text-align: center;
|
|
padding: 2rem;
|
|
background-color: #d4edda;
|
|
border: 1px solid #c3e6cb;
|
|
border-radius: 4px;
|
|
color: #155724;
|
|
margin-top: 2rem;
|
|
}
|
|
|
|
.airport-lookup-results {
|
|
margin-top: 0.5rem;
|
|
padding: 0.5rem;
|
|
background-color: #f8f9fa;
|
|
border-radius: 4px;
|
|
font-size: 0.9rem;
|
|
min-height: 20px;
|
|
border: 1px solid #e9ecef;
|
|
}
|
|
|
|
.aircraft-lookup-results {
|
|
margin-top: 0.5rem;
|
|
padding: 0.5rem;
|
|
background-color: #f8f9fa;
|
|
border-radius: 4px;
|
|
font-size: 0.9rem;
|
|
min-height: 20px;
|
|
border: 1px solid #e9ecef;
|
|
}
|
|
|
|
.lookup-match {
|
|
padding: 0.3rem;
|
|
background-color: #e8f5e8;
|
|
border: 1px solid #c3e6c3;
|
|
border-radius: 4px;
|
|
font-family: 'Courier New', monospace;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.lookup-no-match {
|
|
color: #6c757d;
|
|
font-style: italic;
|
|
}
|
|
|
|
.lookup-searching {
|
|
color: #007bff;
|
|
}
|
|
|
|
.aircraft-list {
|
|
max-height: 200px;
|
|
overflow-y: auto;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 4px;
|
|
background-color: white;
|
|
}
|
|
|
|
.aircraft-option {
|
|
padding: 0.5rem;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
cursor: pointer;
|
|
transition: background-color 0.2s ease;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.aircraft-option:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.aircraft-option:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.aircraft-code {
|
|
font-family: 'Courier New', monospace;
|
|
font-weight: bold;
|
|
color: #495057;
|
|
}
|
|
|
|
.aircraft-details {
|
|
color: #6c757d;
|
|
font-size: 0.85rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>✈️ Swansea Airport PPR Request</h1>
|
|
<p>Please fill out the form below to submit a Prior Permission Required (PPR) request for Swansea Airport.</p>
|
|
</div>
|
|
|
|
<form id="ppr-form">
|
|
<div class="form-grid">
|
|
<div class="form-group">
|
|
<label for="ac_reg" class="required">Aircraft Registration</label>
|
|
<input type="text" id="ac_reg" name="ac_reg" required oninput="handleAircraftLookup(this.value)">
|
|
<div id="aircraft-lookup-results" class="aircraft-lookup-results"></div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="ac_type" class="required">Aircraft Type</label>
|
|
<input type="text" id="ac_type" name="ac_type" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="ac_call">Callsign</label>
|
|
<input type="text" id="ac_call" name="ac_call" placeholder="If different from registration">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="captain" class="required">Captain/Pilot Name</label>
|
|
<input type="text" id="captain" name="captain" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="in_from" class="required">Arriving From</label>
|
|
<input type="text" id="in_from" name="in_from" required placeholder="ICAO Code or Airport Name" oninput="handleArrivalAirportLookup(this.value)">
|
|
<div id="arrival-airport-lookup-results" class="airport-lookup-results"></div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="eta" class="required">Estimated Time of Arrival (Local Time)</label>
|
|
<div style="display: flex; gap: 0.5rem;">
|
|
<input type="date" id="eta-date" name="eta-date" required style="flex: 1;">
|
|
<select id="eta-time" name="eta-time" required style="flex: 1;">
|
|
<option value="">Select Time</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="pob_in" class="required">Persons on Board (Arrival)</label>
|
|
<input type="number" id="pob_in" name="pob_in" required min="1">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="fuel">Fuel Required</label>
|
|
<select id="fuel" name="fuel">
|
|
<option value="">None</option>
|
|
<option value="100LL">100LL</option>
|
|
<option value="JET A1">JET A1</option>
|
|
<option value="FULL">Full Tanks</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="out_to">Departing To</label>
|
|
<input type="text" id="out_to" name="out_to" placeholder="ICAO Code or Airport Name" oninput="handleDepartureAirportLookup(this.value)">
|
|
<div id="departure-airport-lookup-results" class="airport-lookup-results"></div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="etd">Estimated Time of Departure (Local Time)</label>
|
|
<div style="display: flex; gap: 0.5rem;">
|
|
<input type="date" id="etd-date" name="etd-date" style="flex: 1;">
|
|
<select id="etd-time" name="etd-time" style="flex: 1;">
|
|
<option value="">Select Time</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="pob_out">Persons on Board (Departure)</label>
|
|
<input type="number" id="pob_out" name="pob_out" min="1">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Email Address</label>
|
|
<input type="email" id="email" name="email">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="phone">Phone Number</label>
|
|
<input type="tel" id="phone" name="phone">
|
|
</div>
|
|
<div class="form-group full-width">
|
|
<label for="notes">Additional Notes</label>
|
|
<textarea id="notes" name="notes" rows="4" placeholder="Any special requirements, handling instructions, or additional information..."></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn btn-primary" id="submit-btn">
|
|
Submit PPR Request
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="loading" id="loading">
|
|
<div class="spinner"></div>
|
|
Submitting your PPR request...
|
|
</div>
|
|
|
|
<div class="success-message" id="success-message">
|
|
<h3>✅ PPR Request Submitted Successfully!</h3>
|
|
<p>Your Prior Permission Required request has been submitted and will be reviewed by airport operations. You will receive confirmation via email if provided.</p>
|
|
<p><strong>Please note:</strong> This is not confirmation of approval. Airport operations will contact you if additional information is required.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Success Notification -->
|
|
<div id="notification" class="notification"></div>
|
|
|
|
<script>
|
|
// Initialize time dropdowns
|
|
function initializeTimeDropdowns() {
|
|
const timeSelects = ['eta-time', 'etd-time'];
|
|
|
|
timeSelects.forEach(selectId => {
|
|
const select = document.getElementById(selectId);
|
|
// Clear existing options except the first one
|
|
select.innerHTML = '<option value="">Select Time</option>';
|
|
|
|
// Add time options in 15-minute intervals
|
|
for (let hour = 0; hour < 24; hour++) {
|
|
for (let minute = 0; minute < 60; minute += 15) {
|
|
const timeString = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
const option = document.createElement('option');
|
|
option.value = timeString;
|
|
option.textContent = timeString;
|
|
select.appendChild(option);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Notification system
|
|
function showNotification(message, isError = false) {
|
|
const notification = document.getElementById('notification');
|
|
notification.textContent = message;
|
|
notification.className = 'notification' + (isError ? ' error' : '');
|
|
|
|
// Show notification
|
|
setTimeout(() => {
|
|
notification.classList.add('show');
|
|
}, 10);
|
|
|
|
// Hide after 5 seconds
|
|
setTimeout(() => {
|
|
notification.classList.remove('show');
|
|
}, 5000);
|
|
}
|
|
|
|
// Aircraft lookup
|
|
let aircraftLookupTimeout;
|
|
async function handleAircraftLookup(registration) {
|
|
clearTimeout(aircraftLookupTimeout);
|
|
const resultsDiv = document.getElementById('aircraft-lookup-results');
|
|
const regField = document.getElementById('ac_reg');
|
|
|
|
if (!registration || registration.length < 4) {
|
|
resultsDiv.innerHTML = '';
|
|
return;
|
|
}
|
|
|
|
resultsDiv.innerHTML = '<span class="lookup-searching">Searching...</span>';
|
|
|
|
aircraftLookupTimeout = setTimeout(async () => {
|
|
try {
|
|
const response = await fetch(`/api/v1/aircraft/public/lookup/${registration.toUpperCase()}`);
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
if (data && data.length > 0) {
|
|
if (data.length === 1) {
|
|
// Single match - auto-populate the registration field
|
|
const aircraft = data[0];
|
|
regField.value = aircraft.registration || registration.toUpperCase();
|
|
resultsDiv.innerHTML = `
|
|
<div class="lookup-match">
|
|
${aircraft.registration || registration.toUpperCase()} - ${aircraft.type_code || 'Unknown'} ${aircraft.model ? `(${aircraft.model})` : ''}
|
|
</div>
|
|
`;
|
|
// Auto-fill aircraft type if not already filled
|
|
if (!document.getElementById('ac_type').value) {
|
|
document.getElementById('ac_type').value = aircraft.type_code || '';
|
|
}
|
|
} else if (data.length <= 10) {
|
|
// Multiple matches - show as clickable list
|
|
resultsDiv.innerHTML = `
|
|
<div class="aircraft-list">
|
|
${data.map(aircraft => `
|
|
<div class="aircraft-option" onclick="selectAircraft('${aircraft.registration || registration.toUpperCase()}', '${aircraft.type_code || ''}')">
|
|
<div class="aircraft-code">${aircraft.registration || registration.toUpperCase()}</div>
|
|
<div class="aircraft-details">${aircraft.type_code || 'Unknown'} ${aircraft.model ? `(${aircraft.model})` : ''}</div>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
`;
|
|
} else {
|
|
// Too many matches
|
|
resultsDiv.innerHTML = '<span class="lookup-no-match">Too many matches, please be more specific</span>';
|
|
}
|
|
} else {
|
|
resultsDiv.innerHTML = '<span class="lookup-no-match">No aircraft found with this registration</span>';
|
|
}
|
|
} else {
|
|
resultsDiv.innerHTML = '';
|
|
}
|
|
} catch (error) {
|
|
console.error('Aircraft lookup error:', error);
|
|
resultsDiv.innerHTML = '';
|
|
}
|
|
}, 500);
|
|
}
|
|
|
|
function selectAircraft(registration, typeCode) {
|
|
document.getElementById('ac_reg').value = registration;
|
|
// Always update the aircraft type when a specific aircraft is selected
|
|
document.getElementById('ac_type').value = typeCode;
|
|
document.getElementById('aircraft-lookup-results').innerHTML = '';
|
|
// Remove focus from the field to hide the dropdown
|
|
document.getElementById('ac_reg').blur();
|
|
}
|
|
|
|
// Clear aircraft lookup results when input loses focus
|
|
document.getElementById('ac_reg').addEventListener('blur', function() {
|
|
// Delay clearing to allow click events on options
|
|
setTimeout(() => {
|
|
document.getElementById('aircraft-lookup-results').innerHTML = '';
|
|
}, 150);
|
|
});
|
|
|
|
// Airport lookup functions
|
|
let arrivalAirportLookupTimeout;
|
|
async function handleArrivalAirportLookup(query) {
|
|
clearTimeout(arrivalAirportLookupTimeout);
|
|
const resultsDiv = document.getElementById('arrival-airport-lookup-results');
|
|
const inputField = document.getElementById('in_from');
|
|
|
|
if (!query || query.length < 2) {
|
|
resultsDiv.innerHTML = '';
|
|
return;
|
|
}
|
|
|
|
resultsDiv.innerHTML = '<span class="lookup-searching">Searching...</span>';
|
|
|
|
arrivalAirportLookupTimeout = setTimeout(async () => {
|
|
try {
|
|
const response = await fetch(`/api/v1/airport/public/lookup/${query.toUpperCase()}`);
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
if (data && data.length > 0) {
|
|
if (data.length === 1) {
|
|
// Single match - auto-populate the input field with ICAO code
|
|
const airport = data[0];
|
|
inputField.value = airport.icao;
|
|
resultsDiv.innerHTML = `
|
|
<div class="lookup-match">
|
|
${airport.icao}/${airport.iata || ''} - ${airport.name}, ${airport.country}
|
|
</div>
|
|
`;
|
|
} else if (data.length <= 10) {
|
|
// Multiple matches - show as clickable list
|
|
resultsDiv.innerHTML = `
|
|
<div class="aircraft-list">
|
|
${data.map(airport => `
|
|
<div class="aircraft-option" onclick="selectAirport('in_from', '${airport.icao}')">
|
|
<div class="aircraft-code">${airport.icao}/${airport.iata || ''}</div>
|
|
<div class="aircraft-details">${airport.name}, ${airport.country}</div>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
`;
|
|
} else {
|
|
// Too many matches
|
|
resultsDiv.innerHTML = '<span class="lookup-no-match">Too many matches, please be more specific</span>';
|
|
}
|
|
} else {
|
|
resultsDiv.innerHTML = '<span class="lookup-no-match">No airport found</span>';
|
|
}
|
|
} else {
|
|
resultsDiv.innerHTML = '';
|
|
}
|
|
} catch (error) {
|
|
console.error('Arrival airport lookup error:', error);
|
|
resultsDiv.innerHTML = '';
|
|
}
|
|
}, 500);
|
|
}
|
|
|
|
let departureAirportLookupTimeout;
|
|
async function handleDepartureAirportLookup(query) {
|
|
clearTimeout(departureAirportLookupTimeout);
|
|
const resultsDiv = document.getElementById('departure-airport-lookup-results');
|
|
const inputField = document.getElementById('out_to');
|
|
|
|
if (!query || query.length < 2) {
|
|
resultsDiv.innerHTML = '';
|
|
return;
|
|
}
|
|
|
|
resultsDiv.innerHTML = '<span class="lookup-searching">Searching...</span>';
|
|
|
|
departureAirportLookupTimeout = setTimeout(async () => {
|
|
try {
|
|
const response = await fetch(`/api/v1/airport/public/lookup/${query.toUpperCase()}`);
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
if (data && data.length > 0) {
|
|
if (data.length === 1) {
|
|
// Single match - auto-populate the input field with ICAO code
|
|
const airport = data[0];
|
|
inputField.value = airport.icao;
|
|
resultsDiv.innerHTML = `
|
|
<div class="lookup-match">
|
|
${airport.icao}/${airport.iata || ''} - ${airport.name}, ${airport.country}
|
|
</div>
|
|
`;
|
|
} else if (data.length <= 10) {
|
|
// Multiple matches - show as clickable list
|
|
resultsDiv.innerHTML = `
|
|
<div class="aircraft-list">
|
|
${data.map(airport => `
|
|
<div class="aircraft-option" onclick="selectAirport('out_to', '${airport.icao}')">
|
|
<div class="aircraft-code">${airport.icao}/${airport.iata || ''}</div>
|
|
<div class="aircraft-details">${airport.name}, ${airport.country}</div>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
`;
|
|
} else {
|
|
// Too many matches
|
|
resultsDiv.innerHTML = '<span class="lookup-no-match">Too many matches, please be more specific</span>';
|
|
}
|
|
} else {
|
|
resultsDiv.innerHTML = '<span class="lookup-no-match">No airport found</span>';
|
|
}
|
|
} else {
|
|
resultsDiv.innerHTML = '';
|
|
}
|
|
} catch (error) {
|
|
console.error('Departure airport lookup error:', error);
|
|
resultsDiv.innerHTML = '';
|
|
}
|
|
}, 500);
|
|
}
|
|
|
|
function selectAirport(fieldId, icaoCode) {
|
|
document.getElementById(fieldId).value = icaoCode;
|
|
// Clear the results
|
|
const resultsDivId = fieldId === 'in_from' ? 'arrival-airport-lookup-results' : 'departure-airport-lookup-results';
|
|
document.getElementById(resultsDivId).innerHTML = '';
|
|
// Remove focus from the field to hide the dropdown
|
|
document.getElementById(fieldId).blur();
|
|
}
|
|
|
|
// Clear airport lookup results when input loses focus
|
|
document.getElementById('in_from').addEventListener('blur', function() {
|
|
setTimeout(() => {
|
|
document.getElementById('arrival-airport-lookup-results').innerHTML = '';
|
|
}, 150);
|
|
});
|
|
|
|
document.getElementById('out_to').addEventListener('blur', function() {
|
|
setTimeout(() => {
|
|
document.getElementById('departure-airport-lookup-results').innerHTML = '';
|
|
}, 150);
|
|
});
|
|
|
|
// Form submission
|
|
document.getElementById('ppr-form').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(this);
|
|
const pprData = {};
|
|
|
|
formData.forEach((value, key) => {
|
|
if (value.trim() !== '') {
|
|
if (key === 'pob_in' || key === 'pob_out') {
|
|
pprData[key] = parseInt(value);
|
|
} else if (key === 'eta-date' && formData.get('eta-time')) {
|
|
// Combine date and time for ETA
|
|
const dateStr = formData.get('eta-date');
|
|
const timeStr = formData.get('eta-time');
|
|
pprData.eta = new Date(`${dateStr}T${timeStr}`).toISOString();
|
|
} else if (key === 'etd-date' && formData.get('etd-time')) {
|
|
// Combine date and time for ETD
|
|
const dateStr = formData.get('etd-date');
|
|
const timeStr = formData.get('etd-time');
|
|
pprData.etd = new Date(`${dateStr}T${timeStr}`).toISOString();
|
|
} else if (key !== 'eta-time' && key !== 'etd-time') {
|
|
// Skip the time fields as they're handled above
|
|
pprData[key] = value;
|
|
}
|
|
}
|
|
});
|
|
|
|
// Show loading
|
|
document.getElementById('loading').style.display = 'block';
|
|
document.getElementById('submit-btn').disabled = true;
|
|
document.getElementById('submit-btn').textContent = 'Submitting...';
|
|
|
|
try {
|
|
const response = await fetch('/api/v1/pprs/public', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(pprData)
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
console.log('PPR submitted successfully:', result);
|
|
|
|
// Hide form and show success message
|
|
document.getElementById('ppr-form').style.display = 'none';
|
|
document.getElementById('success-message').style.display = 'block';
|
|
|
|
showNotification('PPR request submitted successfully!');
|
|
} else {
|
|
const errorData = await response.json().catch(() => ({}));
|
|
throw new Error(errorData.detail || `Submission failed: ${response.status}`);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error submitting PPR:', error);
|
|
showNotification(`Error submitting PPR: ${error.message}`, true);
|
|
} finally {
|
|
// Hide loading
|
|
document.getElementById('loading').style.display = 'none';
|
|
document.getElementById('submit-btn').disabled = false;
|
|
document.getElementById('submit-btn').textContent = 'Submit PPR Request';
|
|
}
|
|
});
|
|
|
|
// Initialize the page when DOM is loaded
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
initializeTimeDropdowns();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |