Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flight search capability to My Sceneries page
- Loading branch information
Showing
6 changed files
with
349 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
@extends('app') | ||
@section('title', 'My Sceneries') | ||
|
||
@section('content') | ||
<div class="row"> | ||
<div class="col-lg-10"> | ||
<div class="card mb-2"> | ||
<div class="card-header p-1"> | ||
<h5 class="m-1"> | ||
Flights For My Sceneries @if(filled($type)) | {{ ucfirst($type) }} @endif | ||
<i class="fas fa-book-open float-end"></i> | ||
</h5> | ||
</div> | ||
<div class="card-body table-responsive p-0"> | ||
@if($flights->count() > 0) | ||
@include('DBasic::scenery.flights_table') | ||
@else | ||
<span class="m-1">No flights found compatible with your sceneries</span> | ||
@endif | ||
</div> | ||
<div class="card-footer p-0 px-1 text-end small fw-bold"> | ||
@lang('DBasic::common.paginate', ['first' => $flights->firstItem(), 'last' => $flights->lastItem(), 'total' => $flights->total()]) | ||
</div> | ||
</div> | ||
{{ $flights->withQueryString()->links('pagination.default') }} | ||
</div> | ||
<div class="col-lg-2"> | ||
<div class="text-start d-grid mb-2"> | ||
<a href="{{ route('DBasic.scenery') }}" class="btn btn-sm btn-success px-1 py-0 mb-2">My Sceneries</a> | ||
@if(!setting('pilots.only_flights_from_current')) | ||
<a href="{{ route('DBasic.scenery.flights', ['type' => 'departures']) }}" class="btn btn-sm btn-warning px-1 py-0 mb-2">Search Departure Flights</a> | ||
@endif | ||
<a href="{{ route('DBasic.scenery.flights', ['type' => 'arrivals']) }}" class="btn btn-sm btn-warning px-1 py-0 mb-2">Search Arrival Flights</a> | ||
<a href="{{ route('DBasic.scenery.flights', ['type' => 'trips']) }}" class="btn btn-sm btn-warning px-1 py-0 mb-2">Search Round Trip Flights</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
@if(setting('bids.block_aircraft', false)) | ||
<div class="modal fade" id="bidModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="addBidLabel" aria-hidden="true"> | ||
<div class="modal-dialog mx-auto"> | ||
<div class="modal-content"> | ||
<div class="modal-header border-0 p-1"> | ||
<h5 class="modal-title m-0" id="bidModalLabel">Aircraft Selection</h5> | ||
<button type="button" class="btn-close shadow-none" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<select name="bidaircraftdropdown" id="aircraft_select" class="bid_aircraft form-control"></select> | ||
</div> | ||
<div class="modal-footer border-0 p-1"> | ||
<button type="button" id="without_aircraft" class="btn btn-sm btn-danger m-0 mx-1 p-0 px-1" data-bs-dismiss="modal">Don't Book Aircraft</button> | ||
<button type="button" id="with_aircraft" class="btn btn-sm btn-success m-0 mx-1 p-0 px-1" data-bs-dismiss="modal">Book Aircraft</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endif | ||
@endsection | ||
|
||
@include('DBasic::scenery.flights_scripts') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
@section('scripts') | ||
@parent | ||
@if (setting('bids.block_aircraft', false)) | ||
<script> | ||
$(document).ready(function() { | ||
let aircrafts = [{ id: 0, text: 'Loading Aircrafts...'}]; | ||
let sel = $('#aircraft_select'); | ||
$("button.save_flight").click(function(e) { | ||
e.preventDefault(); | ||
const btn = $(this); | ||
const class_name = btn.attr('x-saved-class'); // classname to use is set on the element | ||
const flight_id = btn.attr('x-id'); | ||
$('#aircraft_select').attr('x-saved-class', class_name) | ||
$('#aircraft_select').attr('x-id', flight_id) | ||
if (!btn.hasClass(class_name)) { | ||
// $('#bidModal').modal(); | ||
let bidModal = new bootstrap.Modal(document.getElementById('bidModal')); | ||
bidModal.show(); | ||
$.ajax( | ||
{ | ||
headers: {'X-API-KEY': $('meta[name="api-key"]').attr('content')}, | ||
url: '{{ Config::get('app.url') }}/api/flights/' + flight_id + '/aircraft' | ||
}).then((response) => { | ||
aircrafts = []; | ||
const results = response.map(ac => { | ||
const text = `[${ac.icao}] ${ac.registration} ${ac.registration !== ac.name ? ` ${ac.name}` : ''}`; | ||
aircrafts.push({ id: ac.id, text: text}) | ||
}); | ||
$('#aircraft_select option').remove(); | ||
if (aircrafts.length === 0) $('#with_aircraft').hide() | ||
else $('#with_aircraft').show() | ||
sel.select2({ dropdownParent: $('#bidModal'), data: aircrafts}); | ||
}); | ||
} else { | ||
phpvms.bids.removeBid(flight_id).then(() => { | ||
console.log('successfully removed flight'); | ||
btn.removeClass(class_name); | ||
alert('@lang('flights.bidremoved')'); | ||
location.reload(); | ||
}).catch((error) => { | ||
if (error.response && error.response.data) alert(`Error removing bid: ${error.response.data.details}`) | ||
else alert(`Error removing bid: ${error.message}`) | ||
}); | ||
} | ||
}); | ||
$('#with_aircraft').click(() => { | ||
const ac_id = $('#aircraft_select').val() | ||
const flight_id = $('#aircraft_select').attr('x-id'); | ||
const class_name = $('#aircraft_select').attr('x-saved-class') | ||
phpvms.bids.addBid(flight_id, ac_id).then(() => { | ||
console.log('successfully saved flight'); | ||
$('button.save_flight[x-id="' + flight_id + '"]').addClass(class_name); | ||
alert('@lang('flights.bidadded')'); | ||
location.replace('/flights/bids'); | ||
}).catch((error) => { | ||
if (error.response && error.response.data) alert(`Error adding bid: ${error.response.data.details}`) | ||
else alert(`Error adding bid: ${error.message}`) | ||
}); | ||
}); | ||
$('#without_aircraft').click(async () => { | ||
const flight_id = $('#aircraft_select').attr('x-id'); | ||
const class_name = $('#aircraft_select').attr('x-saved-class') | ||
phpvms.bids.addBid(flight_id).then(() => { | ||
console.log('successfully saved flight'); | ||
$('button.save_flight[x-id="' + flight_id + '"]').addClass(class_name); | ||
alert('@lang('flights.bidadded')'); | ||
location.replace('/flights/bids'); | ||
}).catch((error) => { | ||
if (error.response && error.response.data) alert(`Error adding bid: ${error.response.data.details}`) | ||
else alert(`Error adding bid: ${error.message}`) | ||
}); | ||
}); | ||
}); | ||
</script> | ||
@else | ||
<script> | ||
$(document).ready(function() { | ||
$("button.save_flight").click(function(e) { | ||
e.preventDefault(); | ||
const btn = $(this); | ||
const class_name = btn.attr('x-saved-class'); // classname to use is set on the element | ||
const flight_id = btn.attr('x-id'); | ||
if (!btn.hasClass(class_name)) { | ||
phpvms.bids.addBid(flight_id).then(() => { | ||
console.log('successfully saved flight'); | ||
btn.addClass(class_name); | ||
alert('@lang('flights.bidadded')'); | ||
location.replace('/flights/bids'); | ||
}).catch((error) => { | ||
if (error.response && error.response.data) alert(`Error adding bid: ${error.response.data.details}`) | ||
else alert(`Error adding bid: ${error.message}`) | ||
}); | ||
} else { | ||
phpvms.bids.removeBid(flight_id).then(() => { | ||
console.log('successfully removed flight'); | ||
btn.removeClass(class_name); | ||
alert('@lang('flights.bidremoved')'); | ||
location.reload(); | ||
}).catch((error) => { | ||
if (error.response && error.response.data) alert(`Error removing bid: ${error.response.data.details}`) | ||
else alert(`Error removing bid: ${error.message}`) | ||
}); | ||
} | ||
}); | ||
}); | ||
</script> | ||
@endif | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<table class="table table-sm table-borderless table-striped text-start text-nowrap align-middle mb-0"> | ||
<tr> | ||
<th>@sortablelink('airline_id', 'Airline')</th> | ||
<th>@sortablelink('flight_number', 'Flight No')</th> | ||
<th>@sortablelink('route_code', 'Code')</th> | ||
<th>@sortablelink('route_leg', 'Leg #')</th> | ||
<th>@sortablelink('dpt_airport_id', 'Origin')</th> | ||
<th class="text-center">STD</th> | ||
<th class="text-center">STA</th> | ||
<th>@sortablelink('arr_airport_id', 'Destination')</th> | ||
<th class="text-center">@sortablelink('distance', 'Distance')</th> | ||
<th class="text-center">@sortablelink('flight_time', 'Block Time')</th> | ||
<th class="text-end">Actions</th> | ||
</tr> | ||
@foreach($flights as $flight) | ||
<tr> | ||
<td> | ||
<a href="{{ route('DBasic.airline', [optional($flight->airline)->icao ?? '']) }}"> | ||
{{ optional($flight->airline)->name }} | ||
</a> | ||
</td> | ||
<td> | ||
<a href="{{ route('frontend.flights.show', [$flight->id]) }}"> | ||
{{ optional($flight->airline)->code.' '.$flight->flight_number }} | ||
</a> | ||
</td> | ||
<td>{{ $flight->route_code }}</td> | ||
<td>{{ $flight->route_leg }}</td> | ||
<td> | ||
<img class="img-mh25 me-1" title="{{ strtoupper(optional($flight->dpt_airport)->country) }}" src="{{ public_asset('/image/flags_new/'.strtolower(optional($flight->dpt_airport)->country).'.png') }}" alt=""/> | ||
<a href="{{ route('frontend.airports.show', [$flight->dpt_airport_id]) }}">{{ optional($flight->dpt_airport)->full_name ?? $flight->dpt_airport_id }}</a> | ||
</td> | ||
<td class="text-center">{{ DB_FormatScheduleTime($flight->dpt_time) }}</td> | ||
<td class="text-center">{{ DB_FormatScheduleTime($flight->arr_time) }}</td> | ||
<td> | ||
<img class="img-mh25 me-1" title="{{ strtoupper(optional($flight->arr_airport)->country) }}" src="{{ public_asset('/image/flags_new/'.strtolower(optional($flight->arr_airport)->country).'.png') }}" alt=""/> | ||
<a href="{{ route('frontend.airports.show', [$flight->arr_airport_id]) }}">{{ optional($flight->arr_airport)->full_name ?? $flight->arr_airport_id }}</a> | ||
</td> | ||
<td class="text-center">{{ $flight->distance->local(0).' '.$units['distance'] }}</td> | ||
<td class="text-center">{{ DB_ConvertMinutes($flight->flight_time) }}</td> | ||
<td class="text-end"> | ||
@if(!setting('pilots.only_flights_from_current') || $flight->dpt_airport_id == $user->curr_airport_id) | ||
{{-- Bid --}} | ||
@if(setting('bids.allow_multiple_bids') === true || setting('bids.allow_multiple_bids') === false && count($saved) === 0) | ||
<button class="btn btn-sm m-0 mx-1 p-0 px-1 save_flight {{ isset($saved[$flight->id]) ? 'btn-danger':'btn-success' }}" | ||
x-id="{{ $flight->id }}" | ||
x-saved-class="btn-danger" | ||
type="button" title="Add/Remove Bid"> | ||
<i class="fas fa-map-marker"></i> | ||
</button> | ||
@endif | ||
{{-- Simbrief --}} | ||
@if($simbrief !== false && $flight->simbrief && $flight->simbrief->user_id === $user->id) | ||
<a href="{{ route('frontend.simbrief.briefing', $flight->simbrief->id) }}" class="btn btn-sm m-0 mx-1 p-0 px-1 btn-secondary"> | ||
<i class="fas fa-file-pdf" title="View SimBrief OFP"></i> | ||
</a> | ||
@elseif($simbrief !== false && ($simbrief_bids === false || $simbrief_bids === true && isset($saved[$flight->id]))) | ||
@php | ||
$aircraft_id = isset($saved[$flight->id]) ? App\Models\Bid::find($saved[$flight->id])->aircraft_id : null; | ||
@endphp | ||
<a href="{{ route('frontend.simbrief.generate') }}?flight_id={{ $flight->id }}@if($aircraft_id)&aircraft_id={{ $aircraft_id }} @endif" class="btn btn-sm m-0 mx-1 p-0 px-1 {{ isset($saved[$flight->id]) ? 'btn-success':'btn-primary' }}"> | ||
<i class="fas fa-file-pdf" title="Generate SimBrief OFP"></i> | ||
</a> | ||
@endif | ||
{{-- vmsAcars Load --}} | ||
@if($acars_plugin && isset($saved[$flight->id])) | ||
<a href="vmsacars:bid/{{ $saved[$flight->id] }}" class="btn btn-sm m-0 mx-1 p-0 px-1 btn-warning"> | ||
<i class="fas fa-file-download" title="Load in vmsAcars"></i> | ||
</a> | ||
@elseif($acars_plugin) | ||
<a href="vmsacars:flight/{{ $flight->id }}" class="btn btn-sm m-0 mx-1 p-0 px-1 btn-warning"> | ||
<i class="fas fa-file-download" title="Load in vmsAcars"></i> | ||
</a> | ||
@endif | ||
@if(Theme::getSetting('pireps_manual')) | ||
<a href="{{ route('frontend.pireps.create', ['flight_id' => $flight->id]) }}" class="btn btn-sm btn-info m-0 mx-1 p-0 px-1"> | ||
<i class="fas fa-file-upload" title="New Manual PIREP"></i> | ||
</a> | ||
@endif | ||
@endif | ||
{{-- v7 core Search Page --}} | ||
<a href="{{ route('frontend.flights.search', ['airline_id' => $flight->airline_id, 'flight_number' => $flight->flight_number, 'dep_icao' => $flight->dpt_airport_id, 'arr_icao' => $flight->arr_airport_id]) }}" class="btn btn-sm btn-danger m-0 mx-1 p-0 px-1"> | ||
<i class="fas fa-search" title="v7 Search"></i> | ||
</a> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters