[Operator] Perbaikan Laman Portal -> Mahasiswa
This commit is contained in:
@@ -163,7 +163,9 @@ Untuk akun DB lama, `operator.dashboard` (view `operator/dashboard-legacy.blade.
|
||||
|
||||
Untuk akun DB lama, halaman `operator.halaman` dengan slug `list_mahasiswa` diteruskan oleh `SatuPageController` (daftar `LEGACY_PAGES`) ke `Operator\StudentListController`, sehingga rute, URL, dan menu tetap sama. Data dari `App\Support\Legacy\StudentDirectory`; view bersama `operator/satu/remote-list.blade.php` (markup `satu/list`; kolom dan filter dari controller, tombol bilah dari `flags` katalog). Hanya baca. Akun demo tetap melihat halaman prototipe SATU.
|
||||
|
||||
Tulis (modal Tambah/Ubah dan hapus per baris/terpilih): `POST operator.list-mahasiswa.store`, `PUT operator.list-mahasiswa.update`, `POST operator.list-mahasiswa.destroy` (`StudentListController` -> `App\Support\Legacy\StudentRecords`, tabel `t_mahasiswa`). Cakupan prodi akun; NIM tidak bisa diubah; status Lulus hanya lewat yudisium; hapus ditolak bila mahasiswa punya KRS/nilai/keuangan/histori/akun login; akun login tidak dibuat.
|
||||
Daftar ini hanya untuk melihat: tidak ada Tambah, Hapus, Cetak, kotak centang, maupun Ubah di baris (view memakai `tools => []` dan `selectable => false`); satu-satunya aksi baris adalah Lihat. Tambah dan hapus mahasiswa tidak tersedia (rute `store`/`update`/`destroy` sudah dihapus). Semua perubahan data dilakukan di halaman detail.
|
||||
|
||||
Detail mahasiswa (aksi Lihat pada baris): `GET operator.list-mahasiswa.show` (`/operator/list_mahasiswa/{id}`, `StudentDetailController` -> `operator/satu/mahasiswa-detail.blade.php`) menampilkan ringkasan akademik (semester, SKS lulus, IPK dari `StudentDirectory::find`), biodata lengkap per bagian (data pribadi, kontak dan alamat, orang tua, wali, asal sekolah) dan data akademik yang hanya dibaca. Tiap bagian bisa diubah di tempat: `PUT operator.list-mahasiswa.biodata` (`/operator/list_mahasiswa/{id}/biodata/{section}`) lewat komponen Alpine `studentBiodata`. Definisi bagian dan kolom, pilihan referensi (`xs_agama`, `t_pekerjaan`, `t_tingkat_pendidikan`, `t_penghasilan`, `t_kewarganegaraan`), validasi, dan penulisan ada di `App\Support\Legacy\StudentBiodata`: hanya kolom yang nilainya berubah yang ditulis (kolom kosong tidak diubah jadi 0 atau string kosong), isian yang tidak berubah tidak divalidasi ulang (data lama boleh tidak seragam), audit `cname/cip/uname/tanggal/cip_updated/last_updated` terisi. Bagian Data akademik (prodi, kurikulum, angkatan, program kuliah, jalur masuk, status) ditulis lewat `App\Support\Legacy\StudentRecords` (cakupan prodi akun; status Lulus hanya lewat yudisium; NIM tidak bisa diubah) dan memuat ulang halaman setelah disimpan karena ringkasan di atas ikut berubah. Uji: `tests/Feature/Operator/LegacyStudentDetailTest.php`. Gaya `.bio-*` di `resources/css/pages/operator.css`.
|
||||
|
||||
- **Format sama dengan template SATU** (`operator/satu/list.blade.php`): bingkai `x-satu.frame` (catatan lewat prop `note`), panel filter, bilah cari + tombol (Tambah, Hapus, Aksi, Cetak), tabel `satu-table` dengan kolom #, NIM, Nama, Jenjang, Program Studi, Masuk, Status, Smt, SKS, IPK, Aksi, dan kaki `satu-foot` (Halaman x dari y, 10/25 data, lima nomor halaman). Baris dirender Alpine (`satuRemoteTable` di `resources/js/app.js`, saudara `satuTable`).
|
||||
- **Tanpa query string di alamat halaman:** halaman awal membawa 10 baris pertama; filter, cari (jeda 400 ms), jumlah per halaman, dan nomor halaman diambil dengan `fetch` ke `GET operator.mahasiswa.data` (`/operator/list_mahasiswa/data`, JSON: `rows`, `page`, `last_page`, `total`, `per_page`). Permintaan lama dibatalkan (`AbortController`); setiap permintaan dicatat dengan `console.info("[SIAKAD] GET ...")` dan terlihat di tab Network. Galat (mis. DB tak terjangkau, 503 JSON) muncul sebagai toast. Endpoint hanya untuk akun DB lama yang memegang prodi (lainnya 404) dan berada di grup `role:operator`.
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<?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\Curriculum;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\StudentBiodata;
|
||||
use App\Support\Legacy\StudentDirectory;
|
||||
use App\Support\Legacy\StudentRecords;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Detail mahasiswa (aksi Lihat pada Portal > Mahasiswa) untuk akun DB lama: ringkasan akademik, biodata lengkap per
|
||||
* bagian, dan data akademik, semuanya diubah per bagian lewat JSON. Satu-satunya tempat mengubah data mahasiswa;
|
||||
* daftar hanya untuk melihat. Hanya mahasiswa prodi yang dipegang akun.
|
||||
*/
|
||||
class StudentDetailController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
|
||||
private const string SLUG = 'list_mahasiswa';
|
||||
|
||||
/** Kunci bagian data akademik (ditulis StudentRecords, bukan StudentBiodata). */
|
||||
private const string ACADEMIC = 'akademik';
|
||||
|
||||
public function __construct(
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly StudentDirectory $directory,
|
||||
private readonly StudentBiodata $biodata,
|
||||
private readonly StudentRecords $records,
|
||||
private readonly Curriculum $curriculum,
|
||||
) {}
|
||||
|
||||
public function show(Request $request, int $id): View
|
||||
{
|
||||
$accountId = (int) $request->user()->getKey();
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$student = $this->directory->find($prodi, $id) ?? abort(404);
|
||||
$bio = $this->biodata->find($prodi, $id) ?? abort(404);
|
||||
$page = Catalog::page(self::SLUG);
|
||||
|
||||
// Data akademik tampil tepat sesudah data pribadi.
|
||||
$sections = array_slice($bio['sections'], 0, 1, true)
|
||||
+ [self::ACADEMIC => $this->academic($accountId, $student, $bio['extra'])]
|
||||
+ array_slice($bio['sections'], 1, null, true);
|
||||
|
||||
return view('operator.satu.mahasiswa-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],
|
||||
'student' => $student,
|
||||
'sections' => $sections,
|
||||
'back' => route('operator.halaman', self::SLUG),
|
||||
'saveUrl' => route('operator.list-mahasiswa.biodata', [$id, '__SECTION__']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id, string $section): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
abort_unless(in_array($section, [...StudentBiodata::sectionKeys(), self::ACADEMIC], true) && $this->biodata->exists($prodi, $id), 404);
|
||||
|
||||
try {
|
||||
if ($section === self::ACADEMIC) {
|
||||
return $this->updateAcademic($request, $prodi, $id);
|
||||
}
|
||||
|
||||
$input = $this->biodata->validated($prodi, $id, $section, $request->all());
|
||||
$result = $this->biodata->update($prodi, $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'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ubah data akademik. Ringkasan di bagian atas halaman (prodi, status, semester) ikut berubah, jadi klien memuat
|
||||
* ulang halaman; pesan berhasil dititipkan lewat sesi agar tampil sebagai toast di halaman baru.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
*/
|
||||
private function updateAcademic(Request $request, array $prodi, int $id): JsonResponse
|
||||
{
|
||||
$input = $request->validate([
|
||||
'prodi' => ['required', 'integer'],
|
||||
'kurikulum' => ['required', 'integer'],
|
||||
'angkatan' => ['required', 'integer'],
|
||||
'program' => ['required', 'integer'],
|
||||
'jalur' => ['nullable', 'integer'],
|
||||
'status' => ['required', 'integer', 'in:'.implode(',', array_keys(StudentRecords::STATUS))],
|
||||
], [], ['prodi' => 'program studi', 'kurikulum' => 'kurikulum', 'angkatan' => 'angkatan', 'program' => 'program kuliah', 'jalur' => 'jalur masuk', 'status' => 'status']);
|
||||
|
||||
$this->records->update($prodi, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
$request->session()->flash('status', 'Data akademik diperbarui.');
|
||||
|
||||
return response()->json(['message' => 'Data akademik diperbarui.', 'reload' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bagian data akademik dalam bentuk yang sama dengan bagian biodata: isian yang bisa diubah plus keterangan yang
|
||||
* hanya dibaca (NIM, jenjang, dosen PA, tanggal lulus).
|
||||
*
|
||||
* @param array<string, mixed> $student baris StudentDirectory::find()
|
||||
* @param array<string, mixed> $extra StudentBiodata::find()['extra']
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function academic(int $accountId, array $student, array $extra): array
|
||||
{
|
||||
$programs = $this->overview->programs($accountId)->all();
|
||||
$options = $this->records->options();
|
||||
$form = $student['form'];
|
||||
|
||||
$fields = [
|
||||
['name' => 'prodi', 'label' => 'Program studi', 'type' => 'select', 'options' => $programs, 'required' => true],
|
||||
['name' => 'kurikulum', 'label' => 'Kurikulum', 'type' => 'select', 'options' => $this->curriculum->curricula(array_keys($programs))->all(), 'required' => true],
|
||||
['name' => 'angkatan', 'label' => 'Angkatan', 'type' => 'select', 'options' => $options['angkatan'], 'required' => true],
|
||||
['name' => 'program', 'label' => 'Program kuliah', 'type' => 'select', 'options' => $options['program'], 'required' => true],
|
||||
['name' => 'jalur', 'label' => 'Jalur masuk', 'type' => 'select', 'options' => $options['jalur']],
|
||||
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => StudentRecords::STATUS, 'required' => true],
|
||||
];
|
||||
|
||||
$values = [];
|
||||
$display = ['nim' => $student['nim'], 'jenjang' => $student['jenjang'] ?? '–', 'pa' => $extra['pa'] ?? '–', 'lulus' => $extra['lulus'] ?? '–'];
|
||||
foreach ($fields as &$field) {
|
||||
$name = $field['name'];
|
||||
$value = $form[$name];
|
||||
// Kode yang tidak ada di tabel pilihan tetap tampil agar tidak hilang saat disimpan.
|
||||
if ($value !== '' && ! isset($field['options'][$value])) {
|
||||
$field['options'][$value] = 'Kode '.$value;
|
||||
}
|
||||
$values[$name] = $value;
|
||||
$display[$name] = $value === '' ? '–' : $field['options'][$value];
|
||||
}
|
||||
unset($field);
|
||||
|
||||
return [
|
||||
'key' => self::ACADEMIC,
|
||||
'title' => 'Data akademik',
|
||||
'icon' => 'identification',
|
||||
'description' => 'NIM tidak dapat diubah dan status Lulus ditetapkan lewat yudisium.',
|
||||
'fields' => $fields,
|
||||
'values' => $values,
|
||||
'display' => $display,
|
||||
'readonly' => [['name' => 'nim', 'label' => 'NIM'], ['name' => 'jenjang', 'label' => 'Jenjang'], ['name' => 'pa', 'label' => 'Dosen pembimbing akademik'], ['name' => 'lulus', 'label' => 'Tanggal lulus']],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<int> */
|
||||
private function prodiOrFail(Request $request): array
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$prodi = $this->overview->programs((int) $request->user()->getKey())->keys()->all();
|
||||
abort_if($prodi === [], 404);
|
||||
|
||||
return $prodi;
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Operator\Concerns\ServesLegacyList;
|
||||
use App\Models\Legacy\Account;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\Curriculum;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\StudentDirectory;
|
||||
use App\Support\Legacy\StudentRecords;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -21,6 +18,8 @@ use Illuminate\Support\Collection;
|
||||
* Portal > Mahasiswa (slug list_mahasiswa) untuk akun DB lama: daftar mahasiswa asli prodi yang dipegang akun,
|
||||
* dengan format tabel SATU yang sama. Halaman dipanggil oleh SatuPageController (rute dan menu tetap `operator.halaman`);
|
||||
* filter, pencarian, dan halaman berikutnya diambil lewat data() (JSON) sehingga alamat halaman tidak berubah.
|
||||
* Daftar hanya untuk melihat: tidak ada tambah, hapus, cetak, atau ubah di sini. Biodata dan data akademik diubah
|
||||
* di halaman detail (StudentDetailController).
|
||||
*/
|
||||
class StudentListController extends Controller
|
||||
{
|
||||
@@ -31,8 +30,6 @@ class StudentListController extends Controller
|
||||
public function __construct(
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly StudentDirectory $directory,
|
||||
private readonly StudentRecords $records,
|
||||
private readonly Curriculum $curriculum,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
@@ -45,9 +42,13 @@ class StudentListController 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 mahasiswa asli dari SIAKAD untuk program studi yang Anda kelola. Tambah, ubah, dan hapus langsung tersimpan di basis data; mahasiswa yang sudah punya data akademik, keuangan, atau akun login tidak dapat dihapus, dan NIM tidak dapat diubah.',
|
||||
'note' => 'Data mahasiswa asli dari SIAKAD untuk program studi yang Anda kelola. Pilih Lihat untuk membuka biodata lengkap; perubahan data dilakukan di dalam halaman detail.',
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar mahasiswa tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.mahasiswa.data'),
|
||||
'viewUrl' => route('operator.list-mahasiswa.show', '__ID__'),
|
||||
// Tanpa Tambah, Hapus, Cetak, dan kotak centang (tidak ada aksi massal).
|
||||
'tools' => [],
|
||||
'selectable' => false,
|
||||
'filters' => [
|
||||
['name' => 'prodi', 'label' => $labelProdi, 'options' => $programs->all()],
|
||||
['name' => 'angkatan', 'label' => $labelAngkatan, 'options' => $options['angkatan'] ?? []],
|
||||
@@ -68,121 +69,9 @@ class StudentListController extends Controller
|
||||
],
|
||||
'perPage' => StudentDirectory::PER_PAGE,
|
||||
'data' => $options === null ? null : $this->payload($this->search($request, $programs, $options)),
|
||||
'form' => $options === null ? null : $this->form($programs->all()),
|
||||
'destroyUrl' => $options === null ? null : route('operator.list-mahasiswa.destroy'),
|
||||
'destroy' => ['title' => 'Hapus mahasiswa?', 'message' => 'Hanya mahasiswa tanpa data akademik, keuangan, dan akun login yang dapat dihapus.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$id = $this->records->create($prodi, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Mahasiswa ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$this->records->update($prodi, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Data mahasiswa diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa mahasiswa (POST {ids}). */
|
||||
public function destroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1', 'max:100'], 'ids.*' => ['integer']], [], ['ids' => 'mahasiswa'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->records->delete($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} mahasiswa dihapus."]);
|
||||
}
|
||||
|
||||
/** @return list<int> */
|
||||
private function prodiOrFail(Request $request): array
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$prodi = $this->overview->programs((int) $request->user()->getKey())->keys()->all();
|
||||
abort_if($prodi === [], 404);
|
||||
|
||||
return $prodi;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function validated(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'nim' => ['required', 'string', 'max:15'],
|
||||
'nama' => ['required', 'string', 'max:50'],
|
||||
'prodi' => ['required', 'integer'],
|
||||
'kurikulum' => ['required', 'integer'],
|
||||
'angkatan' => ['required', 'integer'],
|
||||
'program' => ['required', 'integer'],
|
||||
'jalur' => ['nullable', 'integer'],
|
||||
'kelamin' => ['required', 'integer', 'in:1,2'],
|
||||
'tmplahir' => ['nullable', 'string', 'max:30'],
|
||||
'tgllahir' => ['nullable', 'date'],
|
||||
'hp' => ['nullable', 'string', 'max:35'],
|
||||
'email' => ['nullable', 'string', 'email', 'max:50'],
|
||||
'status' => ['required', 'integer', 'in:1,2,3,4,5'],
|
||||
], [], [
|
||||
'nim' => 'NIM', 'nama' => 'nama', 'prodi' => 'program studi', 'kurikulum' => 'kurikulum', 'angkatan' => 'angkatan',
|
||||
'program' => 'program kuliah', 'jalur' => 'jalur masuk', 'kelamin' => 'jenis kelamin', 'tmplahir' => 'tempat lahir',
|
||||
'tgllahir' => 'tanggal lahir', 'hp' => 'no. HP', 'email' => 'email', 'status' => 'status',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formulir tambah/ubah (modal); pilihan kurikulum memuat seluruh kurikulum prodi akun.
|
||||
*
|
||||
* @param array<int, string> $programs
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function form(array $programs): array
|
||||
{
|
||||
$options = $this->records->options();
|
||||
|
||||
return [
|
||||
'title' => 'mahasiswa',
|
||||
'storeUrl' => route('operator.list-mahasiswa.store'),
|
||||
'updateUrl' => route('operator.list-mahasiswa.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM', 'type' => 'text', 'required' => true, 'max' => 15, 'hint' => 'Tidak dapat diubah setelah disimpan.'],
|
||||
['name' => 'nama', 'label' => 'Nama', 'type' => 'text', 'required' => true, 'max' => 50],
|
||||
['name' => 'prodi', 'label' => 'Program studi', 'type' => 'select', 'options' => $programs, 'required' => true],
|
||||
['name' => 'kurikulum', 'label' => 'Kurikulum', 'type' => 'select', 'options' => $this->curriculum->curricula(array_keys($programs))->all(), 'required' => true, 'hint' => 'Pilih kurikulum milik program studi yang sama.'],
|
||||
['name' => 'angkatan', 'label' => 'Angkatan', 'type' => 'select', 'options' => $options['angkatan'], 'required' => true],
|
||||
['name' => 'program', 'label' => 'Program kuliah', 'type' => 'select', 'options' => $options['program'], 'required' => true],
|
||||
['name' => 'jalur', 'label' => 'Jalur masuk', 'type' => 'select', 'options' => $options['jalur']],
|
||||
['name' => 'kelamin', 'label' => 'Jenis kelamin', 'type' => 'select', 'options' => StudentRecords::GENDER, 'required' => true],
|
||||
['name' => 'tmplahir', 'label' => 'Tempat lahir', 'type' => 'text', 'max' => 30],
|
||||
['name' => 'tgllahir', 'label' => 'Tanggal lahir', 'type' => 'date'],
|
||||
['name' => 'hp', 'label' => 'No. HP', 'type' => 'text', 'max' => 35],
|
||||
['name' => 'email', 'label' => 'Email', 'type' => 'text', 'max' => 50],
|
||||
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => StudentRecords::STATUS, 'required' => true, 'default' => 1, 'hint' => 'Status Lulus ditetapkan lewat yudisium.'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** JSON untuk tabel (satuRemoteTable). Hanya akun DB lama yang memegang prodi. */
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
@@ -225,7 +114,6 @@ class StudentListController extends Controller
|
||||
return [
|
||||
'rows' => collect($rows->items())->map(fn (array $m): array => [
|
||||
'id' => $m['id'],
|
||||
'form' => $m['form'],
|
||||
'nim' => $m['nim'],
|
||||
'nama' => $m['nama'],
|
||||
'jenjang' => $m['jenjang'] ?? '–',
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\Legacy;
|
||||
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Biodata lengkap mahasiswa DB lama (t_mahasiswa) untuk halaman detail operator: data pribadi, kontak dan alamat,
|
||||
* orang tua, wali, serta asal sekolah. Dibaca dan ditulis per bagian dalam cakupan prodi akun. Hanya kolom yang nilainya
|
||||
* berubah yang ditulis, jadi kolom kosong yang tidak disentuh tetap seperti semula. NIM, prodi, kurikulum, angkatan,
|
||||
* program, jalur, dan status tidak diubah di sini (lewat Ubah pada daftar mahasiswa).
|
||||
*/
|
||||
final class StudentBiodata
|
||||
{
|
||||
/** Kode pilihan tanpa tabel referensi di DB; arti kode diambil dari komentar kolom t_mahasiswa. */
|
||||
private const array MARITAL = [1 => 'Belum kawin', 2 => 'Kawin'];
|
||||
|
||||
private const array BLOOD = [0 => 'Tidak diisi', 1 => 'O', 2 => 'A', 3 => 'B', 4 => 'AB'];
|
||||
|
||||
/**
|
||||
* Bagian halaman. Isian: name (kunci JSON dan kolom), label, type (text|textarea|date|number|select), max, lookup
|
||||
* (nama pilihan untuk select), required, wide (lebar penuh), hint.
|
||||
*
|
||||
* @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' => 'Identitas diri dan kependudukan.',
|
||||
'fields' => [
|
||||
['name' => 'nama', 'label' => 'Nama lengkap', 'type' => 'text', 'max' => 50, 'required' => true],
|
||||
['name' => 'kelamin', 'label' => 'Jenis kelamin', 'type' => 'select', 'lookup' => 'kelamin', 'required' => true],
|
||||
['name' => 'tmplahir', 'label' => 'Tempat lahir', 'type' => 'text', 'max' => 30],
|
||||
['name' => 'tgllahir', 'label' => 'Tanggal lahir', 'type' => 'date'],
|
||||
['name' => 'agama', 'label' => 'Agama', 'type' => 'select', 'lookup' => 'agama'],
|
||||
['name' => 'kewarganegaraan', 'label' => 'Kewarganegaraan', 'type' => 'select', 'lookup' => 'kewarganegaraan'],
|
||||
['name' => 'stat_nikah', 'label' => 'Status pernikahan', 'type' => 'select', 'lookup' => 'nikah', 'required' => true],
|
||||
['name' => 'gol_darah', 'label' => 'Golongan darah', 'type' => 'select', 'lookup' => 'darah'],
|
||||
['name' => 'pekerjaan', 'label' => 'Pekerjaan', 'type' => 'select', 'lookup' => 'pekerjaan'],
|
||||
['name' => 'no_id', 'label' => 'NIK', 'type' => 'text', 'max' => 20, 'alnum' => true],
|
||||
['name' => 'no_kk', 'label' => 'Nomor KK', 'type' => 'text', 'max' => 20, 'alnum' => true],
|
||||
['name' => 'nisn', 'label' => 'NISN', 'type' => 'text', 'max' => 10, 'alnum' => true],
|
||||
],
|
||||
],
|
||||
'kontak' => [
|
||||
'title' => 'Kontak dan alamat',
|
||||
'icon' => 'map-pin',
|
||||
'description' => 'Alamat tinggal, alamat asal, dan cara menghubungi.',
|
||||
'fields' => [
|
||||
['name' => 'hp', 'label' => 'No. HP', 'type' => 'text', 'max' => 35],
|
||||
['name' => 'telepon', 'label' => 'Telepon', 'type' => 'text', 'max' => 35],
|
||||
['name' => 'email_mhs', 'label' => 'Email', 'type' => 'email', 'max' => 50],
|
||||
['name' => 'kodepos', 'label' => 'Kode pos', 'type' => 'text', 'max' => 5, 'alnum' => true],
|
||||
['name' => 'alamat_mhs', 'label' => 'Alamat tinggal', 'type' => 'textarea', 'max' => 255, 'wide' => true],
|
||||
['name' => 'asal_alamat', 'label' => 'Alamat asal', 'type' => 'textarea', 'max' => 255, 'wide' => true],
|
||||
],
|
||||
],
|
||||
'ortu' => [
|
||||
'title' => 'Orang tua',
|
||||
'icon' => 'users',
|
||||
'description' => 'Data ayah dan ibu.',
|
||||
'fields' => [
|
||||
['name' => 'namaayah', 'label' => 'Nama ayah', 'type' => 'text', 'max' => 50],
|
||||
['name' => 'pend_ayah', 'label' => 'Pendidikan ayah', 'type' => 'select', 'lookup' => 'pendidikan'],
|
||||
['name' => 'pekerjaan_ortu', 'label' => 'Pekerjaan ayah', 'type' => 'select', 'lookup' => 'pekerjaan'],
|
||||
['name' => 'namaibu', 'label' => 'Nama ibu', 'type' => 'text', 'max' => 50],
|
||||
['name' => 'pend_ibu', 'label' => 'Pendidikan ibu', 'type' => 'select', 'lookup' => 'pendidikan'],
|
||||
['name' => 'pekerjaan_ibu', 'label' => 'Pekerjaan ibu', 'type' => 'select', 'lookup' => 'pekerjaan'],
|
||||
['name' => 'penghasilan_ortu', 'label' => 'Penghasilan orang tua', 'type' => 'select', 'lookup' => 'penghasilan'],
|
||||
['name' => 'tanggungan_ortu', 'label' => 'Jumlah tanggungan orang tua', 'type' => 'number', 'min' => 0, 'max' => 30],
|
||||
['name' => 'alamat_ortu', 'label' => 'Alamat orang tua', 'type' => 'textarea', 'max' => 255, 'wide' => true],
|
||||
],
|
||||
],
|
||||
'wali' => [
|
||||
'title' => 'Wali',
|
||||
'icon' => 'user-group',
|
||||
'description' => 'Diisi bila mahasiswa memiliki wali selain orang tua.',
|
||||
'fields' => [
|
||||
['name' => 'nama_wali', 'label' => 'Nama wali', 'type' => 'text', 'max' => 50],
|
||||
['name' => 'pend_wali', 'label' => 'Pendidikan wali', 'type' => 'select', 'lookup' => 'pendidikan'],
|
||||
['name' => 'pekerjaan_wali', 'label' => 'Pekerjaan wali', 'type' => 'select', 'lookup' => 'pekerjaan'],
|
||||
['name' => 'alamat_wali', 'label' => 'Alamat wali', 'type' => 'text', 'max' => 50],
|
||||
],
|
||||
],
|
||||
'sekolah' => [
|
||||
'title' => 'Asal sekolah',
|
||||
'icon' => 'academic-cap',
|
||||
'description' => 'Sekolah menengah atas atau sederajat.',
|
||||
'fields' => [
|
||||
['name' => 'namaslta', 'label' => 'Nama sekolah', 'type' => 'text', 'max' => 60],
|
||||
['name' => 'npsn', 'label' => 'NPSN', 'type' => 'text', 'max' => 10, 'alnum' => true],
|
||||
['name' => 'jurslta', 'label' => 'Jurusan', 'type' => 'text', 'max' => 30],
|
||||
['name' => 'thnlulusslta', 'label' => 'Tahun lulus', 'type' => 'text', 'max' => 4, 'digits' => true],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public static function sectionKeys(): array
|
||||
{
|
||||
return array_keys(self::sections());
|
||||
}
|
||||
|
||||
/** @var array<string, array<int, string>>|null */
|
||||
private ?array $lookups = null;
|
||||
|
||||
private function db(): ConnectionInterface
|
||||
{
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Pilihan select (kode => label). Kode 0 berarti "Tidak diisi" dan selalu ada pada kolom wajib di DB asli.
|
||||
*
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function lookups(): array
|
||||
{
|
||||
if ($this->lookups !== null) {
|
||||
return $this->lookups;
|
||||
}
|
||||
|
||||
$zero = fn (array $options, string $label = 'Tidak diisi'): array => [0 => $label] + array_diff_key($options, [0 => true]);
|
||||
$names = fn (string $table, string $key, string $label): array => $this->db()->table($table)->orderBy($key)->pluck($label, $key)
|
||||
->mapWithKeys(fn (?string $name, int|string $id): array => [(int) $id => trim((string) $name)])->all();
|
||||
|
||||
return $this->lookups = [
|
||||
'kelamin' => StudentRecords::GENDER,
|
||||
'agama' => $zero($names('xs_agama', 'idagama', 'agama')),
|
||||
'kewarganegaraan' => $zero($names('t_kewarganegaraan', 'idwarganegara', 'kewarganegaraan')),
|
||||
'nikah' => self::MARITAL,
|
||||
'darah' => self::BLOOD,
|
||||
'pekerjaan' => $zero($names('t_pekerjaan', 'idpekerjaan', 'pekerjaan')),
|
||||
'pendidikan' => $zero($names('t_tingkat_pendidikan', 'idtingkat', 'tingkatpendidikan')),
|
||||
'penghasilan' => $zero($names('t_penghasilan', 'idpenghasilan', 'penghasilan')),
|
||||
];
|
||||
}
|
||||
|
||||
/** @param list<int> $prodi */
|
||||
public function exists(array $prodi, int $id): bool
|
||||
{
|
||||
return $this->db()->table('t_mahasiswa')->whereIn('idprogdi', $prodi)->where('idmahasiswa', $id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Biodata satu mahasiswa dalam cakupan prodi: per bagian, nilai isian dan teks tampil.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @return array{sections: array<string, array<string, mixed>>, extra: array<string, mixed>}|null
|
||||
*/
|
||||
public function find(array $prodi, int $id): ?array
|
||||
{
|
||||
$row = $this->row($prodi, $id);
|
||||
if ($row === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$lookups = $this->lookups();
|
||||
$sections = [];
|
||||
foreach (self::sections() as $key => $section) {
|
||||
$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)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Simpan satu bagian. Mengembalikan bagian yang sudah diperbarui (nilai isian + teks tampil) dan banyak kolom yang berubah.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param array<string, mixed> $input
|
||||
* @return array{section: array<string, mixed>, changed: int}
|
||||
*/
|
||||
public function update(array $prodi, int $id, string $key, array $input, string $actor, ?string $ip): array
|
||||
{
|
||||
$section = self::sections()[$key] ?? throw new PortalException('Bagian biodata tidak dikenal.');
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
if ($changes !== []) {
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', $id)->update($changes + [
|
||||
'cname' => ActivityTypes::APP_NAME, 'cip' => $ip ?? '', 'uname' => mb_substr($actor, 0, 15), 'tanggal' => now(),
|
||||
'cip_updated' => mb_substr((string) $ip, 0, 20), 'last_updated' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
$fresh = $this->row($prodi, $id);
|
||||
|
||||
return [
|
||||
'section' => $this->present($section, $fresh, $lookups),
|
||||
'changed' => count($changes),
|
||||
];
|
||||
}
|
||||
|
||||
/** @param list<int> $prodi */
|
||||
private function row(array $prodi, int $id): ?object
|
||||
{
|
||||
$columns = collect(self::sections())->pluck('fields')->flatten(1)->pluck('name')->all();
|
||||
|
||||
return $this->db()->table('t_mahasiswa as m')->whereIn('m.idprogdi', $prodi)->where('m.idmahasiswa', $id)
|
||||
->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.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function extra(object $row): array
|
||||
{
|
||||
$jalur = $row->jalur_masuk === null ? null : $this->db()->table('t_jalurmasuk')->where('idjalur_siakad', $row->jalur_masuk)->value('nama_jalur_masuk');
|
||||
$kurikulum = $row->idkurikulum === null ? null : $this->db()->table('t_kurikulum')->where('idkurikulum', $row->idkurikulum)->value('namakurikulum');
|
||||
$pa = $row->idpa === null ? null : $this->db()->table('t_pegawai')->where('idpegawai', $row->idpa)->first(['gelardepan', 'nama', 'gelarbelakang']);
|
||||
|
||||
return [
|
||||
'jalur' => filled($jalur) ? trim($jalur) : null,
|
||||
'kurikulum' => filled($kurikulum) ? trim($kurikulum) : null,
|
||||
'pa' => $pa === null ? null : LegacyFormat::pegawaiName($pa->gelardepan, $pa->nama, $pa->gelarbelakang),
|
||||
'lulus' => (int) $row->stataktif === 2 && $row->tgl_lulus !== null ? Carbon::parse($row->tgl_lulus)->locale('id')->isoFormat('D MMMM YYYY') : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,38 @@ final class StudentDirectory
|
||||
{
|
||||
$q = trim((string) ($filter['q'] ?? ''));
|
||||
|
||||
$page = $this->db()->table('t_mahasiswa as m')
|
||||
$page = $this->base($prodi)
|
||||
->when($q !== '', fn (Builder $query) => $query->where(fn (Builder $w) => $w
|
||||
->whereRaw('upper(m.nim) like ?', ['%'.mb_strtoupper($q).'%'])
|
||||
->orWhereRaw('upper(m.nama) like ?', ['%'.mb_strtoupper($q).'%'])))
|
||||
->when($filter['angkatan'] ?? null, fn (Builder $query, int $tahun) => $query->where('g.tahun', $tahun))
|
||||
->when(self::STATUS[$filter['status'] ?? ''] ?? null, fn (Builder $query, array $codes) => $query->whereIn('m.stataktif', $codes))
|
||||
->when($filter['program'] ?? null, fn (Builder $query, int $program) => $query->where('m.idprogram', $program))
|
||||
->when($filter['jalur'] ?? null, fn (Builder $query, int $jalur) => $query->where('m.jalur_masuk', $jalur))
|
||||
->orderBy('m.nim')
|
||||
->paginate($perPage)
|
||||
->withQueryString();
|
||||
|
||||
return $page->through(fn (object $row): array => $this->present($row));
|
||||
}
|
||||
|
||||
/**
|
||||
* Satu mahasiswa dalam cakupan prodi (null bila tidak ada atau milik prodi lain), bentuk sama dengan baris search().
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
public function find(array $prodi, int $id): ?array
|
||||
{
|
||||
$row = $this->base($prodi)->where('m.idmahasiswa', $id)->first();
|
||||
|
||||
return $row === null ? null : $this->present($row);
|
||||
}
|
||||
|
||||
/** @param list<int> $prodi */
|
||||
private function base(array $prodi): Builder
|
||||
{
|
||||
return $this->db()->table('t_mahasiswa as m')
|
||||
->leftJoin('t_angkatanmhs as g', 'g.idangkatan', '=', 'm.idangkatan')
|
||||
->leftJoin('t_bagian as b', 'b.idbagian', '=', 'm.idprogdi')
|
||||
->leftJoin('t_jenisprogram as p', 'p.idprogram', '=', 'm.idprogram')
|
||||
@@ -80,14 +111,6 @@ final class StudentDirectory
|
||||
->on('h.idperiode', '=', 'pa.idperiode'))
|
||||
->leftJoin('t_stat_akademik as s', 's.idstat_akd', '=', 'h.stat_akd_akhir')
|
||||
->whereIn('m.idprogdi', $prodi)
|
||||
->when($q !== '', fn (Builder $query) => $query->where(fn (Builder $w) => $w
|
||||
->whereRaw('upper(m.nim) like ?', ['%'.mb_strtoupper($q).'%'])
|
||||
->orWhereRaw('upper(m.nama) like ?', ['%'.mb_strtoupper($q).'%'])))
|
||||
->when($filter['angkatan'] ?? null, fn (Builder $query, int $tahun) => $query->where('g.tahun', $tahun))
|
||||
->when(self::STATUS[$filter['status'] ?? ''] ?? null, fn (Builder $query, array $codes) => $query->whereIn('m.stataktif', $codes))
|
||||
->when($filter['program'] ?? null, fn (Builder $query, int $program) => $query->where('m.idprogram', $program))
|
||||
->when($filter['jalur'] ?? null, fn (Builder $query, int $jalur) => $query->where('m.jalur_masuk', $jalur))
|
||||
->orderBy('m.nim')
|
||||
// Jenjang prodi dari data PDDIKTI (kode A sampai J seperti t_jenjangprogdi.kode); t_bagian.kdjen hampir selalu kosong.
|
||||
->selectSub(fn (Builder $sub) => $sub->from('pdpt_tmst_program_studi as pp')
|
||||
->join('t_jenjangprogdi as jp', 'jp.kode', '=', 'pp.kode_jenjang_pendidikan')
|
||||
@@ -99,11 +122,7 @@ final class StudentDirectory
|
||||
'h.stat_akd_akhir', 's.status_akademik',
|
||||
// Nilai isian formulir ubah.
|
||||
'm.idprogdi', 'm.idkurikulum', 'm.idangkatan', 'm.idprogram', 'm.jalur_masuk', 'm.kelamin', 'm.tmplahir', 'm.tgllahir', 'm.hp', 'm.email_mhs',
|
||||
])
|
||||
->paginate($perPage)
|
||||
->withQueryString();
|
||||
|
||||
return $page->through(fn (object $row): array => $this->present($row));
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
|
||||
@@ -7,9 +7,10 @@ use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Tulis data inti mahasiswa DB lama (t_mahasiswa) dalam cakupan program studi akun: tambah, ubah, hapus.
|
||||
* Akun login (t_account) tidak dibuat/diubah/dihapus; mahasiswa yang sudah punya data akademik, keuangan, atau akun
|
||||
* tidak boleh dihapus. NIM tidak bisa diubah (trigger t_mahasiswa_block_ubah_nim_trigger di DB asli juga menolaknya).
|
||||
* Ubah data akademik inti mahasiswa DB lama (t_mahasiswa) dalam cakupan program studi akun: prodi, kurikulum, angkatan,
|
||||
* program, jalur masuk, dan status. Tidak ada tambah atau hapus mahasiswa, NIM tidak diubah (trigger
|
||||
* t_mahasiswa_block_ubah_nim_trigger di DB asli juga menolaknya), dan akun login (t_account) tidak disentuh.
|
||||
* Biodata (pribadi, kontak, orang tua, wali, sekolah) ditulis oleh StudentBiodata.
|
||||
*/
|
||||
final class StudentRecords
|
||||
{
|
||||
@@ -18,13 +19,6 @@ final class StudentRecords
|
||||
|
||||
public const array GENDER = [1 => 'Laki-laki', 2 => 'Perempuan'];
|
||||
|
||||
/** Tabel yang merujuk idmahasiswa; baris di salah satunya menghalangi penghapusan. */
|
||||
private const array DEPENDENTS = [
|
||||
't_kst', 't_transkrip', 't_keuanganmhs', 't_histori_mahasiswa', 't_evaluasi', 't_evaluasi_sp', 't_cuti', 't_skripsi',
|
||||
't_mutasi_dikti', 't_mahasiswa_cekal', 't_pindah', 't_aktivasikeuangan', 't_beasiswa_mhs', 't_kelompokukt',
|
||||
't_mahasiswa_masastudi', 't_update_biodata', 'pdpt_feeder_mahasiswa',
|
||||
];
|
||||
|
||||
private function db(): ConnectionInterface
|
||||
{
|
||||
return DB::connection('untan');
|
||||
@@ -50,111 +44,14 @@ final class StudentRecords
|
||||
|
||||
/**
|
||||
* @param list<int> $prodi
|
||||
* @param array{nim: string, nama: string, prodi: int, kurikulum: int, angkatan: int, program: int, jalur?: ?int, kelamin: int, tmplahir?: ?string, tgllahir?: ?string, hp?: ?string, email?: ?string, status: int} $input
|
||||
* @return int idmahasiswa baru
|
||||
*/
|
||||
public function create(array $prodi, array $input, string $actor, ?string $ip): int
|
||||
{
|
||||
$values = $this->values($prodi, $input, null);
|
||||
if ($values['stataktif'] === 2) {
|
||||
throw new PortalException('Status Lulus ditetapkan lewat yudisium, bukan di sini.');
|
||||
}
|
||||
$nim = $values['nim'];
|
||||
if (! preg_match('/^[A-Z0-9]{5,15}$/', $nim)) {
|
||||
throw new PortalException('NIM hanya boleh huruf dan angka (5 sampai 15 karakter).');
|
||||
}
|
||||
if ($this->db()->table('t_mahasiswa')->whereRaw('upper(trim(nim)) = ?', [$nim])->exists()) {
|
||||
throw new PortalException("NIM {$nim} sudah terdaftar.");
|
||||
}
|
||||
|
||||
return (int) $this->db()->table('t_mahasiswa')->insertGetId($values + $this->audit($actor, $ip), 'idmahasiswa');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $prodi
|
||||
* @param array<string, mixed> $input
|
||||
* @param array{prodi: mixed, kurikulum: mixed, angkatan: mixed, program: mixed, jalur?: mixed, status: mixed} $input
|
||||
*/
|
||||
public function update(array $prodi, int $id, array $input, string $actor, ?string $ip): void
|
||||
{
|
||||
$current = $this->owned($prodi)->where('m.idmahasiswa', $id)->first(['m.nim', 'm.stataktif']);
|
||||
$current = $this->owned($prodi)->where('m.idmahasiswa', $id)->first(['m.stataktif']);
|
||||
if ($current === null) {
|
||||
throw new PortalException('Mahasiswa tidak ditemukan.');
|
||||
}
|
||||
$values = $this->values($prodi, $input, $current);
|
||||
if (strtoupper(trim((string) $current->nim)) !== $values['nim']) {
|
||||
throw new PortalException('NIM tidak dapat diubah. Buat mahasiswa baru dengan NIM yang sesuai.');
|
||||
}
|
||||
if ($values['stataktif'] === 2 && (int) $current->stataktif !== 2) {
|
||||
throw new PortalException('Status Lulus ditetapkan lewat yudisium, bukan di sini.');
|
||||
}
|
||||
unset($values['nim']);
|
||||
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', $id)->update($values + $this->audit($actor, $ip));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hapus mahasiswa tanpa data turunan. Gagal seluruhnya (tanpa menghapus sebagian) bila ada yang dirujuk.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param list<int> $ids
|
||||
*/
|
||||
public function delete(array $prodi, array $ids): int
|
||||
{
|
||||
$rows = $this->owned($prodi)->whereIn('m.idmahasiswa', array_map('intval', $ids))->get(['m.idmahasiswa', 'm.nim']);
|
||||
if ($rows->isEmpty()) {
|
||||
throw new PortalException('Mahasiswa tidak ditemukan.');
|
||||
}
|
||||
|
||||
$blocked = $rows->filter(fn (object $m): bool => $this->isReferenced((int) $m->idmahasiswa))
|
||||
->map(fn (object $m): string => trim((string) $m->nim))->values();
|
||||
if ($blocked->isNotEmpty()) {
|
||||
$list = $blocked->take(5)->implode(', ').($blocked->count() > 5 ? ', dan '.($blocked->count() - 5).' lainnya' : '');
|
||||
throw new PortalException("Mahasiswa {$list} sudah punya data akademik, keuangan, atau akun login sehingga tidak boleh dihapus.");
|
||||
}
|
||||
|
||||
$keys = $rows->pluck('idmahasiswa')->map(fn ($id): int => (int) $id)->all();
|
||||
|
||||
return $this->db()->transaction(function () use ($keys): int {
|
||||
// Baris rekap kosong dibuat otomatis oleh trigger saat mahasiswa ditambahkan.
|
||||
$this->db()->table('t_evaluasi_rekap')->whereIn('idmahasiswa', $keys)->delete();
|
||||
|
||||
return $this->db()->table('t_mahasiswa')->whereIn('idmahasiswa', $keys)->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/** @param list<int> $prodi */
|
||||
private function owned(array $prodi): Builder
|
||||
{
|
||||
return $this->db()->table('t_mahasiswa as m')->whereIn('m.idprogdi', $prodi);
|
||||
}
|
||||
|
||||
private function isReferenced(int $id): bool
|
||||
{
|
||||
$schema = $this->db()->getSchemaBuilder();
|
||||
foreach (self::DEPENDENTS as $table) {
|
||||
if ($schema->hasTable($table) && $this->db()->table($table)->where('idmahasiswa', $id)->exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->db()->table('t_account')->where('jenis', 1)->where('identitas', $id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nilai kolom t_mahasiswa yang sudah diperiksa terhadap cakupan prodi dan tabel referensi.
|
||||
*
|
||||
* @param list<int> $prodi
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function values(array $prodi, array $input, ?object $current): array
|
||||
{
|
||||
$text = fn (mixed $v): ?string => ($v = trim((string) $v)) === '' ? null : $v;
|
||||
$nim = strtoupper(trim((string) ($input['nim'] ?? '')));
|
||||
$nama = trim((string) ($input['nama'] ?? ''));
|
||||
if ($nim === '' || $nama === '') {
|
||||
throw new PortalException('NIM dan nama wajib diisi.');
|
||||
}
|
||||
|
||||
$prodiId = (int) ($input['prodi'] ?? 0);
|
||||
if (! in_array($prodiId, $prodi, true)) {
|
||||
@@ -176,41 +73,27 @@ final class StudentRecords
|
||||
if ($entry !== null && ! $this->db()->table('t_jalurmasuk')->where('idjalur_siakad', $entry)->exists()) {
|
||||
throw new PortalException('Jalur masuk tidak ditemukan.');
|
||||
}
|
||||
$gender = (int) ($input['kelamin'] ?? 0);
|
||||
if (! isset(self::GENDER[$gender])) {
|
||||
throw new PortalException('Jenis kelamin harus dipilih.');
|
||||
}
|
||||
$status = (int) ($input['status'] ?? 1);
|
||||
if (! isset(self::STATUS[$status])) {
|
||||
throw new PortalException('Status mahasiswa tidak dikenal.');
|
||||
}
|
||||
$email = $text($input['email'] ?? null);
|
||||
if ($email !== null && ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new PortalException('Format email tidak valid.');
|
||||
if ($status === 2 && (int) $current->stataktif !== 2) {
|
||||
throw new PortalException('Status Lulus ditetapkan lewat yudisium, bukan di sini.');
|
||||
}
|
||||
|
||||
$values = [
|
||||
'nim' => $nim,
|
||||
'nama' => $nama,
|
||||
'idprogdi' => $prodiId,
|
||||
'idkurikulum' => $curriculum,
|
||||
'idangkatan' => $batch,
|
||||
'idprogram' => $program,
|
||||
'kelamin' => $gender,
|
||||
'tmplahir' => $text($input['tmplahir'] ?? null),
|
||||
'tgllahir' => $text($input['tgllahir'] ?? null),
|
||||
'hp' => $text($input['hp'] ?? null),
|
||||
'email_mhs' => $email,
|
||||
'stataktif' => $status,
|
||||
];
|
||||
// Jalur masuk NOT NULL (bawaan 1) di DB asli: kosong berarti tidak diubah pada ubah, bawaan pada tambah.
|
||||
$values = ['idprogdi' => $prodiId, 'idkurikulum' => $curriculum, 'idangkatan' => $batch, 'idprogram' => $program, 'stataktif' => $status];
|
||||
// Jalur masuk NOT NULL di DB asli: kosong berarti tidak diubah.
|
||||
if ($entry !== null) {
|
||||
$values['jalur_masuk'] = $entry;
|
||||
} elseif ($current === null) {
|
||||
$values['jalur_masuk'] = 1;
|
||||
}
|
||||
|
||||
return $values;
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', $id)->update($values + $this->audit($actor, $ip));
|
||||
}
|
||||
|
||||
/** @param list<int> $prodi */
|
||||
private function owned(array $prodi): Builder
|
||||
{
|
||||
return $this->db()->table('t_mahasiswa as m')->whereIn('m.idprogdi', $prodi);
|
||||
}
|
||||
|
||||
/** Kolom audit seperti aplikasi lama: cname nama aplikasi, cip alamat IP, uname username (dipotong 15). */
|
||||
|
||||
@@ -1 +1,77 @@
|
||||
/* Gaya halaman khusus peran operator. Tambahkan hanya kelas yang tidak bisa dibuat dari komponen dan token; semua warna lewat token. */
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
Detail mahasiswa (operator/satu/mahasiswa-detail)
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
.bio-hero { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-md) var(--space-lg); }
|
||||
.bio-hero__id { display: grid; gap: var(--space-3xs); flex: 1 1 16rem; min-width: 0; }
|
||||
.bio-hero__name { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
|
||||
.bio-hero__nim { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-ink-2); }
|
||||
.bio-hero__prodi { margin: 0; color: var(--color-muted); }
|
||||
|
||||
/* Navigasi bagian: deret mendatar yang bisa digulir di kontainer sempit, kolom tegak di kontainer lebar */
|
||||
.bio { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-md); align-items: start; min-width: 0; }
|
||||
.bio__panels { display: grid; gap: var(--space-md); min-width: 0; }
|
||||
.bio__tabs { display: flex; gap: var(--space-2xs); overflow-x: auto; scrollbar-width: none; }
|
||||
.bio__tabs::-webkit-scrollbar { display: none; }
|
||||
.bio__tab {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 0 0 auto;
|
||||
gap: var(--space-xs);
|
||||
min-height: 2.75rem;
|
||||
padding-inline: var(--space-sm);
|
||||
border: 0;
|
||||
border-radius: var(--radius-control);
|
||||
background: transparent;
|
||||
color: var(--color-ink-2);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
text-align: start;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.bio__tab svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
|
||||
.bio__tab[aria-selected="true"] { background: var(--color-accent-soft); color: var(--color-accent-text); }
|
||||
.bio__tab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
|
||||
@media (hover: hover) {
|
||||
.bio__tab[aria-selected="false"]:hover { background: color-mix(in oklab, var(--color-ink) 6%, transparent); color: var(--color-ink); }
|
||||
}
|
||||
@container (width >= 56rem) {
|
||||
.bio { grid-template-columns: 15rem minmax(0, 1fr); }
|
||||
.bio__nav { position: sticky; inset-block-start: var(--space-md); }
|
||||
.bio__tabs { flex-direction: column; overflow: visible; }
|
||||
.bio__tab { flex: 1 1 auto; }
|
||||
}
|
||||
|
||||
/* Kepala bagian: ikon, judul, petunjuk, tombol Ubah */
|
||||
.bio-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-md); margin-block-end: var(--space-md); }
|
||||
.bio-head__icon {
|
||||
display: grid;
|
||||
flex-shrink: 0;
|
||||
place-items: center;
|
||||
width: 2.75rem;
|
||||
height: 2.75rem;
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--color-accent-soft);
|
||||
color: var(--color-accent-text);
|
||||
}
|
||||
.bio-head__icon svg { width: 1.375rem; height: 1.375rem; }
|
||||
.bio-head__text { display: grid; gap: var(--space-3xs); flex: 1 1 14rem; min-width: 0; }
|
||||
.bio-head__title { font-size: var(--text-title); }
|
||||
.bio-head__hint { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }
|
||||
|
||||
/* Tampilan baca: pasangan label dan nilai dengan garis tipis */
|
||||
.bio-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0 var(--space-lg); margin: 0; }
|
||||
.bio-list__item { display: grid; align-content: start; gap: var(--space-3xs); min-width: 0; padding-block: var(--space-sm); border-block-start: var(--rule-hair) solid var(--color-rule); }
|
||||
.bio-list__item--wide { grid-column: 1 / -1; }
|
||||
.bio-list dt { color: var(--color-muted); font-size: var(--text-sm); }
|
||||
.bio-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
|
||||
.bio-list .bio-list__empty { color: var(--color-muted); font-weight: 400; }
|
||||
|
||||
/* Formulir ubah: grid kolom otomatis, bantuan hanya muncul saat ada galat (aturan .satu-form) */
|
||||
.bio-form { padding-block-start: var(--space-xs); }
|
||||
/* Saat menyimpan: isian meredup dan tidak bisa diklik; tombol Simpan menampilkan pemintal (aturan .btn[data-busy]) */
|
||||
.bio-form[aria-busy="true"] .field { opacity: 0.6; pointer-events: none; }
|
||||
.bio-form[aria-busy="true"] { cursor: progress; }
|
||||
|
||||
@@ -1047,6 +1047,82 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
/*
|
||||
* Detail mahasiswa (Portal operator > Mahasiswa): 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) => ({
|
||||
tab: config.tab,
|
||||
values: config.values,
|
||||
display: config.display,
|
||||
editing: null,
|
||||
form: {},
|
||||
saving: false,
|
||||
reloading: false,
|
||||
|
||||
get nama() {
|
||||
return this.display.pribadi?.nama ?? '';
|
||||
},
|
||||
|
||||
// Inisial seperti ui.avatar: gelar bertitik dan bagian setelah koma dilewati
|
||||
get initials() {
|
||||
const words = this.nama.split(',')[0].trim().split(/\s+/).filter(Boolean);
|
||||
const plain = words.filter((word) => !word.endsWith('.'));
|
||||
const use = plain.length ? plain : words;
|
||||
return ((use[0]?.[0] ?? '?') + (use.length > 1 ? use[use.length - 1][0] : '')).toUpperCase();
|
||||
},
|
||||
|
||||
show(key) {
|
||||
this.tab = key;
|
||||
},
|
||||
|
||||
edit(key) {
|
||||
this.tab = key;
|
||||
this.editing = key;
|
||||
this.form = { ...this.values[key] };
|
||||
this.$nextTick(() => this.$refs['panel-' + key]?.querySelector('input:not([type=hidden]), select, textarea')?.focus());
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.editing = null;
|
||||
},
|
||||
|
||||
async save() {
|
||||
const key = this.editing;
|
||||
if (key === null || this.saving) return;
|
||||
const url = config.saveUrl.replace('__SECTION__', encodeURIComponent(key));
|
||||
this.saving = true;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'X-CSRF-TOKEN': config.token, 'X-Requested-With': 'XMLHttpRequest' },
|
||||
body: JSON.stringify(this.form),
|
||||
});
|
||||
const data = await response.json().catch(() => null);
|
||||
if (!response.ok) {
|
||||
const first = data?.errors ? Object.values(data.errors).flat()[0] : null;
|
||||
throw new Error(first || data?.message || 'Biodata tidak dapat disimpan. Muat ulang halaman lalu coba lagi.');
|
||||
}
|
||||
console.info(`[SIAKAD] PUT ${url}`, { hasil: data.message });
|
||||
// Data akademik mengubah ringkasan di atas halaman: muat ulang (pesan tampil lewat sesi); tombol tetap sibuk
|
||||
if (data.reload) {
|
||||
this.reloading = true;
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
this.values[key] = data.values;
|
||||
this.display[key] = data.display;
|
||||
this.editing = null;
|
||||
window.toast('success', data.message);
|
||||
} catch (error) {
|
||||
window.toast('danger', error.message);
|
||||
} finally {
|
||||
if (!this.reloading) this.saving = false;
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
/*
|
||||
* Kegiatan Akademik (Portal operator, akun DB lama): tabel jenis kegiatan dengan tambah/ubah sebaris dan hapus
|
||||
* berdialog. Baris disaring dan dihalamankan di sisi klien (jumlahnya puluhan); setiap simpan mengirim JSON dan
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
{{--
|
||||
Detail mahasiswa (akun DB lama): ringkasan akademik + biodata dan data akademik per bagian yang bisa diubah di tempat.
|
||||
Dibuka dari aksi Lihat di Portal > Mahasiswa; satu-satunya tempat mengubah data mahasiswa. Bagian biodata diatur
|
||||
StudentBiodata::sections(); bagian akademik dibangun StudentDetailController::academic() dan ditulis StudentRecords.
|
||||
--}}
|
||||
@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(),
|
||||
];
|
||||
@endphp
|
||||
|
||||
<x-layouts.app :title="'Mahasiswa '.$student['nama']">
|
||||
<x-ui.page-header title="Detail Mahasiswa" description="Biodata lengkap mahasiswa. 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="studentBiodata(@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>
|
||||
<div class="bio-hero__id">
|
||||
<h2 id="mhs-nama" class="bio-hero__name" x-text="nama">{{ $student['nama'] }}</h2>
|
||||
<p class="bio-hero__nim">{{ $student['nim'] }}</p>
|
||||
<p class="bio-hero__prodi">{{ $student['jenjang'] ? $student['jenjang'].' ' : '' }}{{ $student['prodi'] }}</p>
|
||||
</div>
|
||||
<div class="cluster cluster--sm">
|
||||
<x-ui.badge :tone="$student['status']['tone'] === 'neutral' ? 'neutral' : $student['status']['tone']">{{ $student['status']['label'] }}</x-ui.badge>
|
||||
@if ($student['angkatan'])
|
||||
<x-ui.badge tone="accent">Angkatan {{ $student['angkatan'] }}</x-ui.badge>
|
||||
@endif
|
||||
@if ($student['program'])
|
||||
<x-ui.badge>{{ $student['program'] }}</x-ui.badge>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
<x-ui.figures label="Capaian akademik">
|
||||
<x-ui.figure label="Semester" :value="$student['semester'] !== null ? (int) $student['semester'] : '–'" hint="Semester berjalan" />
|
||||
<x-ui.figure label="SKS lulus" :value="(int) $student['sks_lulus']" hint="Dari transkrip" />
|
||||
<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>
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
@@ -4,7 +4,8 @@
|
||||
(fetch JSON ke $url), sehingga alamat halaman tidak berubah. Halaman pertama ikut dirender sebagai data awal.
|
||||
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: $viewUrl (aksi Lihat, "__ID__" diganti row.id), $destroyUrl + $destroy['title'|'message'] (Hapus sungguhan
|
||||
Opsional: $tools (kunci tombol bilah yang boleh tampil, [] = tanpa tombol), $selectable (false = tanpa kotak centang),
|
||||
$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
|
||||
modal (baris data menyediakan row.form = nilai isian). Hanya tombol yang sungguh bekerja yang ditampilkan; Lihat tanpa
|
||||
@@ -14,15 +15,18 @@
|
||||
$viewUrl ??= null;
|
||||
$destroyUrl ??= null;
|
||||
$form ??= null;
|
||||
$selectable ??= true;
|
||||
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
|
||||
$tools = [
|
||||
$allTools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', 'startInsert()'],
|
||||
'H' => ['Hapus', 'trash', 'danger', 'remove()'],
|
||||
'C' => ['Cetak', 'printer', 'secondary', 'window.print()'],
|
||||
];
|
||||
$active = array_filter($tools, fn (string $key): bool => str_contains($page['flags'], $key)
|
||||
// $tools (opsional): daftar kunci tombol yang boleh tampil (T, H, C); kosong = tanpa tombol. Bawaan: menurut flags katalog.
|
||||
$allowed = isset($tools) ? array_flip($tools) : $allTools;
|
||||
$active = array_filter($allTools, fn (string $key): bool => isset($allowed[$key]) && str_contains($page['flags'], $key)
|
||||
&& match ($key) { 'T' => (bool) $form, 'H' => (bool) $destroyUrl, default => true }, ARRAY_FILTER_USE_KEY);
|
||||
$checkbox = in_array('#', $page['columns'], true);
|
||||
$checkbox = $selectable && in_array('#', $page['columns'], true);
|
||||
$actions = in_array('Aksi', $page['columns'], true);
|
||||
@endphp
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use App\Http\Controllers\Operator\PembayaranController;
|
||||
use App\Http\Controllers\Operator\RekapRuangController;
|
||||
use App\Http\Controllers\Operator\SatuPageController;
|
||||
use App\Http\Controllers\Operator\SemesterPendekController;
|
||||
use App\Http\Controllers\Operator\StudentDetailController;
|
||||
use App\Http\Controllers\Operator\StudentListController;
|
||||
use App\Http\Controllers\Operator\TahunAjaranController;
|
||||
use App\Http\Controllers\Operator\TahunKurikulumController;
|
||||
@@ -62,9 +63,9 @@ Route::post('pembayaran/{id}/lunas', [PembayaranController::class, 'paid'])->whe
|
||||
// Data JSON tabel Portal > Mahasiswa/Pegawai untuk akun DB lama (halamannya tetap operator.halaman list_mahasiswa/list_pegawai).
|
||||
Route::get('list_mahasiswa/data', [StudentListController::class, 'data'])->name('mahasiswa.data');
|
||||
Route::get('list_pegawai/data', [EmployeeListController::class, 'data'])->name('pegawai.data');
|
||||
Route::post('list_mahasiswa', [StudentListController::class, 'store'])->name('list-mahasiswa.store');
|
||||
Route::post('list_mahasiswa/hapus', [StudentListController::class, 'destroy'])->name('list-mahasiswa.destroy');
|
||||
Route::put('list_mahasiswa/{id}', [StudentListController::class, 'update'])->whereNumber('id')->name('list-mahasiswa.update');
|
||||
// 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/hapus', [EmployeeListController::class, 'destroy'])->name('list-pegawai.destroy');
|
||||
Route::put('list_pegawai/{id}', [EmployeeListController::class, 'update'])->whereNumber('id')->name('list-pegawai.update');
|
||||
|
||||
|
||||
@@ -118,6 +118,25 @@ trait FakesLegacyDatabase
|
||||
$table->string('nmr_ijazah')->nullable();
|
||||
$table->string('nmr_transkrip')->nullable();
|
||||
$table->date('tgl_transkrip')->nullable();
|
||||
// Biodata (halaman detail mahasiswa); nullable agar insert banyak baris di tes lain tetap jalan.
|
||||
$table->smallInteger('agama')->nullable();
|
||||
$table->smallInteger('kewarganegaraan')->nullable();
|
||||
$table->smallInteger('stat_nikah')->nullable();
|
||||
$table->smallInteger('gol_darah')->nullable();
|
||||
$table->smallInteger('pekerjaan')->nullable();
|
||||
foreach (['no_id' => 20, 'no_kk' => 20, 'nisn' => 10, 'telepon' => 35, 'kodepos' => 5, 'alamat_mhs' => 255, 'asal_alamat' => 255,
|
||||
'namaayah' => 50, 'namaibu' => 50, 'alamat_ortu' => 255, 'nama_wali' => 50, 'alamat_wali' => 50, 'namaslta' => 60,
|
||||
'npsn' => 10, 'jurslta' => 30, 'thnlulusslta' => 4, 'cip_updated' => 20] as $column => $length) {
|
||||
$table->string($column, $length)->nullable();
|
||||
}
|
||||
foreach (['pend_ayah', 'pend_ibu', 'pekerjaan_ortu', 'pekerjaan_ibu', 'penghasilan_ortu', 'tanggungan_ortu', 'pend_wali', 'pekerjaan_wali'] as $column) {
|
||||
$table->smallInteger($column)->nullable();
|
||||
}
|
||||
$table->timestamp('last_updated')->nullable();
|
||||
});
|
||||
$schema->create('t_kewarganegaraan', function (Blueprint $table) {
|
||||
$table->smallInteger('idwarganegara')->primary();
|
||||
$table->string('kewarganegaraan');
|
||||
});
|
||||
$schema->create('t_skripsi', function (Blueprint $table) {
|
||||
$table->integer('idmahasiswa');
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
|
||||
use App\Models\User;
|
||||
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 > Mahasiswa > Lihat: halaman detail dengan biodata lengkap yang bisa diubah per bagian (data asli DB lama).
|
||||
* Akun staf fakultas memegang prodi 21 dan 22; mahasiswa 600 milik prodi 99 di luar cakupan.
|
||||
*/
|
||||
class LegacyStudentDetailTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyOverview();
|
||||
$this->seedBiodata();
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
||||
->assertRedirect(route('operator.dashboard'));
|
||||
}
|
||||
|
||||
private function db(): ConnectionInterface
|
||||
{
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
private function seedBiodata(): void
|
||||
{
|
||||
$this->db()->table('xs_agama')->insert([['idagama' => 1, 'agama' => 'Islam'], ['idagama' => 2, 'agama' => 'Katolik']]);
|
||||
$this->db()->table('t_kewarganegaraan')->insert([['idwarganegara' => 0, 'kewarganegaraan' => 'Salah Mengisi / Tidak Mengisi'], ['idwarganegara' => 1, 'kewarganegaraan' => 'Indonesia Asli']]);
|
||||
$this->db()->table('t_pekerjaan')->insert([['idpekerjaan' => 0, 'pekerjaan' => '-'], ['idpekerjaan' => 4, 'pekerjaan' => 'Swasta'], ['idpekerjaan' => 5, 'pekerjaan' => 'Wiraswasta']]);
|
||||
$this->db()->table('t_tingkat_pendidikan')->insert([['idtingkat' => 0, 'tingkatpendidikan' => 'Tidak Mengisi'], ['idtingkat' => 3, 'tingkatpendidikan' => 'SMA (Sekolah Menengah Atas)'], ['idtingkat' => 8, 'tingkatpendidikan' => 'Sarjana / S1']]);
|
||||
$this->db()->table('t_penghasilan')->insert([['idpenghasilan' => 0, 'kodepenghasilan' => '0', 'penghasilan' => 'Salah mengisi'], ['idpenghasilan' => 4, 'kodepenghasilan' => '4', 'penghasilan' => 'Rp. 1 Juta - Rp 2.5 Juta']]);
|
||||
$this->db()->table('t_pegawai')->insert(['idpegawai' => 55, 'nip' => '198712122012122055', 'nama' => 'Siti Aminah', 'gelardepan' => 'Dr.', 'gelarbelakang' => 'M.T.']);
|
||||
$this->db()->table('t_kurikulum')->insertOrIgnore(['idkurikulum' => 900, 'idprogdi' => 21, 'idprogram' => 1, 'namakurikulum' => 'Kurikulum 2020']);
|
||||
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->update([
|
||||
'idprogram' => 1, 'jalur_masuk' => 1, 'idkurikulum' => 900, 'idpa' => 55, 'kelamin' => 2, 'tmplahir' => 'Pontianak', 'tgllahir' => '2001-09-22',
|
||||
'agama' => 1, 'kewarganegaraan' => 1, 'stat_nikah' => 1, 'gol_darah' => 2, 'no_id' => '6171000000000001', 'hp' => '081200000000',
|
||||
'alamat_mhs' => 'Jl. Ahmad Yani No. 1', 'namaayah' => 'Budi Santoso', 'pend_ayah' => 3, 'pekerjaan_ortu' => 4, 'namaibu' => 'Sri Wahyuni',
|
||||
'namaslta' => 'SMAN 1 Pontianak', 'thnlulusslta' => '2019',
|
||||
]);
|
||||
$this->db()->table('t_mahasiswa')->insert(['idmahasiswa' => 600, 'nim' => 'X600', 'nama' => 'Mahasiswa Luar', 'idprogdi' => 99, 'idangkatan' => 150]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function pribadi(array $override = []): array
|
||||
{
|
||||
return $override + [
|
||||
'nama' => 'Rina Lestari', 'kelamin' => 2, 'tmplahir' => 'Pontianak', 'tgllahir' => '2001-09-22', 'agama' => 1, 'kewarganegaraan' => 1,
|
||||
'stat_nikah' => 1, 'gol_darah' => 2, 'pekerjaan' => 0, 'no_id' => '6171000000000001', 'no_kk' => null, 'nisn' => null,
|
||||
];
|
||||
}
|
||||
|
||||
private function save(int $id, string $section, array $input)
|
||||
{
|
||||
return $this->putJson(route('operator.list-mahasiswa.biodata', [$id, $section]), $input);
|
||||
}
|
||||
|
||||
public function test_guests_and_other_roles_are_kept_out(): void
|
||||
{
|
||||
$this->post(route('logout'));
|
||||
$this->get(route('operator.list-mahasiswa.show', 500))->assertRedirect(route('login'));
|
||||
$this->put(route('operator.list-mahasiswa.biodata', [500, 'pribadi']))->assertRedirect(route('login'));
|
||||
|
||||
Auth::forgetGuards();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
$this->actingAs(User::factory()->dosen()->create());
|
||||
$this->get(route('operator.list-mahasiswa.show', 500))->assertForbidden();
|
||||
$this->save(500, 'pribadi', $this->pribadi(['nama' => 'Diubah']))->assertForbidden();
|
||||
$this->assertSame('Rina Lestari', $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('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-mahasiswa.show', 500))->assertNotFound();
|
||||
$this->save(500, 'pribadi', $this->pribadi())->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_list_links_view_action_to_the_detail_page(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_mahasiswa'))->assertOk()
|
||||
->assertSee('link(row)', false)
|
||||
->assertDontSee('startView(row)', false)
|
||||
->assertDontSee('Detail mahasiswa');
|
||||
}
|
||||
|
||||
public function test_detail_page_shows_the_full_biodata(): void
|
||||
{
|
||||
$this->get(route('operator.list-mahasiswa.show', 500))->assertOk()
|
||||
->assertSeeInOrder(['<h1', 'Detail Mahasiswa'], false)
|
||||
->assertSee('studentBiodata', 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')
|
||||
->assertSee('Tempat lahir')->assertSee('Pontianak')->assertSee('22 September 2001')->assertSee('Islam')->assertSee('Indonesia Asli')
|
||||
->assertSee('Budi Santoso')->assertSee('SMA (Sekolah Menengah Atas)')->assertSee('Swasta')->assertSee('SMAN 1 Pontianak')
|
||||
->assertSee('Jl. Ahmad Yani No. 1')
|
||||
// Data akademik: isian yang bisa diubah dan keterangan yang hanya dibaca
|
||||
->assertSee('Kurikulum 2020')->assertSee('SNMPTN')->assertSee('Reguler A')->assertSee('Dr. Siti Aminah')
|
||||
->assertSee('Masih kuliah')->assertSee('Jalur masuk')->assertSee('Dosen pembimbing akademik')
|
||||
->assertSee('x-on:submit.prevent="save()"', false);
|
||||
}
|
||||
|
||||
public function test_academic_section_is_editable_here_and_nowhere_else(): void
|
||||
{
|
||||
foreach (['store', 'update', 'destroy'] as $name) {
|
||||
$this->assertFalse(Route::has('operator.list-mahasiswa.'.$name), "Rute {$name} sudah dihapus.");
|
||||
}
|
||||
|
||||
$this->save(500, 'akademik', ['prodi' => 21, 'kurikulum' => 900, 'angkatan' => 160, 'program' => 2, 'jalur' => 3, 'status' => 3])
|
||||
->assertOk()->assertJsonPath('reload', true)->assertJsonPath('message', 'Data akademik diperbarui.')
|
||||
->assertSessionHas('status', 'Data akademik diperbarui.');
|
||||
|
||||
$row = $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->first();
|
||||
$this->assertSame([160, 2, 3, 3, 21, 900], [(int) $row->idangkatan, (int) $row->idprogram, (int) $row->jalur_masuk, (int) $row->stataktif, (int) $row->idprogdi, (int) $row->idkurikulum]);
|
||||
$this->assertSame(['SIAKAD', '198001012005011'], [$row->cname, $row->uname]);
|
||||
// NIM dan biodata tidak ikut berubah.
|
||||
$this->assertSame(['D1041191001', 'Rina Lestari', 'Pontianak'], [$row->nim, $row->nama, $row->tmplahir]);
|
||||
|
||||
$this->get(route('operator.list-mahasiswa.show', 500))->assertOk()->assertSee('Mengundurkan diri')->assertSee('MANDIRI')->assertSee('Reguler B');
|
||||
}
|
||||
|
||||
public function test_academic_section_is_validated_and_scoped(): void
|
||||
{
|
||||
$valid = ['prodi' => 21, 'kurikulum' => 900, 'angkatan' => 160, 'program' => 1, 'jalur' => 1, 'status' => 1];
|
||||
$this->save(500, 'akademik', [])->assertStatus(422)->assertJsonValidationErrors(['prodi', 'kurikulum', 'angkatan', 'program', 'status']);
|
||||
$this->save(500, 'akademik', ['status' => 9] + $valid)->assertStatus(422)->assertJsonValidationErrors(['status']);
|
||||
|
||||
foreach ([
|
||||
[['prodi' => 99], 'Program studi harus dipilih dari program studi Anda.'],
|
||||
[['kurikulum' => 999], 'Kurikulum harus dipilih dari program studi mahasiswa.'],
|
||||
[['angkatan' => 9999], 'Angkatan tidak ditemukan.'],
|
||||
[['program' => 9], 'Program kuliah tidak ditemukan.'],
|
||||
[['jalur' => 9], 'Jalur masuk tidak ditemukan.'],
|
||||
[['status' => 2], 'Status Lulus ditetapkan lewat yudisium, bukan di sini.'],
|
||||
] as [$override, $message]) {
|
||||
$this->save(500, 'akademik', $override + $valid)->assertStatus(422)->assertJsonPath('message', $message);
|
||||
}
|
||||
|
||||
$this->save(600, 'akademik', $valid)->assertNotFound();
|
||||
$this->assertSame([1, 150], [(int) $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('stataktif'), (int) $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('idangkatan')]);
|
||||
}
|
||||
|
||||
public function test_detail_of_other_programs_or_unknown_students_is_not_found(): void
|
||||
{
|
||||
$this->get(route('operator.list-mahasiswa.show', 600))->assertNotFound();
|
||||
$this->get(route('operator.list-mahasiswa.show', 99999))->assertNotFound();
|
||||
$this->save(600, 'pribadi', $this->pribadi(['nama' => 'Diretas']))->assertNotFound();
|
||||
$this->save(500, 'rahasia', $this->pribadi())->assertNotFound();
|
||||
$this->assertSame('Mahasiswa Luar', $this->db()->table('t_mahasiswa')->where('idmahasiswa', 600)->value('nama'));
|
||||
}
|
||||
|
||||
public function test_saving_a_section_writes_only_changed_columns(): void
|
||||
{
|
||||
$response = $this->save(500, 'pribadi', $this->pribadi(['nama' => 'Rina Lestari Putri', 'tmplahir' => 'Sambas', 'agama' => 2, 'gol_darah' => 3, 'pekerjaan' => 4, 'nisn' => '0012345678']))
|
||||
->assertOk()->assertJsonPath('message', 'Biodata diperbarui.');
|
||||
|
||||
$row = $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->first();
|
||||
$this->assertSame(['Rina Lestari Putri', 'Sambas', 2, 3, 4, '0012345678'], [$row->nama, $row->tmplahir, (int) $row->agama, (int) $row->gol_darah, (int) $row->pekerjaan, $row->nisn]);
|
||||
// Kolom yang tidak berubah dibiarkan: kolom kosong tidak ikut ditulis 0 atau string kosong.
|
||||
$this->assertNull($row->no_kk);
|
||||
$this->assertSame('6171000000000001', $row->no_id);
|
||||
$this->assertSame(['SIAKAD', '198001012005011'], [$row->cname, $row->uname]);
|
||||
$this->assertNotNull($row->last_updated);
|
||||
|
||||
$response->assertJsonPath('display.nama', 'Rina Lestari Putri')->assertJsonPath('display.agama', 'Katolik')
|
||||
->assertJsonPath('display.tgllahir', '22 September 2001')->assertJsonPath('display.no_kk', '–')
|
||||
->assertJsonPath('values.agama', 2)->assertJsonPath('values.pekerjaan', 4);
|
||||
}
|
||||
|
||||
public function test_saving_without_changes_touches_nothing(): void
|
||||
{
|
||||
$before = $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->first();
|
||||
|
||||
$this->save(500, 'pribadi', $this->pribadi())->assertOk()->assertJsonPath('message', 'Tidak ada perubahan.');
|
||||
|
||||
$this->assertEquals($before, $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->first());
|
||||
}
|
||||
|
||||
public function test_each_section_can_be_saved(): void
|
||||
{
|
||||
$this->save(500, 'kontak', ['hp' => '081299999999', 'telepon' => null, 'email_mhs' => 'rina@student.untan.ac.id', 'kodepos' => '78124', 'alamat_mhs' => "Jl. Baru\nBlok C", 'asal_alamat' => null])->assertOk();
|
||||
$this->save(500, 'ortu', ['namaayah' => 'Budi S.', 'pend_ayah' => 8, 'pekerjaan_ortu' => 5, 'namaibu' => 'Sri W.', 'pend_ibu' => 3, 'pekerjaan_ibu' => 4, 'penghasilan_ortu' => 4, 'tanggungan_ortu' => 3, 'alamat_ortu' => 'Sambas'])->assertOk();
|
||||
$this->save(500, 'wali', ['nama_wali' => 'Paman', 'pend_wali' => 8, 'pekerjaan_wali' => 5, 'alamat_wali' => 'Singkawang'])->assertOk();
|
||||
$this->save(500, 'sekolah', ['namaslta' => 'SMAN 2', 'npsn' => '30100001', 'jurslta' => 'IPA', 'thnlulusslta' => '2020'])->assertOk();
|
||||
|
||||
$row = $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->first();
|
||||
$this->assertSame(['rina@student.untan.ac.id', '78124', "Jl. Baru\nBlok C"], [$row->email_mhs, $row->kodepos, $row->alamat_mhs]);
|
||||
$this->assertSame(['Budi S.', 8, 5, 'Sri W.', 3, 4, 4, 3], [$row->namaayah, (int) $row->pend_ayah, (int) $row->pekerjaan_ortu, $row->namaibu, (int) $row->pend_ibu, (int) $row->pekerjaan_ibu, (int) $row->penghasilan_ortu, (int) $row->tanggungan_ortu]);
|
||||
$this->assertSame(['Paman', 8, 5, 'Singkawang'], [$row->nama_wali, (int) $row->pend_wali, (int) $row->pekerjaan_wali, $row->alamat_wali]);
|
||||
$this->assertSame(['SMAN 2', '30100001', 'IPA', '2020'], [$row->namaslta, $row->npsn, $row->jurslta, $row->thnlulusslta]);
|
||||
// Bagian lain tidak terpengaruh.
|
||||
$this->assertSame(['Rina Lestari', 'Pontianak'], [$row->nama, $row->tmplahir]);
|
||||
|
||||
// Mengosongkan teks menjadi null.
|
||||
$this->save(500, 'sekolah', ['namaslta' => '', 'npsn' => '30100001', 'jurslta' => 'IPA', 'thnlulusslta' => '2020'])->assertOk();
|
||||
$this->assertNull($this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('namaslta'));
|
||||
}
|
||||
|
||||
public function test_input_is_validated(): void
|
||||
{
|
||||
$this->save(500, 'pribadi', [])->assertStatus(422)->assertJsonValidationErrors(['nama', 'kelamin', 'stat_nikah']);
|
||||
$this->save(500, 'pribadi', $this->pribadi(['nama' => str_repeat('A', 51)]))->assertStatus(422)->assertJsonValidationErrors(['nama']);
|
||||
$this->save(500, 'pribadi', $this->pribadi(['tgllahir' => 'kemarin', 'agama' => 9, 'kelamin' => 7]))->assertStatus(422)->assertJsonValidationErrors(['tgllahir', 'agama', 'kelamin']);
|
||||
$this->save(500, 'pribadi', $this->pribadi(['tgllahir' => now()->addDay()->toDateString()]))->assertStatus(422)->assertJsonValidationErrors(['tgllahir']);
|
||||
$this->save(500, 'pribadi', $this->pribadi(['no_kk' => '12-34 56']))->assertStatus(422)->assertJsonValidationErrors(['no_kk']);
|
||||
$this->save(500, 'kontak', ['email_mhs' => 'bukan-email'])->assertStatus(422)->assertJsonValidationErrors(['email_mhs']);
|
||||
$this->save(500, 'ortu', ['pend_ayah' => 77, 'tanggungan_ortu' => 99])->assertStatus(422)->assertJsonValidationErrors(['pend_ayah', 'tanggungan_ortu']);
|
||||
$this->save(500, 'sekolah', ['thnlulusslta' => '20x9'])->assertStatus(422)->assertJsonValidationErrors(['thnlulusslta']);
|
||||
|
||||
$this->assertSame('Rina Lestari', $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('nama'));
|
||||
}
|
||||
|
||||
public function test_unchanged_legacy_values_are_not_rejected(): void
|
||||
{
|
||||
// Data lama tidak selalu seragam: NIK berspasi dan kode pendidikan di luar tabel tidak menghalangi perubahan lain.
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['no_id' => '6171 0000 0000 0001']);
|
||||
$this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['pend_ayah' => 55]);
|
||||
|
||||
$this->save(500, 'pribadi', $this->pribadi(['no_id' => '6171 0000 0000 0001', 'tmplahir' => 'Mempawah']))->assertOk();
|
||||
$this->assertSame('Mempawah', $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('tmplahir'));
|
||||
|
||||
$this->get(route('operator.list-mahasiswa.show', 500))->assertOk()->assertSee('Kode 55');
|
||||
$this->save(500, 'ortu', ['namaayah' => 'Budi S.', 'pend_ayah' => 55])->assertOk();
|
||||
$this->assertSame(55, (int) $this->db()->table('t_mahasiswa')->where('idmahasiswa', 500)->value('pend_ayah'));
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* CRUD Portal > Mahasiswa (t_mahasiswa) dan Portal > Pegawai (t_pegawai + t_dosen) berdata asli lewat modal remote-list.
|
||||
* CRUD Portal > Pegawai (t_pegawai + t_dosen) berdata asli lewat modal remote-list. 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
|
||||
@@ -38,15 +39,6 @@ class LegacyStudentEmployeeCrudTest extends TestCase
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function student(array $override = []): array
|
||||
{
|
||||
return $override + [
|
||||
'nim' => 'd1041211001', 'nama' => 'Siti Rahma', 'prodi' => 21, 'kurikulum' => 900, 'angkatan' => 160, 'program' => 1, 'jalur' => 3,
|
||||
'kelamin' => 2, 'tmplahir' => 'Pontianak', 'tgllahir' => '2003-05-17', 'hp' => '081200000000', 'email' => 'siti.rahma@student.untan.ac.id', 'status' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function employee(array $override = []): array
|
||||
{
|
||||
@@ -56,123 +48,25 @@ class LegacyStudentEmployeeCrudTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
private function studentRow(int $id): ?array
|
||||
{
|
||||
return collect($this->getJson(route('operator.mahasiswa.data', ['per' => 25]))->assertOk()->json('rows'))->firstWhere('id', $id);
|
||||
}
|
||||
|
||||
public function test_guests_and_other_roles_cannot_write(): void
|
||||
{
|
||||
$this->post(route('logout'));
|
||||
foreach ([['post', route('operator.list-mahasiswa.store')], ['put', route('operator.list-mahasiswa.update', 500)], ['post', route('operator.list-mahasiswa.destroy')],
|
||||
['put', route('operator.list-pegawai.update', 11)], ['post', route('operator.list-pegawai.destroy')]] as [$method, $url]) {
|
||||
foreach ([['put', route('operator.list-pegawai.update', 11)], ['post', route('operator.list-pegawai.destroy')]] as [$method, $url]) {
|
||||
$this->{$method}($url)->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
Auth::forgetGuards();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
$this->actingAs(User::factory()->dosen()->create())->post(route('operator.list-mahasiswa.store'), $this->student())->assertForbidden();
|
||||
$this->actingAs(User::factory()->mahasiswa()->create())->put(route('operator.list-pegawai.update', 11), $this->employee())->assertForbidden();
|
||||
$this->assertSame(0, $this->db()->table('t_mahasiswa')->where('nim', 'D1041211001')->count());
|
||||
}
|
||||
|
||||
public function test_pages_wire_the_real_buttons(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_mahasiswa'))->assertOk()
|
||||
->assertSee('startInsert()', false)->assertSee('Tambah mahasiswa')->assertSee('Program kuliah')->assertSee('Hapus mahasiswa?')
|
||||
->assertDontSee("demo('Tambah')", false);
|
||||
$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_student_create_and_rows(): void
|
||||
{
|
||||
$id = $this->postJson(route('operator.list-mahasiswa.store'), $this->student())->assertCreated()->assertJsonPath('message', 'Mahasiswa ditambahkan.')->json('id');
|
||||
|
||||
$m = $this->db()->table('t_mahasiswa')->where('idmahasiswa', $id)->first();
|
||||
$this->assertSame(['D1041211001', 'Siti Rahma', 21, 900, 160, 1, 3, 2, 1], [$m->nim, $m->nama, (int) $m->idprogdi, (int) $m->idkurikulum, (int) $m->idangkatan, (int) $m->idprogram, (int) $m->jalur_masuk, (int) $m->kelamin, (int) $m->stataktif]);
|
||||
$this->assertSame(['SIAKAD', '198001012005011'], [$m->cname, $m->uname]);
|
||||
|
||||
$row = $this->studentRow($id);
|
||||
$this->assertSame('D1041211001', $row['nim']);
|
||||
$this->assertSame(
|
||||
['nim' => 'D1041211001', 'nama' => 'Siti Rahma', 'prodi' => 21, 'kurikulum' => 900, 'angkatan' => 160, 'program' => 1, 'jalur' => 3, 'kelamin' => 2,
|
||||
'tmplahir' => 'Pontianak', 'tgllahir' => '2003-05-17', 'hp' => '081200000000', 'email' => 'siti.rahma@student.untan.ac.id', 'status' => 1],
|
||||
$row['form'],
|
||||
);
|
||||
|
||||
// Jalur masuk boleh kosong pada tambah (bawaan 1).
|
||||
$other = $this->postJson(route('operator.list-mahasiswa.store'), $this->student(['nim' => 'D1041211002', 'jalur' => null]))->assertCreated()->json('id');
|
||||
$this->assertSame(1, (int) $this->db()->table('t_mahasiswa')->where('idmahasiswa', $other)->value('jalur_masuk'));
|
||||
}
|
||||
|
||||
public function test_student_create_is_validated_and_guarded(): void
|
||||
{
|
||||
$url = route('operator.list-mahasiswa.store');
|
||||
$this->postJson($url, [])->assertStatus(422)->assertJsonValidationErrors(['nim', 'nama', 'prodi', 'kurikulum', 'angkatan', 'program', 'kelamin', 'status']);
|
||||
$this->postJson($url, $this->student(['email' => 'bukan-email', 'tgllahir' => 'kemarin', 'kelamin' => 7]))->assertStatus(422)->assertJsonValidationErrors(['email', 'tgllahir', 'kelamin']);
|
||||
|
||||
$this->postJson($url, $this->student(['prodi' => 99, 'kurikulum' => 901]))->assertStatus(422)->assertJsonPath('message', 'Program studi harus dipilih dari program studi Anda.');
|
||||
// Kurikulum prodi 22 untuk mahasiswa prodi 21 ditolak.
|
||||
$this->postJson($url, $this->student(['kurikulum' => 902]))->assertStatus(422)->assertJsonPath('message', 'Kurikulum harus dipilih dari program studi mahasiswa.');
|
||||
$this->postJson($url, $this->student(['angkatan' => 9999]))->assertStatus(422)->assertJsonPath('message', 'Angkatan tidak ditemukan.');
|
||||
$this->postJson($url, $this->student(['program' => 9]))->assertStatus(422)->assertJsonPath('message', 'Program kuliah tidak ditemukan.');
|
||||
$this->postJson($url, $this->student(['jalur' => 9]))->assertStatus(422)->assertJsonPath('message', 'Jalur masuk tidak ditemukan.');
|
||||
$this->postJson($url, $this->student(['nim' => 'a b!']))->assertStatus(422)->assertJsonPath('message', 'NIM hanya boleh huruf dan angka (5 sampai 15 karakter).');
|
||||
$this->postJson($url, $this->student(['nim' => 'd1041191001']))->assertStatus(422)->assertJsonPath('message', 'NIM D1041191001 sudah terdaftar.');
|
||||
$this->postJson($url, $this->student(['status' => 2]))->assertStatus(422)->assertJsonPath('message', 'Status Lulus ditetapkan lewat yudisium, bukan di sini.');
|
||||
$this->assertSame(0, $this->db()->table('t_mahasiswa')->where('nim', 'D1041211001')->count());
|
||||
}
|
||||
|
||||
public function test_student_update_keeps_scope_and_nim(): void
|
||||
{
|
||||
$url = fn (int $id): string => route('operator.list-mahasiswa.update', $id);
|
||||
$payload = $this->student(['nim' => 'X501', 'nama' => 'Nama Baru', 'prodi' => 22, 'kurikulum' => 902, 'status' => 3, 'jalur' => null]);
|
||||
|
||||
$this->putJson($url(501), $payload)->assertOk()->assertJsonPath('message', 'Data mahasiswa diperbarui.');
|
||||
$m = $this->db()->table('t_mahasiswa')->where('idmahasiswa', 501)->first();
|
||||
$this->assertSame(['Nama Baru', 22, 902, 3, 1], [$m->nama, (int) $m->idprogdi, (int) $m->idkurikulum, (int) $m->stataktif, (int) $m->jalur_masuk]);
|
||||
$this->assertSame('198001012005011', $m->uname);
|
||||
|
||||
$this->putJson($url(502), $this->student(['nim' => 'X999']))->assertStatus(422)->assertJsonPath('message', 'NIM tidak dapat diubah. Buat mahasiswa baru dengan NIM yang sesuai.');
|
||||
$this->putJson($url(502), $this->student(['nim' => 'X502', 'status' => 2]))->assertStatus(422)->assertJsonPath('message', 'Status Lulus ditetapkan lewat yudisium, bukan di sini.');
|
||||
// Mahasiswa yang sudah lulus boleh disunting tanpa mengubah status.
|
||||
$this->putJson($url(505), $this->student(['nim' => 'X505', 'status' => 2]))->assertOk();
|
||||
// Mahasiswa prodi 99 dan ID yang tidak ada ditolak.
|
||||
$this->putJson($url(600), $this->student(['nim' => 'X600']))->assertStatus(422)->assertJsonPath('message', 'Mahasiswa tidak ditemukan.');
|
||||
$this->putJson($url(9999), $this->student())->assertStatus(422)->assertJsonPath('message', 'Mahasiswa tidak ditemukan.');
|
||||
$this->assertSame('Mahasiswa Luar', $this->db()->table('t_mahasiswa')->where('idmahasiswa', 600)->value('nama'));
|
||||
// Pindah ke prodi di luar cakupan ditolak.
|
||||
$this->putJson($url(502), $this->student(['nim' => 'X502', 'prodi' => 99, 'kurikulum' => 901]))->assertStatus(422)->assertJsonPath('message', 'Program studi harus dipilih dari program studi Anda.');
|
||||
}
|
||||
|
||||
public function test_student_delete_only_without_dependents(): void
|
||||
{
|
||||
$url = route('operator.list-mahasiswa.destroy');
|
||||
$new = $this->postJson(route('operator.list-mahasiswa.store'), $this->student())->assertCreated()->json('id');
|
||||
$this->db()->table('t_evaluasi_rekap')->insert(['idmahasiswa' => $new]);
|
||||
|
||||
// Punya KRS (500), akun login, atau pembayaran: ditolak, dan tidak ada yang terhapus walau dicampur baris yang boleh.
|
||||
$this->postJson($url, ['ids' => [$new, 500]])->assertStatus(422)->assertJsonPath('message', 'Mahasiswa D1041191001 sudah punya data akademik, keuangan, atau akun login sehingga tidak boleh dihapus.');
|
||||
$this->assertSame(1, $this->db()->table('t_mahasiswa')->where('idmahasiswa', $new)->count());
|
||||
|
||||
$this->db()->table('t_account')->insert(['iduser' => 900, 'username' => 'x', 'passwd' => 'y', 'identitas' => 503, 'jenis' => 1]);
|
||||
$this->postJson($url, ['ids' => [503]])->assertStatus(422)->assertJsonPath('message', 'Mahasiswa X503 sudah punya data akademik, keuangan, atau akun login sehingga tidak boleh dihapus.');
|
||||
$this->db()->table('t_keuanganmhs')->insert(['idmahasiswa' => 504, 'jenis' => 1, 'idperiode' => 368, 'jumlah' => 1000]);
|
||||
$this->postJson($url, ['ids' => [504]])->assertStatus(422);
|
||||
$this->assertSame(2, $this->db()->table('t_mahasiswa')->whereIn('idmahasiswa', [503, 504])->count());
|
||||
|
||||
// Di luar cakupan prodi atau tidak ada.
|
||||
$this->postJson($url, ['ids' => [600]])->assertStatus(422)->assertJsonPath('message', 'Mahasiswa tidak ditemukan.');
|
||||
$this->postJson($url, ['ids' => []])->assertStatus(422)->assertJsonValidationErrors('ids');
|
||||
$this->assertSame(1, $this->db()->table('t_mahasiswa')->where('idmahasiswa', 600)->count());
|
||||
|
||||
$this->postJson($url, ['ids' => [$new]])->assertOk()->assertJsonPath('message', '1 mahasiswa dihapus.');
|
||||
$this->assertSame(0, $this->db()->table('t_mahasiswa')->where('idmahasiswa', $new)->count());
|
||||
$this->assertSame(0, $this->db()->table('t_evaluasi_rekap')->where('idmahasiswa', $new)->count());
|
||||
}
|
||||
|
||||
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'));
|
||||
|
||||
@@ -61,16 +61,18 @@ class LegacyStudentListTest extends TestCase
|
||||
|
||||
// Kolom dan filter sama dengan halaman SATU list_mahasiswa.
|
||||
$headers = array_map(fn ($th): string => $this->textOf($th), iterator_to_array($xpath->query("{$panel}//thead/tr/th")));
|
||||
$this->assertSame(['', 'NIM', 'Nama', 'Jenjang', 'Program Studi', 'Masuk', 'Status', 'Smt', 'SKS', 'IPK', 'Aksi'], $headers);
|
||||
$this->assertSame(['NIM', 'Nama', 'Jenjang', 'Program Studi', 'Masuk', 'Status', 'Smt', 'SKS', 'IPK', 'Aksi'], $headers, 'Tanpa kotak centang: tidak ada aksi massal.');
|
||||
$labels = array_map(fn ($label): string => $this->textOf($label), iterator_to_array($xpath->query("//section[@aria-label='Filter data']//label")));
|
||||
$this->assertSame(['Unit / Program Studi', 'Angkatan', 'Status Mahasiswa', 'Sistem Kuliah', 'Jalur Pendaftaran'], $labels);
|
||||
|
||||
foreach (['Tambah', 'Hapus', 'Cetak'] as $label) {
|
||||
$this->assertSame(1, $xpath->query("{$panel}//div[contains(@class, 'satu-bar__tools')]//button[normalize-space()='{$label}']")->length, "Tombol {$label}");
|
||||
}
|
||||
foreach (['Lihat', 'Ubah', 'Hapus'] as $label) {
|
||||
$this->assertSame(1, $xpath->query("{$panel}//tbody/template//button[@aria-label='{$label}']")->length, "Aksi baris {$label}");
|
||||
// Daftar hanya untuk melihat: tanpa Tambah, Hapus, Cetak di bilah, dan tanpa Ubah/Hapus di baris.
|
||||
$this->assertSame(0, $xpath->query("{$panel}//div[contains(@class, 'satu-bar__tools')]//button")->length, 'Bilah tanpa tombol.');
|
||||
foreach (['Ubah', 'Hapus'] as $label) {
|
||||
$this->assertSame(0, $xpath->query("{$panel}//tbody/template//button[@aria-label='{$label}']")->length, "Tanpa aksi baris {$label}");
|
||||
}
|
||||
$response->assertDontSee('startInsert()', false)->assertDontSee('startEdit(row)', false)->assertDontSee('askRemove', false)->assertDontSee('window.print()', false);
|
||||
// Lihat membuka halaman detail mahasiswa (tautan), bukan modal.
|
||||
$this->assertSame(1, $xpath->query("{$panel}//tbody/template//a[@aria-label='Lihat']")->length, 'Aksi baris Lihat');
|
||||
$this->assertSame(1, $xpath->query("//nav[@aria-label='Halaman data']")->length);
|
||||
|
||||
// Tidak ada formulir: filter dan halaman tidak mengubah alamat halaman.
|
||||
|
||||
Reference in New Issue
Block a user