PPR ACK and Bulk Logging start

This commit is contained in:
2026-06-15 15:45:58 -04:00
parent 7b2de645db
commit 1952b89ecf
14 changed files with 1710 additions and 19 deletions
+42 -1
View File
@@ -32,6 +32,7 @@
<a href="#" onclick="window.location.href = '/atc'">🎛️ ATC View</a>
<a href="#" onclick="window.location.href = '/reports'">📊 Reports</a>
<a href="#" onclick="window.location.href = '/movements'">📈 Movements</a>
<a href="#" onclick="window.location.href = '/bulk-log'">🧾 Bulk Flight Log</a>
<a href="#" onclick="window.location.href = '/journal'">📔 Journal Log</a>
<a href="#" onclick="openUserAircraftModal(); closeAdminDropdown()" id="user-aircraft-dropdown">✈️ User Aircraft</a>
<a href="#" onclick="openUserManagementModal(); closeAdminDropdown()" id="user-management-dropdown" style="display: none;">👥 User Management</a>
@@ -260,6 +261,7 @@
<th style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">From</th>
<th style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">ETA</th>
<th style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">Notes</th>
<th style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">ACK</th>
</tr>
</thead>
<tbody id="upcoming-table-body">
@@ -822,6 +824,9 @@
const row = document.createElement('tr');
row.onclick = () => openPPRModal(ppr.id);
row.style.cssText = 'font-size: 0.85rem !important;';
if (pprNeedsStripAck(ppr)) {
row.classList.add('ppr-strip-unacknowledged');
}
// Format date as Day DD/MM (e.g., Wed 11/12)
const etaDate = new Date(ppr.eta);
@@ -835,6 +840,9 @@
<span class="notes-indicator">📝</span>
<span class="tooltip-text">${ppr.notes}</span>
</span>` : '';
const ackButton = pprNeedsStripAck(ppr)
? `<button class="btn btn-ack btn-icon" onclick='event.stopPropagation(); acknowledgePPRStrip(${ppr.id}, ${JSON.stringify(ppr.ac_reg || 'PPR')})' title="Acknowledge paper strip created">ACK</button>`
: '<span class="ack-complete" title="Paper strip acknowledged">ACK</span>';
row.innerHTML = `
<td style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">${dateDisplay}</td>
@@ -844,6 +852,7 @@
<td style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">${ppr.in_from || '-'}</td>
<td style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">${formatTimeOnly(ppr.eta)}</td>
<td style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">${notesIndicator}</td>
<td style="padding: 0.3rem 0.4rem !important; font-size: 0.85rem !important;">${ackButton}</td>
`;
tbody.appendChild(row);
}
@@ -917,6 +926,9 @@
const row = document.createElement('tr');
const isLocal = flight.isLocalFlight;
const isBookedIn = flight.isBookedIn;
if (!isLocal && !isBookedIn && pprNeedsStripAck(flight)) {
row.classList.add('ppr-strip-unacknowledged');
}
// Click handler that routes to correct modal
row.onclick = () => {
@@ -1066,7 +1078,13 @@
eta = formatTimeOnly(flight.eta);
pob = flight.pob_in;
fuel = flight.fuel || '-';
const ackButton = pprNeedsStripAck(flight)
? `<button class="btn btn-ack btn-icon" onclick='event.stopPropagation(); acknowledgePPRStrip(${flight.id}, ${JSON.stringify(flight.ac_reg || 'PPR')})' title="Acknowledge paper strip created">
ACK
</button>`
: '';
actionButtons = `
${ackButton}
<button class="btn btn-primary btn-icon" onclick="event.stopPropagation(); activatePPR(${flight.id}, '${flight.ac_reg}', ${flight.out_to ? 'true' : 'false'})" title="Activate PPR - create arrival/departure records">
ACTIVATE
</button>
@@ -1092,6 +1110,29 @@
setupTooltips();
}
function pprNeedsStripAck(ppr) {
return (ppr.status === 'NEW' || ppr.status === 'CONFIRMED') && !ppr.acknowledged_dt;
}
async function acknowledgePPRStrip(pprId, acReg) {
if (!confirm(`Confirm paper strip has been created for ${acReg}?`)) return;
try {
const response = await authenticatedFetch(`/api/v1/pprs/${pprId}/acknowledge`, { method: 'POST' });
if (!response.ok) {
const err = await response.json().catch(() => ({}));
showNotification(err.detail || 'Failed to acknowledge PPR strip', true);
return;
}
showNotification('PPR strip acknowledged');
await loadPPRs();
} catch (error) {
console.error('Error acknowledging PPR strip:', error);
showNotification('Error acknowledging PPR strip', true);
}
}
async function activatePPR(pprId, acReg, hasDeparture) {
const msg = `Activate PPR for ${acReg}?\nThis will create an INBOUND arrival.`
+ (hasDeparture ? '\nThe outbound departure will appear automatically when the aircraft lands.' : '');
@@ -1439,4 +1480,4 @@
Please contact James Pattinson if you have any ideas about or problems with this system
</div>
</body>
</html>
</html>