2017-07-06 07:48:32 +08:00
|
|
|
@section('scripts')
|
|
|
|
<script>
|
2018-01-03 00:59:44 +08:00
|
|
|
function phpvms_vacentral_airport_lookup(icao, callback) {
|
|
|
|
$.ajax({
|
|
|
|
url: BASE_URL + '/api/airports/'+ icao + '/lookup',
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'x-api-key': PHPVMS_USER_API_KEY
|
|
|
|
}
|
|
|
|
}).done(function (data, status) {
|
|
|
|
callback(data.data);
|
|
|
|
});
|
|
|
|
}
|
2017-12-08 07:22:15 +08:00
|
|
|
|
2017-07-06 07:48:32 +08:00
|
|
|
$(document).ready(function() {
|
2017-12-08 07:22:15 +08:00
|
|
|
|
2017-07-06 07:48:32 +08:00
|
|
|
$('#airports-table a.inline').editable({
|
|
|
|
type: 'text',
|
|
|
|
mode: 'inline',
|
|
|
|
emptytext: '0',
|
2018-01-04 10:42:10 +08:00
|
|
|
url: '{!! url('/admin/airports/fuel') !!}',
|
2017-07-06 07:48:32 +08:00
|
|
|
title: 'Enter price per unit of fuel',
|
|
|
|
ajaxOptions: {'type': 'put'},
|
|
|
|
params: function(params) {
|
|
|
|
return {
|
|
|
|
id: params.pk,
|
|
|
|
name: params.name,
|
|
|
|
value: params.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-12-08 07:22:15 +08:00
|
|
|
|
|
|
|
$('a.airport_data_lookup').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var icao = $("input#airport_icao").val();
|
|
|
|
if(icao === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
phpvms_vacentral_airport_lookup(icao, function(data) {
|
|
|
|
console.log('lookup data', data);
|
|
|
|
_.forEach(data, function(value, key) {
|
|
|
|
if(key === 'city') {
|
|
|
|
key = 'location';
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#" + key).val(value);
|
|
|
|
|
|
|
|
if(key === 'tz') {
|
|
|
|
$("#tz").trigger('change');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-07-06 07:48:32 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@endsection
|