diff --git a/app/Http/Controllers/ControllerDash.php b/app/Http/Controllers/ControllerDash.php index fa5f9d46f..57126f0e3 100644 --- a/app/Http/Controllers/ControllerDash.php +++ b/app/Http/Controllers/ControllerDash.php @@ -85,6 +85,29 @@ public function dash() { $flights = Overflight::where('dep', '!=', '')->where('arr', '!=', '')->take(15)->get(); + $training_metrics = $top_trainers = []; + $training_stats = TrainingDash::generateTrainingStats($now->format('y'), $now->format('n'), 'stats'); + $training_metrics[] = (object)['title' => 'Total', 'metric' => $training_stats['sessionsCompletePerMonth']]; + $training_metrics[] = (object)['title' => 'S1', 'metric' => $training_stats['sessionsByType']['S1']]; + $training_metrics[] = (object)['title' => 'S2', 'metric' => $training_stats['sessionsByType']['S2']]; + $training_metrics[] = (object)['title' => 'S3', 'metric' => $training_stats['sessionsByType']['S3']]; + $training_metrics[] = (object)['title' => 'C1', 'metric' => $training_stats['sessionsByType']['C1']]; + $trainer_by_total = $trainer_by_cid = []; + foreach($training_stats['trainerSessions'] as $t) { + $trainer_by_total[] = [$t['cid']] = $t['total']; + $trainer_by_cid[] = [$t['cid']] = $t['name']; + } + rsort($trainer_by_total); + foreach($trainer_by_total as $tt) { + if($tt == 0) { + break; + } + $top_trainers[] = (object)['name' => $trainer_by_cid[key($trainer_by_total)], 'sessions_given' => $tt]; + if(count($top_trainers) == 3) { + break; + } + } + return view('dashboard.dashboard')->with('calendar', $calendar)->with('news', $news)->with('announcement', $announcement) ->with('winner', $winner_bronze)->with('pwinner', $prev_winner_bronze)->with('month_words', $last_month->format('F'))->with('pmonth_words', $prev_month->format('F')) ->with('controllers', $controllers) @@ -92,6 +115,7 @@ public function dash() { ->with('pyrite', $pyrite)->with('lyear', $last_year->format('Y')) ->with('winner_local', $winner_local)->with('pwinner_local', $prev_winner_local) ->with('month_challenge_description', $month_challenge_description)->with('pmonth_challenge_description', $pmonth_challenge_description) + ->with('training_metrics', $training_metrics)->with('top_trainers', $top_trainers) ->with('flights', $flights)->with('stats', $stats)->with('home', $home); } diff --git a/app/Http/Controllers/TrainingDash.php b/app/Http/Controllers/TrainingDash.php index 3b2b6dfc0..9a0e7a2fe 100644 --- a/app/Http/Controllers/TrainingDash.php +++ b/app/Http/Controllers/TrainingDash.php @@ -605,7 +605,7 @@ public function statistics(Request $request) { return view('dashboard.training.statistics')->with('stats', $stats); } - private function generateTrainingStats($year, $month, $dataType) { + public static function generateTrainingStats($year, $month, $dataType) { $retArr = []; $retArr['dateSelect'] = ['month' => $month, 'year' => $year]; // Set date range @@ -629,7 +629,7 @@ private function generateTrainingStats($year, $month, $dataType) { $retArr['sessionsCompletePreviousMonth'] = $sessionsPrevious->where('type', 12)->count(); } // Training sessions per month by type - if ($dataType == 'graph') { + if (($dataType == 'graph')||($dataType == 'stats')) { $sessionsS1 = $sessions->where('position', '<', 105)->count(); $sessionsS2 = $sessions->where('position', '>', 105)->where('position', '<', 115)->count(); $sessionsS3 = $sessions->whereIn('position', [115, 116, 117, 118, 119, 123])->count(); @@ -650,6 +650,7 @@ private function generateTrainingStats($year, $month, $dataType) { $mtr = 0; foreach ($trainers as $trainer) { $trainerStats = []; + $trainerStats['cid'] = $trainer->id; $trainerStats['name'] = explode(' ', $trainer->getFullNameAttribute())[1]; $trainerSesh = $sessions->where('trainer_id', $trainer->id); $trainerStats['total'] = $trainerSesh->count(); diff --git a/resources/assets/js/mix/sidebar.js b/resources/assets/js/mix/sidebar.js index b7cb87788..8b69f4fab 100644 --- a/resources/assets/js/mix/sidebar.js +++ b/resources/assets/js/mix/sidebar.js @@ -1,74 +1,30 @@ -var coll = document.getElementsByClassName("collapsible-controllers"); -var i; -var iconc = document.getElementById("caret-controllers"); - +var coll = document.getElementsByClassName("collapsible-sidebar"); for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function () { - iconc.classList.toggle("open"); + this.getElementsByClassName("caret")[0].classList.toggle("open"); this.classList.toggle("active"); - - var content = this.nextElementSibling; - + let content = this.nextElementSibling; if (content.style.maxHeight) { content.style.maxHeight = null; } else { content.style.maxHeight = content.scrollHeight + "px"; } - }); - - for (i = 0; i < coll.length; i++) { - if (coll[i].nextElementSibling.innerHTML.indexOf("active") !== -1) { - coll[i].click(); - } - } -} - -var coll = document.getElementsByClassName("collapsible-train"); -var i; -var icont = document.getElementById("caret-train"); - -for (i = 0; i < coll.length; i++) { - coll[i].addEventListener("click", function () { - icont.classList.toggle("open"); - this.classList.toggle("active"); - - var content = this.nextElementSibling; - - if (content.style.maxHeight) { - content.style.maxHeight = null; - } else { - content.style.maxHeight = content.scrollHeight + "px"; + for (j = 0; j < coll.length; j++) { + let e = coll[j]; + if ( + e.getAttribute("name") !== this.getAttribute("name") && + e.classList.contains("active") + ) { + e.getElementsByClassName("caret")[0].classList.toggle("open"); + e.classList.toggle("active"); + e.nextElementSibling.style.maxHeight = null; + } } }); - - for (i = 0; i < coll.length; i++) { - if (coll[i].nextElementSibling.innerHTML.indexOf("active") !== -1) { - coll[i].click(); - } - } } - -var coll = document.getElementsByClassName("collapsible-admin"); -var i; -var icona = document.getElementById("caret-admin"); - -for (i = 0; i < coll.length; i++) { - coll[i].addEventListener("click", function () { - icona.classList.toggle("open"); - this.classList.toggle("active"); - - var content = this.nextElementSibling; - - if (content.style.maxHeight) { - content.style.maxHeight = null; - } else { - content.style.maxHeight = content.scrollHeight + "px"; - } - }); - - for (i = 0; i < coll.length; i++) { - if (coll[i].nextElementSibling.innerHTML.indexOf("active") !== -1) { - coll[i].click(); - } +for (j = 0; j < coll.length; j++) { + if (coll[j].nextElementSibling.innerHTML.indexOf("active") !== -1) { + coll[j].click(); + break; } } diff --git a/resources/assets/sass/mix/sidebar.scss b/resources/assets/sass/mix/sidebar.scss index f542fe70b..1a7b819b6 100644 --- a/resources/assets/sass/mix/sidebar.scss +++ b/resources/assets/sass/mix/sidebar.scss @@ -1,7 +1,15 @@ -.collapsible { +.sidebar-container { + margin-left: 20px; +} + +[class^="collapsible"] { cursor: pointer; } +.collapsible-sidebar { + margin-left: -20px; +} + .content { text-align: left; overflow: hidden; diff --git a/resources/views/inc/sidebar.blade.php b/resources/views/inc/sidebar.blade.php index 8aeaeac27..8bb2d8147 100644 --- a/resources/views/inc/sidebar.blade.php +++ b/resources/views/inc/sidebar.blade.php @@ -1,9 +1,9 @@