[Operator] Perbaikan Laman Portal -> Konsultasi
This commit is contained in:
@@ -179,7 +179,9 @@ Detail mahasiswa (aksi Lihat pada baris): `GET operator.list-mahasiswa.show` (`/
|
||||
|
||||
### Portal > Pegawai (operator) dari data asli
|
||||
|
||||
Slug `list_pegawai` untuk akun DB lama diteruskan `SatuPageController` ke `Operator\EmployeeListController` (view `operator/satu/remote-list.blade.php`, data `App\Support\Legacy\EmployeeDirectory`, JSON `GET operator.pegawai.data` = `/operator/list_pegawai/data`). Tampilan sama dengan prototipe (kolom #, NIP, Nama, L/P, NIDN, NUPTK, No. Telp., Email, Status, Aksi; tombol Aksi dan Cetak); uji membandingkan susunannya langsung dengan halaman prototipe. Ubah dan hapus per baris sungguhan (`PUT operator.list-pegawai.update`, `POST operator.list-pegawai.destroy`; `EmployeeListController` -> `App\Support\Legacy\EmployeeRecords`, tabel `t_pegawai`/`t_dosen`) dalam cakupan daftar; hapus ditolak bila pegawai dirujuk jabatan, jadwal, PA, skripsi, atau akun. Tidak ada Tambah (template SATU tidak punya tombolnya).
|
||||
Slug `list_pegawai` untuk akun DB lama diteruskan `SatuPageController` ke `Operator\EmployeeListController` (view `operator/satu/remote-list.blade.php`, data `App\Support\Legacy\EmployeeDirectory`, JSON `GET operator.pegawai.data` = `/operator/list_pegawai/data`). Tampilan sama dengan prototipe (kolom #, NIP, Nama, L/P, NIDN, NUPTK, No. Telp., Email, Status, Aksi; tombol Aksi dan Cetak di prototipe); uji membandingkan susunannya dengan halaman prototipe. Bilah hanya berisi Tambah dan Hapus (tanpa Cetak) dan baris hanya Lihat dan Hapus: tidak ada Ubah di daftar (rute `update` dihapus), semua perubahan biodata di halaman detail. Hapus per baris/terpilih sungguhan (`POST operator.list-pegawai.destroy`; `EmployeeListController` -> `App\Support\Legacy\EmployeeRecords`, tabel `t_pegawai`/`t_dosen`) dalam cakupan daftar; hapus ditolak bila pegawai dirujuk jabatan, jadwal, PA, skripsi, atau akun. Tambah pegawai juga tersedia (`POST operator.list-pegawai.store` -> `EmployeeRecords::create`): pegawai baru ditambahkan sebagai **dosen** (`idjenispegawai` 1) dengan home base salah satu prodi akun (baris `t_dosen`), sehingga langsung masuk cakupan daftar. Pegawai staf hanya tampil lewat jabatan aktif, yang tidak diatur di sini, jadi menambah staf tidak disediakan. Tombol bilah diatur `EmployeeListController` (`tools` = Tambah dan Hapus, `editable` = false), bukan dari katalog.
|
||||
|
||||
Detail pegawai (aksi Lihat pada baris): `GET operator.list-pegawai.show` (`/operator/list_pegawai/{id}`, `EmployeeDetailController` -> `operator/satu/pegawai-detail.blade.php`) dengan komponen bersama `components/satu/bio-sections.blade.php` dan komponen Alpine `bioDetail` (dipakai juga detail mahasiswa). Bagian berbeda dari mahasiswa, diatur `App\Support\Legacy\EmployeeBiodata`: Data pribadi (nama, gelar, kelamin, tempat dan tanggal lahir, agama, NIK, jumlah istri/suami dan anak), Kontak dan alamat, Kepegawaian (NIP, NIP nasional, NIDN, status kepegawaian dan aktif, SK, NPWP, BPJS; plus jenis pegawai dan jabatan aktif yang hanya dibaca), Pendidikan dan bank (pendidikan terakhir, bank, no. rekening), dan Data dosen (home base, pangkat, jabatan fungsional, nomor PA; ditulis ke `t_dosen`, hanya untuk dosen). Simpan per bagian lewat `PUT operator.list-pegawai.biodata` (`/operator/list_pegawai/{id}/biodata/{section}`); logika isian bersama mahasiswa ada di trait `Concerns\BiodataFields` (hanya kolom berubah yang ditulis, isian tidak berubah tidak divalidasi ulang; NIP dicek tidak kembar). Gelar depan dan belakang diisi tanpa pemisah: DB lama menyimpan gelar belakang sebagai `, M.Pd` (awalan koma, 98% data) dan gelar depan sebagai `Dr. ` (spasi penutup), jadi formulir menampilkan `M.Pd` dan `Dr.` lalu pemisah ditambahkan saat menyimpan (opsi isian `affix` di `BiodataFields`). Pendidikan terakhir pegawai memakai skala `t_tingkat_pendidikan.id_simalum` (7 S1, 8 S2, 9 S3), bukan `idtingkat` (disimpulkan dari data: gelar belakang). Kolom `golongan` tidak ditampilkan karena tabel acuannya tidak ditemukan. Uji: `tests/Feature/Operator/LegacyEmployeeDetailTest.php`.
|
||||
|
||||
- Cakupan: dosen dengan home base prodi akun (`t_dosen.idprogdi`) dan pegawai yang memegang jabatan aktif (`t_jabatanpegawai.aktif = 1`) di prodi atau fakultas akun (`t_jabatanbagian.idbagian`, fakultas dari `t_unituser.idfak`). Urut nama.
|
||||
- Kolom: NIP `nip`; Nama = `gelardepan` + `nama` + `, gelarbelakang`; L/P `kelamin` (1 L, 2 P); NIDN `nidn`; No. Telp. `hp`, atau `telepon` bila kosong; Email `email`. **NUPTK tidak ada di DB lama** (`no_id` berisi NIK), jadi selalu "–".
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Operator;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Operator\Concerns\ServesLegacyList;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\EmployeeBiodata;
|
||||
use App\Support\Legacy\EmployeeDirectory;
|
||||
use App\Support\Legacy\LegacyFormat;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Detail pegawai (aksi Lihat pada Portal > Pegawai) untuk akun DB lama: ringkasan, biodata lengkap per bagian (pribadi,
|
||||
* kontak, kepegawaian, pendidikan dan rekening, data dosen), dan penyimpanan per bagian lewat JSON. Hanya pegawai dalam
|
||||
* cakupan daftar (dosen home base prodi akun atau pemegang jabatan aktif di prodi/fakultas akun).
|
||||
*/
|
||||
class EmployeeDetailController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
|
||||
private const string SLUG = 'list_pegawai';
|
||||
|
||||
public function __construct(
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly EmployeeDirectory $directory,
|
||||
private readonly EmployeeBiodata $biodata,
|
||||
) {}
|
||||
|
||||
public function show(Request $request, int $id): View
|
||||
{
|
||||
[$prodi, $faculties] = $this->scope($request);
|
||||
$bio = $this->biodata->find($prodi, $faculties, $id) ?? abort(404);
|
||||
$page = Catalog::page(self::SLUG);
|
||||
$sections = $bio['sections'];
|
||||
$extra = $bio['extra'];
|
||||
|
||||
// Keterangan hanya dibaca di bagian Kepegawaian.
|
||||
$sections['kepegawaian']['readonly'] = [['name' => 'jenis', 'label' => 'Jenis pegawai'], ['name' => 'jabatan', 'label' => 'Jabatan aktif']];
|
||||
$sections['kepegawaian']['display'] += ['jenis' => $extra['jenis'] ?? '–', 'jabatan' => $extra['jabatan'] === [] ? '–' : implode('; ', $extra['jabatan'])];
|
||||
|
||||
$v = $sections['pribadi']['values'];
|
||||
|
||||
return view('operator.satu.pegawai-detail', [
|
||||
'page' => $page,
|
||||
'crumbs' => ['Beranda' => route('operator.dashboard')] + array_fill_keys(Catalog::trail(self::SLUG), null) + [$page['title'] => route('operator.halaman', self::SLUG), 'Detail' => null],
|
||||
'sections' => $sections,
|
||||
'extra' => $extra,
|
||||
'name' => LegacyFormat::pegawaiName($v['gelardepan'], $v['nama'], $v['gelarbelakang']),
|
||||
'back' => route('operator.halaman', self::SLUG),
|
||||
'saveUrl' => route('operator.list-pegawai.biodata', [$id, '__SECTION__']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id, string $section): JsonResponse
|
||||
{
|
||||
[$prodi, $faculties] = $this->scope($request);
|
||||
abort_unless(in_array($section, EmployeeBiodata::sectionKeys(), true) && $this->biodata->exists($prodi, $faculties, $id), 404);
|
||||
|
||||
try {
|
||||
$input = $this->biodata->validated($prodi, $faculties, $id, $section, $request->all());
|
||||
$result = $this->biodata->update($prodi, $faculties, $id, $section, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => $result['changed'] === 0 ? 'Tidak ada perubahan.' : 'Biodata diperbarui.',
|
||||
'values' => $result['section']['values'],
|
||||
'display' => $result['section']['display'],
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array{0: list<int>, 1: list<int>} prodi dan fakultas akun */
|
||||
private function scope(Request $request): array
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$iduser = (int) $request->user()->getKey();
|
||||
$prodi = $this->overview->programs($iduser)->keys()->all();
|
||||
abort_if($prodi === [], 404);
|
||||
|
||||
return [$prodi, $this->directory->faculties($iduser)];
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,8 @@ class EmployeeListController extends Controller
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
{
|
||||
$page = Catalog::page(self::SLUG);
|
||||
// Template SATU Pegawai tidak punya Tambah dan Hapus di bilah; keduanya dipasang di sini karena sudah bekerja.
|
||||
$page = ['flags' => 'TH'] + Catalog::page(self::SLUG);
|
||||
$iduser = (int) $request->user()->getKey();
|
||||
$programs = $this->overview->programs($iduser);
|
||||
[$labelAdvisor, $labelActive, $labelStatus] = $page['filters'];
|
||||
@@ -41,9 +42,13 @@ class EmployeeListController extends Controller
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => ['Beranda' => route('operator.dashboard')] + array_fill_keys(Catalog::trail(self::SLUG), null) + [$page['title'] => null],
|
||||
'note' => 'Data pegawai asli dari SIAKAD untuk program studi dan fakultas yang Anda kelola. Ubah dan hapus langsung tersimpan di basis data; pegawai yang masih dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun login tidak dapat dihapus.',
|
||||
'note' => 'Data pegawai asli dari SIAKAD untuk program studi dan fakultas yang Anda kelola. Tambah dan hapus langsung tersimpan di basis data; pegawai baru ditambahkan sebagai dosen dengan home base program studi Anda, dan pegawai yang masih dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun login tidak dapat dihapus. Pilih Lihat untuk biodata lengkap; perubahan data dilakukan di dalam halaman detail.',
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar pegawai tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.pegawai.data'),
|
||||
'viewUrl' => route('operator.list-pegawai.show', '__ID__'),
|
||||
// Hanya Tambah dan Hapus di bilah (tanpa Cetak) dan tanpa Ubah di baris: biodata diubah di halaman detail.
|
||||
'tools' => ['T', 'H'],
|
||||
'editable' => false,
|
||||
'filters' => [
|
||||
['name' => 'advisor', 'label' => $labelAdvisor, 'options' => EmployeeDirectory::ADVISOR_OPTIONS],
|
||||
['name' => 'active', 'label' => $labelActive, 'options' => EmployeeDirectory::ACTIVE_OPTIONS],
|
||||
@@ -61,24 +66,26 @@ class EmployeeListController extends Controller
|
||||
],
|
||||
'perPage' => EmployeeDirectory::PER_PAGE,
|
||||
'data' => $programs->isEmpty() ? null : $this->payload($this->search($request, $iduser, $programs->keys()->all())),
|
||||
'form' => $programs->isEmpty() ? null : $this->form(),
|
||||
'form' => $programs->isEmpty() ? null : $this->form($programs->all()),
|
||||
'destroyUrl' => $programs->isEmpty() ? null : route('operator.list-pegawai.destroy'),
|
||||
'destroy' => ['title' => 'Hapus pegawai?', 'message' => 'Hanya pegawai yang tidak dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun login yang dapat dihapus.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
[$prodi, $faculties] = $this->scope($request);
|
||||
$input = $this->validated($request);
|
||||
[$prodi] = $this->scope($request);
|
||||
// Home base diperiksa bersama isian lain agar semua galat tampil sekaligus.
|
||||
$input = $this->validated($request, creating: true);
|
||||
$homeBase = (int) $input['prodi'];
|
||||
|
||||
try {
|
||||
$this->records->update($prodi, $faculties, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
$id = $this->records->create($prodi, $homeBase, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Data pegawai diperbarui.']);
|
||||
return response()->json(['message' => 'Pegawai ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa pegawai (POST {ids}). */
|
||||
@@ -108,9 +115,15 @@ class EmployeeListController extends Controller
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function validated(Request $request): array
|
||||
private function validated(Request $request, bool $creating = false): array
|
||||
{
|
||||
return $request->validate([
|
||||
return $request->validate($creating ? ['prodi' => ['required', 'integer']] + $this->rules() : $this->rules(), [], $this->attributes() + ['prodi' => 'home base']);
|
||||
}
|
||||
|
||||
/** @return array<string, list<string>> */
|
||||
private function rules(): array
|
||||
{
|
||||
return [
|
||||
'nip' => ['required', 'string', 'max:20'],
|
||||
'nama' => ['required', 'string', 'max:50'],
|
||||
'gelardepan' => ['nullable', 'string', 'max:20'],
|
||||
@@ -122,24 +135,32 @@ class EmployeeListController extends Controller
|
||||
'email' => ['nullable', 'string', 'email', 'max:125'],
|
||||
'status' => ['nullable', 'integer'],
|
||||
'aktif' => ['required', 'integer', 'in:0,1'],
|
||||
], [], [
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<string, string> */
|
||||
private function attributes(): array
|
||||
{
|
||||
return [
|
||||
'nip' => 'NIP', 'nama' => 'nama', 'gelardepan' => 'gelar depan', 'gelarbelakang' => 'gelar belakang', 'kelamin' => 'jenis kelamin',
|
||||
'nidn' => 'NIDN', 'hp' => 'no. HP', 'telepon' => 'no. telepon', 'email' => 'email', 'status' => 'status kepegawaian', 'aktif' => 'status aktif',
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Formulir ubah (modal); template SATU tidak punya tombol Tambah untuk Pegawai.
|
||||
* Formulir tambah (modal; tidak ada ubah di daftar). Biodata lengkap diubah di
|
||||
* halaman detail.
|
||||
*
|
||||
* @param array<int, string> $programs
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function form(): array
|
||||
private function form(array $programs): array
|
||||
{
|
||||
return [
|
||||
'title' => 'pegawai',
|
||||
'storeUrl' => null,
|
||||
'updateUrl' => route('operator.list-pegawai.update', '__ID__'),
|
||||
'storeUrl' => route('operator.list-pegawai.store'),
|
||||
'fields' => [
|
||||
['name' => 'prodi', 'label' => 'Home base (program studi)', 'type' => 'select', 'options' => $programs, 'required' => true, 'hint' => 'Pegawai baru ditambahkan sebagai dosen pada program studi ini.'],
|
||||
['name' => 'nip', 'label' => 'NIP', 'type' => 'text', 'required' => true, 'max' => 20],
|
||||
['name' => 'nama', 'label' => 'Nama', 'type' => 'text', 'required' => true, 'max' => 50],
|
||||
['name' => 'gelardepan', 'label' => 'Gelar depan', 'type' => 'text', 'max' => 20],
|
||||
@@ -195,7 +216,6 @@ class EmployeeListController extends Controller
|
||||
return [
|
||||
'rows' => collect($rows->items())->map(fn (array $p): array => [
|
||||
'id' => $p['id'],
|
||||
'form' => $p['form'],
|
||||
'nip' => $dash($p['nip']),
|
||||
'nama' => $p['nama'],
|
||||
'kelamin' => $dash($p['kelamin']),
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\Legacy\Concerns;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Logika isian biodata yang dipakai bersama StudentBiodata dan EmployeeBiodata: bentuk baku nilai kolom, nilai isian dan
|
||||
* teks tampil satu bagian, serta validasi yang hanya memeriksa isian yang berubah (data lama boleh tidak seragam).
|
||||
*
|
||||
* Isian bagian: name (kunci JSON dan kolom), label, type (text|textarea|email|date|number|select), max, min, lookup (nama
|
||||
* pilihan untuk select), required, wide, alnum, digits, notnull (kolom teks NOT NULL: kosong ditulis ''), zero (kode 0 adalah
|
||||
* nilai nyata, bukan "tidak diisi"), placeholder, affix (front|back: gelar depan/belakang; di formulir ditulis tanpa koma dan
|
||||
* spasi pemisah, DB lama menyimpannya sebagai "Dr. " dan ", M.Pd" sehingga pemisah ditambahkan saat menulis).
|
||||
*/
|
||||
trait BiodataFields
|
||||
{
|
||||
/**
|
||||
* Pilihan select (kode => label) menurut nama lookup.
|
||||
*
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
abstract public function lookups(): array;
|
||||
|
||||
/**
|
||||
* Nilai kolom dalam bentuk baku agar dua nilai bisa dibandingkan: teks dipangkas (kosong = null), tanggal Y-m-d,
|
||||
* angka integer, pilihan integer (kosong = 0 pada pilihan yang punya kode 0, selain itu null).
|
||||
*
|
||||
* @param array<string, mixed> $field
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
*/
|
||||
protected function normalize(array $field, mixed $value, array $lookups): string|int|null
|
||||
{
|
||||
$type = $field['type'] ?? 'text';
|
||||
$text = is_scalar($value) ? trim((string) $value) : '';
|
||||
|
||||
// Pilihan tanpa kode 0: nilai kosong atau 0 di DB berarti belum diisi (null).
|
||||
$none = $type === 'select' && ! isset($lookups[$field['lookup']][0]);
|
||||
|
||||
return match ($type) {
|
||||
'select' => $text === '' || ($none && (int) $text === 0) ? ($none ? null : 0) : (int) $text,
|
||||
'number' => $text === '' ? null : (int) $text,
|
||||
'date' => $text === '' ? null : substr($text, 0, 10),
|
||||
default => ($text = self::stripAffix($field, $text)) === '' ? null : $text,
|
||||
};
|
||||
}
|
||||
|
||||
/** Buang pemisah gelar (koma dan spasi di depan gelar belakang, spasi pada gelar depan) agar nilai konsisten. */
|
||||
private static function stripAffix(array $field, string $text): string
|
||||
{
|
||||
return match ($field['affix'] ?? null) {
|
||||
'back' => trim(ltrim($text, " ,\t")),
|
||||
'front' => trim($text),
|
||||
default => $text,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Nilai siap tulis ke kolom: gelar belakang diberi awalan ", " dan gelar depan spasi penutup (konvensi DB lama);
|
||||
* kolom teks NOT NULL yang kosong ditulis ''.
|
||||
*
|
||||
* @param array<string, mixed> $field
|
||||
*/
|
||||
private function stored(array $field, string|int|null $value): string|int|null
|
||||
{
|
||||
if ($value === null) {
|
||||
return ($field['notnull'] ?? false) ? '' : null;
|
||||
}
|
||||
|
||||
return match ($field['affix'] ?? null) {
|
||||
'back' => ', '.$value,
|
||||
'front' => $value.' ',
|
||||
default => $value,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Nilai isian (untuk formulir) dan teks tampil satu bagian.
|
||||
*
|
||||
* @param array<string, mixed> $section
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
* @return array{fields: list<array<string, mixed>>, values: array<string, mixed>, display: array<string, string>}
|
||||
*/
|
||||
protected function present(array $section, object $row, array $lookups): array
|
||||
{
|
||||
$fields = [];
|
||||
$values = [];
|
||||
$display = [];
|
||||
|
||||
foreach ($section['fields'] as $field) {
|
||||
$name = $field['name'];
|
||||
$value = $this->normalize($field, $row->{$name} ?? null, $lookups);
|
||||
|
||||
if (($field['type'] ?? '') === 'select') {
|
||||
$options = $lookups[$field['lookup']];
|
||||
if ($value === null) {
|
||||
// Kolom boleh kosong dan pilihannya tidak punya kode 0: tampil pilihan kosong.
|
||||
$field['blank'] = true;
|
||||
$values[$name] = '';
|
||||
$display[$name] = '–';
|
||||
} else {
|
||||
// Kode yang tidak ada di tabel referensi tetap tampil dan bisa dipertahankan.
|
||||
$options += isset($options[$value]) ? [] : [$value => 'Kode '.$value];
|
||||
$values[$name] = $value;
|
||||
$display[$name] = $value === 0 && ! ($field['zero'] ?? false) ? '–' : $options[$value];
|
||||
}
|
||||
$field['options'] = $options;
|
||||
} else {
|
||||
$values[$name] = $value ?? '';
|
||||
$display[$name] = match (true) {
|
||||
$value === null => '–',
|
||||
($field['type'] ?? '') === 'date' => Carbon::parse($value)->locale('id')->isoFormat('D MMMM YYYY'),
|
||||
default => (string) $value,
|
||||
};
|
||||
}
|
||||
|
||||
$fields[] = $field;
|
||||
}
|
||||
|
||||
return ['fields' => $fields, 'values' => $values, 'display' => $display];
|
||||
}
|
||||
|
||||
/**
|
||||
* Kolom yang berubah dari satu bagian (kolom => nilai baru siap tulis). Isian yang tidak dikirim dilewati.
|
||||
*
|
||||
* @param list<array<string, mixed>> $fields
|
||||
* @param array<string, mixed> $input
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
* @return array<string, string|int|null>
|
||||
*/
|
||||
protected function changes(array $fields, object $row, array $input, array $lookups): array
|
||||
{
|
||||
$changes = [];
|
||||
foreach ($fields as $field) {
|
||||
$name = $field['name'];
|
||||
if (! array_key_exists($name, $input)) {
|
||||
continue;
|
||||
}
|
||||
$new = $this->normalize($field, $input[$name], $lookups);
|
||||
if ($new !== $this->normalize($field, $row->{$name} ?? null, $lookups)) {
|
||||
$changes[$name] = $this->stored($field, $new);
|
||||
}
|
||||
}
|
||||
|
||||
return $changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Periksa isian satu bagian. Isian yang nilainya sama dengan yang tersimpan (dan tidak kosong) tidak diperiksa bentuknya
|
||||
* dan tidak ikut dikembalikan; isian wajib yang kosong selalu diperiksa.
|
||||
*
|
||||
* @param list<array<string, mixed>> $fields
|
||||
* @param array<string, mixed> $input
|
||||
* @param array<string, list<mixed>> $extraRules aturan tambahan per isian
|
||||
* @return array<string, mixed>
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validateFields(array $fields, object $row, array $input, array $extraRules = []): array
|
||||
{
|
||||
$lookups = $this->lookups();
|
||||
$rules = $this->rulesFor($fields, $lookups);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$name = $field['name'];
|
||||
if (array_key_exists($name, $input)) {
|
||||
$new = $this->normalize($field, $input[$name], $lookups);
|
||||
if ($new !== null && $new === $this->normalize($field, $row->{$name} ?? null, $lookups)) {
|
||||
unset($rules[$name]);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isset($extraRules[$name])) {
|
||||
$rules[$name] = array_merge($rules[$name], $extraRules[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
$attributes = collect($fields)->mapWithKeys(fn (array $f): array => [$f['name'] => mb_strtolower($f['label'])])->all();
|
||||
|
||||
return Validator::make($input, $rules, [], $attributes)->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $fields
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
private function rulesFor(array $fields, array $lookups): array
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$type = $field['type'] ?? 'text';
|
||||
$base = ($field['required'] ?? false) ? ['required'] : ['nullable'];
|
||||
|
||||
$rules[$field['name']] = array_merge($base, match (true) {
|
||||
$type === 'select' => ['integer', 'in:'.implode(',', array_keys($lookups[$field['lookup']]))],
|
||||
$type === 'number' => ['integer', 'min:'.($field['min'] ?? 0), 'max:'.($field['max'] ?? 99)],
|
||||
$type === 'date' => ['date_format:Y-m-d', 'before_or_equal:today'],
|
||||
$type === 'email' => ['string', 'email', 'max:'.$field['max']],
|
||||
default => array_values(array_filter([
|
||||
'string',
|
||||
'max:'.$field['max'],
|
||||
($field['alnum'] ?? false) ? 'regex:/^[0-9A-Za-z]+$/' : null,
|
||||
($field['digits'] ?? false) ? 'regex:/^[0-9]{4}$/' : null,
|
||||
])),
|
||||
});
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\Legacy;
|
||||
|
||||
use App\Support\Legacy\Concerns\BiodataFields;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Biodata lengkap pegawai DB lama (t_pegawai, dan t_dosen untuk dosen) untuk halaman detail operator: data pribadi, kontak
|
||||
* dan alamat, kepegawaian, pendidikan dan rekening, serta data dosen. Dibaca dan ditulis per bagian dalam cakupan yang sama
|
||||
* dengan daftar (EmployeeDirectory::scoped). Hanya kolom yang nilainya berubah yang ditulis. Akun login tidak disentuh dan
|
||||
* jenis pegawai (dosen atau staf) tidak diubah di sini.
|
||||
*/
|
||||
final class EmployeeBiodata
|
||||
{
|
||||
use BiodataFields;
|
||||
|
||||
/** Bagian yang ditulis ke t_dosen (bukan t_pegawai); hanya ada untuk pegawai yang punya baris t_dosen. */
|
||||
private const string DOSEN = 'dosen';
|
||||
|
||||
private const array ACTIVE = [1 => 'Aktif', 0 => 'Tidak aktif'];
|
||||
|
||||
/** @var array<string, array<int, string>>|null */
|
||||
private ?array $lookups = null;
|
||||
|
||||
/** @var list<int> */
|
||||
private array $prodi = [];
|
||||
|
||||
public function __construct(private readonly EmployeeDirectory $directory) {}
|
||||
|
||||
/**
|
||||
* Bagian halaman; lihat BiodataFields untuk arti isian.
|
||||
*
|
||||
* @return array<string, array{title: string, icon: string, description: string, fields: list<array<string, mixed>>}>
|
||||
*/
|
||||
public static function sections(): array
|
||||
{
|
||||
return [
|
||||
'pribadi' => [
|
||||
'title' => 'Data pribadi',
|
||||
'icon' => 'user',
|
||||
'description' => 'Nama, gelar, dan identitas diri.',
|
||||
'fields' => [
|
||||
['name' => 'nama', 'label' => 'Nama', 'type' => 'text', 'max' => 50, 'required' => true],
|
||||
['name' => 'gelardepan', 'label' => 'Gelar depan', 'type' => 'text', 'max' => 19, 'notnull' => true, 'affix' => 'front', 'placeholder' => 'Contoh: Dr. atau Prof. Dr.'],
|
||||
['name' => 'gelarbelakang', 'label' => 'Gelar belakang', 'type' => 'text', 'max' => 23, 'notnull' => true, 'affix' => 'back', 'placeholder' => 'Contoh: S.Kom., M.T. (tanpa koma di depan)'],
|
||||
['name' => 'kelamin', 'label' => 'Jenis kelamin', 'type' => 'select', 'lookup' => 'kelamin'],
|
||||
['name' => 'tempatlahir', 'label' => 'Tempat lahir', 'type' => 'text', 'max' => 60],
|
||||
['name' => 'tgllahir', 'label' => 'Tanggal lahir', 'type' => 'date'],
|
||||
['name' => 'agama', 'label' => 'Agama', 'type' => 'select', 'lookup' => 'agama'],
|
||||
['name' => 'no_id', 'label' => 'NIK', 'type' => 'text', 'max' => 16, 'alnum' => true],
|
||||
['name' => 'jmlistri', 'label' => 'Jumlah istri atau suami', 'type' => 'number', 'min' => 0, 'max' => 20, 'required' => true],
|
||||
['name' => 'jmlanak', 'label' => 'Jumlah anak', 'type' => 'number', 'min' => 0, 'max' => 30, 'required' => true],
|
||||
],
|
||||
],
|
||||
'kontak' => [
|
||||
'title' => 'Kontak dan alamat',
|
||||
'icon' => 'map-pin',
|
||||
'description' => 'Alamat tinggal dan cara menghubungi.',
|
||||
'fields' => [
|
||||
['name' => 'hp', 'label' => 'No. HP', 'type' => 'text', 'max' => 20],
|
||||
['name' => 'telepon', 'label' => 'Telepon', 'type' => 'text', 'max' => 15],
|
||||
['name' => 'email', 'label' => 'Email', 'type' => 'email', 'max' => 125],
|
||||
['name' => 'kodepos', 'label' => 'Kode pos', 'type' => 'text', 'max' => 5, 'alnum' => true],
|
||||
['name' => 'alamat', 'label' => 'Alamat', 'type' => 'textarea', 'max' => 255, 'wide' => true],
|
||||
],
|
||||
],
|
||||
'kepegawaian' => [
|
||||
'title' => 'Kepegawaian',
|
||||
'icon' => 'briefcase',
|
||||
'description' => 'Nomor induk, status, dan surat keputusan.',
|
||||
'fields' => [
|
||||
['name' => 'nip', 'label' => 'NIP', 'type' => 'text', 'max' => 20, 'required' => true],
|
||||
['name' => 'nipnasional', 'label' => 'NIP nasional', 'type' => 'text', 'max' => 30],
|
||||
['name' => 'nidn', 'label' => 'NIDN', 'type' => 'text', 'max' => 25],
|
||||
['name' => 'idstatuspegawai', 'label' => 'Status kepegawaian', 'type' => 'select', 'lookup' => 'status'],
|
||||
['name' => 'statusaktif', 'label' => 'Status aktif', 'type' => 'select', 'lookup' => 'aktif', 'required' => true, 'zero' => true],
|
||||
['name' => 'skpegawai', 'label' => 'No. SK pegawai', 'type' => 'text', 'max' => 30],
|
||||
['name' => 'tglskpegawai', 'label' => 'Tanggal SK pegawai', 'type' => 'date'],
|
||||
['name' => 'npwp', 'label' => 'NPWP', 'type' => 'text', 'max' => 20],
|
||||
['name' => 'no_bpjs', 'label' => 'No. BPJS', 'type' => 'text', 'max' => 20],
|
||||
],
|
||||
],
|
||||
'pendidikan' => [
|
||||
'title' => 'Pendidikan dan bank',
|
||||
'icon' => 'academic-cap',
|
||||
'description' => 'Pendidikan terakhir dan rekening gaji.',
|
||||
'fields' => [
|
||||
['name' => 'pendidikanterakhir', 'label' => 'Pendidikan terakhir', 'type' => 'select', 'lookup' => 'pendidikan'],
|
||||
['name' => 'idbank', 'label' => 'Bank', 'type' => 'select', 'lookup' => 'bank'],
|
||||
['name' => 'norekening', 'label' => 'No. rekening', 'type' => 'text', 'max' => 30],
|
||||
],
|
||||
],
|
||||
self::DOSEN => [
|
||||
'title' => 'Data dosen',
|
||||
'icon' => 'identification',
|
||||
'description' => 'Home base, pangkat, dan jabatan fungsional.',
|
||||
'fields' => [
|
||||
['name' => 'idprogdi', 'label' => 'Home base (program studi)', 'type' => 'select', 'lookup' => 'prodi', 'required' => true],
|
||||
['name' => 'idpangkatdosen', 'label' => 'Pangkat', 'type' => 'select', 'lookup' => 'pangkat', 'required' => true],
|
||||
['name' => 'idjabatanfungsional', 'label' => 'Jabatan fungsional', 'type' => 'select', 'lookup' => 'jabfung'],
|
||||
['name' => 'nomerpa', 'label' => 'Nomor PA', 'type' => 'text', 'max' => 10],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public static function sectionKeys(): array
|
||||
{
|
||||
return array_keys(self::sections());
|
||||
}
|
||||
|
||||
private function db(): ConnectionInterface
|
||||
{
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
/** Pilihan home base dibatasi pada program studi akun, jadi pilihan bergantung pada cakupan. */
|
||||
private function scope(array $prodi): void
|
||||
{
|
||||
if ($this->prodi !== $prodi) {
|
||||
$this->prodi = $prodi;
|
||||
$this->lookups = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pilihan select (kode => label). Kode 0 berarti "Tidak diisi" pada kolom yang memakainya di DB asli.
|
||||
*
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function lookups(): array
|
||||
{
|
||||
if ($this->lookups !== null) {
|
||||
return $this->lookups;
|
||||
}
|
||||
|
||||
$zero = fn (array $options): array => [0 => 'Tidak diisi'] + array_diff_key($options, [0 => true]);
|
||||
$names = fn (string $table, string $key, string $label, bool $upper = false): array => $this->db()->table($table)->orderBy($key)->pluck($label, $key)
|
||||
->mapWithKeys(fn (?string $name, int|string $id): array => [(int) $id => $upper ? ucfirst(trim((string) $name)) : trim((string) $name)])->all();
|
||||
|
||||
// Pendidikan terakhir pegawai memakai skala id_simalum (1 SMP, 2 SMA, 3 D1 ... 7 S1, 8 S2, 9 S3), bukan idtingkat.
|
||||
$education = $this->db()->table('t_tingkat_pendidikan')->where('id_simalum', '>', 0)->orderBy('id_simalum')->pluck('tingkatpendidikan', 'id_simalum')
|
||||
->mapWithKeys(fn (string $name, int|string $id): array => [(int) $id => trim($name)])->all();
|
||||
|
||||
return $this->lookups = [
|
||||
'kelamin' => EmployeeRecords::GENDER,
|
||||
'agama' => $zero($names('xs_agama', 'idagama', 'agama')),
|
||||
'aktif' => self::ACTIVE,
|
||||
'status' => $names('t_statuspegawai', 'idstatuspegawai', 'statuspegawai', true),
|
||||
'pendidikan' => $zero($education),
|
||||
'bank' => $names('t_bank', 'idbank', 'namabank'),
|
||||
'prodi' => $this->prodi === [] ? [] : $this->db()->table('t_bagian')->whereIn('idbagian', $this->prodi)->orderBy('namabagian')->pluck('namabagian', 'idbagian')
|
||||
->mapWithKeys(fn (string $name, int|string $id): array => [(int) $id => trim($name)])->all(),
|
||||
'pangkat' => $names('t_pangkatdosen', 'idpangkatdosen', 'pangkatdosen'),
|
||||
'jabfung' => $names('t_jabatanfungsional', 'idjabatanfungsional', 'jabatan'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $faculties
|
||||
*/
|
||||
public function exists(array $prodi, array $faculties, int $id): bool
|
||||
{
|
||||
return $this->directory->scoped($prodi, $faculties)->where('p.idpegawai', $id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Biodata satu pegawai dalam cakupan: per bagian, nilai isian dan teks tampil. Bagian dosen hanya untuk dosen.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $faculties
|
||||
* @return array{sections: array<string, array<string, mixed>>, extra: array<string, mixed>}|null
|
||||
*/
|
||||
public function find(array $prodi, array $faculties, int $id): ?array
|
||||
{
|
||||
$this->scope($prodi);
|
||||
$row = $this->row($prodi, $faculties, $id);
|
||||
if ($row === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$lookups = $this->lookups();
|
||||
$sections = [];
|
||||
foreach (self::sections() as $key => $section) {
|
||||
if ($key === self::DOSEN && $row->dosen_id === null) {
|
||||
continue;
|
||||
}
|
||||
$sections[$key] = $this->present($section, $row, $lookups) + ['key' => $key, 'title' => $section['title'], 'icon' => $section['icon'], 'description' => $section['description']];
|
||||
}
|
||||
|
||||
return ['sections' => $sections, 'extra' => $this->extra($row, $id)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Periksa isian satu bagian. NIP diperiksa tidak kembar dengan pegawai lain; home base hanya prodi akun.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $faculties
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function validated(array $prodi, array $faculties, int $id, string $key, array $input): array
|
||||
{
|
||||
$this->scope($prodi);
|
||||
$row = $this->row($prodi, $faculties, $id) ?? throw new PortalException('Pegawai tidak ditemukan.');
|
||||
if ($key === self::DOSEN && $row->dosen_id === null) {
|
||||
throw new PortalException('Pegawai ini bukan dosen.');
|
||||
}
|
||||
|
||||
$unique = function (string $attribute, mixed $value, \Closure $fail) use ($id): void {
|
||||
$nip = trim((string) $value);
|
||||
if ($this->db()->table('t_pegawai')->whereRaw('upper(trim(nip)) = ?', [mb_strtoupper($nip)])->where('idpegawai', '<>', $id)->exists()) {
|
||||
$fail("NIP {$nip} sudah terdaftar.");
|
||||
}
|
||||
};
|
||||
|
||||
return $this->validateFields(self::sections()[$key]['fields'], $row, $input, ['nip' => [$unique]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simpan satu bagian. Mengembalikan bagian yang sudah diperbarui (nilai isian + teks tampil) dan banyak kolom yang berubah.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $faculties
|
||||
* @param array<string, mixed> $input
|
||||
* @return array{section: array<string, mixed>, changed: int}
|
||||
*/
|
||||
public function update(array $prodi, array $faculties, int $id, string $key, array $input, string $actor, ?string $ip): array
|
||||
{
|
||||
$this->scope($prodi);
|
||||
$section = self::sections()[$key] ?? throw new PortalException('Bagian biodata tidak dikenal.');
|
||||
$row = $this->row($prodi, $faculties, $id) ?? throw new PortalException('Pegawai tidak ditemukan.');
|
||||
if ($key === self::DOSEN && $row->dosen_id === null) {
|
||||
throw new PortalException('Pegawai ini bukan dosen.');
|
||||
}
|
||||
$lookups = $this->lookups();
|
||||
|
||||
$changes = $this->changes($section['fields'], $row, $input, $lookups);
|
||||
if ($changes !== []) {
|
||||
$this->db()->table($key === self::DOSEN ? 't_dosen' : 't_pegawai')->where('idpegawai', $id)->update($changes + [
|
||||
'cname' => ActivityTypes::APP_NAME, 'cip' => $ip ?? '', 'uname' => mb_substr($actor, 0, 15), 'tanggal' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'section' => $this->present($section, $this->row($prodi, $faculties, $id), $lookups),
|
||||
'changed' => count($changes),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $faculties
|
||||
*/
|
||||
private function row(array $prodi, array $faculties, int $id): ?object
|
||||
{
|
||||
$columns = [];
|
||||
foreach (self::sections() as $key => $section) {
|
||||
foreach ($section['fields'] as $field) {
|
||||
$columns[] = ($key === self::DOSEN ? 'dd.' : 'p.').$field['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->directory->scoped($prodi, $faculties)
|
||||
->leftJoin('t_dosen as dd', 'dd.idpegawai', '=', 'p.idpegawai')
|
||||
->where('p.idpegawai', $id)
|
||||
->first(array_merge($columns, ['p.idjenispegawai', 'dd.idpegawai as dosen_id']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Keterangan yang hanya dibaca dan angka ringkasan: jenis pegawai, jabatan aktif, mahasiswa bimbingan, kelas diampu.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function extra(object $row, int $id): array
|
||||
{
|
||||
$type = $row->idjenispegawai === null ? null : $this->db()->table('t_jenispegawai')->where('idjenispegawai', $row->idjenispegawai)->value('jenispegawai');
|
||||
$positions = $this->db()->table('t_jabatanpegawai as jp')
|
||||
->join('t_jabatanbagian as jb', 'jb.idjabatanbagian', '=', 'jp.idjabatanbagian')
|
||||
->leftJoin('t_jenisjabatan as jj', 'jj.idjenisjabatan', '=', 'jb.idjenisjabatan')
|
||||
->leftJoin('t_bagian as b', 'b.idbagian', '=', 'jb.idbagian')
|
||||
->where('jp.idpegawai', $id)->where('jp.aktif', 1)->orderBy('jp.idjabatan')
|
||||
->get(['jj.namajabatan', 'b.namabagian'])
|
||||
->map(fn (object $p): string => trim(trim((string) $p->namajabatan).' '.trim((string) $p->namabagian)))
|
||||
->filter()->values();
|
||||
|
||||
return [
|
||||
'jenis' => filled($type) ? trim($type) : null,
|
||||
'dosen' => $row->dosen_id !== null,
|
||||
'jabatan' => $positions->all(),
|
||||
'bimbingan' => $this->count($this->db()->table('t_mahasiswa')->where('idpa', $id)->whereIn('stataktif', StudentDirectory::STATUS['aktif'])),
|
||||
'kelas' => $this->count($this->db()->table('t_jadwaldosen')->where('iddosen', $id), 'idjadwal'),
|
||||
];
|
||||
}
|
||||
|
||||
private function count(Builder $query, ?string $distinct = null): int
|
||||
{
|
||||
return $distinct === null ? $query->count() : $query->distinct()->count($distinct);
|
||||
}
|
||||
}
|
||||
@@ -108,12 +108,6 @@ final class EmployeeDirectory
|
||||
|
||||
return [
|
||||
'id' => (int) $p->idpegawai,
|
||||
'form' => [
|
||||
'nip' => $filled($p->nip) ?? '', 'nama' => trim((string) $p->nama), 'gelardepan' => trim((string) $p->gelardepan), 'gelarbelakang' => trim((string) $p->gelarbelakang),
|
||||
'kelamin' => (int) $p->kelamin ?: '', 'nidn' => $filled($p->nidn) ?? '', 'hp' => $filled($p->hp) ?? '', 'telepon' => $filled($p->telepon) ?? '',
|
||||
'email' => $filled($p->email) ?? '', 'status' => $p->idstatuspegawai === null ? '' : (int) $p->idstatuspegawai,
|
||||
'aktif' => (int) $p->statusaktif === self::INACTIVE ? 0 : 1,
|
||||
],
|
||||
'nip' => $filled($p->nip),
|
||||
'nama' => trim(($filled($p->gelardepan) ?? '').' '.trim($p->nama)).($suffix === null ? '' : ', '.ltrim($suffix, ', ')),
|
||||
'kelamin' => [1 => 'L', 2 => 'P'][(int) $p->kelamin] ?? null,
|
||||
|
||||
@@ -8,8 +8,8 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Tulis data pegawai DB lama (t_pegawai) dalam cakupan yang tampil di daftar operator (EmployeeDirectory::scoped).
|
||||
* Hanya ubah data dasar dan hapus (template SATU tidak punya tombol Tambah untuk Pegawai). Akun login
|
||||
* (t_account) tidak disentuh, dan pegawai yang dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun tidak boleh dihapus.
|
||||
* Tambah (sebagai dosen) dan hapus. Mengubah biodata dilakukan di halaman detail (EmployeeBiodata). Akun login (t_account)
|
||||
* tidak disentuh, dan pegawai yang dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun tidak boleh dihapus.
|
||||
*/
|
||||
final class EmployeeRecords
|
||||
{
|
||||
@@ -17,6 +17,9 @@ final class EmployeeRecords
|
||||
|
||||
public const array ACTIVE = [1 => 'Aktif', 0 => 'Tidak aktif'];
|
||||
|
||||
/** t_jenispegawai: 1 Dosen, 2 Staff. */
|
||||
private const int TYPE_LECTURER = 1;
|
||||
|
||||
/** [tabel, kolom rujukan ke idpegawai]; baris di salah satunya menghalangi penghapusan. */
|
||||
private const array DEPENDENTS = [
|
||||
['t_jabatanpegawai', 'idpegawai'], ['t_mastermk', 'idpegawai'], ['t_jadwaldosen', 'iddosen'], ['t_jadwal', 'idpegperkuliahan'],
|
||||
@@ -38,19 +41,26 @@ final class EmployeeRecords
|
||||
}
|
||||
|
||||
/**
|
||||
* Tambah pegawai baru sebagai dosen dengan home base salah satu prodi akun (t_dosen.idprogdi), sehingga langsung masuk
|
||||
* cakupan daftar. Pegawai staf (bukan dosen) hanya tampil di daftar lewat jabatan aktif, yang tidak diatur di sini.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $faculties
|
||||
* @param array<string, mixed> $input
|
||||
* @return int idpegawai baru
|
||||
*/
|
||||
public function update(array $prodi, array $faculties, int $id, array $input, string $actor, ?string $ip): void
|
||||
public function create(array $prodi, int $homeBase, array $input, string $actor, ?string $ip): int
|
||||
{
|
||||
$current = $this->owned($prodi, $faculties)->where('p.idpegawai', $id)->first(['p.idpegawai', 'p.statusaktif']);
|
||||
if ($current === null) {
|
||||
throw new PortalException('Pegawai tidak ditemukan.');
|
||||
if (! in_array($homeBase, $prodi, true)) {
|
||||
throw new PortalException('Home base harus dipilih dari program studi Anda.');
|
||||
}
|
||||
$values = $this->values($input, $current);
|
||||
$values = $this->values($input);
|
||||
|
||||
$this->db()->table('t_pegawai')->where('idpegawai', $id)->update($values + $this->audit($actor, $ip));
|
||||
return $this->db()->transaction(function () use ($values, $homeBase, $actor, $ip): int {
|
||||
$id = (int) $this->db()->table('t_pegawai')->insertGetId($values + ['idjenispegawai' => self::TYPE_LECTURER] + $this->audit($actor, $ip), 'idpegawai');
|
||||
$this->db()->table('t_dosen')->insert(['idpegawai' => $id, 'idprogdi' => $homeBase] + $this->audit($actor, $ip));
|
||||
|
||||
return $id;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +119,7 @@ final class EmployeeRecords
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function values(array $input, ?object $current): array
|
||||
private function values(array $input): array
|
||||
{
|
||||
$text = fn (mixed $v): ?string => ($v = trim((string) $v)) === '' ? null : $v;
|
||||
$nip = trim((string) ($input['nip'] ?? ''));
|
||||
@@ -117,9 +127,7 @@ final class EmployeeRecords
|
||||
if ($nip === '' || $nama === '') {
|
||||
throw new PortalException('NIP dan nama wajib diisi.');
|
||||
}
|
||||
$duplicate = $this->db()->table('t_pegawai')->whereRaw('upper(trim(nip)) = ?', [mb_strtoupper($nip)])
|
||||
->when($current !== null, fn (Builder $q) => $q->where('idpegawai', '<>', $current->idpegawai))->exists();
|
||||
if ($duplicate) {
|
||||
if ($this->db()->table('t_pegawai')->whereRaw('upper(trim(nip)) = ?', [mb_strtoupper($nip)])->exists()) {
|
||||
throw new PortalException("NIP {$nip} sudah terdaftar.");
|
||||
}
|
||||
$gender = filled($input['kelamin'] ?? null) ? (int) $input['kelamin'] : null;
|
||||
@@ -138,8 +146,6 @@ final class EmployeeRecords
|
||||
if (! isset(self::ACTIVE[$active])) {
|
||||
throw new PortalException('Status aktif tidak dikenal.');
|
||||
}
|
||||
// Kode aktif selain 0 dan 1 (mis. 2, 3, 5, 6) tidak ada artinya di sini: dibiarkan selama tetap dianggap aktif.
|
||||
$keep = $current !== null && (int) $current->statusaktif !== 0 ? (int) $current->statusaktif : 1;
|
||||
|
||||
return [
|
||||
'nip' => $nip,
|
||||
@@ -152,7 +158,7 @@ final class EmployeeRecords
|
||||
'telepon' => $text($input['telepon'] ?? null),
|
||||
'email' => $email,
|
||||
'idstatuspegawai' => $status,
|
||||
'statusaktif' => $active === 0 ? 0 : $keep,
|
||||
'statusaktif' => $active,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Support\Legacy;
|
||||
|
||||
use App\Support\Legacy\Concerns\BiodataFields;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
@@ -16,6 +16,8 @@ use Illuminate\Validation\ValidationException;
|
||||
*/
|
||||
final class StudentBiodata
|
||||
{
|
||||
use BiodataFields;
|
||||
|
||||
/** Kode pilihan tanpa tabel referensi di DB; arti kode diambil dari komentar kolom t_mahasiswa. */
|
||||
private const array MARITAL = [1 => 'Belum kawin', 2 => 'Kawin'];
|
||||
|
||||
@@ -185,21 +187,7 @@ final class StudentBiodata
|
||||
$row = $this->row($prodi, $id) ?? throw new PortalException('Mahasiswa tidak ditemukan.');
|
||||
$lookups = $this->lookups();
|
||||
|
||||
$changes = [];
|
||||
foreach ($section['fields'] as $field) {
|
||||
$name = $field['name'];
|
||||
if (! array_key_exists($name, $input)) {
|
||||
continue;
|
||||
}
|
||||
$new = $this->normalize($field, $input[$name], $lookups);
|
||||
if ($field['name'] === 'nama' && $new === null) {
|
||||
throw new PortalException('Nama wajib diisi.');
|
||||
}
|
||||
if ($new !== $this->normalize($field, $row->{$name}, $lookups)) {
|
||||
// Kolom wajib di DB asli (NOT NULL) tidak pernah diisi null.
|
||||
$changes[$name] = $new ?? (($field['type'] ?? '') === 'select' ? 0 : null);
|
||||
}
|
||||
}
|
||||
$changes = $this->changes($section['fields'], $row, $input, $lookups);
|
||||
|
||||
if ($changes !== []) {
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', $id)->update($changes + [
|
||||
@@ -225,46 +213,6 @@ final class StudentBiodata
|
||||
->first(array_merge(array_map(fn (string $c): string => 'm.'.$c, $columns), ['m.idpa', 'm.jalur_masuk', 'm.idkurikulum', 'm.stataktif', 'm.tgl_lulus']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Nilai isian (untuk formulir) dan teks tampil satu bagian.
|
||||
*
|
||||
* @param array<string, mixed> $section
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
* @return array{fields: list<array<string, mixed>>, values: array<string, mixed>, display: array<string, string>}
|
||||
*/
|
||||
private function present(array $section, object $row, array $lookups): array
|
||||
{
|
||||
$fields = [];
|
||||
$values = [];
|
||||
$display = [];
|
||||
|
||||
foreach ($section['fields'] as $field) {
|
||||
$name = $field['name'];
|
||||
$value = $this->normalize($field, $row->{$name}, $lookups);
|
||||
|
||||
if (($field['type'] ?? '') === 'select') {
|
||||
$options = $lookups[$field['lookup']];
|
||||
$current = (int) ($value ?? 0);
|
||||
// Kode yang tidak ada di tabel referensi tetap tampil dan bisa dipertahankan.
|
||||
$options += isset($options[$current]) ? [] : [$current => 'Kode '.$current];
|
||||
$field['options'] = $options;
|
||||
$values[$name] = $current;
|
||||
$display[$name] = $current === 0 ? '–' : $options[$current];
|
||||
} else {
|
||||
$values[$name] = $value ?? '';
|
||||
$display[$name] = match (true) {
|
||||
$value === null => '–',
|
||||
($field['type'] ?? '') === 'date' => Carbon::parse($value)->locale('id')->isoFormat('D MMMM YYYY'),
|
||||
default => (string) $value,
|
||||
};
|
||||
}
|
||||
|
||||
$fields[] = $field;
|
||||
}
|
||||
|
||||
return ['fields' => $fields, 'values' => $values, 'display' => $display];
|
||||
}
|
||||
|
||||
/**
|
||||
* Data akademik yang hanya dibaca: jalur masuk, kurikulum, dosen PA, tanggal lulus.
|
||||
*
|
||||
@@ -285,34 +233,7 @@ final class StudentBiodata
|
||||
}
|
||||
|
||||
/**
|
||||
* Nilai kolom dalam bentuk baku agar dua nilai bisa dibandingkan: teks dipangkas (kosong = null), tanggal Y-m-d,
|
||||
* angka integer, pilihan integer (kosong = 0 pada pilihan yang punya kode 0).
|
||||
*
|
||||
* @param array<string, mixed> $field
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
*/
|
||||
private function normalize(array $field, mixed $value, array $lookups): string|int|null
|
||||
{
|
||||
$type = $field['type'] ?? 'text';
|
||||
$text = is_scalar($value) ? trim((string) $value) : '';
|
||||
|
||||
return match ($type) {
|
||||
'select' => (function () use ($text, $field, $lookups): ?int {
|
||||
if ($text === '') {
|
||||
return isset($lookups[$field['lookup']][0]) ? 0 : null;
|
||||
}
|
||||
|
||||
return (int) $text;
|
||||
})(),
|
||||
'number' => $text === '' ? null : (int) $text,
|
||||
'date' => $text === '' ? null : substr($text, 0, 10),
|
||||
default => $text === '' ? null : $text,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Periksa isian satu bagian. Isian yang nilainya sama dengan yang tersimpan tidak diperiksa bentuknya (data lama
|
||||
* boleh tidak seragam) dan tidak ikut dikembalikan; kolom wajib selalu diperiksa.
|
||||
* Periksa isian satu bagian (hanya isian yang berubah diperiksa bentuknya; lihat BiodataFields::validateFields).
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param array<string, mixed> $input
|
||||
@@ -323,50 +244,7 @@ final class StudentBiodata
|
||||
public function validated(array $prodi, int $id, string $key, array $input): array
|
||||
{
|
||||
$row = $this->row($prodi, $id) ?? throw new PortalException('Mahasiswa tidak ditemukan.');
|
||||
$lookups = $this->lookups();
|
||||
$rules = $this->rules($key);
|
||||
|
||||
foreach (self::sections()[$key]['fields'] as $field) {
|
||||
$name = $field['name'];
|
||||
if (! ($field['required'] ?? false) && array_key_exists($name, $input)
|
||||
&& $this->normalize($field, $input[$name], $lookups) === $this->normalize($field, $row->{$name}, $lookups)) {
|
||||
unset($rules[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
return Validator::make($input, $rules, [], $this->attributes($key))->validate();
|
||||
}
|
||||
|
||||
/** @return array<string, list<string>> */
|
||||
private function rules(string $key): array
|
||||
{
|
||||
$lookups = $this->lookups();
|
||||
$rules = [];
|
||||
|
||||
foreach (self::sections()[$key]['fields'] as $field) {
|
||||
$type = $field['type'] ?? 'text';
|
||||
$base = ($field['required'] ?? false) ? ['required'] : ['nullable'];
|
||||
|
||||
$rules[$field['name']] = array_merge($base, match (true) {
|
||||
$type === 'select' => ['integer', 'in:'.implode(',', array_keys($lookups[$field['lookup']]))],
|
||||
$type === 'number' => ['integer', 'min:'.($field['min'] ?? 0), 'max:'.($field['max'] ?? 99)],
|
||||
$type === 'date' => ['date_format:Y-m-d', 'before_or_equal:today'],
|
||||
$type === 'email' => ['string', 'email', 'max:'.$field['max']],
|
||||
default => array_values(array_filter([
|
||||
'string',
|
||||
'max:'.$field['max'],
|
||||
($field['alnum'] ?? false) ? 'regex:/^[0-9A-Za-z]+$/' : null,
|
||||
($field['digits'] ?? false) ? 'regex:/^[0-9]{4}$/' : null,
|
||||
])),
|
||||
});
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/** @return array<string, string> */
|
||||
private function attributes(string $key): array
|
||||
{
|
||||
return collect(self::sections()[$key]['fields'])->mapWithKeys(fn (array $f): array => [$f['name'] => mb_strtolower($f['label'])])->all();
|
||||
return $this->validateFields(self::sections()[$key]['fields'], $row, $input);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -1048,11 +1048,11 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
}));
|
||||
|
||||
/*
|
||||
* Detail mahasiswa (Portal operator > Mahasiswa): biodata per bagian yang bisa diubah di tempat. Tiap bagian punya nilai
|
||||
* Detail mahasiswa dan pegawai (Portal operator): biodata per bagian yang bisa diubah di tempat. Tiap bagian punya nilai
|
||||
* isian (values) dan teks tampil (display); Simpan mengirim PUT JSON untuk satu bagian lalu memakai nilai segar dari server.
|
||||
* config: { tab, saveUrl ("__SECTION__"), token, values: { bagian: { kolom: nilai } }, display: { bagian: { kolom: teks } } }.
|
||||
*/
|
||||
Alpine.data('studentBiodata', (config) => ({
|
||||
Alpine.data('bioDetail', (config) => ({
|
||||
tab: config.tab,
|
||||
values: config.values,
|
||||
display: config.display,
|
||||
@@ -1061,8 +1061,12 @@ Alpine.data('studentBiodata', (config) => ({
|
||||
saving: false,
|
||||
reloading: false,
|
||||
|
||||
// Nama lengkap dari bagian pribadi: gelar depan + nama, gelar belakang setelah koma (mahasiswa tidak punya gelar)
|
||||
get nama() {
|
||||
return this.display.pribadi?.nama ?? '';
|
||||
const v = this.values.pribadi ?? {};
|
||||
const name = [String(v.gelardepan ?? '').trim(), String(v.nama ?? '').trim()].filter(Boolean).join(' ');
|
||||
const back = String(v.gelarbelakang ?? '').trim().replace(/^[,\s]+/, '');
|
||||
return back ? name + ', ' + back : name;
|
||||
},
|
||||
|
||||
// Inisial seperti ui.avatar: gelar bertitik dan bagian setelah koma dilewati
|
||||
@@ -1112,7 +1116,8 @@ Alpine.data('studentBiodata', (config) => ({
|
||||
return;
|
||||
}
|
||||
this.values[key] = data.values;
|
||||
this.display[key] = data.display;
|
||||
// Gabung: keterangan hanya-baca (bukan isian) di display tetap dipertahankan
|
||||
this.display[key] = { ...this.display[key], ...data.display };
|
||||
this.editing = null;
|
||||
window.toast('success', data.message);
|
||||
} catch (error) {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
{{--
|
||||
Navigasi bagian + panel biodata (lihat/ubah di tempat) untuk halaman detail operator. Dipakai di dalam elemen ber-x-data
|
||||
`bioDetail` (resources/js/app.js). $sections: bagian dari StudentBiodata/EmployeeBiodata (+ opsional `readonly`).
|
||||
--}}
|
||||
@props(['sections'])
|
||||
|
||||
<div class="bio">
|
||||
<x-glass.panel padding="sm" as="nav" class="bio__nav" aria-label="Bagian biodata">
|
||||
<div class="bio__tabs" role="tablist" aria-orientation="vertical">
|
||||
@foreach ($sections as $key => $section)
|
||||
<button type="button" role="tab" id="bio-tab-{{ $key }}" class="bio__tab" aria-controls="bio-panel-{{ $key }}" data-no-busy
|
||||
x-bind:aria-selected="tab === '{{ $key }}'" x-bind:tabindex="tab === '{{ $key }}' ? 0 : -1" x-on:click="show('{{ $key }}')">
|
||||
<x-dynamic-component :component="'heroicon-o-'.$section['icon']" />
|
||||
<span>{{ $section['title'] }}</span>
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
<div class="bio__panels">
|
||||
@foreach ($sections as $key => $section)
|
||||
<x-glass.panel padding="lg" as="section" role="tabpanel" id="bio-panel-{{ $key }}" aria-labelledby="bio-tab-{{ $key }}" x-ref="panel-{{ $key }}" x-show="tab === '{{ $key }}'" x-cloak>
|
||||
<div class="bio-head">
|
||||
<span class="bio-head__icon" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.$section['icon']" /></span>
|
||||
<div class="bio-head__text">
|
||||
<h2 class="bio-head__title">{{ $section['title'] }}</h2>
|
||||
<p class="bio-head__hint">{{ $section['description'] }}</p>
|
||||
</div>
|
||||
<x-ui.button variant="secondary" size="sm" icon="pencil-square" x-show="editing !== '{{ $key }}'" x-on:click="edit('{{ $key }}')">Ubah</x-ui.button>
|
||||
</div>
|
||||
|
||||
<dl class="bio-list" x-show="editing !== '{{ $key }}'">
|
||||
@foreach ($section['readonly'] ?? [] as $item)
|
||||
<div class="bio-list__item">
|
||||
<dt>{{ $item['label'] }}</dt>
|
||||
<dd x-text="display.{{ $key }}.{{ $item['name'] }}" x-bind:class="{ 'bio-list__empty': display.{{ $key }}.{{ $item['name'] }} === '–' }">{{ $section['display'][$item['name']] }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
@foreach ($section['fields'] as $field)
|
||||
<div @class(['bio-list__item', 'bio-list__item--wide' => $field['wide'] ?? false])>
|
||||
<dt>{{ $field['label'] }}</dt>
|
||||
<dd x-text="display.{{ $key }}.{{ $field['name'] }}" x-bind:class="{ 'bio-list__empty': display.{{ $key }}.{{ $field['name'] }} === '–' }">{{ $section['display'][$field['name']] }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
</dl>
|
||||
|
||||
<form class="satu-form bio-form" novalidate data-no-busy x-bind:aria-busy="saving" x-show="editing === '{{ $key }}'" x-cloak x-on:submit.prevent="save()" x-on:keydown.escape="cancel()">
|
||||
@foreach ($section['fields'] as $field)
|
||||
@php
|
||||
$type = $field['type'] ?? 'text';
|
||||
$id = 'bio_'.$field['name'];
|
||||
$wide = ($field['wide'] ?? false) ? 'col-span-full' : null;
|
||||
@endphp
|
||||
@if ($type === 'select')
|
||||
<x-form.select :name="$id" :label="$field['label']" :options="$field['options']" :placeholder="($field['blank'] ?? false) ? '' : null" :required="$field['required'] ?? false" x-model="form.{{ $field['name'] }}" />
|
||||
@elseif ($type === 'textarea')
|
||||
<x-form.textarea :name="$id" :label="$field['label']" :rows="3" :maxlength="$field['max']" :class="$wide" x-model="form.{{ $field['name'] }}" />
|
||||
@else
|
||||
<x-form.field :name="$id" :label="$field['label']" :type="$type" :maxlength="$type === 'number' ? null : ($field['max'] ?? null)" :min="$type === 'number' ? ($field['min'] ?? null) : null" :max="$type === 'number' ? ($field['max'] ?? null) : null" :required="$field['required'] ?? false" :placeholder="$field['placeholder'] ?? null" :class="$wide" x-model="form.{{ $field['name'] }}" />
|
||||
@endif
|
||||
@endforeach
|
||||
<div class="satu-form__actions">
|
||||
<x-ui.button type="submit" variant="primary" icon="check" x-bind:disabled="saving" x-bind:data-busy="saving ? '' : false" x-bind:aria-busy="saving"><span x-text="saving ? 'Menyimpan...' : 'Simpan'">Simpan</span></x-ui.button>
|
||||
<x-ui.button variant="secondary" data-no-busy x-bind:disabled="saving" x-on:click="cancel()">Batal</x-ui.button>
|
||||
</div>
|
||||
</form>
|
||||
</x-glass.panel>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@@ -20,7 +20,7 @@
|
||||
</x-slot:actions>
|
||||
</x-ui.page-header>
|
||||
|
||||
<div class="stack" x-data="studentBiodata(@js($config))">
|
||||
<div class="stack" x-data="bioDetail(@js($config))">
|
||||
<x-glass.panel padding="lg" as="section" aria-labelledby="mhs-nama">
|
||||
<div class="bio-hero">
|
||||
<span class="avatar avatar--xl" role="img" x-bind:aria-label="nama" x-text="initials">{{ \Illuminate\Support\Str::of($student['nama'])->before(',')->squish()->substr(0, 1)->upper() }}</span>
|
||||
@@ -47,69 +47,6 @@
|
||||
<x-ui.figure label="IPK" :value="$student['ipk'] === null ? '–' : number_format($student['ipk'], 2, ',', '')" hint="Indeks prestasi kumulatif" />
|
||||
</x-ui.figures>
|
||||
|
||||
<div class="bio">
|
||||
<x-glass.panel padding="sm" as="nav" class="bio__nav" aria-label="Bagian biodata">
|
||||
<div class="bio__tabs" role="tablist" aria-orientation="vertical">
|
||||
@foreach ($sections as $key => $section)
|
||||
<button type="button" role="tab" id="bio-tab-{{ $key }}" class="bio__tab" aria-controls="bio-panel-{{ $key }}" data-no-busy
|
||||
x-bind:aria-selected="tab === '{{ $key }}'" x-bind:tabindex="tab === '{{ $key }}' ? 0 : -1" x-on:click="show('{{ $key }}')">
|
||||
<x-dynamic-component :component="'heroicon-o-'.$section['icon']" />
|
||||
<span>{{ $section['title'] }}</span>
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
<div class="bio__panels">
|
||||
@foreach ($sections as $key => $section)
|
||||
<x-glass.panel padding="lg" as="section" role="tabpanel" id="bio-panel-{{ $key }}" aria-labelledby="bio-tab-{{ $key }}" x-ref="panel-{{ $key }}" x-show="tab === '{{ $key }}'" x-cloak>
|
||||
<div class="bio-head">
|
||||
<span class="bio-head__icon" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.$section['icon']" /></span>
|
||||
<div class="bio-head__text">
|
||||
<h2 class="bio-head__title">{{ $section['title'] }}</h2>
|
||||
<p class="bio-head__hint">{{ $section['description'] }}</p>
|
||||
</div>
|
||||
<x-ui.button variant="secondary" size="sm" icon="pencil-square" x-show="editing !== '{{ $key }}'" x-on:click="edit('{{ $key }}')">Ubah</x-ui.button>
|
||||
</div>
|
||||
|
||||
<dl class="bio-list" x-show="editing !== '{{ $key }}'">
|
||||
@foreach ($section['readonly'] ?? [] as $item)
|
||||
<div class="bio-list__item">
|
||||
<dt>{{ $item['label'] }}</dt>
|
||||
<dd x-text="display.{{ $key }}.{{ $item['name'] }}" x-bind:class="{ 'bio-list__empty': display.{{ $key }}.{{ $item['name'] }} === '–' }">{{ $section['display'][$item['name']] }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
@foreach ($section['fields'] as $field)
|
||||
<div @class(['bio-list__item', 'bio-list__item--wide' => $field['wide'] ?? false])>
|
||||
<dt>{{ $field['label'] }}</dt>
|
||||
<dd x-text="display.{{ $key }}.{{ $field['name'] }}" x-bind:class="{ 'bio-list__empty': display.{{ $key }}.{{ $field['name'] }} === '–' }">{{ $section['display'][$field['name']] }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
</dl>
|
||||
|
||||
<form class="satu-form bio-form" novalidate data-no-busy x-bind:aria-busy="saving" x-show="editing === '{{ $key }}'" x-cloak x-on:submit.prevent="save()" x-on:keydown.escape="cancel()">
|
||||
@foreach ($section['fields'] as $field)
|
||||
@php
|
||||
$type = $field['type'] ?? 'text';
|
||||
$id = 'bio_'.$field['name'];
|
||||
$wide = ($field['wide'] ?? false) ? 'col-span-full' : null;
|
||||
@endphp
|
||||
@if ($type === 'select')
|
||||
<x-form.select :name="$id" :label="$field['label']" :options="$field['options']" :required="$field['required'] ?? false" x-model="form.{{ $field['name'] }}" />
|
||||
@elseif ($type === 'textarea')
|
||||
<x-form.textarea :name="$id" :label="$field['label']" :rows="3" :maxlength="$field['max']" :class="$wide" x-model="form.{{ $field['name'] }}" />
|
||||
@else
|
||||
<x-form.field :name="$id" :label="$field['label']" :type="$type" :maxlength="$type === 'number' ? null : ($field['max'] ?? null)" :min="$type === 'number' ? ($field['min'] ?? null) : null" :max="$type === 'number' ? ($field['max'] ?? null) : null" :required="$field['required'] ?? false" :class="$wide" x-model="form.{{ $field['name'] }}" />
|
||||
@endif
|
||||
@endforeach
|
||||
<div class="satu-form__actions">
|
||||
<x-ui.button type="submit" variant="primary" icon="check" x-bind:disabled="saving" x-bind:data-busy="saving ? '' : false" x-bind:aria-busy="saving"><span x-text="saving ? 'Menyimpan...' : 'Simpan'">Simpan</span></x-ui.button>
|
||||
<x-ui.button variant="secondary" data-no-busy x-bind:disabled="saving" x-on:click="cancel()">Batal</x-ui.button>
|
||||
</div>
|
||||
</form>
|
||||
</x-glass.panel>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<x-satu.bio-sections :sections="$sections" />
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
{{--
|
||||
Detail pegawai (akun DB lama): ringkasan + biodata per bagian yang bisa diubah di tempat. Dibuka dari aksi Lihat di
|
||||
Portal > Pegawai. Bagian diatur EmployeeBiodata::sections(); bagian Data dosen hanya untuk dosen.
|
||||
--}}
|
||||
@php
|
||||
$config = [
|
||||
'tab' => 'pribadi',
|
||||
'saveUrl' => $saveUrl,
|
||||
'token' => csrf_token(),
|
||||
'values' => collect($sections)->map(fn (array $s): array => $s['values'])->all(),
|
||||
'display' => collect($sections)->map(fn (array $s): array => $s['display'])->all(),
|
||||
];
|
||||
$kep = $sections['kepegawaian']['values'];
|
||||
$initial = \Illuminate\Support\Str::of($sections['pribadi']['values']['nama'])->squish()->substr(0, 1)->upper();
|
||||
@endphp
|
||||
|
||||
<x-layouts.app :title="'Pegawai '.$name">
|
||||
<x-ui.page-header title="Detail Pegawai" description="Biodata lengkap pegawai. Pilih bagian biodata, lalu ubah langsung di halaman ini." :breadcrumbs="$crumbs">
|
||||
<x-slot:actions>
|
||||
<x-ui.button variant="secondary" size="sm" :href="$back" icon="arrow-left">Kembali ke daftar</x-ui.button>
|
||||
</x-slot:actions>
|
||||
</x-ui.page-header>
|
||||
|
||||
<div class="stack" x-data="bioDetail(@js($config))">
|
||||
<x-glass.panel padding="lg" as="section" aria-labelledby="peg-nama">
|
||||
<div class="bio-hero">
|
||||
<span class="avatar avatar--xl" role="img" x-bind:aria-label="nama" x-text="initials">{{ $initial }}</span>
|
||||
<div class="bio-hero__id">
|
||||
<h2 id="peg-nama" class="bio-hero__name" x-text="nama">{{ $name }}</h2>
|
||||
<p class="bio-hero__nim" x-text="values.kepegawaian.nip">{{ $kep['nip'] }}</p>
|
||||
<p class="bio-hero__prodi" x-text="display.dosen?.idprogdi ?? 'Staf'">{{ $sections['dosen']['display']['idprogdi'] ?? 'Staf' }}</p>
|
||||
</div>
|
||||
<div class="cluster cluster--sm">
|
||||
<x-ui.badge tone="accent">{{ $extra['jenis'] ?? 'Pegawai' }}</x-ui.badge>
|
||||
<span class="badge" x-bind:class="values.kepegawaian.statusaktif === 0 ? 'badge--danger' : 'badge--success'" x-text="values.kepegawaian.statusaktif === 0 ? 'Tidak aktif' : 'Aktif'">{{ $kep['statusaktif'] === 0 ? 'Tidak aktif' : 'Aktif' }}</span>
|
||||
<span class="badge" x-show="display.kepegawaian.idstatuspegawai !== '–'" x-text="display.kepegawaian.idstatuspegawai" @if ($sections['kepegawaian']['display']['idstatuspegawai'] === '–') style="display: none" @endif>{{ $sections['kepegawaian']['display']['idstatuspegawai'] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
<x-ui.figures label="Ringkasan kepegawaian">
|
||||
<x-ui.figure label="Mahasiswa bimbingan" :value="$extra['bimbingan']" hint="Mahasiswa aktif sebagai dosen PA" />
|
||||
<x-ui.figure label="Kelas diampu" :value="$extra['kelas']" hint="Kelas yang tercatat" />
|
||||
<x-ui.figure label="Jabatan aktif" :value="count($extra['jabatan'])" hint="Jabatan saat ini" />
|
||||
</x-ui.figures>
|
||||
|
||||
<x-satu.bio-sections :sections="$sections" />
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
@@ -5,6 +5,7 @@
|
||||
columns: [['key', 'label', 'num' => bool, 'badge' => bool]]; kolom badge memakai row.{key} dan nada row.tone.
|
||||
filters: [['name', 'label', 'options' => [], 'value' => bawaan]] atau ['name', 'label', 'type' => 'check'].
|
||||
Opsional: $tools (kunci tombol bilah yang boleh tampil, [] = tanpa tombol), $selectable (false = tanpa kotak centang),
|
||||
$editable (false = tanpa aksi Ubah di baris; $form hanya untuk Tambah),
|
||||
$viewUrl (aksi Lihat, "__ID__" diganti row.id), $destroyUrl + $destroy['title'|'message'] (Hapus sungguhan
|
||||
lewat POST {ids}); $form = ['title', 'storeUrl', 'updateUrl' ("__ID__"), 'fields' => [['name', 'label', 'type' =>
|
||||
text|number|date|select, 'options', 'required', 'max', 'min', 'hint', 'multiple', 'default']]] untuk Tambah/Ubah lewat
|
||||
@@ -16,6 +17,7 @@
|
||||
$destroyUrl ??= null;
|
||||
$form ??= null;
|
||||
$selectable ??= true;
|
||||
$editable ??= true;
|
||||
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
|
||||
$allTools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', 'startInsert()'],
|
||||
@@ -43,7 +45,7 @@
|
||||
'data' => $data,
|
||||
'viewUrl' => $viewUrl,
|
||||
'destroyUrl' => $destroyUrl,
|
||||
'form' => $form ? ['storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'], 'fields' => array_map(fn (array $f): array => ['name' => $f['name'], 'default' => $f['default'] ?? (($f['multiple'] ?? false) ? [] : '')], $form['fields'])] : null,
|
||||
'form' => $form ? ['storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'] ?? null, 'fields' => array_map(fn (array $f): array => ['name' => $f['name'], 'default' => $f['default'] ?? (($f['multiple'] ?? false) ? [] : '')], $form['fields'])] : null,
|
||||
'columns' => collect($columns)->map(fn (array $c): array => ['key' => $c['key'], 'label' => $c['label']])->values()->all(),
|
||||
'token' => csrf_token(),
|
||||
];
|
||||
@@ -129,7 +131,7 @@
|
||||
@else
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="startView(row)" />
|
||||
@endif
|
||||
@if ($form)
|
||||
@if ($form && $editable)
|
||||
<template x-if="row.form">
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
</template>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use App\Http\Controllers\Operator\AdministrasiController;
|
||||
use App\Http\Controllers\Operator\DashboardController;
|
||||
use App\Http\Controllers\Operator\DataPelengkapController;
|
||||
use App\Http\Controllers\Operator\EmployeeDetailController;
|
||||
use App\Http\Controllers\Operator\EmployeeListController;
|
||||
use App\Http\Controllers\Operator\GrupMkController;
|
||||
use App\Http\Controllers\Operator\JadwalController;
|
||||
@@ -66,8 +67,11 @@ Route::get('list_pegawai/data', [EmployeeListController::class, 'data'])->name('
|
||||
// Detail mahasiswa (aksi Lihat): biodata dan data akademik, simpan per bagian. Daftar hanya baca.
|
||||
Route::get('list_mahasiswa/{id}', [StudentDetailController::class, 'show'])->whereNumber('id')->name('list-mahasiswa.show');
|
||||
Route::put('list_mahasiswa/{id}/biodata/{section}', [StudentDetailController::class, 'update'])->whereNumber('id')->whereAlpha('section')->name('list-mahasiswa.biodata');
|
||||
Route::post('list_pegawai', [EmployeeListController::class, 'store'])->name('list-pegawai.store');
|
||||
Route::post('list_pegawai/hapus', [EmployeeListController::class, 'destroy'])->name('list-pegawai.destroy');
|
||||
Route::put('list_pegawai/{id}', [EmployeeListController::class, 'update'])->whereNumber('id')->name('list-pegawai.update');
|
||||
// Detail pegawai (aksi Lihat): biodata lengkap per bagian, simpan per bagian.
|
||||
Route::get('list_pegawai/{id}', [EmployeeDetailController::class, 'show'])->whereNumber('id')->name('list-pegawai.show');
|
||||
Route::put('list_pegawai/{id}/biodata/{section}', [EmployeeDetailController::class, 'update'])->whereNumber('id')->whereAlpha('section')->name('list-pegawai.biodata');
|
||||
|
||||
// Portal > Konsultasi, Kegiatan Akademik, Kalender Akademik untuk akun DB lama (halaman tetap operator.halaman {slug}).
|
||||
Route::get('list_konsultasi/data', [KonsultasiController::class, 'data'])->name('konsultasi.data');
|
||||
|
||||
@@ -84,6 +84,17 @@ trait FakesLegacyDatabase
|
||||
$table->smallInteger('statusaktif')->default(1);
|
||||
$table->smallInteger('idstatuspegawai')->nullable();
|
||||
$table->smallInteger('idjenispegawai')->nullable();
|
||||
// Biodata pegawai (halaman detail pegawai); kolom NOT NULL di DB asli bernilai bawaan 0.
|
||||
foreach (['tempatlahir' => 60, 'no_id' => 16, 'alamat' => 255, 'kodepos' => 5, 'norekening' => 30, 'skpegawai' => 30, 'npwp' => 20, 'no_bpjs' => 20] as $column => $length) {
|
||||
$table->string($column, $length)->nullable();
|
||||
}
|
||||
$table->date('tgllahir')->nullable();
|
||||
$table->date('tglskpegawai')->nullable();
|
||||
$table->smallInteger('agama')->nullable();
|
||||
$table->integer('idbank')->nullable();
|
||||
$table->smallInteger('jmlistri')->default(0);
|
||||
$table->smallInteger('jmlanak')->default(0);
|
||||
$table->smallInteger('pendidikanterakhir')->default(0);
|
||||
$table->string('cname', 20)->nullable();
|
||||
$table->string('cip', 20)->nullable();
|
||||
$table->string('uname', 15)->nullable();
|
||||
@@ -499,6 +510,8 @@ trait FakesLegacyDatabase
|
||||
$schema->create('t_dosen', function (Blueprint $table) {
|
||||
$table->integer('idpegawai')->primary();
|
||||
$table->integer('idjabatanfungsional')->nullable();
|
||||
$table->smallInteger('idpangkatdosen')->default(1);
|
||||
$table->string('nomerpa', 10)->nullable();
|
||||
$table->integer('idprogdi')->nullable();
|
||||
$table->string('cname', 20)->nullable();
|
||||
$table->string('cip', 20)->nullable();
|
||||
@@ -512,6 +525,7 @@ trait FakesLegacyDatabase
|
||||
$schema->create('t_jabatanbagian', function (Blueprint $table) {
|
||||
$table->integer('idjabatanbagian')->primary();
|
||||
$table->integer('idbagian');
|
||||
$table->integer('idjenisjabatan')->nullable();
|
||||
});
|
||||
$schema->create('t_jabatanpegawai', function (Blueprint $table) {
|
||||
$table->increments('idjabatan');
|
||||
@@ -578,6 +592,11 @@ trait FakesLegacyDatabase
|
||||
$schema->create('t_tingkat_pendidikan', function (Blueprint $table) {
|
||||
$table->integer('idtingkat')->primary();
|
||||
$table->string('tingkatpendidikan');
|
||||
$table->integer('id_simalum')->nullable();
|
||||
});
|
||||
$schema->create('t_bank', function (Blueprint $table) {
|
||||
$table->integer('idbank')->primary();
|
||||
$table->string('namabank');
|
||||
});
|
||||
$schema->create('xs_agama', function (Blueprint $table) {
|
||||
$table->smallInteger('idagama')->primary();
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Support\Legacy\EmployeeBiodata;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Portal > Pegawai: tambah pegawai, serta halaman detail dengan biodata per bagian yang bisa diubah (data asli DB lama).
|
||||
* Akun staf fakultas memegang prodi 21 dan 22 (fakultas 5). Dalam cakupan: 11 Siti (dosen prodi 21), 20 Andi (dosen prodi 22),
|
||||
* 21 Dewi (staf, jabatan aktif), 24 Lina (dosen prodi 21). Di luar: 22 (dosen prodi 99) dan 23 (jabatan tidak aktif).
|
||||
*/
|
||||
class LegacyEmployeeDetailTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyOverview();
|
||||
$this->seedLegacyEmployees();
|
||||
$this->seedReferences();
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
||||
->assertRedirect(route('operator.dashboard'));
|
||||
}
|
||||
|
||||
private function db(): ConnectionInterface
|
||||
{
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
private function seedReferences(): void
|
||||
{
|
||||
$this->db()->table('xs_agama')->insertOrIgnore([['idagama' => 1, 'agama' => 'Islam'], ['idagama' => 2, 'agama' => 'Katolik']]);
|
||||
$this->db()->table('t_tingkat_pendidikan')->insertOrIgnore([
|
||||
['idtingkat' => 8, 'tingkatpendidikan' => 'Sarjana / S1', 'id_simalum' => 7], ['idtingkat' => 9, 'tingkatpendidikan' => 'Magister / S2', 'id_simalum' => 8],
|
||||
['idtingkat' => 10, 'tingkatpendidikan' => 'Doktor / S3', 'id_simalum' => 9],
|
||||
]);
|
||||
$this->db()->table('t_bank')->insert([['idbank' => 1, 'namabank' => '-'], ['idbank' => 3, 'namabank' => 'Bank Kalbar']]);
|
||||
$this->db()->table('t_pangkatdosen')->insertOrIgnore([['idpangkatdosen' => 1, 'pangkatdosen' => 'Tanpa Pangkat'], ['idpangkatdosen' => 36, 'pangkatdosen' => 'Pembina']]);
|
||||
$this->db()->table('t_jabatanfungsional')->insertOrIgnore([['idjabatanfungsional' => 1, 'jabatan' => '-'], ['idjabatanfungsional' => 3, 'jabatan' => 'Lektor']]);
|
||||
$this->db()->table('t_jenispegawai')->insertOrIgnore([['idjenispegawai' => 1, 'jenispegawai' => 'Dosen'], ['idjenispegawai' => 2, 'jenispegawai' => 'Staff']]);
|
||||
$this->db()->table('t_jenisjabatan')->insertOrIgnore(['idjenisjabatan' => 5, 'namajabatan' => 'Dekan', 'urut' => 2]);
|
||||
$this->db()->table('t_jabatanbagian')->where('idjabatanbagian', 1)->update(['idjenisjabatan' => 5]);
|
||||
$this->db()->table('t_bagian')->insertOrIgnore(['idbagian' => 5, 'idbagian_induk' => 0, 'idjenisbagian' => 1, 'namabagian' => 'Fakultas Teknik']);
|
||||
|
||||
$this->db()->table('t_pegawai')->where('idpegawai', 11)->update([
|
||||
'gelardepan' => 'Dr.', 'tempatlahir' => 'Pontianak', 'tgllahir' => '1975-01-01', 'agama' => 1, 'no_id' => '6171000000000011', 'jmlistri' => 1, 'jmlanak' => 2,
|
||||
'alamat' => 'Jl. Imam Bonjol No. 5', 'kodepos' => '78124', 'idjenispegawai' => 1, 'pendidikanterakhir' => 9, 'idbank' => 3, 'norekening' => '1234567',
|
||||
'skpegawai' => 'SK/001', 'tglskpegawai' => '2000-03-01', 'nipnasional' => '197501012000031002', 'npwp' => '12.345.678.9-012.000',
|
||||
]);
|
||||
$this->db()->table('t_dosen')->where('idpegawai', 11)->update(['idpangkatdosen' => 36, 'idjabatanfungsional' => 3, 'nomerpa' => 'PA-11']);
|
||||
$this->db()->table('t_pegawai')->where('idpegawai', 21)->update(['idjenispegawai' => 2]);
|
||||
$this->db()->table('t_jadwaldosen')->insert([['idjadwal' => 1, 'iddosen' => 11], ['idjadwal' => 2, 'iddosen' => 11]]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function pribadi(array $override = []): array
|
||||
{
|
||||
return $override + [
|
||||
'nama' => 'Siti Aminah', 'gelardepan' => 'Dr.', 'gelarbelakang' => 'M.Pd.', 'kelamin' => 2, 'tempatlahir' => 'Pontianak', 'tgllahir' => '1975-01-01',
|
||||
'agama' => 1, 'no_id' => '6171000000000011', 'jmlistri' => 1, 'jmlanak' => 2,
|
||||
];
|
||||
}
|
||||
|
||||
private function save(int $id, string $section, array $input)
|
||||
{
|
||||
return $this->putJson(route('operator.list-pegawai.biodata', [$id, $section]), $input);
|
||||
}
|
||||
|
||||
private function row(int $id): object
|
||||
{
|
||||
return $this->db()->table('t_pegawai')->where('idpegawai', $id)->first();
|
||||
}
|
||||
|
||||
public function test_guests_and_other_roles_are_kept_out(): void
|
||||
{
|
||||
$this->post(route('logout'));
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertRedirect(route('login'));
|
||||
$this->put(route('operator.list-pegawai.biodata', [11, 'pribadi']))->assertRedirect(route('login'));
|
||||
$this->post(route('operator.list-pegawai.store'))->assertRedirect(route('login'));
|
||||
|
||||
Auth::forgetGuards();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
$this->actingAs(User::factory()->dosen()->create());
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertForbidden();
|
||||
$this->save(11, 'pribadi', $this->pribadi(['nama' => 'Diubah']))->assertForbidden();
|
||||
$this->post(route('operator.list-pegawai.store'), ['nip' => '1', 'nama' => 'X'])->assertForbidden();
|
||||
$this->assertSame('Siti Aminah', $this->row(11)->nama);
|
||||
}
|
||||
|
||||
public function test_demo_operator_has_no_detail_page(): void
|
||||
{
|
||||
$this->post(route('logout'));
|
||||
Auth::forgetGuards();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
$this->actingAs(User::factory()->operator()->create());
|
||||
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertNotFound();
|
||||
$this->save(11, 'pribadi', $this->pribadi())->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_list_has_only_add_delete_and_view_and_no_edit_route(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_pegawai'))->assertOk()
|
||||
->assertSee('startInsert()', false)->assertSee('remove()', false)->assertSee('askRemove([row.id])', false)
|
||||
->assertSee('Home base (program studi)')->assertSee('link(row)', false)->assertDontSee('startView(row)', false)
|
||||
// Tanpa Cetak dan tanpa Ubah di baris: biodata diubah di halaman detail.
|
||||
->assertDontSee('window.print()', false)->assertDontSee('startEdit(row)', false);
|
||||
$this->assertFalse(Route::has('operator.list-pegawai.update'), 'Ubah lewat daftar sudah dihapus.');
|
||||
}
|
||||
|
||||
public function test_detail_page_shows_the_biodata_sections_of_a_lecturer(): void
|
||||
{
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertOk()
|
||||
->assertSeeInOrder(['<h1', 'Detail Pegawai'], false)->assertSee('bioDetail', false)
|
||||
->assertSee('Dr. Siti Aminah, M.Pd.')->assertSee('197501012000031002')->assertSee('Dosen')
|
||||
// Bagian khusus pegawai
|
||||
->assertSee('Data pribadi')->assertSee('Kontak dan alamat')->assertSee('Kepegawaian')->assertSee('Pendidikan dan bank')->assertSee('Data dosen')
|
||||
->assertSee('Pontianak')->assertSee('1 Januari 1975')->assertSee('Islam')->assertSee('Jl. Imam Bonjol No. 5')->assertSee('78124')
|
||||
->assertSee('Tetap')->assertSee('SK/001')->assertSee('Magister / S2')->assertSee('Bank Kalbar')->assertSee('1234567')
|
||||
->assertSee('Pembina')->assertSee('Lektor')->assertSee('PA-11')
|
||||
// Ringkasan: 11 membimbing mahasiswa 500 dan memiliki dua kelas
|
||||
->assertSee('Mahasiswa bimbingan')->assertSee('Kelas diampu')->assertSee('Jabatan aktif')
|
||||
->assertSee('x-on:submit.prevent="save()"', false)
|
||||
->assertDontSee('Orang tua')->assertDontSee('Asal sekolah');
|
||||
}
|
||||
|
||||
public function test_staff_has_no_lecturer_section_and_shows_active_positions(): void
|
||||
{
|
||||
$this->get(route('operator.list-pegawai.show', 21))->assertOk()
|
||||
->assertSee('Dewi Kartika')->assertSee('Staff')->assertSee('Dekan Fakultas Teknik')
|
||||
->assertDontSee('Data dosen')->assertDontSee('Home base (program studi)');
|
||||
|
||||
$this->save(21, 'dosen', ['idprogdi' => 21, 'idpangkatdosen' => 1])->assertStatus(422)->assertJsonPath('message', 'Pegawai ini bukan dosen.');
|
||||
}
|
||||
|
||||
public function test_detail_of_employees_out_of_scope_is_not_found(): void
|
||||
{
|
||||
foreach ([22, 23, 9999] as $id) {
|
||||
$this->get(route('operator.list-pegawai.show', $id))->assertNotFound();
|
||||
$this->save($id, 'pribadi', $this->pribadi(['nama' => 'Diretas']))->assertNotFound();
|
||||
}
|
||||
$this->save(11, 'rahasia', $this->pribadi())->assertNotFound();
|
||||
$this->assertSame('Joko Prodi Lain', $this->row(22)->nama);
|
||||
}
|
||||
|
||||
public function test_saving_a_section_writes_only_changed_columns(): void
|
||||
{
|
||||
$response = $this->save(11, 'pribadi', $this->pribadi(['nama' => 'Siti Aminah Putri', 'tempatlahir' => 'Sambas', 'agama' => 2, 'jmlanak' => 3, 'gelarbelakang' => '']))
|
||||
->assertOk()->assertJsonPath('message', 'Biodata diperbarui.');
|
||||
|
||||
$row = $this->row(11);
|
||||
$this->assertSame(['Siti Aminah Putri', 'Sambas', 2, 3, ''], [$row->nama, $row->tempatlahir, (int) $row->agama, (int) $row->jmlanak, $row->gelarbelakang]);
|
||||
$this->assertSame(['Dr.', '6171000000000011', 'SIAKAD', '198001012005011'], [$row->gelardepan, $row->no_id, $row->cname, $row->uname]);
|
||||
$response->assertJsonPath('display.nama', 'Siti Aminah Putri')->assertJsonPath('display.agama', 'Katolik')->assertJsonPath('display.tgllahir', '1 Januari 1975')
|
||||
->assertJsonPath('values.agama', 2)->assertJsonPath('values.gelarbelakang', '');
|
||||
|
||||
// Tanpa perubahan tidak ada yang ditulis.
|
||||
$before = $this->row(11);
|
||||
$this->save(11, 'pribadi', $this->pribadi(['nama' => 'Siti Aminah Putri', 'tempatlahir' => 'Sambas', 'agama' => 2, 'jmlanak' => 3, 'gelarbelakang' => '']))->assertOk()->assertJsonPath('message', 'Tidak ada perubahan.');
|
||||
$this->assertEquals($before, $this->row(11));
|
||||
}
|
||||
|
||||
public function test_academic_titles_are_written_without_typing_the_separator(): void
|
||||
{
|
||||
// Data lama: gelar belakang berawalan ", " dan gelar depan berspasi penutup. Formulir menampilkannya tanpa pemisah.
|
||||
$this->db()->table('t_pegawai')->where('idpegawai', 11)->update(['gelardepan' => 'Drs. ', 'gelarbelakang' => ', M.Pd']);
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertOk()
|
||||
->assertSee('Drs. Siti Aminah, M.Pd');
|
||||
$pribadi = app(EmployeeBiodata::class)->find([21, 22], [5], 11)['sections']['pribadi'];
|
||||
$this->assertSame(['Drs.', 'M.Pd'], [$pribadi['values']['gelardepan'], $pribadi['values']['gelarbelakang']]);
|
||||
$this->assertSame(['Drs.', 'M.Pd'], [$pribadi['display']['gelardepan'], $pribadi['display']['gelarbelakang']]);
|
||||
|
||||
// Dikirim apa adanya (tanpa koma) dan tidak berubah: kolom lama tidak ditulis ulang.
|
||||
$this->save(11, 'pribadi', $this->pribadi(['gelardepan' => 'Drs.', 'gelarbelakang' => 'M.Pd']))->assertOk()->assertJsonPath('message', 'Tidak ada perubahan.');
|
||||
$this->assertSame(['Drs. ', ', M.Pd'], [$this->row(11)->gelardepan, $this->row(11)->gelarbelakang]);
|
||||
|
||||
// Gelar baru ditulis tanpa koma: pemisah ditambahkan otomatis, sesuai konvensi DB lama.
|
||||
$this->save(11, 'pribadi', $this->pribadi(['gelardepan' => 'Prof. Dr.', 'gelarbelakang' => 'S.Kom., M.T.']))->assertOk()
|
||||
->assertJsonPath('values.gelardepan', 'Prof. Dr.')->assertJsonPath('values.gelarbelakang', 'S.Kom., M.T.');
|
||||
$this->assertSame(['Prof. Dr. ', ', S.Kom., M.T.'], [$this->row(11)->gelardepan, $this->row(11)->gelarbelakang]);
|
||||
|
||||
// Koma yang terlanjur diketik tidak digandakan.
|
||||
$this->save(11, 'pribadi', $this->pribadi(['gelardepan' => 'Dr.', 'gelarbelakang' => ', M.T.']))->assertOk();
|
||||
$this->assertSame(['Dr. ', ', M.T.'], [$this->row(11)->gelardepan, $this->row(11)->gelarbelakang]);
|
||||
|
||||
// Dikosongkan: kolom NOT NULL berisi string kosong, tanpa koma tersisa.
|
||||
$this->save(11, 'pribadi', $this->pribadi(['gelardepan' => '', 'gelarbelakang' => '']))->assertOk();
|
||||
$this->assertSame(['', ''], [$this->row(11)->gelardepan, $this->row(11)->gelarbelakang]);
|
||||
}
|
||||
|
||||
public function test_each_section_can_be_saved(): void
|
||||
{
|
||||
$this->save(11, 'kontak', ['hp' => '0812999', 'telepon' => null, 'email' => 'siti.baru@untan.ac.id', 'kodepos' => '78000', 'alamat' => "Jl. Baru\nNo. 2"])->assertOk();
|
||||
$this->save(11, 'kepegawaian', ['nip' => '197501012000031002', 'nipnasional' => null, 'nidn' => '0001017599', 'idstatuspegawai' => 3, 'statusaktif' => 0, 'skpegawai' => 'SK/002', 'tglskpegawai' => '2001-01-01', 'npwp' => null, 'no_bpjs' => '000111'])->assertOk();
|
||||
$this->save(11, 'pendidikan', ['pendidikanterakhir' => 9, 'idbank' => 1, 'norekening' => '999'])->assertOk();
|
||||
$this->save(11, 'dosen', ['idprogdi' => 22, 'idpangkatdosen' => 1, 'idjabatanfungsional' => null, 'nomerpa' => 'PA-99'])->assertOk();
|
||||
|
||||
$p = $this->row(11);
|
||||
$this->assertSame(['0812999', 'siti.baru@untan.ac.id', '78000', "Jl. Baru\nNo. 2"], [$p->hp, $p->email, $p->kodepos, $p->alamat]);
|
||||
$this->assertSame(['0001017599', 3, 0, 'SK/002', '2001-01-01', null, '000111'], [$p->nidn, (int) $p->idstatuspegawai, (int) $p->statusaktif, $p->skpegawai, $p->tglskpegawai, $p->nipnasional, $p->no_bpjs]);
|
||||
$this->assertSame([9, 1, '999'], [(int) $p->pendidikanterakhir, (int) $p->idbank, $p->norekening]);
|
||||
$d = $this->db()->table('t_dosen')->where('idpegawai', 11)->first();
|
||||
$this->assertSame([22, 1, null, 'PA-99', 'SIAKAD'], [(int) $d->idprogdi, (int) $d->idpangkatdosen, $d->idjabatanfungsional, $d->nomerpa, $d->cname]);
|
||||
// Bagian lain tidak terpengaruh.
|
||||
$this->assertSame(['Siti Aminah', 'Pontianak'], [$p->nama, $p->tempatlahir]);
|
||||
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertOk()->assertSee('Tidak aktif')->assertSee('Doktor / S3')->assertSee('Teknik Sipil');
|
||||
}
|
||||
|
||||
public function test_input_is_validated(): void
|
||||
{
|
||||
$this->save(11, 'pribadi', ['nama' => ''])->assertStatus(422)->assertJsonValidationErrors(['nama', 'jmlistri', 'jmlanak']);
|
||||
$this->save(11, 'pribadi', $this->pribadi(['nama' => str_repeat('A', 51), 'agama' => 9, 'kelamin' => 7, 'tgllahir' => 'kemarin']))->assertStatus(422)->assertJsonValidationErrors(['nama', 'agama', 'kelamin', 'tgllahir']);
|
||||
$this->save(11, 'pribadi', $this->pribadi(['tgllahir' => now()->addDay()->toDateString(), 'no_id' => '61 71-00', 'jmlanak' => 99]))->assertStatus(422)->assertJsonValidationErrors(['tgllahir', 'no_id', 'jmlanak']);
|
||||
$this->save(11, 'kontak', ['email' => 'bukan-email'])->assertStatus(422)->assertJsonValidationErrors(['email']);
|
||||
$this->save(11, 'kepegawaian', ['nip' => '', 'statusaktif' => 5, 'idstatuspegawai' => 77])->assertStatus(422)->assertJsonValidationErrors(['nip', 'statusaktif', 'idstatuspegawai']);
|
||||
// NIP kembar dengan pegawai lain ditolak; NIP sendiri tidak.
|
||||
$this->save(11, 'kepegawaian', ['nip' => '198502022010121001', 'statusaktif' => 1])->assertStatus(422)->assertJsonValidationErrors(['nip']);
|
||||
$this->save(11, 'kepegawaian', ['nip' => '197501012000031002', 'statusaktif' => 1])->assertOk();
|
||||
// Home base hanya prodi akun.
|
||||
$this->save(11, 'dosen', ['idprogdi' => 99, 'idpangkatdosen' => 1])->assertStatus(422)->assertJsonValidationErrors(['idprogdi']);
|
||||
$this->save(11, 'dosen', ['idprogdi' => 21, 'idpangkatdosen' => 5555])->assertStatus(422)->assertJsonValidationErrors(['idpangkatdosen']);
|
||||
$this->save(11, 'pendidikan', ['pendidikanterakhir' => 55])->assertStatus(422)->assertJsonValidationErrors(['pendidikanterakhir']);
|
||||
|
||||
$this->assertSame(['Siti Aminah', 21], [$this->row(11)->nama, (int) $this->db()->table('t_dosen')->where('idpegawai', 11)->value('idprogdi')]);
|
||||
}
|
||||
|
||||
public function test_unchanged_legacy_values_are_not_rejected(): void
|
||||
{
|
||||
$this->db()->table('t_pegawai')->where('idpegawai', 11)->update(['no_id' => '6171-0000 0011', 'pendidikanterakhir' => 55]);
|
||||
|
||||
$this->save(11, 'pribadi', $this->pribadi(['no_id' => '6171-0000 0011', 'tempatlahir' => 'Mempawah']))->assertOk();
|
||||
$this->assertSame('Mempawah', $this->row(11)->tempatlahir);
|
||||
$this->get(route('operator.list-pegawai.show', 11))->assertOk()->assertSee('Kode 55');
|
||||
$this->save(11, 'pendidikan', ['pendidikanterakhir' => 55, 'idbank' => 3, 'norekening' => '1234567'])->assertOk();
|
||||
$this->assertSame(55, (int) $this->row(11)->pendidikanterakhir);
|
||||
}
|
||||
|
||||
public function test_add_employee_creates_a_lecturer_in_scope(): void
|
||||
{
|
||||
$payload = ['prodi' => 21, 'nip' => '199901012024011001', 'nama' => 'Bayu Pratama', 'gelardepan' => '', 'gelarbelakang' => 'S.Kom., M.T.', 'kelamin' => 1,
|
||||
'nidn' => '0001019901', 'hp' => '0811000', 'telepon' => null, 'email' => 'bayu@untan.ac.id', 'status' => 2, 'aktif' => 1];
|
||||
|
||||
$id = $this->postJson(route('operator.list-pegawai.store'), $payload)->assertCreated()->assertJsonPath('message', 'Pegawai ditambahkan.')->json('id');
|
||||
|
||||
$p = $this->row($id);
|
||||
$this->assertSame(['199901012024011001', 'Bayu Pratama', 1, 2, 1, 'SIAKAD', '198001012005011'], [$p->nip, $p->nama, (int) $p->kelamin, (int) $p->idstatuspegawai, (int) $p->idjenispegawai, $p->cname, $p->uname]);
|
||||
$this->assertSame(1, (int) $p->statusaktif);
|
||||
$this->assertSame(21, (int) $this->db()->table('t_dosen')->where('idpegawai', $id)->value('idprogdi'));
|
||||
|
||||
// Langsung tampil di daftar, dan detailnya bisa dibuka.
|
||||
$rows = collect($this->getJson(route('operator.pegawai.data', ['per' => 25]))->assertOk()->json('rows'));
|
||||
$this->assertSame('Bayu Pratama, S.Kom., M.T.', $rows->firstWhere('id', $id)['nama']);
|
||||
$this->get(route('operator.list-pegawai.show', $id))->assertOk()->assertSee('Bayu Pratama')->assertSee('Data dosen');
|
||||
}
|
||||
|
||||
public function test_add_employee_is_validated_and_scoped(): void
|
||||
{
|
||||
$url = route('operator.list-pegawai.store');
|
||||
$valid = ['prodi' => 21, 'nip' => '199901012024011001', 'nama' => 'Bayu Pratama', 'aktif' => 1];
|
||||
|
||||
$this->postJson($url, [])->assertStatus(422)->assertJsonValidationErrors(['nip', 'nama', 'aktif', 'prodi']);
|
||||
$this->postJson($url, ['email' => 'bukan-email', 'kelamin' => 7] + $valid)->assertStatus(422)->assertJsonValidationErrors(['email', 'kelamin']);
|
||||
$this->postJson($url, ['prodi' => 99] + $valid)->assertStatus(422)->assertJsonPath('message', 'Home base harus dipilih dari program studi Anda.');
|
||||
$this->postJson($url, ['nip' => '197501012000031002'] + $valid)->assertStatus(422)->assertJsonPath('message', 'NIP 197501012000031002 sudah terdaftar.');
|
||||
$this->postJson($url, ['status' => 99] + $valid)->assertStatus(422)->assertJsonPath('message', 'Status kepegawaian tidak ditemukan.');
|
||||
|
||||
$this->assertSame(0, $this->db()->table('t_pegawai')->where('nip', '199901012024011001')->count());
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class LegacyEmployeeListTest extends TestCase
|
||||
'headers' => $texts("{$panel}//thead/tr/th"),
|
||||
'filters' => $texts("//section[@aria-label='Filter data']//label"),
|
||||
'tools' => $texts("{$panel}//div[contains(@class, 'satu-bar__tools')]//button"),
|
||||
'row_actions' => array_map(fn ($node): string => $node->getAttribute('aria-label'), iterator_to_array($xpath->query("{$panel}//tbody//td[contains(@class, 'table__actions')]//button"))),
|
||||
'row_actions' => array_map(fn ($node): string => $node->getAttribute('aria-label'), iterator_to_array($xpath->query("{$panel}//tbody//td[contains(@class, 'table__actions')]//*[self::button or self::a]"))),
|
||||
'pager' => $xpath->query("//nav[@aria-label='Halaman data']")->length,
|
||||
];
|
||||
}
|
||||
@@ -71,8 +71,8 @@ class LegacyEmployeeListTest extends TestCase
|
||||
|
||||
$this->assertSame(['', 'NIP', 'Nama', 'L/P', 'NIDN', 'NUPTK', 'No. Telp.', 'Email', 'Status', 'Aksi'], $legacy['headers']);
|
||||
$this->assertSame(['Kuota Pembimbing Akademik', 'Status Aktif', 'Status'], $legacy['filters']);
|
||||
$this->assertSame(['Cetak'], $legacy['tools']);
|
||||
$this->assertSame(['Lihat', 'Ubah', 'Hapus'], $legacy['row_actions']);
|
||||
$this->assertSame(['Tambah', 'Hapus'], $legacy['tools']);
|
||||
$this->assertSame(['Lihat', 'Hapus'], $legacy['row_actions']);
|
||||
$this->assertSame(0, $this->dom($response)->query('//main//form[not(ancestor::dialog)]')->length, 'Filter tidak memakai formulir (alamat tetap).');
|
||||
$this->assertSame(1, $this->dom($response)->query("//a[@aria-current='page' and contains(@href, '/list_pegawai')]")->length);
|
||||
|
||||
@@ -82,7 +82,9 @@ class LegacyEmployeeListTest extends TestCase
|
||||
Auth::forgetGuards();
|
||||
$prototype = $this->actingAs(User::factory()->operator()->create())->get(route('operator.halaman', 'list_pegawai'))->assertOk();
|
||||
$expected = $this->layout($this->dom($prototype));
|
||||
$expected['tools'] = array_values(array_diff($expected['tools'], ['Aksi'])); // tombol Aksi tanpa fungsi disembunyikan di akun asli
|
||||
// Akun asli: tanpa Aksi dan Cetak, dengan Tambah dan Hapus yang sudah bekerja; baris tanpa Ubah (diubah di halaman detail).
|
||||
$expected['tools'] = ['Tambah', 'Hapus'];
|
||||
$expected['row_actions'] = ['Lihat', 'Hapus'];
|
||||
$this->assertSame($expected, $legacy);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class LegacyStudentDetailTest extends TestCase
|
||||
{
|
||||
$this->get(route('operator.list-mahasiswa.show', 500))->assertOk()
|
||||
->assertSeeInOrder(['<h1', 'Detail Mahasiswa'], false)
|
||||
->assertSee('studentBiodata', false)
|
||||
->assertSee('bioDetail', false)
|
||||
->assertSee('Rina Lestari')->assertSee('D1041191001')->assertSee('Teknik Informatika')
|
||||
// Bagian dan isiannya
|
||||
->assertSee('Data pribadi')->assertSee('Kontak dan alamat')->assertSee('Orang tua')->assertSee('Wali')->assertSee('Asal sekolah')->assertSee('Data akademik')
|
||||
|
||||
@@ -7,13 +7,12 @@ use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* CRUD Portal > Pegawai (t_pegawai + t_dosen) berdata asli lewat modal remote-list. Portal > Mahasiswa hanya baca (ubah di
|
||||
* halaman detail: LegacyStudentDetailTest).
|
||||
* Hapus pegawai (t_pegawai + t_dosen) berdata asli di Portal > Pegawai. Tambah dan ubah: LegacyEmployeeDetailTest; Portal >
|
||||
* Mahasiswa hanya baca (ubah di halaman detail: LegacyStudentDetailTest).
|
||||
* Akun staf fakultas memegang prodi 21 dan 22 (fakultas 5); prodi 99 di luar cakupan.
|
||||
*/
|
||||
class LegacyStudentEmployeeCrudTest extends TestCase
|
||||
@@ -39,70 +38,23 @@ class LegacyStudentEmployeeCrudTest extends TestCase
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function employee(array $override = []): array
|
||||
{
|
||||
return $override + [
|
||||
'nip' => '199201012020121001', 'nama' => 'Hendra Saputra', 'gelardepan' => 'Dr.', 'gelarbelakang' => 'M.Kom.', 'kelamin' => 1,
|
||||
'nidn' => '0001019201', 'hp' => '08111111', 'telepon' => '0561-7777', 'email' => 'hendra@untan.ac.id', 'status' => 2, 'aktif' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
public function test_guests_and_other_roles_cannot_write(): void
|
||||
{
|
||||
$this->post(route('logout'));
|
||||
foreach ([['put', route('operator.list-pegawai.update', 11)], ['post', route('operator.list-pegawai.destroy')]] as [$method, $url]) {
|
||||
$this->{$method}($url)->assertRedirect(route('login'));
|
||||
}
|
||||
$this->post(route('operator.list-pegawai.destroy'))->assertRedirect(route('login'));
|
||||
|
||||
Auth::forgetGuards();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
$this->actingAs(User::factory()->mahasiswa()->create())->put(route('operator.list-pegawai.update', 11), $this->employee())->assertForbidden();
|
||||
$this->actingAs(User::factory()->mahasiswa()->create())->post(route('operator.list-pegawai.destroy'), ['ids' => [11]])->assertForbidden();
|
||||
$this->assertSame(1, $this->db()->table('t_pegawai')->where('idpegawai', 11)->count());
|
||||
}
|
||||
|
||||
public function test_pages_wire_the_real_buttons(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_pegawai'))->assertOk()
|
||||
->assertSee('startEdit(row)', false)->assertSee('Status kepegawaian')->assertSee('Hapus pegawai?')->assertSee('askRemove([row.id])', false)
|
||||
->assertSee('startView(row)', false)->assertSee('Detail pegawai')->assertDontSee("demo('", false)->assertDontSee('Aksi'.': tampilan prototipe');
|
||||
}
|
||||
|
||||
public function test_employee_rows_carry_the_edit_form_and_have_no_create_route(): void
|
||||
{
|
||||
$rows = collect($this->getJson(route('operator.pegawai.data', ['per' => 25]))->assertOk()->json('rows'));
|
||||
$this->assertSame(
|
||||
['nip' => '197501012000031002', 'nama' => 'Siti Aminah', 'gelardepan' => '', 'gelarbelakang' => 'M.Pd.', 'kelamin' => 2, 'nidn' => '0001017501', 'hp' => '081234567890',
|
||||
'telepon' => '', 'email' => 'siti@untan.ac.id', 'status' => 2, 'aktif' => 1],
|
||||
$rows->firstWhere('id', 11)['form'],
|
||||
);
|
||||
$this->assertSame(0, $rows->firstWhere('id', 20)['form']['aktif']);
|
||||
$this->assertFalse(Route::has('operator.list-pegawai.store'));
|
||||
}
|
||||
|
||||
public function test_employee_update_is_scoped_and_keeps_activity_code(): void
|
||||
{
|
||||
$url = fn (int $id): string => route('operator.list-pegawai.update', $id);
|
||||
|
||||
$this->putJson($url(11), $this->employee(['nip' => '197501012000031002', 'nama' => 'Siti Aminah Baru', 'nidn' => '', 'status' => null]))
|
||||
->assertOk()->assertJsonPath('message', 'Data pegawai diperbarui.');
|
||||
$p = $this->db()->table('t_pegawai')->where('idpegawai', 11)->first();
|
||||
$this->assertSame(['Siti Aminah Baru', null, null, 'M.Kom.'], [$p->nama, $p->nidn, $p->idstatuspegawai, $p->gelarbelakang]);
|
||||
$this->assertSame(21, (int) $this->db()->table('t_dosen')->where('idpegawai', 11)->value('idprogdi'));
|
||||
|
||||
// Kode aktif lain (3) dipertahankan saat tetap aktif; Tidak aktif menjadi 0; aktif kembali menjadi 1.
|
||||
$this->putJson($url(24), $this->employee(['nip' => 'lina']))->assertOk();
|
||||
$this->assertSame(3, (int) $this->db()->table('t_pegawai')->where('idpegawai', 24)->value('statusaktif'));
|
||||
$this->putJson($url(24), $this->employee(['nip' => 'lina', 'aktif' => 0]))->assertOk();
|
||||
$this->assertSame(0, (int) $this->db()->table('t_pegawai')->where('idpegawai', 24)->value('statusaktif'));
|
||||
$this->putJson($url(24), $this->employee(['nip' => 'lina', 'aktif' => 1]))->assertOk();
|
||||
$this->assertSame(1, (int) $this->db()->table('t_pegawai')->where('idpegawai', 24)->value('statusaktif'));
|
||||
|
||||
$this->putJson($url(21), $this->employee(['nip' => '197501012000031002']))->assertStatus(422)->assertJsonPath('message', 'NIP 197501012000031002 sudah terdaftar.');
|
||||
// Pegawai di luar cakupan (home base prodi 99, jabatan tidak aktif) dan ID tidak ada.
|
||||
$this->putJson($url(22), $this->employee(['nip' => '197001012000011099']))->assertStatus(422)->assertJsonPath('message', 'Pegawai tidak ditemukan.');
|
||||
$this->putJson($url(23), $this->employee(['nip' => '196501011990011023']))->assertStatus(422)->assertJsonPath('message', 'Pegawai tidak ditemukan.');
|
||||
$this->putJson($url(9999), $this->employee())->assertStatus(422)->assertJsonPath('message', 'Pegawai tidak ditemukan.');
|
||||
$this->assertSame('Joko Prodi Lain', $this->db()->table('t_pegawai')->where('idpegawai', 22)->value('nama'));
|
||||
->assertSee('Hapus pegawai?')->assertSee('askRemove([row.id])', false)->assertSee('startInsert()', false)->assertSee('link(row)', false)
|
||||
->assertDontSee('startEdit(row)', false)->assertDontSee('startView(row)', false)->assertDontSee('window.print()', false)
|
||||
->assertDontSee("demo('", false)->assertDontSee('Aksi'.': tampilan prototipe');
|
||||
}
|
||||
|
||||
public function test_employee_delete_only_when_unreferenced(): void
|
||||
|
||||
Reference in New Issue
Block a user