Capturing pilot transfer hours

This commit is contained in:
Kevin 2018-09-05 08:09:33 +08:00
parent ec873f2b82
commit b73182f830
11 changed files with 44 additions and 2 deletions

View File

@ -180,3 +180,10 @@
options: ''
type: boolean
description: 'Restrict flights to the user''s airline'
- key: pilots.allow_transfer_hours
name: 'Allow transfer hours'
group: pilots
value: true
options: ''
type: boolean
description: 'Allow specifying transfer hours on registration page and displayed on profile page'

View File

@ -237,6 +237,9 @@ class UserController extends Controller
$original_user_state = $user->state;
// Convert transferred hours to minutes
$req_data['transfer_time'] = $req_data['transfer_time'] * 60;
$user = $this->userRepo->update($req_data, $id);
if ($original_user_state !== $user->state) {

View File

@ -115,6 +115,11 @@ class RegisterController extends Controller
$opts['curr_airport_id'] = $data['home_airport_id'];
$opts['password'] = Hash::make($data['password']);
// Convert transfer hours into minutes
if (isset($opts['transfer_time'])) {
$opts['transfer_time'] = $opts['transfer_time'] * 60;
}
$user = User::create($opts);
$user = $this->userService->createPilot($user);
@ -142,6 +147,7 @@ class RegisterController extends Controller
'password' => 'required|confirmed',
'timezone' => 'required',
'country' => 'required',
'transfer_time' => 'integer|min:0',
];
if (config('captcha.enabled')) {

View File

@ -57,7 +57,7 @@ class User extends Authenticatable
'last_pirep_id',
'flights',
'flight_time',
'transferred_time',
'transfer_time',
'avatar',
'timezone',
'state',
@ -79,7 +79,7 @@ class User extends Authenticatable
protected $casts = [
'flights' => 'integer',
'flight_time' => 'integer',
'transferred_time' => 'integer',
'transfer_time' => 'integer',
'balance' => 'double',
'state' => 'integer',
'status' => 'integer',

View File

@ -20,4 +20,5 @@ return [
'deniedmessage' => 'Your registration was denied. Please contact an administrator.',
'accountsuspended' => 'Account Suspended',
'suspendedmessage' => 'Your account has been suspended. Please contact an administrator.',
'transferhours' => 'Transfer Hours',
];

View File

@ -14,4 +14,5 @@ return [
'updateprofile' => 'Update Profile',
'editprofile' => 'Edit Profile',
'edityourprofile' => 'Edit Your Profile',
'transferhours' => 'Transferred Hours',
];

View File

@ -20,4 +20,5 @@ return [
'deniedmessage' => 'La tua registrazione è stata rifiutata. Contatta un amministratore per favore.',
'accountsuspended' => 'Account Sospeso',
'suspendedmessage' => 'Il tuo account è stato sospeso. Contatta un amministratore per favore.',
'transferhours' => 'Ore di trasferimento',
];

View File

@ -13,4 +13,5 @@ return [
'updateprofile' => 'Aggiorna Profilo',
'editprofile' => 'Modifica Profilo',
'edityourprofile' => 'Modifica Il Tuo Profilo',
'transferhours' => 'Ore trasferite',
];

View File

@ -30,6 +30,11 @@
{{ Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]) }}
<p class="text-danger">{{ $errors->first('timezone') }}</p>
</div>
<div class="form-group col-sm-4">
{{ Form::label('transfer_time', 'Transferred Hours:') }}
{{ Form::text('transfer_time', \App\Facades\Utils::minutesToHours($user->transfer_time), ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('transfer_time') }}</p>
</div>
</div>
<div class="form-group col-sm-6">
{{ Form::label('home_airport_id', 'Home Airport:') }}

View File

@ -59,6 +59,16 @@
<p class="text-danger">{{ $errors->first('timezone') }}</p>
@endif
@if (setting('pilots.allow_transfer_hours') === true)
<label for="transfer_time" class="control-label">@lang('auth.transferhours')</label>
<div class="input-group form-group-no-border {{ $errors->has('transfer_time') ? 'has-danger' : '' }}">
{{ Form::text('transfer_time', 0, ['class' => 'form-control']) }}
</div>
@if ($errors->has('transfer_time'))
<p class="text-danger">{{ $errors->first('transfer_time') }}</p>
@endif
@endif
<label for="password" class="control-label">@lang('auth.password')</label>
<div class="input-group form-group-no-border {{ $errors->has('password') ? 'has-danger' : '' }}">
{{ Form::password('password', ['class' => 'form-control']) }}

View File

@ -45,6 +45,13 @@
</div>
@endif
@if(setting('pilots.allow_transfer_hours') === true)
<div class="social-description">
<h2>{{ \App\Facades\Utils::minutesToHours($user->transfer_time) }}h</h2>
<p>@lang('profile.transferhours')</p>
</div>
@endif
</div>
</div>
</div>