39024-vm/includes/helpers.php
Flatlogic Bot b6a9bec423 001
2026-03-06 13:34:25 +00:00

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;
}