diff --git a/app/Http/Controllers/Tabulation/EntryFlagController.php b/app/Http/Controllers/Tabulation/EntryFlagController.php index 8154120..5a1a8c0 100644 --- a/app/Http/Controllers/Tabulation/EntryFlagController.php +++ b/app/Http/Controllers/Tabulation/EntryFlagController.php @@ -4,12 +4,8 @@ namespace App\Http\Controllers\Tabulation; use App\Exceptions\AuditionAdminException; use App\Http\Controllers\Controller; -use App\Models\BonusScore; use App\Models\Entry; -use App\Models\EntryTotalScore; -use App\Models\ScoreSheet; use Illuminate\Http\Request; -use Illuminate\Support\Facades\DB; use function to_route; @@ -82,27 +78,6 @@ class EntryFlagController extends Controller return to_route('entry-flags.noShowSelect')->with('error', $e->getMessage()); } - // if ($entry->audition->hasFlag('seats_published')) { - // return to_route('entry-flags.noShowSelect')->with('error', - // 'Cannot enter a no-show for an entry in an audition where seats are published'); - // } - // if ($entry->audition->hasFlag('advancement_published')) { - // return to_route('entry-flags.noShowSelect')->with('error', - // 'Cannot enter a no-show for an entry in an audition where advancement is published'); - // } - // DB::table('score_sheets')->where('entry_id', $entry->id)->delete(); - // - // ScoreSheet::where('entry_id', $entry->id)->delete(); - // BonusScore::where('entry_id', $entry->id)->delete(); - // EntryTotalScore::where('entry_id', $entry->id)->delete(); - // if (request()->input('noshow-type') == 'failprelim') { - // $msg = 'Failed prelim has been entered for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').'; - // $entry->addFlag('failed_prelim'); - // } else { - // $entry->addFlag('no_show'); - // $msg = 'No Show has been entered for '.$entry->audition->name.' #'.$entry->draw_number.' (ID: '.$entry->id.').'; - // } - return to_route('entry-flags.noShowSelect')->with('success', $msg); } diff --git a/app/Http/Controllers/Tabulation/SeatAuditionFormController.php b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php index 5a0411f..c83b59d 100644 --- a/app/Http/Controllers/Tabulation/SeatAuditionFormController.php +++ b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Tabulation; use App\Actions\Tabulation\GetAuditionSeats; use App\Actions\Tabulation\RankAuditionEntries; +use App\Exceptions\AuditionAdminException; use App\Http\Controllers\Controller; use App\Models\Audition; use App\Models\Doubler; @@ -75,6 +76,37 @@ class SeatAuditionFormController extends Controller $entry->student->full_name().' has declined '.$audition->name); } + public function acceptSeat(Audition $audition, Entry $entry) + { + $doublerData = Doubler::findDoubler($entry->student_id, $audition->event_id); + foreach ($doublerData->entries() as $doublerEntry) { + if (! $doublerEntry->totalScore && ! $doublerEntry->hasFlag('declined') && ! $doublerEntry->hasFlag('no_show') && ! $doublerEntry->hasFlag('failed_prelim')) { + return redirect()->route('seating.audition', ['audition' => $audition->id])->with('error', + 'Cannot accept seating for '.$entry->student->full_name().' because student has unscored entries'); + } + } + foreach ($doublerData->entries() as $doublerEntry) { + if ($doublerEntry->id !== $entry->id && ! $doublerEntry->hasFlag('no_show') && ! $doublerEntry->hasFlag('failed_prelim') && ! $doublerEntry->hasFlag('declined')) { + $doublerEntry->addFlag('declined'); + } + } + + return redirect()->route('seating.audition', ['audition' => $audition->id])->with('success', + $entry->student->full_name().' has accepted '.$audition->name); + } + + public function noshow(Audition $audition, Entry $entry) + { + $recorder = app('App\Actions\Tabulation\EnterNoShow'); + try { + $msg = $recorder($entry); + } catch (AuditionAdminException $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + + return redirect()->route('seating.audition', [$audition])->with('success', $msg); + } + protected function pickRightPanel(Audition $audition, array $seatable) { if ($audition->hasFlag('seats_published')) { diff --git a/resources/views/tabulation/auditionSeating-doubler-block.blade.php b/resources/views/tabulation/auditionSeating-doubler-block.blade.php index e3c5a85..99b5829 100644 --- a/resources/views/tabulation/auditionSeating-doubler-block.blade.php +++ b/resources/views/tabulation/auditionSeating-doubler-block.blade.php @@ -27,6 +27,10 @@ @endforeach