diff --git a/app/Http/Controllers/Atc/EndorsementController.php b/app/Http/Controllers/Atc/EndorsementController.php index bd7909844f..b9b83deb6b 100644 --- a/app/Http/Controllers/Atc/EndorsementController.php +++ b/app/Http/Controllers/Atc/EndorsementController.php @@ -4,30 +4,43 @@ use App\Http\Controllers\BaseController; use App\Models\Atc\PositionGroup; +use App\Models\NetworkData\Atc; +use App\Models\Roster; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\Redirect; class EndorsementController extends BaseController { + const GATWICK_HOURS_REQUIREMENT = 50; + public function getGatwickGroundIndex() { - return Redirect::route('mship.manage.dashboard') - ->withError("We're making some changes to this page, please check back later."); + if (! $this->account->fully_defined || ! $this->account->qualification_atc->isS1) { + return Redirect::route('mship.manage.dashboard') + ->withError('Only S1 rated controllers are eligible for a Gatwick Ground endorsement.'); + } - // $endorsement = PositionGroup::with('conditions')->where('name', 'Gatwick S1 (DEL/GND)')->first(); - // - // $hours = $endorsement->conditions->map(function ($condition) { - // return $condition->progressForUser($this->account); - // }); - // - // if (! $this->account->fully_defined || ! $this->account->qualificationAtc->isS1) { - // return Redirect::route('mship.manage.dashboard') - // ->withError('Only S1 rated controllers are eligible for a Gatwick Ground endorsement.'); - // } - // - // return $this->viewMake('controllers.endorsements.gatwick_ground') - // ->with('endorsment', $endorsement) - // ->with('conditions', $endorsement->conditions) - // ->with('hours', $hours->all()); + // active on roster + $onRoster = Roster::where('account_id', $this->account->id)->exists(); + + // 50 hours on _GND or _DEL + $minutesOnline = $this->account->networkDataAtc() + ->isUK() + ->where(function (Builder $builder) { + $builder->where('facility_type', Atc::TYPE_GND) + ->orWhere('facility_type', Atc::TYPE_DEL); + }) + ->sum('minutes_online'); + + $totalHours = $minutesOnline / 60; + $hoursMet = $totalHours >= self::GATWICK_HOURS_REQUIREMENT; + + return $this->viewMake('controllers.endorsements.gatwick_ground') + ->with('totalHours', $totalHours) + ->with('progress', ($totalHours / self::GATWICK_HOURS_REQUIREMENT) * 100) + ->with('hoursMet', $hoursMet) + ->with('onRoster', $onRoster) + ->with('conditionsMet', $hoursMet && $onRoster); } public function getAreaIndex() diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index f022b25fe1..5c33aa35fa 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -21,6 +21,7 @@ class BaseController extends \Illuminate\Routing\Controller } use DispatchesJobs, RedirectsUsers, ValidatesRequests; + /** @var Account */ protected $account; protected $pageTitle; diff --git a/resources/views/controllers/endorsements/gatwick_ground.blade.php b/resources/views/controllers/endorsements/gatwick_ground.blade.php index 4f93964e66..8127a78e8e 100644 --- a/resources/views/controllers/endorsements/gatwick_ground.blade.php +++ b/resources/views/controllers/endorsements/gatwick_ground.blade.php @@ -7,120 +7,117 @@
+ Gatwick is one of the busiest airports on the VATSIM network. Before controlling it, we want to + ensure you have the knowledge you need to provide a good service to pilots and get the most from + your controlling session. +
+ In order to control Gatwick Ground as an S1, you will need to first meet + the requirements outlined on this page. +
++ You must be a home member of the UK, be active on the controller roster, be rated as an S1 + and have controlled for 50 hours on UK GMC or GMP positions. +
+ You will be given access to the 'Gatwick ADC | S1 Endorsement' course. This Moodle course covers + Gatwick specific procedures, radiotelephony, and local flight planning restrictions. + There is a quiz at the end of the course with a pass mark of 90% - you must pass this quiz to + proceed. +
++ If you do not pass the quiz on your first attempt, there is a study period of seven days for you to + review the Moodle course and improve your knowledge before you try again. +
++ When you have passed the quiz at the end of the Moodle course, you will be prompted to submit + another ticket to ATC TRAINING. +
+ One of our Gatwick mentors will take you onto the live network, on either EGKK_GND or EGKK_DEL, and + offer you hints and tips as you control You will also have the chance to ask any questions that you have. +
+
+ This is not a test and you will not pass or fail, rather it is an opportunity for you to practically
+ apply the skills and knowledge which you have learned through completing the Moodle course.
+ You will do this until the mentor deems you ready for the Gatwick ground endorsement. Once granted
+ the endorsement, you will be able to control EGKK_GND and EGKK_DEL on the live network without
+ supervision.
+
You are a home member of the UK.
+ @else +You are not a home member of the UK Division. If you wish to hold + a Gatwick endorsement, apply to transfer to the UK + by {!! link_to_route("visiting.landing", "clicking here") !!}.
+ @endif + + @if($onRoster) +You are active on the controller roster.
+ @else +You are not active on the controller roster. If you wish to hold a + Gatwick endorsement you must be active on the roster.
+ @endifYou are not a home member of the UK Division. If you wish to hold a Gatwick endorsement, apply to transfer to the UK by {!! link_to_route("visiting.landing", "clicking here") !!}.
- @endif -