Account for units when entering fuel amounts #493

This commit is contained in:
Nabeel Shahzad 2020-01-09 07:34:05 -05:00
parent 74052e4542
commit 4844692bd9
2 changed files with 8 additions and 2 deletions

View File

@ -21,6 +21,7 @@ use App\Services\FareService;
use App\Services\GeoService;
use App\Services\PirepService;
use App\Services\UserService;
use App\Support\Units\Fuel;
use App\Support\Units\Time;
use Carbon\Carbon;
use Illuminate\Http\Request;
@ -325,8 +326,13 @@ class PirepController extends Controller
$minutes = (int) $request->input('minutes', 0);
$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
$attrs['submitted_at'] = Carbon::now('UTC');
$pirep->submitted_at = Carbon::now('UTC');
$pirep = $this->pirepSvc->create($pirep);
$this->saveCustomFields($pirep, $request);

View File

@ -218,7 +218,7 @@ flight reports that have been filed. You've been warned!
@endif
</div>
<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)
<p>{{ $pirep->block_fuel }}</p>
@else
@ -234,7 +234,7 @@ flight reports that have been filed. You've been warned!
@endif
</div>
<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)
<p>{{ $pirep->fuel_used }}</p>
@else