110 lines
3.6 KiB
PHP
110 lines
3.6 KiB
PHP
@extends('layouts.vertical', ['page_title' => 'SBM Goal & Proficiency Tracking'])
|
|
|
|
@section('css')
|
|
<style>
|
|
.table-scroll {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.sticky-col {
|
|
position: sticky;
|
|
left: 0;
|
|
background: #fff;
|
|
z-index: 2;
|
|
}
|
|
|
|
.timeline-table th,
|
|
.timeline-table td {
|
|
white-space: nowrap;
|
|
text-align: left;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.goal-name {
|
|
text-align: left;
|
|
background-color: #e6f0ff;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
@endsection
|
|
|
|
@section('content')
|
|
|
|
@php
|
|
$submissionsArr = $response->data->submissions ?? [];
|
|
|
|
// Flatten array of month-objects into [ 'YYYY-MM' => (object goals=>arrays) ]
|
|
$byMonth = [];
|
|
foreach ($submissionsArr as $item) {
|
|
foreach ((array) $item as $month => $payload) {
|
|
$byMonth[$month] = (object) $payload;
|
|
}
|
|
}
|
|
|
|
// Months sorted ascending (YYYY-MM)
|
|
$months = array_keys($byMonth);
|
|
sort($months, SORT_STRING);
|
|
|
|
// Fixed proficiency order
|
|
$ratings = ['Proficient', 'Competent', 'Intermediate', 'Beginner'];
|
|
|
|
// Helper: safe fetch count for a given goal/month/label
|
|
function goalCount($byMonth, $month, $goalName, $label) {
|
|
if (!isset($byMonth[$month]) || !isset($byMonth[$month]->{$goalName})) return 0;
|
|
$rows = $byMonth[$month]->{$goalName};
|
|
$sum = 0;
|
|
foreach ($rows as $row) {
|
|
if (($row->goal_value ?? null) === $label) {
|
|
$sum += (int) ($row->user_count ?? 0);
|
|
}
|
|
}
|
|
return $sum;
|
|
}
|
|
@endphp
|
|
|
|
<div class="container-fluid">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">{{ $title ?? '' }} Goal & Proficiency Tracking</h5>
|
|
</div>
|
|
<div class="card-body table-scroll">
|
|
<table class="table table-bordered table-striped timeline-table">
|
|
<thead>
|
|
<tr>
|
|
<th rowspan="2" class="text-start">SBM/ME Goals</th>
|
|
@foreach ($months as $month)
|
|
<th colspan="4" class="text-center">
|
|
{{ preg_match('/^\d{4}-\d{2}$/', $month) ? \Carbon\Carbon::createFromFormat('Y-m', $month)->format('M-y') : $month }}
|
|
</th>
|
|
@endforeach
|
|
</tr>
|
|
<tr>
|
|
@foreach ($months as $month)
|
|
@foreach ($ratings as $r)
|
|
<th class="text-end">{{ $r }}</th>
|
|
@endforeach
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($goalsList as $idx => $goalName)
|
|
<tr>
|
|
<td class="text-start">Goal {{ $loop->iteration }}: {{ $goalName }}*</td>
|
|
@foreach ($months as $month)
|
|
@foreach ($ratings as $r)
|
|
<td class="text-end">
|
|
{{ goalCount($byMonth, $month, $goalName, $r) }}
|
|
</td>
|
|
@endforeach
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@endsection
|