Auditionadmin 53 - Card Printing #74
|
|
@ -3,11 +3,49 @@
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Entry;
|
||||||
|
use App\Models\Event;
|
||||||
|
|
||||||
class PrintCards extends Controller
|
class PrintCards extends Controller
|
||||||
{
|
{
|
||||||
public function index() // Display a form to select which cards to print
|
public function index() // Display a form to select which cards to print
|
||||||
{
|
{
|
||||||
return view('admin.printcards.index');
|
$events = Event::with('auditions.flags')->get();
|
||||||
|
$sortOptions = [
|
||||||
|
'name' => 'Student Name',
|
||||||
|
'school' => 'School Name',
|
||||||
|
'audition' => 'Audition',
|
||||||
|
'room' => 'Room',
|
||||||
|
'drawNumber' => 'Draw Number',
|
||||||
|
];
|
||||||
|
|
||||||
|
return view('admin.print_cards.index', compact('events', 'sortOptions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function print()
|
||||||
|
{
|
||||||
|
//dump(request()->all());
|
||||||
|
|
||||||
|
$selectedAuditionIds = array_keys(request()->audition);
|
||||||
|
$cards = Entry::whereIn('audition_id', $selectedAuditionIds)->get();
|
||||||
|
$sorts = [];
|
||||||
|
// Process submitted sort criteria
|
||||||
|
foreach (request()->sort as $sortField) {
|
||||||
|
// continue if nothing to sort by
|
||||||
|
if ($sortField === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// set appropriate sort parameters for later processing
|
||||||
|
$sorts[] = match ($sortField) {
|
||||||
|
'name' => fn (Entry $a, Entry $b) => $a->student->full_name(true) <=> $b->student->full_name(true),
|
||||||
|
'school' => fn (Entry $a, Entry $b) => $a->student->school->name <=> $b->student->school->name,
|
||||||
|
'audition' => fn (Entry $a, Entry $b) => $a->audition->score_order <=> $b->audition->score_order,
|
||||||
|
'room' => fn (Entry $a, Entry $b) => $a->audition->room->name <=> $b->audition->room->name,
|
||||||
|
'drawNumber' => fn (Entry $a, Entry $b) => $a->draw_number <=> $b->draw_number,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$cards = $cards->sortBy($sorts);
|
||||||
|
|
||||||
|
return view('admin.print_cards.print', compact('cards'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<x-layout.app>
|
||||||
|
<x-slot:page_title>Select Cards to Print</x-slot:page_title>
|
||||||
|
<x-form.form method="POST" action="{{route('admin.cards.print')}}">
|
||||||
|
{{--Audition Select--}}
|
||||||
|
@foreach($events as $event)
|
||||||
|
@continue($event->auditions->isEmpty())
|
||||||
|
<x-card.card class="mb-5 mx-auto max-w-3xl" id="event-section-{{$event->id}}" x-data="{ checked{{$event->id}}: false }">
|
||||||
|
<x-card.heading>
|
||||||
|
{{ $event->name }}
|
||||||
|
<x-slot:right_side>
|
||||||
|
<button @click="checked{{$event->id}} = true" class="rounded bg-indigo-50 px-2 py-1 text-xs font-semibold text-indigo-600 shadow-sm hover:bg-indigo-100 mr-3" type="button">Check All</button>
|
||||||
|
<button @click="checked{{$event->id}} = false" class="rounded bg-indigo-50 px-2 py-1 text-xs font-semibold text-indigo-600 shadow-sm hover:bg-indigo-100" type="button">Uncheck All</button>
|
||||||
|
</x-slot:right_side>
|
||||||
|
</x-card.heading>
|
||||||
|
<div class="grid gap-y-3 md:grid-cols-2 lg:grid-cols-3 px-5 my-3 pb-3 border-b border-gray-100">
|
||||||
|
@foreach($event->auditions as $audition)
|
||||||
|
<div id="auditiongroup-{{$audition->id}}" class="flex align-middle">
|
||||||
|
<x-form.checkbox id="auditionCheckbox-{{$audition->id}}" name="audition[{{$audition->id}}]" x-bind:checked="checked{{$event->id}}"/>
|
||||||
|
{{$audition->name}} {{ $audition->hasFlag('drawn') ? '':'(*)' }}
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
<div class="ml-5 mb-3">
|
||||||
|
(*): Draw has not been run for this audition
|
||||||
|
</div>
|
||||||
|
</x-card.card>
|
||||||
|
|
||||||
|
{{--Sort Options--}}
|
||||||
|
<x-card.card class="mx-auto max-w-3xl">
|
||||||
|
<x-card.heading>Card Sorting</x-card.heading>
|
||||||
|
<div class="px-5 pb-5 pt-1">
|
||||||
|
<x-form.select name="sort[1]">
|
||||||
|
<x-slot:label>Primary Sort: </x-slot:label>
|
||||||
|
<option value="">Choose Sort Criteria</option>
|
||||||
|
@foreach($sortOptions as $value => $label)
|
||||||
|
<option value="{{$value}}">{{ $label }}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-form.select>
|
||||||
|
<x-form.select name="sort[2]">
|
||||||
|
<x-slot:label>Secondary Slot: </x-slot:label>
|
||||||
|
<option value="">Choose Sort Criteria</option>
|
||||||
|
@foreach($sortOptions as $value => $label)
|
||||||
|
<option value="{{$value}}">{{ $label }}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-form.select>
|
||||||
|
<x-form.select name="sort[3]">
|
||||||
|
<x-slot:label>Tertiary Slot: </x-slot:label>
|
||||||
|
<option value="">Choose Sort Criteria</option>
|
||||||
|
@foreach($sortOptions as $value => $label)
|
||||||
|
<option value="{{$value}}">{{ $label }}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-form.select>
|
||||||
|
</div>
|
||||||
|
</x-card.card>
|
||||||
|
<x-form.button class="mt-5 mx-auto max-w-3xl" type="submit">Print Cards</x-form.button>
|
||||||
|
@endforeach
|
||||||
|
</x-form.form>
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
@php
|
||||||
|
dump($cards);
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<x-layout.app>
|
||||||
|
<x-table.table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<x-table.th>Room</x-table.th>
|
||||||
|
<x-table.th>Audition</x-table.th>
|
||||||
|
<x-table.th>Draw Number</x-table.th>
|
||||||
|
<x-table.th>Student</x-table.th>
|
||||||
|
<x-table.th>School</x-table.th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<x-table.body>
|
||||||
|
@foreach($cards as $card)
|
||||||
|
<tr>
|
||||||
|
<td>{{$card->audition->room->name}}</td>
|
||||||
|
<td>{{ $card->audition->name }}</td>
|
||||||
|
<td>{{ $card->draw_number }}</td>
|
||||||
|
<td>{{ $card->student->full_name(true) }}</td>
|
||||||
|
<td>{{ $card->student->school->name }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</x-table.body>
|
||||||
|
</x-table.table>
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
<x-layout.app>
|
|
||||||
<x-slot:page_title>Select Cards to Print</x-slot:page_title>
|
|
||||||
</x-layout.app>
|
|
||||||
|
|
@ -168,5 +168,6 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
// Admin Card Routes
|
// Admin Card Routes
|
||||||
Route::prefix('cards')->controller(PrintCards::class)->group(function () {
|
Route::prefix('cards')->controller(PrintCards::class)->group(function () {
|
||||||
Route::get('/', 'index')->name('admin.cards.index');
|
Route::get('/', 'index')->name('admin.cards.index');
|
||||||
|
Route::post('/print', 'print')->name('admin.cards.print');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue