T-shirt totals
This commit is contained in:
parent
3551f28b7a
commit
d582317030
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\NominationEnsembles;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\NominationEnsemble;
|
||||
use App\Models\NominationEnsembleEntry;
|
||||
use App\Models\Student;
|
||||
|
||||
use function redirect;
|
||||
|
||||
|
|
@ -12,10 +13,29 @@ class ScobdaNominationSeatingController extends Controller implements Nomination
|
|||
{
|
||||
public function index()
|
||||
{
|
||||
$shirtReportType = request()->get('shirtReportType') || null;
|
||||
$ensembles = NominationEnsemble::all();
|
||||
$ensemble = null;
|
||||
$shirtCounts = ($shirtReportType == 'full') ? $this->totalShirtCount() : null;
|
||||
|
||||
return view('nomination_ensembles.scobda.admin.seating.index', compact('ensembles', 'ensemble'));
|
||||
return view('nomination_ensembles.scobda.admin.seating.index',
|
||||
compact('ensembles', 'ensemble', 'shirtReportType', 'shirtCounts'));
|
||||
}
|
||||
|
||||
protected function totalShirtCount()
|
||||
{
|
||||
$acceptedNominationEntries = NominationEnsembleEntry::where('data->accepted', true)->with('student')->get();
|
||||
$possibleSizes = Student::$shirtSizes;
|
||||
$shirtCounts = ['none' => 0];
|
||||
foreach ($possibleSizes as $shortSize => $size) {
|
||||
$shirtCounts[$shortSize] = 0;
|
||||
}
|
||||
foreach ($acceptedNominationEntries as $entry) {
|
||||
$shirtSize = $entry->student->optional_data['shirt_size'] ?? 'none';
|
||||
$shirtCounts[$shirtSize] += 1;
|
||||
}
|
||||
|
||||
return $shirtCounts;
|
||||
}
|
||||
|
||||
public function show(NominationEnsemble $ensemble)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,11 @@ class ScobdaNominationEnsembleAndEntrySeeder extends Seeder
|
|||
$faker = Faker::create();
|
||||
$schools = School::all();
|
||||
foreach ($schools as $school) {
|
||||
$students = Student::factory()->count(10)->create(['school_id' => $school->id, 'grade' => 5]);
|
||||
$students = Student::factory()->count(10)->create([
|
||||
'school_id' => $school->id,
|
||||
'grade' => 5,
|
||||
'optional_data' => ['shirt_size' => $faker->randomElement(['S', 'M', 'L', 'XL', '2XL'])],
|
||||
]);
|
||||
$n = 1;
|
||||
foreach ($students as $student) {
|
||||
$nomData = [
|
||||
|
|
|
|||
|
|
@ -14,53 +14,42 @@
|
|||
</a>
|
||||
@endforeach
|
||||
</ul>
|
||||
<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">
|
||||
<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
|
||||
</a>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div id="seating-pane" class="col-span-4">
|
||||
@if($ensemble)
|
||||
<x-card.card>
|
||||
<x-card.heading>
|
||||
{{ $ensemble->name }}
|
||||
<x-slot:right_side class="flex">
|
||||
@if($ensemble->data['seated'] ?? false)
|
||||
<x-form.form method="POST"
|
||||
action="{{ route('nomination.admin.seating.seat',[$ensemble]) }}">
|
||||
<input type="hidden" name="action" value="clear">
|
||||
<x-form.button>Clear Seats</x-form.button>
|
||||
</x-form.form>
|
||||
@else
|
||||
<x-form.form method="POST"
|
||||
action="{{ route('nomination.admin.seating.seat',[$ensemble]) }}">
|
||||
<input type="hidden" name="action" value="seat">
|
||||
<x-form.button>Seat Ensemble</x-form.button>
|
||||
</x-form.form>
|
||||
@include('nomination_ensembles.scobda.admin.seating.seating_card')
|
||||
@endif
|
||||
</x-slot:right_side>
|
||||
</x-card.heading>
|
||||
|
||||
@if($shirtReportType ?? NULL == 'full')
|
||||
<x-card.card>
|
||||
<x-card.heading>Total Shirt Needs</x-card.heading>
|
||||
<x-table.table>
|
||||
@foreach($ensemble->data['instruments'] as $instrument)
|
||||
@php($seatOn = 1)
|
||||
@continue(! $acceptedNominations->has($instrument))
|
||||
<tr class="border-t-2 border b-2">
|
||||
<x-table.th>{{ $instrument }}</x-table.th>
|
||||
<x-table.th>Student Name</x-table.th>
|
||||
<x-table.th>School (Nom Rank)</x-table.th>
|
||||
</tr>
|
||||
@foreach($acceptedNominations[$instrument] as $nom)
|
||||
<thead>
|
||||
<tr>
|
||||
<x-table.td>{{ $seatOn }}</x-table.td>
|
||||
<x-table.td>{{ $nom->student->full_name() }}</x-table.td>
|
||||
<x-table.td>{{ $nom->student->school->name }} ({{ $nom->data['rank'] }})
|
||||
</x-table.td>
|
||||
<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>
|
||||
@php($seatOn++)
|
||||
@endforeach
|
||||
@endforeach
|
||||
</x-table.body>
|
||||
</x-table.table>
|
||||
</x-card.card>
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<x-card.card>
|
||||
<x-card.heading>
|
||||
{{ $ensemble->name }}
|
||||
<x-slot:right_side class="flex">
|
||||
@if($ensemble->data['seated'] ?? false)
|
||||
<x-form.form method="POST"
|
||||
action="{{ route('nomination.admin.seating.seat',[$ensemble]) }}">
|
||||
<input type="hidden" name="action" value="clear">
|
||||
<x-form.button>Clear Seats</x-form.button>
|
||||
</x-form.form>
|
||||
@else
|
||||
<x-form.form method="POST"
|
||||
action="{{ route('nomination.admin.seating.seat',[$ensemble]) }}">
|
||||
<input type="hidden" name="action" value="seat">
|
||||
<x-form.button>Seat Ensemble</x-form.button>
|
||||
</x-form.form>
|
||||
@endif
|
||||
</x-slot:right_side>
|
||||
</x-card.heading>
|
||||
|
||||
<x-table.table>
|
||||
@foreach($ensemble->data['instruments'] as $instrument)
|
||||
@php($seatOn = 1)
|
||||
@continue(! $acceptedNominations->has($instrument))
|
||||
<tr class="border-t-2 border b-2">
|
||||
<x-table.th>{{ $instrument }}</x-table.th>
|
||||
<x-table.th>Student Name</x-table.th>
|
||||
<x-table.th>School (Nom Rank)</x-table.th>
|
||||
</tr>
|
||||
@foreach($acceptedNominations[$instrument] as $nom)
|
||||
<tr>
|
||||
<x-table.td>{{ $seatOn }}</x-table.td>
|
||||
<x-table.td>{{ $nom->student->full_name() }}</x-table.td>
|
||||
<x-table.td>{{ $nom->student->school->name }} ({{ $nom->data['rank'] }})
|
||||
</x-table.td>
|
||||
</tr>
|
||||
@php($seatOn++)
|
||||
@endforeach
|
||||
@endforeach
|
||||
</x-table.table>
|
||||
</x-card.card>
|
||||
Loading…
Reference in New Issue