Add fares and set prices on flights #125

This commit is contained in:
Nabeel Shahzad
2018-01-07 10:38:16 -06:00
parent 7e45291b27
commit 0495ff27cb
15 changed files with 285 additions and 102 deletions

View File

@@ -22,5 +22,11 @@
@include('admin.flights.subfleets')
</div>
</div>
<div class="card border-blue-bottom">
<div class="content">
@include('admin.flights.fares')
</div>
</div>
@endsection
@include('admin.flights.scripts')

View File

@@ -0,0 +1,78 @@
<div id="flight_fares_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
<div class="header">
<h3>fares</h3>
<p class="category">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
Fares assigned to the current flight. These can be overridden,
otherwise, the values used come from the subfleet of the aircraft
that the flight is filed with. Only assign the fares you want to
override.
</p>
</div>
<table id="flight_fares"
class="table table-hover"
role="grid" aria-describedby="aircraft_fares_info">
<thead>
<tr role="row">
<th>name</th>
<th style="text-align: center;">code</th>
<th>capacity</th>
<th>price</th>
<th>cost</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($flight->fares as $atf)
<tr>
<td class="sorting_1">{!! $atf->name !!}</td>
<td style="text-align: center;">{!! $atf->code !!}</td>
<td>
<a href="#" data-pk="{!! $atf->id !!}" data-name="capacity">{!! $atf->pivot->capacity !!}</a>
</td>
<td>
<a href="#" data-pk="{!! $atf->id !!}" data-name="price">{!! $atf->pivot->price !!}</a>
</td>
<td>
<a href="#" data-pk="{!! $atf->id !!}" data-name="cost">{!! $atf->pivot->cost !!}</a>
</td>
<td style="text-align: right; width:3%;">
{!! Form::open(['url' => '/admin/flights/'.$flight->id.'/fares',
'method' => 'delete',
'class' => 'pjax_fares_form'
])
!!}
{!! Form::hidden('fare_id', $atf->id) !!}
{!! Form::button('<i class="fa fa-times"></i>',
['type' => 'submit',
'class' => 'btn btn-sm btn-danger btn-icon']) !!}
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
<hr />
<div class="row">
<div class="col-xs-12">
<div class="text-right">
{!! Form::open(['url' => '/admin/flights/'.$flight->id.'/fares',
'method' => 'post',
'class' => 'pjax_fares_form form-inline'
])
!!}
{!! Form::select('fare_id', $avail_fares, null, [
'placeholder' => 'Select Fare',
'class' => 'ac-fare-dropdown form-control input-lg select2',
])
!!}
{!! Form::button('<i class="glyphicon glyphicon-plus"></i> add',
['type' => 'submit',
'class' => 'btn btn-success btn-s']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>

View File

@@ -24,4 +24,3 @@
</div>
</div>
@endsection
@include('admin.flights.scripts')

View File

@@ -1,35 +1,64 @@
@section('scripts')
<script>
$(document).ready(function () {
$('#flight_fields_wrapper a.inline').editable({
type: 'text',
mode: 'inline',
emptytext: '0',
url: '/admin/flights/{!! $flight->id !!}/fields',
ajaxOptions: {'type': 'put'},
params: function (params) {
return {
field_id: params.pk,
name: params.name,
value: params.value
}
function setEditable() {
$('#flight_fares a').editable({
type: 'text',
mode: 'inline',
emptytext: 'inherited',
url: '{!! url('/admin/flights/'.$flight->id.'/fares') !!}',
title: 'Enter override value',
ajaxOptions: {'type': 'put'},
params: function (params) {
return {
fare_id: params.pk,
name: params.name,
value: params.value
}
});
$(document).on('submit', 'form.pjax_flight_fields', function (event) {
event.preventDefault();
$.pjax.submit(event, '#flight_fields_wrapper', {push: false});
});
$(document).on('submit', 'form.pjax_subfleet_form', function (event) {
event.preventDefault();
$.pjax.submit(event, '#subfleet_flight_wrapper', {push: false});
});
$(document).on('pjax:complete', function () {
$(".select2").select2();
});
}
});
}
$(document).ready(function () {
setEditable();
$('#flight_fields_wrapper a.inline').editable({
type: 'text',
mode: 'inline',
emptytext: '0',
url: '/admin/flights/{!! $flight->id !!}/fields',
ajaxOptions: {'type': 'put'},
params: function (params) {
return {
field_id: params.pk,
name: params.name,
value: params.value
}
}
});
$(document).on('submit', 'form.pjax_flight_fields', function (event) {
event.preventDefault();
$.pjax.submit(event, '#flight_fields_wrapper', {push: false});
});
$(document).on('submit', 'form.pjax_subfleet_form', function (event) {
event.preventDefault();
$.pjax.submit(event, '#subfleet_flight_wrapper', {push: false});
});
$(document).on('submit', 'form.pjax_fares_form', function (event) {
event.preventDefault();
console.log(event);
$.pjax.submit(event, '#flight_fares_wrapper', {push: false});
setEditable();
});
$(document).on('pjax:complete', function () {
$(".select2").select2();
setEditable();
});
});
</script>
@endsection

View File

@@ -10,21 +10,10 @@
{!! Form::close() !!}
</div>
</div>
<div class="card border-blue-bottom">
<div class="header">
<h3>fares</h3>
<p class="category">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
Fares assigned to the current subfleet. These can be overridden,
otherwise, the value used is the default, which comes from the fare.
</p>
</div>
<div class="content">
<div class="row">
<div class="col-xs-12">
@include('admin.subfleets.fares')
</div>
</div>
@include('admin.subfleets.fares')
</div>
</div>
@endsection

View File

@@ -1,42 +1,30 @@
{{--<div class="row"> <div class="col-12">--}}
<div id="aircraft_fares_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
<div class="header">
<h3>fares</h3>
<p class="category">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
Fares assigned to the current subfleet. These can be overridden,
otherwise, the value used is the default, which comes from the fare.
</p>
</div>
<br />
<table id="aircraft_fares"
class="table table-bordered table-hover dataTable"
role="grid" aria-describedby="aircraft_fares_info">
<thead>
<tr role="row">
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
rowspan="1" colspan="1"
aria-label="name: activate to sort column ascending">
name
</th>
<th class="sorting_asc" tabindex="0" style="text-align: center;"
aria-controls="aircraft_fares" rowspan="1" colspan="1"
aria-sort="ascending"
aria-label="code: activate to sort column descending">
code
</th>
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
rowspan="1" colspan="1"
aria-label="capacity: activate to sort column ascending">
capacity (default)
</th>
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
rowspan="1" colspan="1"
aria-label="price: activate to sort column ascending">
price (default)
</th>
<th class="sorting" tabindex="0" aria-controls="aircraft_fares"
rowspan="1" colspan="1"
aria-label="cost: activate to sort column ascending">
cost (default)
</th>
<tr>
<th>name</th>
<th>code</th>
<th>capacity (default)</th>
<th>price (default)</th>
<th>cost (default)</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($subfleet->fares as $atf)
<tr role="row" class="@if ($loop->iteration % 2) even @else odd @endif">
<tr>
<td class="sorting_1">{!! $atf->name !!}</td>
<td style="text-align: center;">{!! $atf->code !!}</td>
<td><a href="#" data-pk="{!! $atf->id !!}" data-name="capacity">{!! $atf->pivot->capacity !!}</a>
@@ -65,7 +53,7 @@
<hr />
<div class="row">
<div class="col-xs-12">
<div class="input-group input-group-lg pull-right">
<div class="text-right">
{!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/fares',
'method' => 'post',
'class' => 'rm_fare form-inline'