Format exam sheet labels

This commit is contained in:
Wojtek
2026-10-15 09:16:08 +02:00
parent 1f5c773477
commit e7c40292b7
6 changed files with 39 additions and 10 deletions
@@ -12,6 +12,32 @@ class HtmlView extends BaseHtmlView
protected $symbol;
protected $symbols;
public function formatSheetLabel($sheet)
{
$qualification = (string) ($sheet->category_title ?: '');
if (preg_match('/^([A-Z]+)(\d+)$/i', $qualification, $matches)) {
$qualification = strtoupper($matches[1]) . '.' . $matches[2];
}
$months = [
1 => 'Styczeń', 2 => 'Luty', 3 => 'Marzec', 4 => 'Kwiecień',
5 => 'Maj', 6 => 'Czerwiec', 7 => 'Lipiec', 8 => 'Sierpień',
9 => 'Wrzesień', 10 => 'Październik', 11 => 'Listopad', 12 => 'Grudzień',
];
$period = '';
if (preg_match('/-(\d{2})\.(\d{2})$/', (string) $sheet->test_symbol, $matches)) {
$month = (int) $matches[2];
$year = (int) $sheet->exam_year ?: 2000 + (int) $matches[1];
$period = ($months[$month] ?? '') . ' ' . $year;
} elseif ($sheet->exam_year) {
$period = (string) $sheet->exam_year;
}
return trim('Kwalifikacja ' . $qualification . ($period ? ' - ' . $period : '') . ' (' . $sheet->test_symbol . ')');
}
public function display($tpl = null)
{
$this->items = $this->get('Items');