parent
6eb883de73
commit
4125cdd373
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Frontend;
|
|||||||
|
|
||||||
use App\Exceptions\AssetNotFound;
|
use App\Exceptions\AssetNotFound;
|
||||||
use App\Models\Aircraft;
|
use App\Models\Aircraft;
|
||||||
|
use App\Models\Bid;
|
||||||
use App\Models\Enums\AircraftState;
|
use App\Models\Enums\AircraftState;
|
||||||
use App\Models\Enums\AircraftStatus;
|
use App\Models\Enums\AircraftStatus;
|
||||||
use App\Models\Enums\FareType;
|
use App\Models\Enums\FareType;
|
||||||
@ -14,6 +15,7 @@ use App\Models\SimBrief;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\FlightRepository;
|
use App\Repositories\FlightRepository;
|
||||||
use App\Services\FareService;
|
use App\Services\FareService;
|
||||||
|
use App\Services\ModuleService;
|
||||||
use App\Services\SimBriefService;
|
use App\Services\SimBriefService;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -24,17 +26,20 @@ class SimBriefController
|
|||||||
{
|
{
|
||||||
private $fareSvc;
|
private $fareSvc;
|
||||||
private $flightRepo;
|
private $flightRepo;
|
||||||
|
private $moduleSvc;
|
||||||
private $simBriefSvc;
|
private $simBriefSvc;
|
||||||
private $userSvc;
|
private $userSvc;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
FareService $fareSvc,
|
FareService $fareSvc,
|
||||||
FlightRepository $flightRepo,
|
FlightRepository $flightRepo,
|
||||||
|
ModuleService $moduleSvc,
|
||||||
SimBriefService $simBriefSvc,
|
SimBriefService $simBriefSvc,
|
||||||
UserService $userSvc
|
UserService $userSvc
|
||||||
) {
|
) {
|
||||||
$this->fareSvc = $fareSvc;
|
$this->fareSvc = $fareSvc;
|
||||||
$this->flightRepo = $flightRepo;
|
$this->flightRepo = $flightRepo;
|
||||||
|
$this->moduleSvc = $moduleSvc;
|
||||||
$this->simBriefSvc = $simBriefSvc;
|
$this->simBriefSvc = $simBriefSvc;
|
||||||
$this->userSvc = $userSvc;
|
$this->userSvc = $userSvc;
|
||||||
}
|
}
|
||||||
@ -106,6 +111,7 @@ class SimBriefController
|
|||||||
if (setting('simbrief.block_aircraft')) {
|
if (setting('simbrief.block_aircraft')) {
|
||||||
// Build a list of aircraft_id's being used for active sb packs
|
// Build a list of aircraft_id's being used for active sb packs
|
||||||
$sb_aircraft = SimBrief::whereNotNull('flight_id')->pluck('aircraft_id');
|
$sb_aircraft = SimBrief::whereNotNull('flight_id')->pluck('aircraft_id');
|
||||||
|
|
||||||
// Filter aircraft list to non used/blocked ones
|
// Filter aircraft list to non used/blocked ones
|
||||||
$aircrafts = $aircrafts->whereNotIn('id', $sb_aircraft);
|
$aircrafts = $aircrafts->whereNotIn('id', $sb_aircraft);
|
||||||
}
|
}
|
||||||
@ -225,7 +231,7 @@ class SimBriefController
|
|||||||
|
|
||||||
// Show the main simbrief form
|
// Show the main simbrief form
|
||||||
return view('flights.simbrief_form', [
|
return view('flights.simbrief_form', [
|
||||||
'user' => Auth::user(),
|
'user' => $user,
|
||||||
'flight' => $flight,
|
'flight' => $flight,
|
||||||
'aircraft' => $aircraft,
|
'aircraft' => $aircraft,
|
||||||
'pax_weight' => $pax_weight,
|
'pax_weight' => $pax_weight,
|
||||||
@ -253,7 +259,11 @@ class SimBriefController
|
|||||||
*/
|
*/
|
||||||
public function briefing($id)
|
public function briefing($id)
|
||||||
{
|
{
|
||||||
$simbrief = SimBrief::find($id);
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
/** @var SimBrief $simbrief */
|
||||||
|
$simbrief = SimBrief::with(['flight'])->find($id);
|
||||||
if (!$simbrief) {
|
if (!$simbrief) {
|
||||||
flash()->error('SimBrief briefing not found');
|
flash()->error('SimBrief briefing not found');
|
||||||
return redirect(route('frontend.flights.index'));
|
return redirect(route('frontend.flights.index'));
|
||||||
@ -266,11 +276,18 @@ class SimBriefController
|
|||||||
$equipment = substr($str, $wc + 1, $tr - 2);
|
$equipment = substr($str, $wc + 1, $tr - 2);
|
||||||
$transponder = substr($str, $tr + 1);
|
$transponder = substr($str, $tr + 1);
|
||||||
|
|
||||||
|
// See if a bid exists for this flight
|
||||||
|
$bid = Bid::where(['user_id' => $user->id, 'flight_id' => $simbrief->flight_id])->first();
|
||||||
|
|
||||||
return view('flights.simbrief_briefing', [
|
return view('flights.simbrief_briefing', [
|
||||||
'simbrief' => $simbrief,
|
'user' => $user,
|
||||||
'wakecat' => $wakecat,
|
'simbrief' => $simbrief,
|
||||||
'equipment' => $equipment,
|
'wakecat' => $wakecat,
|
||||||
'transponder' => $transponder,
|
'equipment' => $equipment,
|
||||||
|
'transponder' => $transponder,
|
||||||
|
'bid' => $bid,
|
||||||
|
'flight' => $simbrief->flight,
|
||||||
|
'acars_plugin' => $this->moduleSvc->isModuleActive('VMSAcars'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,22 +195,22 @@ class Pirep extends Model
|
|||||||
/**
|
/**
|
||||||
* Create a new PIREP from a SimBrief instance
|
* Create a new PIREP from a SimBrief instance
|
||||||
*
|
*
|
||||||
* @param \App\Models\SimBrief $simBrief
|
* @param \App\Models\SimBrief $simbrief
|
||||||
*
|
*
|
||||||
* @return \App\Models\Pirep
|
* @return \App\Models\Pirep
|
||||||
*/
|
*/
|
||||||
public static function fromSimBrief(SimBrief $simBrief): self
|
public static function fromSimBrief(SimBrief $simbrief): self
|
||||||
{
|
{
|
||||||
return new self([
|
return new self([
|
||||||
'flight_id' => $simBrief->flight->id,
|
'flight_id' => $simbrief->flight->id,
|
||||||
'airline_id' => $simBrief->flight->airline_id,
|
'airline_id' => $simbrief->flight->airline_id,
|
||||||
'flight_number' => $simBrief->flight->flight_number,
|
'flight_number' => $simbrief->flight->flight_number,
|
||||||
'route_code' => $simBrief->flight->route_code,
|
'route_code' => $simbrief->flight->route_code,
|
||||||
'route_leg' => $simBrief->flight->route_leg,
|
'route_leg' => $simbrief->flight->route_leg,
|
||||||
'dpt_airport_id' => $simBrief->flight->dpt_airport_id,
|
'dpt_airport_id' => $simbrief->flight->dpt_airport_id,
|
||||||
'arr_airport_id' => $simBrief->flight->arr_airport_id,
|
'arr_airport_id' => $simbrief->flight->arr_airport_id,
|
||||||
'route' => $simBrief->xml->getRouteString(),
|
'route' => $simbrief->xml->getRouteString(),
|
||||||
'level' => $simBrief->xml->getFlightLevel(),
|
'level' => $simbrief->xml->getFlightLevel(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +92,12 @@ class SimBrief extends Model
|
|||||||
|
|
||||||
public function flight()
|
public function flight()
|
||||||
{
|
{
|
||||||
if (!empty($this->attributes['flight_id'])) {
|
return $this->belongsTo(Flight::class, 'flight_id');
|
||||||
return $this->belongsTo(Flight::class, 'flight_id');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($this->attributes['pirep_id'])) {
|
public function pirep()
|
||||||
return $this->belongsTo(Pirep::class, 'pirep_id');
|
{
|
||||||
}
|
return $this->belongsTo(Pirep::class, 'pirep_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
@ -7,26 +7,39 @@
|
|||||||
<h2>{{ $simbrief->xml->general->icao_airline }}{{ $simbrief->xml->general->flight_number }}
|
<h2>{{ $simbrief->xml->general->icao_airline }}{{ $simbrief->xml->general->flight_number }}
|
||||||
: {{ $simbrief->xml->origin->icao_code }} to {{ $simbrief->xml->destination->icao_code }}</h2>
|
: {{ $simbrief->xml->origin->icao_code }} to {{ $simbrief->xml->destination->icao_code }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col">
|
||||||
@if (empty($simbrief->pirep_id))
|
@if (empty($simbrief->pirep_id))
|
||||||
<a class="btn btn-outline-info pull-right btn-lg"
|
<a class="btn btn-outline-info pull-right btn-lg"
|
||||||
style="margin-top: -10px; margin-bottom: 5px"
|
style="margin-top: -10px; margin-bottom: 5px"
|
||||||
href="{{ url(route('frontend.simbrief.prefile', [$simbrief->id])) }}">Prefile PIREP</a>
|
href="{{ url(route('frontend.simbrief.prefile', [$simbrief->id])) }}">Prefile PIREP</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
@if (!empty($simbrief->xml->params->static_id) && $user === $simbrief->user_id)
|
||||||
@if (!empty($simbrief->xml->params->static_id) && Auth::id() == $simbrief->user_id)
|
<div class="col">
|
||||||
<a class="btn btn-secondary pull-right btn-lg"
|
<a class="btn btn-secondary btn-lg"
|
||||||
style="margin-top: -10px; margin-bottom: 5px"
|
style="margin-top: -10px; margin-bottom: 5px"
|
||||||
href="#"
|
href="#"
|
||||||
data-toggle="modal" data-target="#OFP_Edit">Edit OFP</a>
|
data-toggle="modal" data-target="#OFP_Edit">Edit OFP</a>
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
@endif
|
||||||
<a class="btn btn-primary pull-right btn-lg"
|
<div class="col">
|
||||||
|
<a class="btn btn-primary btn-lg"
|
||||||
style="margin-top: -10px; margin-bottom: 5px"
|
style="margin-top: -10px; margin-bottom: 5px"
|
||||||
href="{{ url(route('frontend.simbrief.generate_new', [$simbrief->id])) }}">Generate New OFP</a>
|
href="{{ url(route('frontend.simbrief.generate_new', [$simbrief->id])) }}">Generate New OFP</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
@if ($acars_plugin)
|
||||||
|
@if ($bid)
|
||||||
|
<a href="vmsacars:bid/{{$bid->id}}"
|
||||||
|
style="margin-top: -10px; margin-bottom: 5px"
|
||||||
|
class="btn btn-info btn-lg">Load in vmsACARS</a>
|
||||||
|
@else
|
||||||
|
<a href="vmsacars:flight/{{$flight->id}}"
|
||||||
|
style="margin-top: -10px; margin-bottom: 5px"
|
||||||
|
class="btn btn-info btn-lg">Load in vmsACARS</a>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -307,7 +320,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer text-right p-1">
|
<div class="modal-footer text-right p-1">
|
||||||
<a
|
<a
|
||||||
class="btn btn-success btn-sm m-1 p-1"
|
class="btn btn-success btn-sm m-1 p-1"
|
||||||
href="{{ route('frontend.simbrief.update_ofp') }}?ofp_id={{ $simbrief->id }}&flight_id={{ $simbrief->flight_id }}&aircraft_id={{ $simbrief->aircraft_id }}&sb_userid={{ $simbrief->xml->params->user_id }}&sb_static_id={{ $simbrief->xml->params->static_id }}">
|
href="{{ route('frontend.simbrief.update_ofp') }}?ofp_id={{ $simbrief->id }}&flight_id={{ $simbrief->flight_id }}&aircraft_id={{ $simbrief->aircraft_id }}&sb_userid={{ $simbrief->xml->params->user_id }}&sb_static_id={{ $simbrief->xml->params->static_id }}">
|
||||||
Download Updated OFP & Close
|
Download Updated OFP & Close
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user