Account for units when entering fuel amounts #493
This commit is contained in:
@@ -21,6 +21,7 @@ use App\Services\FareService;
|
|||||||
use App\Services\GeoService;
|
use App\Services\GeoService;
|
||||||
use App\Services\PirepService;
|
use App\Services\PirepService;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
|
use App\Support\Units\Fuel;
|
||||||
use App\Support\Units\Time;
|
use App\Support\Units\Time;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -325,8 +326,13 @@ class PirepController extends Controller
|
|||||||
$minutes = (int) $request->input('minutes', 0);
|
$minutes = (int) $request->input('minutes', 0);
|
||||||
$pirep->flight_time = Utils::hoursToMinutes($hours) + $minutes;
|
$pirep->flight_time = Utils::hoursToMinutes($hours) + $minutes;
|
||||||
|
|
||||||
|
// Set the correct fuel units
|
||||||
|
$pirep->block_fuel = new Fuel((float) $request->input('block_fuel'), setting('units.fuel'));
|
||||||
|
$pirep->fuel_used = new Fuel((float) $request->input('fuel_used'), setting('units.fuel'));
|
||||||
|
|
||||||
// Put the time that this is currently submitted
|
// Put the time that this is currently submitted
|
||||||
$attrs['submitted_at'] = Carbon::now('UTC');
|
$attrs['submitted_at'] = Carbon::now('UTC');
|
||||||
|
$pirep->submitted_at = Carbon::now('UTC');
|
||||||
|
|
||||||
$pirep = $this->pirepSvc->create($pirep);
|
$pirep = $this->pirepSvc->create($pirep);
|
||||||
$this->saveCustomFields($pirep, $request);
|
$this->saveCustomFields($pirep, $request);
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ flight reports that have been filed. You've been warned!
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
{{ Form::label('block_fuel', __('pireps.block_fuel')) }} ({{config('phpvms.internal_units.fuel')}})
|
{{ Form::label('block_fuel', __('pireps.block_fuel')) }} ({{setting('units.fuel')}})
|
||||||
@if(!empty($pirep) && $pirep->read_only)
|
@if(!empty($pirep) && $pirep->read_only)
|
||||||
<p>{{ $pirep->block_fuel }}</p>
|
<p>{{ $pirep->block_fuel }}</p>
|
||||||
@else
|
@else
|
||||||
@@ -234,7 +234,7 @@ flight reports that have been filed. You've been warned!
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
{{ Form::label('fuel_used', __('pireps.fuel_used')) }} ({{config('phpvms.internal_units.fuel')}})
|
{{ Form::label('fuel_used', __('pireps.fuel_used')) }} ({{setting('units.fuel')}})
|
||||||
@if(!empty($pirep) && $pirep->read_only)
|
@if(!empty($pirep) && $pirep->read_only)
|
||||||
<p>{{ $pirep->fuel_used }}</p>
|
<p>{{ $pirep->fuel_used }}</p>
|
||||||
@else
|
@else
|
||||||
|
|||||||
Reference in New Issue
Block a user