SimBrief integration enhancements (#1045)
* SimBrief Integration Update * Added SimBrief Type field to subfleets, can be used to assign simbrief airframes to subfleets and fix non existing or wrong types. If not used simbrief form will use aircraft's icao type code * Added Passenger and Baggage weights to settings * Added setting for using PhpVms Pilot/User Ident as simbrief atc callsign * SimBrief form code cleaned up a bit and improved. Now form supports both cargo and passenger fares to be used at the same time. Generated passenger baggage weight will be reduced from aircraft's cargo capacity and remaining amount will be used for random cargo generation. Also multiple cargo fares or any mix is possible now (like only cargo, only passenger, multiple cargo and passenger fares) * StyleFix (SimBrief Controller) * Fix Callsign Setting Check * Code Cleanup Reduced loops and removed if's in loops, getting fares from aircraft instead of flight/subfleets. No need to go through getReconciledFaresForFlight anymore. Aircraft provides all fare info we need. Removed unnecessary html elements, added some comments. * Update Simbrief Controller Fixed setting checks. Removed non used $subfleet and from main form and $aircraft from aircraft selection form blade. Added/fixed comments. * StyleFix for Controller
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Add a SimBrief Type to subfleet
|
||||
*/
|
||||
class AddSbtypeToSubfleets extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('subfleets', function (Blueprint $table) {
|
||||
$table->string('simbrief_type', 20)
|
||||
->nullable()
|
||||
->after('type');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -200,6 +200,41 @@
|
||||
options: ''
|
||||
type: number
|
||||
description: 'Days after how long to remove unused briefs'
|
||||
- key: simbrief.noncharter_pax_weight
|
||||
name: 'SimBrief Passenger Weight for Non-Charter (Scheduled etc) Flights'
|
||||
group: simbrief
|
||||
value: 185
|
||||
options: ''
|
||||
type: number
|
||||
description: 'Passenger weight for Non-Charter flights excluding baggage (lbs)'
|
||||
- key: simbrief.noncharter_baggage_weight
|
||||
name: 'SimBrief Baggage Weight per Pax for Non-Charter (Scheduled etc) Flights'
|
||||
group: simbrief
|
||||
value: 35
|
||||
options: ''
|
||||
type: number
|
||||
description: 'Passenger baggage weight for Non-Charter flights (lbs)'
|
||||
- key: simbrief.charter_pax_weight
|
||||
name: 'SimBrief Passenger Weight for Charter Flights'
|
||||
group: simbrief
|
||||
value: 168
|
||||
options: ''
|
||||
type: number
|
||||
description: 'Passenger weight for Charter flights excluding baggage (lbs)'
|
||||
- key: simbrief.charter_baggage_weight
|
||||
name: 'SimBrief Baggage Weight per Pax for Charter Flights'
|
||||
group: simbrief
|
||||
value: 28
|
||||
options: ''
|
||||
type: number
|
||||
description: 'Passenger baggage weight for Charter flights (lbs)'
|
||||
- key: simbrief.callsign
|
||||
name: 'SimBrief ATC Callsign'
|
||||
group: simbrief
|
||||
value: false
|
||||
options: ''
|
||||
type: boolean
|
||||
description: 'Use pilot ident as SimBrief ATC Callsign'
|
||||
- key: pireps.duplicate_check_time
|
||||
name: 'PIREP duplicate time check'
|
||||
group: pireps
|
||||
|
||||
@@ -50,7 +50,7 @@ class SimBriefController
|
||||
$flight_id = $request->input('flight_id');
|
||||
$aircraft_id = $request->input('aircraft_id');
|
||||
$flight = $this->flightRepo->with(['subfleets'])->find($flight_id);
|
||||
$flight = $this->fareSvc->getReconciledFaresForFlight($flight);
|
||||
// $flight = $this->fareSvc->getReconciledFaresForFlight($flight);
|
||||
|
||||
if (!$flight) {
|
||||
flash()->error('Unknown flight');
|
||||
@@ -63,6 +63,21 @@ class SimBriefController
|
||||
return redirect(route('frontend.flights.index'));
|
||||
}
|
||||
|
||||
// If no subfleets defined for flight get them from user
|
||||
if ($flight->subfleets->count() > 0) {
|
||||
$subfleets = $flight->subfleets;
|
||||
} else {
|
||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||
}
|
||||
|
||||
// No aircraft selected, show selection form
|
||||
if (!$aircraft_id) {
|
||||
return view('flights.simbrief_aircraft', [
|
||||
'flight' => $flight,
|
||||
'subfleets' => $subfleets,
|
||||
]);
|
||||
}
|
||||
|
||||
// Check if a Simbrief profile already exists
|
||||
$simbrief = SimBrief::select('id')->where([
|
||||
'flight_id' => $flight_id,
|
||||
@@ -73,34 +88,20 @@ class SimBriefController
|
||||
return redirect(route('frontend.simbrief.briefing', [$simbrief->id]));
|
||||
}
|
||||
|
||||
// Simbrief Profile doesn't exist; prompt the user to create a new one
|
||||
$aircraft = Aircraft::select('registration', 'name', 'icao', 'iata', 'subfleet_id')
|
||||
->where('id', $aircraft_id)
|
||||
->get();
|
||||
|
||||
if ($flight->subfleets->count() > 0) {
|
||||
$subfleets = $flight->subfleets;
|
||||
} else {
|
||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||
}
|
||||
// SimBrief profile does not exists and everything else is ok
|
||||
// Select aircraft which will be used for calculations and details
|
||||
$aircraft = Aircraft::where('id', $aircraft_id)->first();
|
||||
|
||||
// Get passenger and baggage weights with failsafe defaults
|
||||
if ($flight->flight_type === FlightType::CHARTER_PAX_ONLY) {
|
||||
$pax_weight = 197;
|
||||
$pax_weight = setting('simbrief.charter_pax_weight', 168);
|
||||
$bag_weight = setting('simbrief.charter_baggage_weight', 28);
|
||||
} else {
|
||||
$pax_weight = 208;
|
||||
$pax_weight = setting('simbrief.noncharter_pax_weight', 185);
|
||||
$bag_weight = setting('simbrief.noncharter_baggage_weight', 35);
|
||||
}
|
||||
|
||||
// No aircraft selected, show that form
|
||||
if (!$aircraft_id) {
|
||||
return view('flights.simbrief_aircraft', [
|
||||
'flight' => $flight,
|
||||
'aircraft' => $aircraft,
|
||||
'subfleets' => $subfleets,
|
||||
'pax_weight' => $pax_weight,
|
||||
]);
|
||||
}
|
||||
|
||||
// Get the correct load factors
|
||||
// Get the load factors with failsafe for loadmax if nothing is defined
|
||||
$lfactor = $flight->load_factor ?? setting('flights.default_load_factor');
|
||||
$lfactorv = $flight->load_factor_variance ?? setting('flights.load_factor_variance');
|
||||
|
||||
@@ -110,8 +111,6 @@ class SimBriefController
|
||||
$loadmax = $lfactor + $lfactorv;
|
||||
$loadmax = $loadmax > 100 ? 100 : $loadmax;
|
||||
|
||||
// Failsafe for admins not defining load values for their flights
|
||||
// and also leave the general settings empty, set loadmax to 100
|
||||
if ($loadmax === 0) {
|
||||
$loadmax = 100;
|
||||
}
|
||||
@@ -120,8 +119,8 @@ class SimBriefController
|
||||
return view('flights.simbrief_form', [
|
||||
'flight' => $flight,
|
||||
'aircraft' => $aircraft,
|
||||
'subfleets' => $subfleets,
|
||||
'pax_weight' => $pax_weight,
|
||||
'bag_weight' => $bag_weight,
|
||||
'loadmin' => $loadmin,
|
||||
'loadmax' => $loadmax,
|
||||
]);
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Traits\FilesTrait;
|
||||
/**
|
||||
* @property int id
|
||||
* @property string type
|
||||
* @property string simbrief_type
|
||||
* @property string name
|
||||
* @property int airline_id
|
||||
* @property int hub_id
|
||||
@@ -29,6 +30,7 @@ class Subfleet extends Model
|
||||
'airline_id',
|
||||
'hub_id',
|
||||
'type',
|
||||
'simbrief_type',
|
||||
'name',
|
||||
'fuel_type',
|
||||
'cost_block_hour',
|
||||
|
||||
Reference in New Issue
Block a user