diff --git a/app/Http/Controllers/Admin/PrintRoomAssignmentsController.php b/app/Http/Controllers/Admin/PrintRoomAssignmentsController.php new file mode 100644 index 0000000..66a3137 --- /dev/null +++ b/app/Http/Controllers/Admin/PrintRoomAssignmentsController.php @@ -0,0 +1,104 @@ +pdf = new reportPDF('P', 'in', 'letter'); + $this->pdf->SetMargins(.3, .3); + $this->pdf->SetAutoPageBreak(true, .5); + $this->pdf->AddPage(); + $this->pdf->SetFont('arial', 'B', '10'); + $headerText = auditionSetting('auditionName').' - Room and Judge Assignments'; + $this->pdf->Cell(0, .2, $headerText, 1, 1, 'C'); + $this->pdf->Ln(.1); + + $this->pdf->SetFont('arial', 'B', '10'); + + /* TABLE HEADER */ + $this->pdf->cell($this->col1width, $this->lineHeight, 'Room', 1); + $this->pdf->cell($this->col2width, $this->lineHeight, 'Auditions', 1); + $this->pdf->cell(0, $this->lineHeight, 'Judges', 1, 1); + + $rooms = Room::withCount('entries')->where('id', '>', 0)->with('auditions')->with('judges')->get(); + + foreach ($rooms as $room) { + $this->roomRow($room); + } + + $this->pdf->Output('D', 'JudgingAssignments.pdf'); + } + + private function roomRow(Room $room) + { + $this->pdf->SetFont('arial', '', '9'); + $roomDescription = $room->name.' ('.$room->entries_count.')'; + $judgingAssignments = $room->judges; + $auditions = $room->auditions()->withCount('entries')->get(); + $numLines = max([$judgingAssignments->count(), $auditions->count()]); + $rowHeight = $this->lineHeight * $numLines; + $auditionText = ''; + $judgeText = ''; + + foreach ($auditions as $audition) { + $auditionText .= $audition->name.' ('.$audition->entries_count.')'; + $auditionText .= PHP_EOL; + } + + foreach ($judgingAssignments as $ja) { + $judgeText .= $ja->full_name(); + $judgeText .= PHP_EOL; + } + + if ($this->pdf->GetY() + $rowHeight > $this->pdf->getPageBreakTrigger()) { + $this->pdf->AddPage(); + } + + $startx = $this->pdf->getX(); + $starty = $this->pdf->getY(); + + /* CELL BORDERS */ + $this->pdf->MultiCell($this->col1width, $rowHeight, ' ', 1, 'C'); + $this->pdf->SetXY($startx + $this->col1width, $starty); + $this->pdf->MultiCell($this->col2width, $rowHeight, ' ', 1); + $this->pdf->SetXY($startx + $this->col1width + $this->col2width, $starty); + $this->pdf->MultiCell(0, $rowHeight, ' ', 1); + + /* CELL CONTENTS */ + $this->pdf->SetXY($startx, $starty); + $this->pdf->MultiCell($this->col1width, $this->lineHeight, $roomDescription, 0, 'C'); + $this->pdf->SetXY($startx + $this->col1width, $starty); + $this->pdf->MultiCell($this->col2width, $this->lineHeight, $auditionText); + $this->pdf->SetXY($startx + $this->col1width + $this->col2width, $starty); + $this->pdf->MultiCell(0, $this->lineHeight, $judgeText, 0); + + /* SET LOCATION FOR NEXT ROW */ + $this->pdf->setXY($startx, $starty + $rowHeight); + + } +} + +class reportPDF extends FPDF +{ + public function getPageBreakTrigger() + { + return $this->PageBreakTrigger; + } +} diff --git a/resources/views/components/layout/navbar/menus/setup.blade.php b/resources/views/components/layout/navbar/menus/setup.blade.php index 47998b7..85e884b 100644 --- a/resources/views/components/layout/navbar/menus/setup.blade.php +++ b/resources/views/components/layout/navbar/menus/setup.blade.php @@ -32,6 +32,8 @@ Run Draw Print Cards Print Sign-In Sheets + Print Room and Judge Assignments + diff --git a/routes/admin.php b/routes/admin.php index b38f4ab..0ab9b6c 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -9,6 +9,7 @@ use App\Http\Controllers\Admin\EnsembleController; use App\Http\Controllers\Admin\EntryController; use App\Http\Controllers\Admin\EventController; use App\Http\Controllers\Admin\PrintCards; +use App\Http\Controllers\Admin\PrintRoomAssignmentsController; use App\Http\Controllers\Admin\PrintSignInSheetsController; use App\Http\Controllers\Admin\RoomController; use App\Http\Controllers\Admin\SchoolController; @@ -177,4 +178,7 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')-> Route::get('/', 'index')->name('admin.signInSheets.index'); Route::post('/print', 'print')->name('admin.signInSheets.print'); }); + + // Print Room and Judge Assignment Report + Route::get('room_assignment_report', PrintRoomAssignmentsController::class)->name('admin.print_room_assignment_report'); });