From 2f0fdde55ce3f820219699aecd6086565d908e72 Mon Sep 17 00:00:00 2001
From: Hugues Ferland
day worked"),
- ReportColumn(title : "Dual Flights"),
- ReportColumn(title : "Dual Flights /
day worked")], withAlternatingRowColor : true)
+ generator.startTable([[ReportColumn(title : ""),
+ ReportColumn(title : "Days Worked"),
+ ReportColumn(title : "PIC Flights"),
+ ReportColumn(title : "PIC flights /
day worked"),
+ ReportColumn(title : "Dual Flights"),
+ ReportColumn(title : "Dual Flights /
day worked")]], withAlternatingRowColor : true)
let staffAttendanceRequest = AttendanceRecord.request
- let staffAttendanceRequestPredicate = NSPredicate(format: "timeIn > %@ AND timeIn < %@ AND participantType != %@ AND pilot != nil", argumentArray: [startDate, endDate, "cadet"])
+ let staffAttendanceRequestPredicate = NSPredicate(format: "timeIn > %@ AND timeIn < %@ AND participantType != %@ AND pilot != nil", argumentArray: [beginningOfReport, endDate, "cadet"])
if siteSpecific
{
@@ -2156,7 +2157,7 @@ final class ReportGenerator
{
for timesheet in GC.timesheets
{
- if (startDate...endDate).contains(timesheet.date)
+ if (beginningOfReport...endDate).contains(timesheet.date)
{
flightRecordsInTimePeriod.formUnion(timesheet.flightRecords)
}
@@ -2166,7 +2167,7 @@ final class ReportGenerator
else
{
let flightRecordRequest = FlightRecord.request
- let flightRecordRequestPredicate = NSPredicate(format: "\(#keyPath(FlightRecord.timeUp)) > %@ AND \(#keyPath(FlightRecord.timeUp)) < %@ AND \(#keyPath(FlightRecord.pilot)) != nil", argumentArray: [startDate, endDate])
+ let flightRecordRequestPredicate = NSPredicate(format: "\(#keyPath(FlightRecord.timeUp)) > %@ AND \(#keyPath(FlightRecord.timeUp)) < %@ AND \(#keyPath(FlightRecord.pilot)) != nil", argumentArray: [beginningOfReport, endDate])
flightRecordRequest.predicate = flightRecordRequestPredicate
do{flightRecordsInTimePeriod = try Set(dataModel.managedObjectContext.fetch(flightRecordRequest))}
catch{}
@@ -2289,18 +2290,18 @@ final class ReportGenerator
// Start Staff Cadet Attendance
if siteSpecific
{
- generator.addNewSectionTitle("\(unit.uppercased()) STAFF CADET ATTENDANCE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("\(unit.uppercased()) STAFF CADET ATTENDANCE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
}
else
{
- generator.addNewSectionTitle("STAFF CADET ATTENDANCE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("STAFF CADET ATTENDANCE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
}
- generator.startTable([ReportColumn(title : "Name"),
- ReportColumn(title : "Squadron"),
- ReportColumn(title : "Site"),
- ReportColumn(title : "Days Worked")],
+ generator.startTable([[ReportColumn(title : "Name"),
+ ReportColumn(title : "Squadron"),
+ ReportColumn(title : "Site"),
+ ReportColumn(title : "Days Worked")]],
withAlternatingRowColor : true,
withInformationText : "Cadets signed in less than 2 days are not shown in this report.")
@@ -2324,21 +2325,21 @@ final class ReportGenerator
if siteSpecific
{
- generator.addNewSectionTitle("\(unit.uppercased()) STAFF UPGRADES \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("\(unit.uppercased()) STAFF UPGRADES \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
}
else
{
- generator.addNewSectionTitle("STAFF UPGRADES \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("STAFF UPGRADES \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
}
- generator.startTable([ReportColumn(title : "Upgrade"),
- ReportColumn(title : "Name"),
- ReportColumn(title : "Type of Participant"),
- ReportColumn(title : "Site")], withAlternatingRowColor: true)
+ generator.startTable([[ReportColumn(title : "Upgrade"),
+ ReportColumn(title : "Name"),
+ ReportColumn(title : "Type of Participant"),
+ ReportColumn(title : "Site")]], withAlternatingRowColor: true)
let upgradeFetchRequest = Pilot.request
- var upgradeFetchRequestPredicate = NSPredicate(format: "dateOfFrontSeatFamilPilot > %@ AND dateOfFrontSeatFamilPilot < %@ AND highestGliderQual >2 ", argumentArray: [startDate, endDate])
+ var upgradeFetchRequestPredicate = NSPredicate(format: "dateOfFrontSeatFamilPilot > %@ AND dateOfFrontSeatFamilPilot < %@ AND highestGliderQual >2 ", argumentArray: [beginningOfReport, endDate])
if siteSpecific
{
compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [upgradeFetchRequestPredicate, sitePredicate])
@@ -2372,46 +2373,46 @@ final class ReportGenerator
let FSFupgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfRearSeatFamilPilot > %@ AND dateOfRearSeatFamilPilot < %@ AND highestGliderQual >3", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfRearSeatFamilPilot > %@ AND dateOfRearSeatFamilPilot < %@ AND highestGliderQual >3", argumentArray: [beginningOfReport, endDate])
let RSFupgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderInstructorPilot > %@ AND dateOfGliderInstructorPilot < %@ AND highestGliderQual >4", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderInstructorPilot > %@ AND dateOfGliderInstructorPilot < %@ AND highestGliderQual >4", argumentArray: [beginningOfReport, endDate])
let instructorUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderCheckPilot > %@ AND dateOfGliderCheckPilot < %@ AND highestGliderQual >5", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderCheckPilot > %@ AND dateOfGliderCheckPilot < %@ AND highestGliderQual >5", argumentArray: [beginningOfReport, endDate])
let gliderCheckPilotUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderStandardsPilot > %@ AND dateOfGliderStandardsPilot < %@ AND highestGliderQual >6", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderStandardsPilot > %@ AND dateOfGliderStandardsPilot < %@ AND highestGliderQual >6", argumentArray: [beginningOfReport, endDate])
let gliderStandardsPilotUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderPilotXCountry > %@ AND dateOfGliderPilotXCountry < %@", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfGliderPilotXCountry > %@ AND dateOfGliderPilotXCountry < %@", argumentArray: [beginningOfReport, endDate])
let gliderXCountryUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("Glider Xcountry")})
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchLaunchPilot > %@ AND dateOfWinchLaunchPilot < %@",argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchLaunchPilot > %@ AND dateOfWinchLaunchPilot < %@",argumentArray: [beginningOfReport, endDate])
let winchPilotUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("Winch Launch")})
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchLaunchOperator > %@ AND dateOfWinchLaunchOperator < %@", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchLaunchOperator > %@ AND dateOfWinchLaunchOperator < %@", argumentArray: [beginningOfReport, endDate])
let winchOperatorUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("Winch Operator")})
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchLaunchInstructor > %@ AND dateOfWinchLaunchInstructor < %@", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchLaunchInstructor > %@ AND dateOfWinchLaunchInstructor < %@", argumentArray: [beginningOfReport, endDate])
let winchInstructorUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("Winch Launch Instructor")})
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchRetrieveDriver > %@ AND dateOfWinchRetrieveDriver < %@", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfWinchRetrieveDriver > %@ AND dateOfWinchRetrieveDriver < %@", argumentArray: [beginningOfReport, endDate])
let winchRetrieveUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("Winch Retrieve Driver")})
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowPilot > %@ AND dateOfTowPilot < %@ AND highestScoutQual >0", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowPilot > %@ AND dateOfTowPilot < %@ AND highestScoutQual >0", argumentArray: [beginningOfReport, endDate])
let towPilotUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowCheckPilot > %@ AND dateOfTowCheckPilot < %@ AND highestScoutQual >1", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowCheckPilot > %@ AND dateOfTowCheckPilot < %@ AND highestScoutQual >1", argumentArray: [beginningOfReport, endDate])
let towCheckPilotUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowStandardsPilot > %@ AND dateOfTowStandardsPilot < %@ AND highestScoutQual >2", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowStandardsPilot > %@ AND dateOfTowStandardsPilot < %@ AND highestScoutQual >2", argumentArray: [beginningOfReport, endDate])
let towStandardsPilotUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate)
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowPilotXCountry > %@ AND dateOfTowPilotXCountry < %@", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfTowPilotXCountry > %@ AND dateOfTowPilotXCountry < %@", argumentArray: [beginningOfReport, endDate])
let towXcountryUpgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("Tow Xcountry")})
- upgradeFetchRequestPredicate = NSPredicate(format: "dateOfLaunchControlOfficer > %@ AND dateOfLaunchControlOfficer < %@", argumentArray: [startDate, endDate])
+ upgradeFetchRequestPredicate = NSPredicate(format: "dateOfLaunchControlOfficer > %@ AND dateOfLaunchControlOfficer < %@", argumentArray: [beginningOfReport, endDate])
let LCOupgrades = executeupgradeFetchRequest(newPredicate: upgradeFetchRequestPredicate).filter({$0.pilotHoldsQual("LCO")})
func addCellForUpgrade(_ name: String, upgradedPilots: [Pilot])
@@ -2681,38 +2682,38 @@ final class ReportGenerator
switch vehicle.type
{
case .glider:
- gliders.append(GliderData(glider: vehicle, startDate: startDate, endDate: endDate))
+ gliders.append(GliderData(glider: vehicle, startDate: beginningOfReport, endDate: endDate))
case .towplane:
- towplanes.append(TowplaneData(towplane: vehicle, startDate: startDate, endDate: endDate))
+ towplanes.append(TowplaneData(towplane: vehicle, startDate: beginningOfReport, endDate: endDate))
case .winch:
- winches.append(WinchData(winch: vehicle, startDate: startDate, endDate: endDate))
+ winches.append(WinchData(winch: vehicle, startDate: beginningOfReport, endDate: endDate))
default:
break
}
}
- generator.addNewSectionTitle("GLIDER USAGE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("GLIDER USAGE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
- generator.startTable([ReportColumn(colSpan : 2, title : ""),
- ReportColumn(colSpan : 5, title : "Glider Flights"),
- ReportColumn(colSpan : 5, title : "Glider Hours"),
- ReportColumn(colSpan : 2, title : "")],
- [ReportColumn(colSpan : 2, title : "Gliders"),
- ReportColumn(title : "Transit"),
- ReportColumn(title : "Famil"),
- ReportColumn(title : "Prof"),
- ReportColumn(title : "Student"),
- ReportColumn(title : "Upgrade"),
- ReportColumn(title : "Transit"),
- ReportColumn(title : "Famil"),
- ReportColumn(title : "Prof"),
- ReportColumn(title : "Student"),
- ReportColumn(title : "Upgrade"),
- ReportColumn(title : "Time Flown"),
- ReportColumn(title : "Current TTSN")], withAlternatingRowColor : true)
+ generator.startTable([[ReportColumn(colSpan : 2, title : ""),
+ ReportColumn(colSpan : 5, title : "Glider Flights"),
+ ReportColumn(colSpan : 5, title : "Glider Hours"),
+ ReportColumn(colSpan : 2, title : "")],
+ [ReportColumn(colSpan : 2, title : "Gliders"),
+ ReportColumn(title : "Transit"),
+ ReportColumn(title : "Famil"),
+ ReportColumn(title : "Prof"),
+ ReportColumn(title : "Student"),
+ ReportColumn(title : "Upgrade"),
+ ReportColumn(title : "Transit"),
+ ReportColumn(title : "Famil"),
+ ReportColumn(title : "Prof"),
+ ReportColumn(title : "Student"),
+ ReportColumn(title : "Upgrade"),
+ ReportColumn(title : "Time Flown"),
+ ReportColumn(title : "Current TTSN")]], withAlternatingRowColor : true)
for glider in gliders
{
@@ -2738,23 +2739,23 @@ final class ReportGenerator
generator.endTable()
- generator.addNewSectionTitle("TOWPLANE USAGE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("TOWPLANE USAGE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
- generator.startTable([ReportColumn(colSpan : 2, title : ""),
- ReportColumn(colSpan : 7, title : "Scout Hours"),
- ReportColumn(title : "Scout Flights"),
- ReportColumn(colSpan : 2, title : "")],
- [ReportColumn(colSpan : 2, title : "Towplanes"),
- ReportColumn(title : "Transit"),
- ReportColumn(title : "Towing"),
- ReportColumn(title : "TPC"),
- ReportColumn(title : "Maintenance"),
- ReportColumn(title : "Prof"),
- ReportColumn(title : "Upgrade"),
- ReportColumn(title : "Fam"),
- ReportColumn(title : "Fam"),
- ReportColumn(title : "Time Flown"),
- ReportColumn(title : "Current TTSN")], withAlternatingRowColor: true)
+ generator.startTable([[ReportColumn(colSpan : 2, title : ""),
+ ReportColumn(colSpan : 7, title : "Scout Hours"),
+ ReportColumn(title : "Scout Flights"),
+ ReportColumn(colSpan : 2, title : "")],
+ [ReportColumn(colSpan : 2, title : "Towplanes"),
+ ReportColumn(title : "Transit"),
+ ReportColumn(title : "Towing"),
+ ReportColumn(title : "TPC"),
+ ReportColumn(title : "Maintenance"),
+ ReportColumn(title : "Prof"),
+ ReportColumn(title : "Upgrade"),
+ ReportColumn(title : "Fam"),
+ ReportColumn(title : "Fam"),
+ ReportColumn(title : "Time Flown"),
+ ReportColumn(title : "Current TTSN")]], withAlternatingRowColor: true)
for towplane in towplanes
{
@@ -2776,12 +2777,12 @@ final class ReportGenerator
}
generator.endTable()
- generator.addNewSectionTitle("WINCH USAGE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
+ generator.addNewSectionTitle("WINCH USAGE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())")
- generator.startTable([ReportColumn(colSpan : 2, title : ""),
- ReportColumn(title : "Current TTSN"),
- ReportColumn(title : "Hours"),
- ReportColumn(title : "Flights")], withAlternatingRowColor: true)
+ generator.startTable([[ReportColumn(colSpan : 2, title : ""),
+ ReportColumn(title : "Current TTSN"),
+ ReportColumn(title : "Hours"),
+ ReportColumn(title : "Flights")]], withAlternatingRowColor: true)
for winch in winches
{
@@ -2855,12 +2856,12 @@ final class ReportGenerator
if siteSpecific
{
- report += "\(unit.uppercased()) STATS REPORT \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
+ report += "\(unit.uppercased()) STATS REPORT \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
}
else
{
- report += "REGIONAL STATS REPORT \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
+ report += "REGIONAL STATS REPORT \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
}
report += "
"
@@ -2985,12 +2986,12 @@ final class ReportGenerator
if siteSpecific
{
- report += "\(unit.uppercased()) NATIONAL REPORT STATS \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
+ report += "\(unit.uppercased()) NATIONAL REPORT STATS \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
}
else
{
- report += "NATIONAL REPORT STATS \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
+ report += "NATIONAL REPORT STATS \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())
"
}
report += "
" report += "
" - report += "GLIDER USAGE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())" + report += "GLIDER USAGE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())" report += "Glider Flights | Glider Hours | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gliders | Transit | Famil | Prof | Student | Upgrade | Transit | Famil | Prof | Student | Upgrade | Time Flown | Current TTSN |
" report += "
" - report += "TOWPLANE USAGE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())" + report += "TOWPLANE USAGE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())" report += "Scout Hours | Scout Flights | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Towplanes | Transit | Towing | TPC | Maintenance | Prof | Upgrade | Fam | Fam | Time Flown | Current TTSN |
" report += "
" - report += "WINCH USAGE \(startDate.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())" + report += "WINCH USAGE \(beginningOfReport.militaryFormatShort.uppercased()) TO \(endDate.militaryFormatShort.uppercased())" report += "Current TTSN | Hours | Flights |
---|