Add school rosters with shirt sizes to SCOBDA nomination ensembles.
This commit is contained in:
parent
72c86e3a8a
commit
56931ca391
|
|
@ -3,11 +3,64 @@
|
|||
namespace App\Http\Controllers\NominationEnsembles;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\School;
|
||||
use Codedge\Fpdf\Fpdf\Fpdf;
|
||||
|
||||
class ScobdaNominationAdminUtilitiesController extends Controller implements NominationAdminUtilitiesController
|
||||
{
|
||||
public function __invoke(string $action)
|
||||
{
|
||||
// TODO: Implement __invoke() method.
|
||||
match ($action) {
|
||||
'school_shirt_distribution_report' => $this->printShirtDistributionLists(),
|
||||
default => $this->invalidAction(),
|
||||
};
|
||||
}
|
||||
|
||||
private function printShirtDistributionLists()
|
||||
{
|
||||
$output = '';
|
||||
$schools = School::with('nominations.student')->orderBy('name')->get();
|
||||
|
||||
$pdf = new Fpdf('P', 'in', 'letter');
|
||||
|
||||
foreach ($schools as $school) {
|
||||
if ($school->nominations->count() < 1) {
|
||||
continue;
|
||||
}
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('Arial', 'B', 16);
|
||||
$pdf->Cell(0, .3, $school->name, 1, 1, 'L');
|
||||
$director_text = 'Directors: ';
|
||||
$first_director = true;
|
||||
foreach ($school->users as $user) {
|
||||
if (! $first_director) {
|
||||
$director_text .= ', ';
|
||||
}
|
||||
$director_text .= $user->full_name();
|
||||
$first_director = false;
|
||||
}
|
||||
$pdf->SetFont('Arial', 'B', 12);
|
||||
$pdf->MultiCell(0, .3, $director_text, 0, 'L', 0);
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$nominations = $school->nominations;
|
||||
$nominations = $nominations->sortBy(function ($entry) {
|
||||
return $entry->student->full_name(true);
|
||||
});
|
||||
foreach ($nominations as $nomination) {
|
||||
$accepted = $nomination->data['accepted'] ?? false;
|
||||
if (! $accepted) {
|
||||
continue;
|
||||
}
|
||||
$text = $nomination->student->full_name().' - ';
|
||||
if ($nomination->student->optional_data && array_key_exists('shirt_size',
|
||||
$nomination->student->optional_data)) {
|
||||
$text .= $nomination->student->optional_data['shirt_size'];
|
||||
} else {
|
||||
$text .= 'No size provided';
|
||||
}
|
||||
$pdf->Cell(0, .25, $text, 0, 1, 'L');
|
||||
}
|
||||
}
|
||||
$pdf->Output('D', 'ShirtRosters.pdf');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@
|
|||
By School
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('nomination.admin.utilities',['action'=>'school_shirt_distribution_report']) }}"
|
||||
class="group flex gap-x-3 rounded-md p-2 pl-3 text-sm/6 font-semibold text-gray-700 hover:bg-gray-50 hover:text-indigo-600">
|
||||
School Rosters
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue