36 lines
968 B
PHP
36 lines
968 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
function h(?string $value): string {
|
|
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
function roman_month(int $month): string {
|
|
$roman = [1 => 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII'];
|
|
return $roman[$month] ?? '';
|
|
}
|
|
|
|
function format_nomor(string $kode, int $urut, int $bulan, int $tahun): string {
|
|
$kode = strtoupper(trim($kode));
|
|
$urutFormatted = str_pad((string)$urut, 3, '0', STR_PAD_LEFT);
|
|
return $kode . '/' . $urutFormatted . '/' . roman_month($bulan) . '/' . $tahun;
|
|
}
|
|
|
|
function status_badge(string $status, string $type): string {
|
|
$map = [
|
|
'masuk' => [
|
|
'baru' => 'info',
|
|
'diproses' => 'warning',
|
|
'selesai' => 'success',
|
|
],
|
|
'keluar' => [
|
|
'draft' => 'info',
|
|
'review' => 'warning',
|
|
'approved' => 'success',
|
|
'kirim' => 'success',
|
|
],
|
|
];
|
|
$key = $map[$type][$status] ?? 'info';
|
|
return 'badge-soft ' . $key;
|
|
}
|