T-shirt by school for SCOBDA
This commit is contained in:
parent
abc8b0bcb1
commit
fb750aaea1
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\NominationEnsembles;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\NominationEnsemble;
|
use App\Models\NominationEnsemble;
|
||||||
use App\Models\NominationEnsembleEntry;
|
use App\Models\NominationEnsembleEntry;
|
||||||
|
use App\Models\School;
|
||||||
use App\Models\Student;
|
use App\Models\Student;
|
||||||
|
|
||||||
use function redirect;
|
use function redirect;
|
||||||
|
|
@ -13,13 +14,16 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$shirtReportType = request()->get('shirtReportType') || null;
|
$shirtReportType = request()->get('shirtReportType') ?? 'none';
|
||||||
$ensembles = NominationEnsemble::all();
|
$ensembles = NominationEnsemble::all();
|
||||||
$ensemble = null;
|
$ensemble = null;
|
||||||
$shirtCounts = ($shirtReportType == 'full') ? $this->totalShirtCount() : null;
|
$shirtCounts = ($shirtReportType == 'full') ? $this->totalShirtCount() : null;
|
||||||
|
$schoolShirtCounts = ($shirtReportType == 'by_school') ? $this->schoolShirtCount() : null;
|
||||||
|
$shirtSizes = Student::$shirtSizes;
|
||||||
|
$schools = School::all();
|
||||||
|
|
||||||
return view('nomination_ensembles.scobda.admin.seating.index',
|
return view('nomination_ensembles.scobda.admin.seating.index',
|
||||||
compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts'));
|
compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts', 'schoolShirtCounts', 'shirtSizes', 'schools'));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function totalShirtCount()
|
protected function totalShirtCount()
|
||||||
|
|
@ -38,6 +42,26 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
|
||||||
return $shirtCounts;
|
return $shirtCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array an array of school ids, each containing and array where the key is a shirt size and the value is the count
|
||||||
|
*/
|
||||||
|
protected function schoolShirtCount(): array
|
||||||
|
{
|
||||||
|
$acceptedNominationEntries = NominationEnsembleEntry::where('data->accepted', true)
|
||||||
|
->with('student.school')
|
||||||
|
->get();
|
||||||
|
$schoolShirtCounts = [];
|
||||||
|
foreach ($acceptedNominationEntries as $entry) {
|
||||||
|
if (! isset($schoolShirtCounts[$entry->student->school->id])) {
|
||||||
|
$schoolShirtCounts[$entry->student->school->id] = [];
|
||||||
|
}
|
||||||
|
$schoolShirtCounts[$entry->student->school->id][$entry->student->optional_data['shirt_size']] =
|
||||||
|
($schoolShirtCounts[$entry->student->school->id][$entry->student->optional_data['shirt_size']] ?? 0) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $schoolShirtCounts;
|
||||||
|
}
|
||||||
|
|
||||||
public function show(NominationEnsemble $ensemble)
|
public function show(NominationEnsemble $ensemble)
|
||||||
{
|
{
|
||||||
$ensembles = NominationEnsemble::all();
|
$ensembles = NominationEnsemble::all();
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,17 @@
|
||||||
<p class="text-md/6 font-semibold text-gray-800 mb-3 mt-3">Shirts Needed</p>
|
<p class="text-md/6 font-semibold text-gray-800 mb-3 mt-3">Shirts Needed</p>
|
||||||
<ul role="list" class="-mx2 space-y-1">
|
<ul role="list" class="-mx2 space-y-1">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ route('nomination.admin.seating.index', ['shirtReportType'=>'full']) }}" class="group flex gap-x-3 rounded-md p-2 pl-3 text-sm/6 font-semibold text-gray-700 hover:bg-gray-50 hover:text-indigo-600">
|
<a href="{{ route('nomination.admin.seating.index', ['shirtReportType'=>'full']) }}"
|
||||||
|
class="group flex gap-x-3 rounded-md p-2 pl-3 text-sm/6 font-semibold text-gray-700 hover:bg-gray-50 hover:text-indigo-600">
|
||||||
Total Needed
|
Total Needed
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ route('nomination.admin.seating.index', ['shirtReportType'=>'by_school']) }}"
|
||||||
|
class="group flex gap-x-3 rounded-md p-2 pl-3 text-sm/6 font-semibold text-gray-700 hover:bg-gray-50 hover:text-indigo-600">
|
||||||
|
By School
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -31,27 +38,11 @@
|
||||||
@if($ensemble)
|
@if($ensemble)
|
||||||
@include('nomination_ensembles.scobda.admin.seating.seating_card')
|
@include('nomination_ensembles.scobda.admin.seating.seating_card')
|
||||||
@endif
|
@endif
|
||||||
@if($shirtReportType ?? NULL == 'full')
|
@if($shirtReportType == 'full')
|
||||||
<x-card.card>
|
@include('nomination_ensembles.scobda.admin.seating.total_shirt_report')
|
||||||
<x-card.heading>Total Shirt Needs</x-card.heading>
|
@endif
|
||||||
<x-table.table>
|
@if($shirtReportType == 'by_school')
|
||||||
<thead>
|
@include('nomination_ensembles.scobda.admin.seating.school_shirt_report')
|
||||||
<tr>
|
|
||||||
<x-table.th>Shirt Size</x-table.th>
|
|
||||||
<x-table.th>Total Needed</x-table.th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<x-table.body>
|
|
||||||
@foreach($shirtCounts as $size => $count)
|
|
||||||
<tr>
|
|
||||||
<x-table.td>{{ $size }}</x-table.td>
|
|
||||||
<x-table.td>{{ $count }}</x-table.td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</x-table.body>
|
|
||||||
</x-table.table>
|
|
||||||
</x-card.card>
|
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<x-card.card>
|
||||||
|
<x-card.heading>Shirt Needs by School</x-card.heading>
|
||||||
|
<x-table.table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<x-table.th>School</x-table.th>
|
||||||
|
@foreach($shirtSizes as $shortSize => $size)
|
||||||
|
<x-table.th>{{ $shortSize }}</x-table.th>
|
||||||
|
@endforeach
|
||||||
|
<x-table.th>Total</x-table.th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<x-table.body>
|
||||||
|
@foreach($schools as $school)
|
||||||
|
@php($total = 0)
|
||||||
|
<tr>
|
||||||
|
<x-table.td>{{ $school->name }}</x-table.td>
|
||||||
|
@foreach($shirtSizes as $shortSize => $size)
|
||||||
|
<x-table.td>
|
||||||
|
{{ $schoolShirtCounts[$school->id][$shortSize] ?? '-' }}
|
||||||
|
@php($total += $schoolShirtCounts[$school->id][$shortSize] ?? 0)
|
||||||
|
</x-table.td>
|
||||||
|
@endforeach
|
||||||
|
<td>{{ $total }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</x-table.body>
|
||||||
|
</x-table.table>
|
||||||
|
</x-card.card>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<x-card.card>
|
||||||
|
<x-card.heading>Total Shirt Needs</x-card.heading>
|
||||||
|
<x-table.table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<x-table.th>Shirt Size</x-table.th>
|
||||||
|
<x-table.th>Total Needed</x-table.th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<x-table.body>
|
||||||
|
@foreach($shirtCounts as $size => $count)
|
||||||
|
<tr>
|
||||||
|
<x-table.td>{{ $size }}</x-table.td>
|
||||||
|
<x-table.td>{{ $count }}</x-table.td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</x-table.body>
|
||||||
|
</x-table.table>
|
||||||
|
</x-card.card>
|
||||||
Loading…
Reference in New Issue