Auditionadmin 77 - judge assignment report #81
|
|
@ -0,0 +1,104 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Room;
|
||||||
|
use Codedge\Fpdf\Fpdf\Fpdf;
|
||||||
|
|
||||||
|
use function auditionSetting;
|
||||||
|
|
||||||
|
class PrintRoomAssignmentsController extends Controller
|
||||||
|
{
|
||||||
|
private $pdf;
|
||||||
|
|
||||||
|
/* TABLE DIMENSIONS */
|
||||||
|
private $col1width = 1.7;
|
||||||
|
|
||||||
|
private $col2width = 2.6;
|
||||||
|
|
||||||
|
private $lineHeight = .2;
|
||||||
|
|
||||||
|
public function __invoke()
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.draw.index')">Run Draw</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.draw.index')">Run Draw</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.cards.index')">Print Cards</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.cards.index')">Print Cards</x-layout.navbar.menus.menu-item>
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.signInSheets.index')">Print Sign-In Sheets</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.signInSheets.index')">Print Sign-In Sheets</x-layout.navbar.menus.menu-item>
|
||||||
|
<x-layout.navbar.menus.menu-item :href="route('admin.print_room_assignment_report')">Print Room and Judge Assignments</x-layout.navbar.menus.menu-item>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use App\Http\Controllers\Admin\EnsembleController;
|
||||||
use App\Http\Controllers\Admin\EntryController;
|
use App\Http\Controllers\Admin\EntryController;
|
||||||
use App\Http\Controllers\Admin\EventController;
|
use App\Http\Controllers\Admin\EventController;
|
||||||
use App\Http\Controllers\Admin\PrintCards;
|
use App\Http\Controllers\Admin\PrintCards;
|
||||||
|
use App\Http\Controllers\Admin\PrintRoomAssignmentsController;
|
||||||
use App\Http\Controllers\Admin\PrintSignInSheetsController;
|
use App\Http\Controllers\Admin\PrintSignInSheetsController;
|
||||||
use App\Http\Controllers\Admin\RoomController;
|
use App\Http\Controllers\Admin\RoomController;
|
||||||
use App\Http\Controllers\Admin\SchoolController;
|
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::get('/', 'index')->name('admin.signInSheets.index');
|
||||||
Route::post('/print', 'print')->name('admin.signInSheets.print');
|
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');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue