#41 inline editing of fuel prices
This commit is contained in:
@@ -33,9 +33,10 @@ class AirportController extends InfyOmBaseController
|
|||||||
$this->airportRepository->pushCriteria(new RequestCriteria($request));
|
$this->airportRepository->pushCriteria(new RequestCriteria($request));
|
||||||
$airports = $this->airportRepository->all();
|
$airports = $this->airportRepository->all();
|
||||||
|
|
||||||
return view('admin.airports.index')
|
return view('admin.airports.index', [
|
||||||
->with('airports', $airports)
|
'airports' => $airports,
|
||||||
->with('coords', ['lat' => '', 'lon' => '']);
|
'coords' => ['lat' => '', 'lon' => ''],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,27 +51,21 @@ class AirportController extends InfyOmBaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created Airport in storage.
|
* Store a newly created Airport in storage.
|
||||||
*
|
|
||||||
* @param CreateAirportRequest $request
|
* @param CreateAirportRequest $request
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function store(CreateAirportRequest $request)
|
public function store(CreateAirportRequest $request)
|
||||||
{
|
{
|
||||||
$input = $request->all();
|
$input = $request->all();
|
||||||
|
|
||||||
$airport = $this->airportRepository->create($input);
|
$airport = $this->airportRepository->create($input);
|
||||||
|
|
||||||
Flash::success('Airport saved successfully.');
|
Flash::success('Airport saved successfully.');
|
||||||
|
|
||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the specified Airport.
|
* Display the specified Airport.
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
@@ -82,15 +77,14 @@ class AirportController extends InfyOmBaseController
|
|||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('admin.airports.show')
|
return view('admin.airports.show', [
|
||||||
->with('airport', $airport);
|
'airport' => $airport,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified Airport.
|
* Show the form for editing the specified Airport.
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
@@ -99,19 +93,18 @@ class AirportController extends InfyOmBaseController
|
|||||||
|
|
||||||
if (empty($airport)) {
|
if (empty($airport)) {
|
||||||
Flash::error('Airport not found');
|
Flash::error('Airport not found');
|
||||||
|
|
||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('admin.airports.edit')->with('airport', $airport);
|
return view('admin.airports.edit', [
|
||||||
|
'airport' => $airport,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified Airport in storage.
|
* Update the specified Airport in storage.
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param UpdateAirportRequest $request
|
* @param UpdateAirportRequest $request
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function update($id, UpdateAirportRequest $request)
|
public function update($id, UpdateAirportRequest $request)
|
||||||
@@ -120,22 +113,18 @@ class AirportController extends InfyOmBaseController
|
|||||||
|
|
||||||
if (empty($airport)) {
|
if (empty($airport)) {
|
||||||
Flash::error('Airport not found');
|
Flash::error('Airport not found');
|
||||||
|
|
||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$airport = $this->airportRepository->update($request->all(), $id);
|
$airport = $this->airportRepository->update($request->all(), $id);
|
||||||
|
|
||||||
Flash::success('Airport updated successfully.');
|
Flash::success('Airport updated successfully.');
|
||||||
|
|
||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified Airport from storage.
|
* Remove the specified Airport from storage.
|
||||||
*
|
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
@@ -144,14 +133,30 @@ class AirportController extends InfyOmBaseController
|
|||||||
|
|
||||||
if (empty($airport)) {
|
if (empty($airport)) {
|
||||||
Flash::error('Airport not found');
|
Flash::error('Airport not found');
|
||||||
|
|
||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->airportRepository->delete($id);
|
$this->airportRepository->delete($id);
|
||||||
|
|
||||||
Flash::success('Airport deleted successfully.');
|
Flash::success('Airport deleted successfully.');
|
||||||
|
|
||||||
return redirect(route('admin.airports.index'));
|
return redirect(route('admin.airports.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fuel(Request $request)
|
||||||
|
{
|
||||||
|
$id = $request->id;
|
||||||
|
|
||||||
|
$airport = $this->airportRepository->findWithoutFail($id);
|
||||||
|
if (empty($airport)) {
|
||||||
|
Flash::error('Flight not found');
|
||||||
|
return redirect(route('admin.flights.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add aircraft to flight
|
||||||
|
if ($request->isMethod('put')) {
|
||||||
|
$airport->{$request->name} = $request->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$airport->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,15 @@ use Eloquent as Model;
|
|||||||
class Airport extends Model
|
class Airport extends Model
|
||||||
{
|
{
|
||||||
public $table = 'airports';
|
public $table = 'airports';
|
||||||
|
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'icao'
|
'icao',
|
||||||
|
'name',
|
||||||
|
'location',
|
||||||
|
'fuel_100ll_cost',
|
||||||
|
'fuel_jeta_cost',
|
||||||
|
'fuel_mogas_cost',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
'status' => [
|
||||||
|
'INACTIVE' => 0,
|
||||||
|
'ACTIVE' => 1,
|
||||||
|
],
|
||||||
|
|
||||||
'sources' => [
|
'sources' => [
|
||||||
'MANUAL' => 0,
|
'MANUAL' => 0,
|
||||||
'ACARS' => 1,
|
'ACARS' => 1,
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ class CreateAirportsTable extends Migration
|
|||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('location')->nullable();
|
$table->string('location')->nullable();
|
||||||
$table->string('country')->nullable();
|
$table->string('country')->nullable();
|
||||||
$table->double('fuel_100ll_cost', 19, 2)->nullable();
|
$table->double('fuel_100ll_cost', 19, 2)->default(0);
|
||||||
$table->double('fuel_jeta_cost', 19, 2)->nullable();
|
$table->double('fuel_jeta_cost', 19, 2)->default(0);
|
||||||
$table->double('fuel_mogas_cost', 19, 2)->nullable();
|
$table->double('fuel_mogas_cost', 19, 2)->default(0);
|
||||||
$table->float('lat', 7, 4)->default(0.0);
|
$table->float('lat', 7, 4)->default(0.0);
|
||||||
$table->float('lon', 7, 4)->default(0.0);
|
$table->float('lon', 7, 4)->default(0.0);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|||||||
+43
@@ -32,5 +32,48 @@
|
|||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="PHP" type="php">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$APPLICATION_HOME_DIR$/bin" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/chrisbjr/api-guard" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/ellipsesynergie/api-response" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/jeremeamia/SuperClosure" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/league/fractal" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/maatwebsite/excel" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/phenx/php-font-lib" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/phenx/php-svg-lib" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/phpoffice/phpexcel" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/spatie/fractalistic" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/spatie/laravel-fractal" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php56" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/symfony/polyfill-util" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/webpatser/laravel-uuid" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/yajra/laravel-datatables-oracle" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$APPLICATION_HOME_DIR$/bin" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/chrisbjr/api-guard" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/ellipsesynergie/api-response" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/jeremeamia/SuperClosure" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/league/fractal" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/maatwebsite/excel" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/phenx/php-font-lib" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/phenx/php-svg-lib" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/phpoffice/phpexcel" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/spatie/fractalistic" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/spatie/laravel-fractal" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php56" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/symfony/polyfill-util" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/webpatser/laravel-uuid" />
|
||||||
|
<root url="file://$MODULE_DIR$/vendor/yajra/laravel-datatables-oracle" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -20,4 +20,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@include('admin.airports.script')
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#airports-table a.inline').editable({
|
||||||
|
type: 'text',
|
||||||
|
mode: 'inline',
|
||||||
|
emptytext: '0',
|
||||||
|
url: '/admin/airports/fuel',
|
||||||
|
title: 'Enter price per unit of fuel',
|
||||||
|
ajaxOptions: {'type': 'put'},
|
||||||
|
params: function(params) {
|
||||||
|
return {
|
||||||
|
id: params.pk,
|
||||||
|
name: params.name,
|
||||||
|
value: params.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -1,26 +1,40 @@
|
|||||||
<table class="table table-responsive" id="airports-table">
|
<div id="airports_table_wrapper">
|
||||||
<thead>
|
<table class="table table-responsive" id="airports-table">
|
||||||
<th>ICAO</th>
|
<thead>
|
||||||
<th>Name</th>
|
<th>ICAO</th>
|
||||||
<th>Location</th>
|
<th>Name</th>
|
||||||
<th colspan="3">Action</th>
|
<th>Location</th>
|
||||||
</thead>
|
<th style="text-align: center;">100LL</th>
|
||||||
<tbody>
|
<th style="text-align: center;">JetA</th>
|
||||||
@foreach($airports as $airport)
|
<th style="text-align: center;">MOGAS</th>
|
||||||
<tr>
|
<th colspan="3">Action</th>
|
||||||
<td>{!! $airport->icao !!}</td>
|
</thead>
|
||||||
<td>{!! $airport->name !!}</td>
|
<tbody>
|
||||||
<td>{!! $airport->location !!} ({!! $airport->lat !!}x{!! $airport->lon !!})</td>
|
@foreach($airports as $airport)
|
||||||
<td>
|
<tr>
|
||||||
{!! Form::open(['route' => ['admin.airports.destroy', $airport->id], 'method' => 'delete']) !!}
|
<td>{!! $airport->icao !!}</td>
|
||||||
<div class='btn-group'>
|
<td>{!! $airport->name !!}</td>
|
||||||
<a href="{!! route('admin.airports.show', [$airport->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
|
<td>{!! $airport->location !!}</td>
|
||||||
<a href="{!! route('admin.airports.edit', [$airport->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
|
<td style="text-align: center;">
|
||||||
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
|
<a class="inline" href="#" data-pk="{!! $airport->id !!}" data-name="fuel_100ll_cost">{!! $airport->fuel_100ll_cost !!}</a>
|
||||||
</div>
|
</td>
|
||||||
{!! Form::close() !!}
|
<td style="text-align: center;">
|
||||||
</td>
|
<a class="inline" href="#" data-pk="{!! $airport->id !!}" data-name="fuel_jeta_cost">{!! $airport->fuel_jeta_cost !!}</a>
|
||||||
</tr>
|
</td>
|
||||||
@endforeach
|
<td style="text-align: center;">
|
||||||
</tbody>
|
<a class="inline" href="#" data-pk="{!! $airport->id !!}" data-name="fuel_mogas_cost">{!! $airport->fuel_mogas_cost !!}</a>
|
||||||
</table>
|
</td>
|
||||||
|
<td>
|
||||||
|
{!! Form::open(['route' => ['admin.airports.destroy', $airport->id], 'method' => 'delete']) !!}
|
||||||
|
<div class='btn-group'>
|
||||||
|
<a href="{!! route('admin.airports.show', [$airport->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
|
||||||
|
<a href="{!! route('admin.airports.edit', [$airport->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
|
||||||
|
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
|
||||||
|
</div>
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|||||||
+4
-1
@@ -7,8 +7,11 @@ Route::group([
|
|||||||
'namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.',
|
'namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.',
|
||||||
'middleware' => ['role:admin'],
|
'middleware' => ['role:admin'],
|
||||||
], function () {
|
], function () {
|
||||||
Route::resource('airports', 'AirportController');
|
|
||||||
Route::resource('airlines', 'AirlinesController');
|
Route::resource('airlines', 'AirlinesController');
|
||||||
|
|
||||||
|
Route::match(['get', 'put'], 'airports/fuel', 'AirportController@fuel');
|
||||||
|
Route::resource('airports', 'AirportController');
|
||||||
|
|
||||||
Route::resource('aircraftclasses', 'AircraftClassController');
|
Route::resource('aircraftclasses', 'AircraftClassController');
|
||||||
Route::resource('fares', 'FareController');
|
Route::resource('fares', 'FareController');
|
||||||
|
|
||||||
|
|||||||
@@ -55,12 +55,14 @@ airports:
|
|||||||
location: Austin, Texas, USA
|
location: Austin, Texas, USA
|
||||||
lat: 30.1945278
|
lat: 30.1945278
|
||||||
lon: -97.6698889
|
lon: -97.6698889
|
||||||
|
fuel_jeta_cost: 100
|
||||||
- id: 2
|
- id: 2
|
||||||
icao: KJFK
|
icao: KJFK
|
||||||
name: John F Kennedy
|
name: John F Kennedy
|
||||||
location: New York, New York, USA
|
location: New York, New York, USA
|
||||||
lat: 40.6399257
|
lat: 40.6399257
|
||||||
lon: -73.7786950
|
lon: -73.7786950
|
||||||
|
fuel_jeta_cost: 50
|
||||||
|
|
||||||
aircraft:
|
aircraft:
|
||||||
- id: 1
|
- id: 1
|
||||||
@@ -96,10 +98,12 @@ subfleets:
|
|||||||
airline_id: 1
|
airline_id: 1
|
||||||
name: 747-400 Winglets
|
name: 747-400 Winglets
|
||||||
type: 744W
|
type: 744W
|
||||||
|
fuel_type: 1
|
||||||
- id: 2
|
- id: 2
|
||||||
airline_id: 1
|
airline_id: 1
|
||||||
name: 777-200 LR
|
name: 777-200 LR
|
||||||
type: 772-LR
|
type: 772-LR
|
||||||
|
fuel_type: 1
|
||||||
|
|
||||||
# add a few mods to aircraft and fares
|
# add a few mods to aircraft and fares
|
||||||
subfleet_fare:
|
subfleet_fare:
|
||||||
|
|||||||
Reference in New Issue
Block a user