Movement summary
This commit is contained in:
@@ -754,7 +754,7 @@
|
||||
displayOtherFlights(otherFlights);
|
||||
|
||||
// Calculate and display movements summary
|
||||
calculateMovementsSummary(pprs, otherFlights);
|
||||
calculateMovementsSummary(pprs, otherFlights, dateFrom, dateTo);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading reports:', error);
|
||||
@@ -768,7 +768,7 @@
|
||||
}
|
||||
|
||||
// Calculate and display movements summary
|
||||
function calculateMovementsSummary(pprs, otherFlights) {
|
||||
function calculateMovementsSummary(pprs, otherFlights, dateFrom, dateTo) {
|
||||
let pprArrivals = 0; // PPR landings
|
||||
let pprDepartures = 0; // PPR takeoffs
|
||||
let localFlightsMovements = 0;
|
||||
@@ -776,21 +776,47 @@
|
||||
let nonPprArrivals = 0;
|
||||
let nonPprDepartures = 0;
|
||||
|
||||
// PPR movements:
|
||||
// Format date range for display
|
||||
let dateRangeText = '';
|
||||
if (dateFrom && dateTo && dateFrom === dateTo) {
|
||||
// Single day
|
||||
const date = new Date(dateFrom + 'T00:00:00Z');
|
||||
dateRangeText = `for ${date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' })}`;
|
||||
} else if (dateFrom && dateTo) {
|
||||
// Date range
|
||||
const fromDate = new Date(dateFrom + 'T00:00:00Z');
|
||||
const toDate = new Date(dateTo + 'T00:00:00Z');
|
||||
const fromText = fromDate.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||
const toText = toDate.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||
dateRangeText = `for ${fromText} to ${toText}`;
|
||||
} else if (dateFrom) {
|
||||
const date = new Date(dateFrom + 'T00:00:00Z');
|
||||
dateRangeText = `from ${date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' })}`;
|
||||
} else if (dateTo) {
|
||||
const date = new Date(dateTo + 'T00:00:00Z');
|
||||
dateRangeText = `until ${date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' })}`;
|
||||
}
|
||||
|
||||
// Update summary title with date range
|
||||
const summaryTitle = document.querySelector('.summary-title');
|
||||
if (summaryTitle) {
|
||||
summaryTitle.textContent = `📊 Movements Summary ${dateRangeText}`;
|
||||
}
|
||||
|
||||
// PPR movements (excluding CANCELED):
|
||||
// - LANDED = 1 arrival (landing)
|
||||
// - DEPARTED = 1 departure + 1 arrival (because departure implies a prior landing)
|
||||
pprs.forEach(ppr => {
|
||||
pprs.filter(ppr => ppr.status !== 'CANCELED').forEach(ppr => {
|
||||
if (ppr.status === 'LANDED') {
|
||||
pprArrivals += 1;
|
||||
} else if (ppr.status === 'DEPARTED') {
|
||||
pprDepartures += 1;
|
||||
pprArrivals += 1; // Each departure implies a landing happened
|
||||
}
|
||||
// CANCELED = 0 movements, not counted
|
||||
});
|
||||
|
||||
// Other flights movements
|
||||
otherFlights.forEach(flight => {
|
||||
// Other flights movements (excluding CANCELLED)
|
||||
otherFlights.filter(flight => flight.status !== 'CANCELLED').forEach(flight => {
|
||||
if (flight.flightType === 'ARRIVAL') {
|
||||
nonPprArrivals += 1;
|
||||
} else if (flight.flightType === 'DEPARTURE') {
|
||||
|
||||
Reference in New Issue
Block a user