Auditionadmin 73 - Sign In Sheets #80
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Actions\Print;
|
||||||
|
|
||||||
|
use App\Models\Entry;
|
||||||
|
use App\Models\Room;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class PrintSignInSheets
|
||||||
|
{
|
||||||
|
protected $pdf;
|
||||||
|
|
||||||
|
protected $margin = .5;
|
||||||
|
|
||||||
|
protected $roomOn;
|
||||||
|
|
||||||
|
protected $columnWidth = [
|
||||||
|
'id' => .5,
|
||||||
|
'instrument' => 1.25,
|
||||||
|
'drawNumber' => .3,
|
||||||
|
'name' => 1.8,
|
||||||
|
'school' => 1.4,
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $headerRowHeight = .25;
|
||||||
|
|
||||||
|
protected $bodyRowHeight = .3125;
|
||||||
|
|
||||||
|
protected $blankLinesPerRoom = 10;
|
||||||
|
|
||||||
|
protected $addBlankLinesAuditionFactor = .1;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(Collection $rooms): void
|
||||||
|
{
|
||||||
|
$this->print($rooms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection|Room[] $rooms
|
||||||
|
*/
|
||||||
|
public function print(Collection $rooms)
|
||||||
|
{
|
||||||
|
$this->pdf = new signInPDF('P', 'in', 'letter');
|
||||||
|
$this->pdf->columnWidth = $this->columnWidth;
|
||||||
|
$this->pdf->headerRowHeight = $this->headerRowHeight;
|
||||||
|
$this->pdf->SetMargins($this->margin, $this->margin);
|
||||||
|
$this->pdf->SetAutoPageBreak(true, .5);
|
||||||
|
//$this->pdf->SetFont('arial', '', '10');
|
||||||
|
foreach ($rooms as $room) {
|
||||||
|
$this->pdf->roomOn = $room->name;
|
||||||
|
$auditions = $room->auditions;
|
||||||
|
$this->pdf->AddPage();
|
||||||
|
foreach ($auditions as $audition) {
|
||||||
|
$entries = $audition->entries()->orderBy('draw_number')->get();
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
$this->addEntryRow($entry);
|
||||||
|
}
|
||||||
|
// Add extra rows for audition
|
||||||
|
$extraRowCount = ceil($audition->entries()->count() * $this->addBlankLinesAuditionFactor);
|
||||||
|
for ($n = 0; $n < $extraRowCount; $n++) {
|
||||||
|
$this->addBlankRow($audition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ($n = 0; $n < $this->blankLinesPerRoom; $n++) {
|
||||||
|
$this->addBlankRow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->pdf->Output('D', 'SignInSheets.pdf');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addEntryRow(Entry $entry)
|
||||||
|
{
|
||||||
|
$this->pdf->Cell($this->columnWidth['id'], $this->bodyRowHeight, $entry->id, 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['instrument'], $this->bodyRowHeight, $entry->audition->name, 1, 0,
|
||||||
|
'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['drawNumber'], $this->bodyRowHeight, $entry->draw_number, 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['name'], $this->bodyRowHeight, $entry->student->full_name(), 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['school'], $this->bodyRowHeight, $entry->student->school->name, 1, 0, 'L');
|
||||||
|
$this->pdf->Cell(0, $this->bodyRowHeight, ' ', 1, 1, 'L');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addBlankRow($audition = null)
|
||||||
|
{
|
||||||
|
$a = ($audition ? $audition->name : ' ');
|
||||||
|
$this->pdf->Cell($this->columnWidth['id'], $this->bodyRowHeight, ' ', 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['instrument'], $this->bodyRowHeight, $a, 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['drawNumber'], $this->bodyRowHeight, ' ', 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['name'], $this->bodyRowHeight, ' ', 1, 0, 'L');
|
||||||
|
$this->pdf->Cell($this->columnWidth['school'], $this->bodyRowHeight, ' ', 1, 0, 'L');
|
||||||
|
$this->pdf->Cell(0, $this->bodyRowHeight, ' ', 1, 1, 'L');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Actions\Print;
|
||||||
|
|
||||||
|
use Codedge\Fpdf\Fpdf\Fpdf;
|
||||||
|
|
||||||
|
class signInPDF extends Fpdf
|
||||||
|
{
|
||||||
|
public $roomOn;
|
||||||
|
|
||||||
|
public $columnWidth = [
|
||||||
|
'id' => .5,
|
||||||
|
'instrument' => 1.25,
|
||||||
|
'drawNumber' => .3,
|
||||||
|
'name' => 1.8,
|
||||||
|
'school' => 1.4,
|
||||||
|
];
|
||||||
|
|
||||||
|
public $headerRowHeight = .25;
|
||||||
|
|
||||||
|
public function Header()
|
||||||
|
{
|
||||||
|
$this->SetFont('arial', '', '10');
|
||||||
|
$headerText = auditionSetting('auditionName').' - Student Sign In - Room: ';
|
||||||
|
$headerText .= $this->roomOn;
|
||||||
|
$this->Cell(0, .3, $headerText, 1, 0, 'C');
|
||||||
|
$this->Ln(.4);
|
||||||
|
$this->Cell($this->columnWidth['id'], $this->headerRowHeight, 'I.D.', 1, 0, 'L');
|
||||||
|
$this->Cell($this->columnWidth['instrument'], $this->headerRowHeight, 'Instrument', 1, 0, 'L');
|
||||||
|
$this->Cell($this->columnWidth['drawNumber'], $this->headerRowHeight, '#', 1, 0, 'L');
|
||||||
|
$this->Cell($this->columnWidth['name'], $this->headerRowHeight, 'Name (D) = Doubler', 1, 0, 'L');
|
||||||
|
$this->Cell($this->columnWidth['school'], $this->headerRowHeight, 'School', 1, 0, 'L');
|
||||||
|
$this->Cell(0, $this->headerRowHeight, 'Signature', 1, 1, 'L');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Actions\Print\PrintSignInSheets;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Room;
|
||||||
|
|
||||||
|
use function array_keys;
|
||||||
|
use function request;
|
||||||
|
|
||||||
|
class PrintSignInSheetsController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$rooms = Room::where('id', '>', 0)->get();
|
||||||
|
|
||||||
|
return view('admin.print_sign_in_sheets.index', compact('rooms'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function print(PrintSignInSheets $printer)
|
||||||
|
{
|
||||||
|
$selectedRoomIds = array_keys(request()->room);
|
||||||
|
$rooms = Room::whereIn('id', $selectedRoomIds)->get();
|
||||||
|
$printer->print($rooms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<x-layout.app>
|
||||||
|
<x-slot:page_title>Select Sign-In Sheets to Print</x-slot:page_title>
|
||||||
|
<x-form.form method="POST" action="{{route('admin.signInSheets.print')}}">
|
||||||
|
<x-card.card class="mb-5 mx-auto max-w-3xl" id="room-card" x-data="{ allChecked: false }">
|
||||||
|
<x-card.heading>
|
||||||
|
Rooms
|
||||||
|
<x-slot:right_side>
|
||||||
|
<button @click="allChecked = 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="allChecked = 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($rooms as $room)
|
||||||
|
<div id="room-div-{{$room->id}}" class="flex align-middle">
|
||||||
|
<x-form.checkbox id="roomCheckbox-{{$room->id}}" name="room[{{$room->id}}]" x-bind:checked="allChecked"/>
|
||||||
|
{{$room->name}}
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</x-card.card>
|
||||||
|
<x-form.button class="mt-5 mx-auto max-w-3xl" type="submit">Print Sign-In Sheets</x-form.button>
|
||||||
|
</x-form.form>
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
<x-layout.navbar.menus.menu-item :href="route('admin.rooms.judgingAssignment')">Judges</x-layout.navbar.menus.menu-item>
|
<x-layout.navbar.menus.menu-item :href="route('admin.rooms.judgingAssignment')">Judges</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.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>
|
||||||
</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\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;
|
||||||
use App\Http\Controllers\Admin\ScoringGuideController;
|
use App\Http\Controllers\Admin\ScoringGuideController;
|
||||||
|
|
@ -170,4 +171,10 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
Route::get('/', 'index')->name('admin.cards.index');
|
Route::get('/', 'index')->name('admin.cards.index');
|
||||||
Route::post('/print', 'print')->name('admin.cards.print');
|
Route::post('/print', 'print')->name('admin.cards.print');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Admin SignIn Sheet Routes
|
||||||
|
Route::prefix('signInSheets')->controller(PrintSignInSheetsController::class)->group(function () {
|
||||||
|
Route::get('/', 'index')->name('admin.signInSheets.index');
|
||||||
|
Route::post('/print', 'print')->name('admin.signInSheets.print');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Room;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Laravel\get;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('ignores requests from normal users', function () {
|
||||||
|
// Arrange
|
||||||
|
actAsNormal();
|
||||||
|
get(route('admin.signInSheets.index'))
|
||||||
|
->assertRedirect(route('dashboard'))
|
||||||
|
->assertSessionHas('error', 'You are not authorized to perform this action');
|
||||||
|
});
|
||||||
|
it('ignores requests from tabulation users', function () {
|
||||||
|
// Arrange
|
||||||
|
actAsTab();
|
||||||
|
get(route('admin.signInSheets.index'))
|
||||||
|
->assertRedirect(route('dashboard'))
|
||||||
|
->assertSessionHas('error', 'You are not authorized to perform this action');
|
||||||
|
});
|
||||||
|
it('ignores requests from guests', function () {
|
||||||
|
// Arrange
|
||||||
|
get(route('admin.signInSheets.index'))
|
||||||
|
->assertRedirect(route('home'));
|
||||||
|
});
|
||||||
|
it('allows access to admin users', function () {
|
||||||
|
// Arrange
|
||||||
|
actAsAdmin();
|
||||||
|
// Act and Assert
|
||||||
|
get(route('admin.signInSheets.index'))
|
||||||
|
->assertOk()
|
||||||
|
->assertViewIs('admin.print_sign_in_sheets.index')
|
||||||
|
->assertSessionHasNoErrors();
|
||||||
|
});
|
||||||
|
it('shows rooms', function () {
|
||||||
|
$room = Room::factory()->create();
|
||||||
|
actAsAdmin();
|
||||||
|
get(route('admin.signInSheets.index'))
|
||||||
|
->assertSee($room->name);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Process the form and print the sheets
|
||||||
Loading…
Reference in New Issue