diff --git a/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php b/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php
index 10a48330..16ae2174 100644
--- a/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php
+++ b/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php
@@ -57,8 +57,8 @@ class CreateSubfleetTables extends Migration
Schema::create('subfleet_rank', function(Blueprint $table) {
$table->unsignedInteger('rank_id');
$table->unsignedInteger('subfleet_id');
- $table->unsignedDecimal('acars_pay')->nullable();
- $table->unsignedDecimal('manual_pay')->nullable();
+ $table->string('acars_pay')->nullable();
+ $table->string('manual_pay')->nullable();
$table->primary(['rank_id', 'subfleet_id']);
$table->index(['subfleet_id', 'rank_id']);
diff --git a/app/Http/Controllers/Admin/RankController.php b/app/Http/Controllers/Admin/RankController.php
index 5c2b2442..e89deb92 100644
--- a/app/Http/Controllers/Admin/RankController.php
+++ b/app/Http/Controllers/Admin/RankController.php
@@ -207,6 +207,13 @@ class RankController extends BaseController
$rank->subfleets()->syncWithoutDetaching([$request->subfleet_id]);
}
+ elseif($request->isMethod('put')) {
+ $override = [];
+ $subfleet = $this->subfleetRepo->find($request->input('subfleet_id'));
+ $override[$request->name] = $request->value;
+ $rank->subfleets()->updateExistingPivot($subfleet->id, $override);
+ }
+
// remove aircraft from flight
elseif ($request->isMethod('delete')) {
$rank->subfleets()->detach($request->subfleet_id);
diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php
index bcae7542..43f684f3 100644
--- a/app/Http/Controllers/Admin/SubfleetController.php
+++ b/app/Http/Controllers/Admin/SubfleetController.php
@@ -274,6 +274,13 @@ class SubfleetController extends BaseController
$subfleet->ranks()->syncWithoutDetaching([$request->input('rank_id')]);
}
+ elseif ($request->isMethod('put')) {
+ $override = [];
+ $rank = $this->fareRepo->find($request->input('rank_id'));
+ $override[$request->name] = $request->value;
+ $subfleet->ranks()->updateExistingPivot($rank->id, $override);
+ }
+
// dissassociate fare from teh aircraft
elseif ($request->isMethod('delete')) {
$subfleet->ranks()->detach($request->input('rank_id'));
@@ -305,21 +312,21 @@ class SubfleetController extends BaseController
* update specific fare data
*/
if ($request->isMethod('post')) {
- $fare = $this->fareRepo->findWithoutFail($request->fare_id);
+ $fare = $this->fareRepo->find($request->fare_id);
$this->fareSvc->setForSubfleet($subfleet, $fare);
}
// update the pivot table with overrides for the fares
elseif ($request->isMethod('put')) {
$override = [];
- $fare = $this->fareRepo->findWithoutFail($request->fare_id);
+ $fare = $this->fareRepo->find($request->fare_id);
$override[$request->name] = $request->value;
$this->fareSvc->setForSubfleet($subfleet, $fare, $override);
}
// dissassociate fare from teh aircraft
elseif ($request->isMethod('delete')) {
- $fare = $this->fareRepo->findWithoutFail($request->fare_id);
+ $fare = $this->fareRepo->find($request->fare_id);
$this->fareSvc->delFareFromSubfleet($subfleet, $fare);
}
diff --git a/app/Routes/admin.php b/app/Routes/admin.php
index 08ac6549..775bf06e 100644
--- a/app/Routes/admin.php
+++ b/app/Routes/admin.php
@@ -47,7 +47,7 @@ Route::group([
# subfleet
Route::resource('subfleets', 'SubfleetController');
Route::match(['get', 'post', 'put', 'delete'], 'subfleets/{id}/fares', 'SubfleetController@fares');
- Route::match(['get', 'post', 'delete'], 'subfleets/{id}/ranks', 'SubfleetController@ranks');
+ Route::match(['get', 'post', 'put', 'delete'], 'subfleets/{id}/ranks', 'SubfleetController@ranks');
Route::resource('users', 'UserController');
Route::get('users/{id}/regen_apikey',
diff --git a/resources/views/admin/ranks/edit.blade.php b/resources/views/admin/ranks/edit.blade.php
index 3052cf0b..523d8e36 100644
--- a/resources/views/admin/ranks/edit.blade.php
+++ b/resources/views/admin/ranks/edit.blade.php
@@ -14,7 +14,8 @@
diff --git a/resources/views/admin/ranks/index.blade.php b/resources/views/admin/ranks/index.blade.php
index 5e5ec3a7..92140a5a 100644
--- a/resources/views/admin/ranks/index.blade.php
+++ b/resources/views/admin/ranks/index.blade.php
@@ -15,4 +15,3 @@
@endsection
-@include('admin.ranks.scripts')
diff --git a/resources/views/admin/ranks/scripts.blade.php b/resources/views/admin/ranks/scripts.blade.php
index 1d105ca6..da4543bb 100644
--- a/resources/views/admin/ranks/scripts.blade.php
+++ b/resources/views/admin/ranks/scripts.blade.php
@@ -1,7 +1,26 @@
@section('scripts')
diff --git a/resources/views/admin/ranks/subfleets.blade.php b/resources/views/admin/ranks/subfleets.blade.php
index ebcb1845..9d7513f6 100644
--- a/resources/views/admin/ranks/subfleets.blade.php
+++ b/resources/views/admin/ranks/subfleets.blade.php
@@ -3,15 +3,24 @@
Airline |
Name |
- Type |
+ ACARS Pay |
+ Manual Pay |
Actions |
@foreach($rank->subfleets as $sf)
{!! $sf->airline->name !!} |
- {!! $sf->name !!} |
- {!! $sf->type !!} |
+ {!! $sf->name !!} ({!! $sf->type !!}) |
+
+ {!! $sf->pivot->acars_pay !!}
+ |
+
+
+ {!! $sf->pivot->manual_pay !!}
+ |
{!! Form::open(['url' => '/admin/ranks/'.$rank->id.'/subfleets', 'method' => 'delete', 'class' => 'pjax_form']) !!}
{!! Form::hidden('subfleet_id', $sf->id) !!}
diff --git a/resources/views/admin/subfleets/fares.blade.php b/resources/views/admin/subfleets/fares.blade.php
index 28bfac8b..f5ee0426 100644
--- a/resources/views/admin/subfleets/fares.blade.php
+++ b/resources/views/admin/subfleets/fares.blade.php
@@ -4,17 +4,18 @@
@component('admin.components.info')
Fares assigned to the current subfleet. These can be overridden,
otherwise, the value used is the default, which comes from the fare.
+ The pay can be set as a fixed amount, or a percentage of the default rate
@endcomponent
- name |
- code |
- capacity (default) |
- price (default) |
- cost (default) |
+ Name |
+ Code |
+ Capacity (default) |
+ Price (default) |
+ Cost (default) |
|
diff --git a/resources/views/admin/subfleets/ranks.blade.php b/resources/views/admin/subfleets/ranks.blade.php
index ad6d880f..80282819 100644
--- a/resources/views/admin/subfleets/ranks.blade.php
+++ b/resources/views/admin/subfleets/ranks.blade.php
@@ -2,14 +2,18 @@
- name |
+ Name |
+ Base rate |
+ ACARS pay |
+ Manual pay |
|
@@ -17,6 +21,17 @@
@foreach($subfleet->ranks as $rank)
{!! $rank->name !!} |
+ {!! $rank->base_pay_rate ?: '-' !!} |
+
+ {!! $rank->pivot->acars_pay !!}
+ |
+
+
+ {!! $rank->pivot->manual_pay !!}
+ |
+
{!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/ranks',
'method' => 'delete',
diff --git a/resources/views/admin/subfleets/script.blade.php b/resources/views/admin/subfleets/script.blade.php
index afeac49c..aa2aeb9e 100644
--- a/resources/views/admin/subfleets/script.blade.php
+++ b/resources/views/admin/subfleets/script.blade.php
@@ -4,7 +4,7 @@ function setEditable() {
$('#aircraft_fares a').editable({
type: 'text',
mode: 'inline',
- emptytext: 'default',
+ emptytext: 'inherited',
url: '{!! url('/admin/subfleets/'.$subfleet->id.'/fares') !!}',
title: 'Enter override value',
ajaxOptions: {'type': 'put'},
@@ -16,6 +16,22 @@ function setEditable() {
}
}
});
+
+ $('#subfleet_ranks a').editable({
+ type: 'text',
+ mode: 'inline',
+ emptytext: 'inherited',
+ url: '{!! url('/admin/subfleets/'.$subfleet->id.'/ranks') !!}',
+ title: 'Enter override value',
+ ajaxOptions: {'type': 'put'},
+ params: function (params) {
+ return {
+ rank_id: params.pk,
+ name: params.name,
+ value: params.value
+ }
+ }
+ });
}
$(document).ready(function() {
| |