Enhancement to monitor pages.
This commit is contained in:
parent
40363a5964
commit
ee958d350d
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Actions\Tabulation\CheckPrelimResult;
|
use App\Models\Audition;
|
||||||
use App\Models\Entry;
|
use App\Models\Entry;
|
||||||
use App\Models\PrelimDefinition;
|
|
||||||
|
|
||||||
use function compact;
|
use function compact;
|
||||||
|
|
||||||
|
|
@ -15,115 +14,44 @@ class MonitorController extends Controller
|
||||||
if (! auth()->user()->hasFlag('monitor')) {
|
if (! auth()->user()->hasFlag('monitor')) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
$method = 'POST';
|
|
||||||
$formRoute = 'monitor.enterFlag';
|
|
||||||
$title = 'Flag Entry';
|
|
||||||
|
|
||||||
//return view('tabulation.choose_entry', compact('method', 'formRoute', 'title'));
|
$auditions = Audition::orderBy('score_order')->with('flags')->get();
|
||||||
$prelims = PrelimDefinition::with('audition')->get();
|
$audition = null;
|
||||||
$prelimDefinition = null;
|
|
||||||
|
|
||||||
return view('monitor.index', compact('prelims', 'prelimDefinition'));
|
return view('monitor.index', compact('audition', 'auditions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prelimStatus(PrelimDefinition $prelimDefinition)
|
public function auditionStatus(Audition $audition)
|
||||||
{
|
{
|
||||||
if (! auth()->user()->hasFlag('monitor')) {
|
if (! auth()->user()->hasFlag('monitor')) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
$prelims = PrelimDefinition::with('audition')->get();
|
|
||||||
$entries = $prelimDefinition->audition->entries()->with('student.school')->with('PrelimScoreSheets')->get();
|
|
||||||
|
|
||||||
// foreach ($entries as $entry) {
|
if ($audition->hasFlag('seats_published') || $audition->hasFlag('advancement_published')) {
|
||||||
// app(CheckPrelimResult::class)->__invoke($entry);
|
return redirect()->route('monitor.index')->with('error', 'Results for that audition are published');
|
||||||
// }
|
}
|
||||||
return view('monitor.index', compact('prelims', 'prelimDefinition', 'entries'));
|
|
||||||
|
$auditions = Audition::orderBy('score_order')->with('flags')->get();
|
||||||
|
$entries = $audition->entries()->with('flags')->with('student.school')->withCount([
|
||||||
|
'prelimScoreSheets', 'scoreSheets',
|
||||||
|
])->orderBy('draw_number')->get();
|
||||||
|
|
||||||
|
return view('monitor.index', compact('audition', 'auditions', 'entries'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleNoShow(Entry $entry)
|
public function toggleNoShow(Entry $entry)
|
||||||
{
|
{
|
||||||
|
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
|
||||||
|
return redirect()->route('monitor.index')->with('error', 'Results for that audition are published');
|
||||||
|
}
|
||||||
|
|
||||||
if ($entry->hasFlag('no_show')) {
|
if ($entry->hasFlag('no_show')) {
|
||||||
$entry->removeFlag('no_show');
|
$entry->removeFlag('no_show');
|
||||||
|
|
||||||
return;
|
return redirect()->back()->with('success', 'No Show Flag Cleared');
|
||||||
}
|
}
|
||||||
$entry->addFlag('no_show');
|
$entry->addFlag('no_show');
|
||||||
|
|
||||||
return redirect()->back()->with('success', 'No Show Entered');
|
return redirect()->back()->with('success', 'No Show Entered');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function flagForm()
|
|
||||||
{
|
|
||||||
if (! auth()->user()->hasFlag('monitor')) {
|
|
||||||
abort(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
$validData = request()->validate([
|
|
||||||
'entry_id' => ['required', 'integer', 'exists:entries,id'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$entry = Entry::find($validData['entry_id']);
|
|
||||||
|
|
||||||
// If the entries audition is published, bounce out
|
|
||||||
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
|
|
||||||
return redirect()->route('monitor.index')->with('error', 'Cannot set flags while results are published');
|
|
||||||
}
|
|
||||||
|
|
||||||
// If entry has scores, bounce on out
|
|
||||||
if ($entry->scoreSheets()->count() > 0) {
|
|
||||||
return redirect()->route('monitor.index')->with('error', 'That entry has existing scores');
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('monitor_entry_flag_form', compact('entry'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storeFlag(Entry $entry)
|
|
||||||
{
|
|
||||||
if (! auth()->user()->hasFlag('monitor')) {
|
|
||||||
abort(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the entries audition is published, bounce out
|
|
||||||
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
|
|
||||||
return redirect()->route('monitor.index')->with('error', 'Cannot set flags while results are published');
|
|
||||||
}
|
|
||||||
|
|
||||||
// If entry has scores, bounce on out
|
|
||||||
if ($entry->scoreSheets()->count() > 0) {
|
|
||||||
return redirect()->route('monitor.index')->with('error', 'That entry has existing scores');
|
|
||||||
}
|
|
||||||
|
|
||||||
$action = request()->input('action');
|
|
||||||
$result = match ($action) {
|
|
||||||
'failed-prelim' => $this->setFlag($entry, 'failed_prelim'),
|
|
||||||
'no-show' => $this->setFlag($entry, 'no_show'),
|
|
||||||
'clear' => $this->setFlag($entry, 'clear'),
|
|
||||||
default => redirect()->route('monitor.index')->with('error', 'Invalid action requested'),
|
|
||||||
};
|
|
||||||
|
|
||||||
return redirect()->route('monitor.index')->with('success', 'Flag set for entry #'.$entry->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setFlag(Entry $entry, string $flag)
|
|
||||||
{
|
|
||||||
if ($flag === 'no_show') {
|
|
||||||
$entry->removeFlag('failed_prelim');
|
|
||||||
$entry->addFlag('no_show');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ($flag === 'failed_prelim') {
|
|
||||||
$entry->addFlag('failed_prelim');
|
|
||||||
$entry->addFlag('no_show');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ($flag === 'clear') {
|
|
||||||
$entry->removeFlag('failed_prelim');
|
|
||||||
$entry->removeFlag('no_show');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,72 +1,76 @@
|
||||||
<x-layout.app>
|
<x-layout.app>
|
||||||
<x-slot:page_title>Monitor Dashboard</x-slot:page_title>
|
<x-slot:page_title>Monitor Dashboard</x-slot:page_title>
|
||||||
|
<x-card.card class="max-w-lg mx-auto mb-5">
|
||||||
{{-- PRELIM AUDITION STATUS CARD --}}
|
|
||||||
<x-card.card class="max-w-md mx-auto">
|
|
||||||
<x-card.heading>
|
<x-card.heading>
|
||||||
Prelim Auditions
|
Audition Status
|
||||||
<x-slot:right_side>
|
<x-slot:right_side>
|
||||||
<x-form.select name="prelim_id" onchange="if (this.value) window.location.href = this.value">
|
<x-form.select name="audition_id" onchange="if (this.value) window.location.href = this.value">
|
||||||
<option value="" disabled hidden @if(! $prelimDefinition) selected @endif>Choose Prelim...</option>
|
<option value="" disabled hidden @if(! $audition) selected @endif>Choose Audition...</option>
|
||||||
@foreach ($prelims as $prelim)
|
@foreach ($auditions as $menuAudition)
|
||||||
<option @if($prelimDefinition && $prelimDefinition->id === $prelim->id) selected @endif
|
@continue($menuAudition->hasFlag('seats_published') || $menuAudition->hasFlag('advance_published'))
|
||||||
value="{{ route('monitor.prelimStatus', $prelim) }}">{{$prelim->audition->name}}</option>
|
<option @if($audition && $audition->id === $menuAudition->id) selected @endif
|
||||||
|
value="{{ route('monitor.auditionStatus', $menuAudition) }}">{{$menuAudition->name}}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-form.select>
|
</x-form.select>
|
||||||
</x-slot:right_side>
|
</x-slot:right_side>
|
||||||
</x-card.heading>
|
</x-card.heading>
|
||||||
@if($prelimDefinition)
|
@if($audition)
|
||||||
<x-table.table>
|
<x-table.table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<x-table.th>Entry</x-table.th>
|
<x-table.th>Entry</x-table.th>
|
||||||
<x-table.th> </x-table.th>
|
@if($audition->prelimDefinition)
|
||||||
|
<x-table.th>Prelim<br/>Scores</x-table.th>
|
||||||
|
@endif
|
||||||
|
<x-table.th>Finals<br/>Scores</x-table.th>
|
||||||
|
<x-table.th></x-table.th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<x-table.body>
|
||||||
@foreach($entries as $entry)
|
@foreach($entries as $entry)
|
||||||
<tr>
|
<tr>
|
||||||
<x-table.td>
|
<x-table.td>
|
||||||
{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}
|
{{ $audition->name }} {{ $entry->draw_number }}
|
||||||
@if($entry->hasFlag('no_show'))
|
@if($audition->prelimDefinition && ! $entry->hasFlag('no_show'))
|
||||||
<span class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">No-Show</span>
|
@if($entry->hasFlag('failed_prelim'))
|
||||||
@elseif($entry->hasFlag('failed_prelim'))
|
<span
|
||||||
<span class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">Failed</span>
|
class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">Failed</span>
|
||||||
|
@elseif($entry->hasFlag('passed_prelim'))
|
||||||
@elseif($entry->hasFlag('passed_prelim'))
|
<span
|
||||||
<span class="inline-flex items-center rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-700 dark:bg-green-400/10 dark:text-green-400">Passed</span>
|
class="inline-flex items-center rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-700 dark:bg-green-400/10 dark:text-green-400">Passed</span>
|
||||||
|
@else
|
||||||
@else
|
<span
|
||||||
<span class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-800 dark:bg-yellow-400/10 dark:text-yellow-300">
|
class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-800 dark:bg-yellow-400/10 dark:text-yellow-300">Pending</span>
|
||||||
Pending
|
@endif
|
||||||
</span>
|
@elseif($entry->hasFlag('no_show'))
|
||||||
|
<span
|
||||||
|
class="inline-flex items-center rounded-full bg-red-100 px-2 py-1 text-xs font-medium text-red-700 dark:bg-red-400/10 dark:text-red-400">No-Show</span>
|
||||||
|
@endif
|
||||||
|
</x-table.td>
|
||||||
|
@if($audition->prelimDefinition)
|
||||||
|
<x-table.td>
|
||||||
|
{{ $entry->prelim_score_sheets_count }}
|
||||||
|
</x-table.td>
|
||||||
@endif
|
@endif
|
||||||
</x-table.td>
|
<x-table.td>
|
||||||
<x-table.td>
|
{{ $entry->score_sheets_count }}
|
||||||
@if($entry->prelimScoreSheets()->count() < 1 && ! $entry->hasFlag('no_show'))
|
</x-table.td>
|
||||||
<x-modal>
|
|
||||||
<x-slot:button_text>
|
<x-table.td>
|
||||||
<x-form.button href="#">Mark No-Show</x-form.button>
|
@if($entry->prelim_score_sheets_count < 1 && $entry->score_sheets_count < 1 && ! $entry->hasFlag('no_show') && ! $audition->hasFlag('seats_published'))
|
||||||
</x-slot:button_text>
|
@include('monitor.noshow_modal')
|
||||||
<x-slot:title>Mark {{ $prelimDefinition->audition->name }} {{ $entry->draw_number }} as a no-show</x-slot:title>
|
@endif
|
||||||
Confirm that you would like to mark this entry as a no-show<br>
|
|
||||||
{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}<br>
|
@if($entry->hasFlag('no_show') && ! $audition->hasFlag('seats_published'))
|
||||||
Entry ID: {{ $entry->id }}<br>
|
@include('monitor.remove_nowshow_modal')
|
||||||
Name: {{ $entry->student->full_name() }}<br>
|
@endif
|
||||||
School: {{ $entry->student->school->name }}
|
</x-table.td>
|
||||||
<hr class="mt-3">
|
</tr>
|
||||||
<x-form.form method="POST" action="{{ route('monitor.toggleNoShow', $entry) }}">
|
@endforeach
|
||||||
<x-form.button class="mt-3" type="submit">Confirm No-Show<br>{{ $prelimDefinition->audition->name }} {{ $entry->draw_number }}</x-form.button>
|
</x-table.body>
|
||||||
</x-form.form>
|
|
||||||
</x-modal>
|
|
||||||
@endif
|
|
||||||
</x-table.td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</x-table.table>
|
</x-table.table>
|
||||||
@endif
|
@endif
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
|
|
||||||
{{-- FINAL AUDITION STATUS CARD --}}
|
|
||||||
</x-layout.app>
|
</x-layout.app>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<x-modal>
|
||||||
|
<x-slot:button_text>
|
||||||
|
<x-form.button href="#">Mark No-Show</x-form.button>
|
||||||
|
</x-slot:button_text>
|
||||||
|
<x-slot:title>Mark {{ $audition->name }} {{ $entry->draw_number }}
|
||||||
|
as a no-show
|
||||||
|
</x-slot:title>
|
||||||
|
Confirm that you would like to mark this entry as a no-show<br>
|
||||||
|
{{ $audition->name }} {{ $entry->draw_number }}<br>
|
||||||
|
Entry ID: {{ $entry->id }}<br>
|
||||||
|
Name: {{ $entry->student->full_name() }}<br>
|
||||||
|
School: {{ $entry->student->school->name }}
|
||||||
|
<hr class="mt-3">
|
||||||
|
<x-form.form method="POST" action="{{ route('monitor.toggleNoShow', $entry) }}">
|
||||||
|
<x-form.button class="mt-3" type="submit">Confirm
|
||||||
|
No-Show<br>{{ $audition->name }} {{ $entry->draw_number }}
|
||||||
|
</x-form.button>
|
||||||
|
</x-form.form>
|
||||||
|
</x-modal>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<x-modal>
|
||||||
|
<x-slot:button_text>
|
||||||
|
<x-form.button href="#">Undo No-Show</x-form.button>
|
||||||
|
</x-slot:button_text>
|
||||||
|
<x-slot:title>Remove No-Show Flag for {{ $audition->name }} {{ $entry->draw_number }}
|
||||||
|
</x-slot:title>
|
||||||
|
Confirm that you would like to remove the no-show flag for this entry<br>
|
||||||
|
{{ $audition->name }} {{ $entry->draw_number }}<br>
|
||||||
|
Entry ID: {{ $entry->id }}<br>
|
||||||
|
Name: {{ $entry->student->full_name() }}<br>
|
||||||
|
School: {{ $entry->student->school->name }}
|
||||||
|
<hr class="mt-3">
|
||||||
|
<x-form.form method="POST" action="{{ route('monitor.toggleNoShow', $entry) }}">
|
||||||
|
<x-form.button class="mt-3" type="submit">Remove
|
||||||
|
No-Show Flag<br>{{ $audition->name }} {{ $entry->draw_number }}
|
||||||
|
</x-form.button>
|
||||||
|
</x-form.form>
|
||||||
|
</x-modal>
|
||||||
|
|
@ -31,11 +31,8 @@ Route::prefix('filters')->middleware(['auth', 'verified'])->controller(FilterCon
|
||||||
// Monitor Related Routes
|
// Monitor Related Routes
|
||||||
Route::prefix('monitor')->middleware(['auth', 'verified'])->controller(MonitorController::class)->group(function () {
|
Route::prefix('monitor')->middleware(['auth', 'verified'])->controller(MonitorController::class)->group(function () {
|
||||||
Route::get('/', 'index')->name('monitor.index');
|
Route::get('/', 'index')->name('monitor.index');
|
||||||
Route::get('/prelim/{prelimDefinition}', 'prelimStatus')->name('monitor.prelimStatus');
|
Route::get('/audition/{audition}', 'auditionStatus')->name('monitor.auditionStatus');
|
||||||
Route::post('/toggleNoShow/{entry}', 'toggleNoShow')->name('monitor.toggleNoShow');
|
Route::post('/toggleNoShow/{entry}', 'toggleNoShow')->name('monitor.toggleNoShow');
|
||||||
|
|
||||||
Route::post('/enter_flag', 'flagForm')->name('monitor.enterFlag');
|
|
||||||
Route::post('enter_flag/{entry}', 'storeFlag')->name('monitor.storeFlag');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Route::get('/my_school', [SchoolController::class, 'my_school'])->middleware('auth','verified');
|
//Route::get('/my_school', [SchoolController::class, 'my_school'])->middleware('auth','verified');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue