Pembaruan halaman Operator dan Mahasiswa
This commit is contained in:
@@ -6,8 +6,10 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Operator\Concerns\ServesLegacyList;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\Administration;
|
||||
use App\Support\Legacy\AdministrationWriter;
|
||||
use App\Support\Legacy\ClassSchedule;
|
||||
use App\Support\Legacy\Curriculum;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -15,8 +17,9 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Perkuliahan > Administrasi untuk akun DB lama (hanya baca): Status Semester, Pembimbing Akademik, Paket Kuliah,
|
||||
* Evaluasi Mahasiswa, Transfer Mahasiswa, Cekal, Berhenti Studi, Konversi Nilai, Mahasiswa Keluar.
|
||||
* Perkuliahan > Administrasi untuk akun DB lama: Status Semester, Pembimbing Akademik, Paket Kuliah, Evaluasi Mahasiswa,
|
||||
* Transfer Mahasiswa, Cekal, Berhenti Studi, Konversi Nilai, Mahasiswa Keluar. Pembimbing Akademik, Cekal, Berhenti Studi
|
||||
* (pengajuan cuti), dan Mahasiswa Keluar bisa ditulis (AdministrationWriter); halaman lain turunan dan hanya baca.
|
||||
* Satu metode halaman + satu metode data() per slug; semua memakai view remote-list kecuali Paket Kuliah (formulir GET).
|
||||
*/
|
||||
class AdministrasiController extends Controller
|
||||
@@ -30,6 +33,7 @@ class AdministrasiController extends Controller
|
||||
private readonly Administration $admin,
|
||||
private readonly ClassSchedule $schedule,
|
||||
private readonly Curriculum $curriculum,
|
||||
private readonly AdministrationWriter $writer,
|
||||
) {}
|
||||
|
||||
// ---- Status Semester (set_semester) -------------------------------------------------------------------------
|
||||
@@ -40,6 +44,7 @@ class AdministrasiController extends Controller
|
||||
[$labelPeriode, $labelMasuk, $labelUnit] = $page['filters'];
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('set_semester', $page),
|
||||
'note' => 'Rekap status semester asli (t_histori_mahasiswa) mahasiswa yang masih kuliah per program studi: Belum Ada = belum berstatus pada periode; Kampus Merdeka dari pendaftaran MBKM; Belum Diajukan/Disetujui dari KRS. Double Degree tidak tercatat.',
|
||||
'empty' => self::EMPTY,
|
||||
@@ -87,10 +92,12 @@ class AdministrasiController extends Controller
|
||||
{
|
||||
[$page, $programs, $prodi, $periods, $default] = $this->context($request, 'list_mhspa');
|
||||
[$labelPeriode, $labelUnit, $labelPa, $labelKrs, $labelMasuk, $labelStatus] = $page['filters'];
|
||||
$page = $this->withTools($page, 'THC', actions: true);
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_mhspa', $page),
|
||||
'note' => 'Mahasiswa yang masih kuliah beserta pembimbing akademik (t_mahasiswa.idpa), status semester, KRS periode terpilih, batas SKS (f_maxsks), SKS lulus dan IPK asli. Tombol aksi belum mengubah data.',
|
||||
'note' => 'Mahasiswa yang masih kuliah beserta pembimbing akademik (t_mahasiswa.idpa), status semester, KRS periode terpilih, batas SKS (f_maxsks), SKS lulus dan IPK asli. Tambah/Ubah menetapkan dosen PA (dosen aktif prodi Anda) dan Hapus melepasnya; langsung tersimpan di t_mahasiswa.idpa.',
|
||||
'empty' => self::EMPTY,
|
||||
'url' => route('operator.pembimbing-akademik.data'),
|
||||
'filters' => [
|
||||
@@ -117,6 +124,17 @@ class AdministrasiController extends Controller
|
||||
],
|
||||
'perPage' => Administration::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->admin->advisees($prodi, $this->adviseeFilter($request, $prodi, $periods, $default), $this->perPage($request, Administration::PER_PAGE))),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'pembimbing akademik',
|
||||
'storeUrl' => route('operator.pembimbing-akademik.store'),
|
||||
'updateUrl' => route('operator.pembimbing-akademik.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM mahasiswa', 'type' => 'text', 'required' => true, 'max' => 15, 'hint' => 'Mahasiswa aktif program studi Anda. Saat mengubah, NIM tidak berubah.'],
|
||||
['name' => 'dosen', 'label' => 'Dosen pembimbing akademik', 'type' => 'select', 'options' => $this->writer->advisorOptions($prodi), 'required' => true],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => $prodi === [] ? null : route('operator.pembimbing-akademik.destroy'),
|
||||
'destroy' => ['title' => 'Lepas pembimbing akademik?', 'message' => 'Pembimbing akademik mahasiswa terpilih dilepas.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -177,6 +195,7 @@ class AdministrasiController extends Controller
|
||||
[$labelPeriode, $labelStatus, $labelUnit, $labelMasuk] = $page['filters'];
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_evaluasimhs', $page),
|
||||
'note' => 'Hasil evaluasi asli (t_evaluasi) mahasiswa yang terkena evaluasi. Kode status evaluasi DB lama tidak punya tabel referensi, jadi ditampilkan sebagai nomor; SKS/IPK evaluasi pembanding tidak tercatat.',
|
||||
'empty' => $prodi === [] ? self::EMPTY : ['icon' => 'clipboard-document-check', 'title' => 'Belum ada hasil evaluasi', 'description' => 'Belum ada mahasiswa program studi Anda yang terkena evaluasi.'],
|
||||
@@ -235,6 +254,7 @@ class AdministrasiController extends Controller
|
||||
[$labelProdi, $labelAngkatan, $labelJenis, $labelStatus] = $page['filters'];
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('set_transfermhs', $page),
|
||||
'note' => 'Mahasiswa pindahan asli antarprogram studi (t_pindah) yang masuk ke program studi Anda. Pindahan dari perguruan tinggi lain, IPK asal, dan status nilai transfer tidak tercatat di DB lama.',
|
||||
'empty' => self::EMPTY,
|
||||
@@ -275,10 +295,12 @@ class AdministrasiController extends Controller
|
||||
{
|
||||
[$page, $programs, $prodi, $periods, $default] = $this->context($request, 'set_cekal');
|
||||
[$labelPeriode, $labelProdi, $labelTahun] = $page['filters'];
|
||||
$page = $this->withTools($page, 'T', actions: true);
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('set_cekal', $page),
|
||||
'note' => 'Penanda cekal asli (t_mahasiswa_cekal) pada mahasiswa yang masih kuliah; mahasiswa tercekal tampil lebih dulu. DB lama tidak merinci jenis cekal (akademik, keuangan, perpustakaan, kemahasiswaan).',
|
||||
'note' => 'Penanda cekal asli (t_mahasiswa_cekal) pada mahasiswa yang masih kuliah; mahasiswa tercekal tampil lebih dulu. DB lama tidak merinci jenis cekal (akademik, keuangan, perpustakaan, kemahasiswaan). Tambah/Ubah menetapkan atau mencabut cekal; Hapus mencabut cekal mahasiswa itu.',
|
||||
'empty' => self::EMPTY,
|
||||
'url' => route('operator.cekal.data'),
|
||||
'filters' => [
|
||||
@@ -300,6 +322,17 @@ class AdministrasiController extends Controller
|
||||
],
|
||||
'perPage' => Administration::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->admin->blacklist($prodi, ['periode' => $this->periode($request, $periods, $default)] + $this->simpleFilter($request, $prodi), $this->perPage($request, Administration::PER_PAGE))),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'cekal',
|
||||
'storeUrl' => route('operator.cekal.store'),
|
||||
'updateUrl' => route('operator.cekal.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM mahasiswa', 'type' => 'text', 'required' => true, 'max' => 15, 'hint' => 'Mahasiswa aktif program studi Anda. Saat mengubah, NIM tidak berubah.'],
|
||||
['name' => 'cekal', 'label' => 'Cekal', 'type' => 'select', 'options' => [1 => 'Ya', 0 => 'Tidak'], 'required' => true, 'default' => 1],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => $prodi === [] ? null : route('operator.cekal.destroy'),
|
||||
'destroy' => ['title' => 'Cabut cekal?', 'message' => 'Cekal mahasiswa terpilih dicabut.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -316,10 +349,12 @@ class AdministrasiController extends Controller
|
||||
{
|
||||
[$page, $programs, $prodi, $periods] = $this->context($request, 'set_berhentistudi');
|
||||
[$labelPeriode, $labelProdi, $labelStatus] = $page['filters'];
|
||||
$page = $this->withTools($page, 'T', actions: true);
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('set_berhentistudi', $page),
|
||||
'note' => 'Pengajuan cuti asli (t_cuti; status dari pola verifikasi DB lama) dan mutasi keluar (t_mutasi_dikti) mahasiswa program studi Anda. Hanya baca.',
|
||||
'note' => 'Pengajuan cuti asli (t_cuti; status dari pola verifikasi DB lama) dan mutasi keluar (t_mutasi_dikti) mahasiswa program studi Anda. Tambah/Ubah/Hapus hanya berlaku untuk pengajuan cuti; mutasi keluar berasal dari DIKTI dan hanya dibaca.',
|
||||
'empty' => self::EMPTY,
|
||||
'url' => route('operator.berhenti-studi.data'),
|
||||
'filters' => [
|
||||
@@ -336,6 +371,19 @@ class AdministrasiController extends Controller
|
||||
],
|
||||
'perPage' => Administration::PER_PAGE,
|
||||
'data' => $prodi === [] ? null : $this->payload($this->admin->withdrawals($prodi, $this->withdrawalFilter($request, $prodi, $periods), $this->perPage($request, Administration::PER_PAGE))),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'pengajuan cuti',
|
||||
'storeUrl' => route('operator.berhenti-studi.store'),
|
||||
'updateUrl' => route('operator.berhenti-studi.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM mahasiswa', 'type' => 'text', 'required' => true, 'max' => 15, 'hint' => 'Mahasiswa aktif program studi Anda. Saat mengubah, NIM tidak berubah.'],
|
||||
['name' => 'periode', 'label' => 'Periode cuti', 'type' => 'select', 'options' => $periods->all(), 'required' => true],
|
||||
['name' => 'alasan', 'label' => 'Alasan', 'type' => 'select', 'options' => $this->writer->leaveReasons()],
|
||||
['name' => 'status', 'label' => 'Status pengajuan', 'type' => 'select', 'options' => Administration::CUTI_STATUS, 'required' => true, 'default' => 0],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => $prodi === [] ? null : route('operator.berhenti-studi.destroy'),
|
||||
'destroy' => ['title' => 'Hapus pengajuan cuti?', 'message' => 'Hanya pengajuan cuti yang dihapus; mutasi keluar DIKTI tidak ikut terhapus.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -366,6 +414,7 @@ class AdministrasiController extends Controller
|
||||
[$labelProdi, $labelPeriode, $labelStatus] = $page['filters'];
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_ekivnilai', $page),
|
||||
'note' => 'Konversi nilai asli (t_kst_konversi_log) per mahasiswa per periode nilai, dengan SKS KRS periode itu. Status aktivitas (double degree, kampus merdeka) tidak tercatat; filter itu tidak menyaring.',
|
||||
'empty' => self::EMPTY,
|
||||
@@ -412,8 +461,9 @@ class AdministrasiController extends Controller
|
||||
[$page, , $prodi] = $this->context($request, 'list_mhskeluar');
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'strict' => true,
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_mhskeluar', $page),
|
||||
'note' => 'Mahasiswa keluar asli (status t_mahasiswa.stataktif: mengundurkan diri, keluar, pindah) program studi Anda; periode keluar dari mutasi DIKTI atau riwayat semester terakhir. Tombol tambah belum mengubah data.',
|
||||
'note' => 'Mahasiswa keluar asli (status t_mahasiswa.stataktif: mengundurkan diri, keluar, pindah) program studi Anda; periode keluar dari mutasi DIKTI atau riwayat semester terakhir. Tambah menandai mahasiswa aktif sebagai keluar, Ubah mengganti statusnya, Hapus mengembalikannya sebagai masih kuliah (t_mahasiswa.stataktif).',
|
||||
'empty' => self::EMPTY,
|
||||
'url' => route('operator.mahasiswa-keluar.data'),
|
||||
'filters' => [],
|
||||
@@ -426,6 +476,17 @@ class AdministrasiController extends Controller
|
||||
],
|
||||
'perPage' => Administration::PER_PAGE,
|
||||
'data' => $prodi === [] ? null : $this->payload($this->admin->leavers($prodi, ['q' => $this->query($request)], $this->perPage($request, Administration::PER_PAGE))),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'mahasiswa keluar',
|
||||
'storeUrl' => route('operator.mahasiswa-keluar.store'),
|
||||
'updateUrl' => route('operator.mahasiswa-keluar.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM mahasiswa', 'type' => 'text', 'required' => true, 'max' => 15, 'hint' => 'Mahasiswa aktif program studi Anda. Saat mengubah, NIM tidak berubah.'],
|
||||
['name' => 'status', 'label' => 'Status mahasiswa', 'type' => 'select', 'options' => Administration::LEFT_STATUS, 'required' => true],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => $prodi === [] ? null : route('operator.mahasiswa-keluar.destroy'),
|
||||
'destroy' => ['title' => 'Batalkan status keluar?', 'message' => 'Mahasiswa terpilih dikembalikan sebagai mahasiswa yang masih kuliah.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -436,6 +497,160 @@ class AdministrasiController extends Controller
|
||||
return response()->json($this->payload($this->admin->leavers($prodi, ['q' => $this->query($request)], $this->perPage($request, Administration::PER_PAGE))));
|
||||
}
|
||||
|
||||
// ---- Aksi tulis (Pembimbing Akademik, Cekal, Berhenti Studi, Mahasiswa Keluar) -------------------------------
|
||||
|
||||
public function pembimbingStore(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate(['nim' => ['required', 'string', 'max:20'], 'dosen' => ['required', 'integer']], [], ['nim' => 'NIM', 'dosen' => 'dosen pembimbing akademik']);
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => 'Pembimbing akademik ditetapkan.', 'id' => $this->writer->assignAdvisor($prodi, $in['nim'], (int) $in['dosen'])], 201));
|
||||
}
|
||||
|
||||
public function pembimbingUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate(['dosen' => ['required', 'integer']], [], ['dosen' => 'dosen pembimbing akademik']);
|
||||
|
||||
return $this->attempt(function () use ($prodi, $id, $in): JsonResponse {
|
||||
$this->writer->changeAdvisor($prodi, $id, (int) $in['dosen']);
|
||||
|
||||
return response()->json(['message' => 'Pembimbing akademik diperbarui.']);
|
||||
});
|
||||
}
|
||||
|
||||
public function pembimbingDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$ids = $this->ids($request, 'mahasiswa');
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => $this->writer->releaseAdvisors($prodi, $ids).' pembimbing akademik dilepas.']));
|
||||
}
|
||||
|
||||
public function cekalStore(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate(['nim' => ['required', 'string', 'max:20'], 'cekal' => ['required', 'boolean']], [], ['nim' => 'NIM', 'cekal' => 'cekal']);
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => 'Mahasiswa dicekal.', 'id' => $this->writer->addBlacklist($prodi, $in['nim'], (bool) $in['cekal'])], 201));
|
||||
}
|
||||
|
||||
public function cekalUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate(['cekal' => ['required', 'boolean']], [], ['cekal' => 'cekal']);
|
||||
|
||||
return $this->attempt(function () use ($prodi, $id, $in): JsonResponse {
|
||||
$this->writer->setBlacklist($prodi, $id, (bool) $in['cekal']);
|
||||
|
||||
return response()->json(['message' => 'Status cekal diperbarui.']);
|
||||
});
|
||||
}
|
||||
|
||||
public function cekalDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$ids = $this->ids($request, 'mahasiswa');
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => $this->writer->revokeBlacklist($prodi, $ids).' cekal dicabut.']));
|
||||
}
|
||||
|
||||
public function berhentiStore(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate([
|
||||
'nim' => ['required', 'string', 'max:20'], 'periode' => ['required', 'integer'], 'alasan' => ['nullable', 'integer'], 'status' => ['required', 'integer'],
|
||||
], [], ['nim' => 'NIM', 'periode' => 'periode cuti', 'alasan' => 'alasan', 'status' => 'status pengajuan']);
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => 'Pengajuan cuti ditambahkan.', 'id' => $this->writer->createLeave($prodi, $in)], 201));
|
||||
}
|
||||
|
||||
public function berhentiUpdate(Request $request, string $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate([
|
||||
'periode' => ['required', 'integer'], 'alasan' => ['nullable', 'integer'], 'status' => ['required', 'integer'],
|
||||
], [], ['periode' => 'periode cuti', 'alasan' => 'alasan', 'status' => 'status pengajuan']);
|
||||
|
||||
return $this->attempt(function () use ($prodi, $id, $in): JsonResponse {
|
||||
$this->writer->updateLeave($prodi, $id, $in);
|
||||
|
||||
return response()->json(['message' => 'Pengajuan cuti diperbarui.']);
|
||||
});
|
||||
}
|
||||
|
||||
public function berhentiDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['string', 'max:30']], [], ['ids' => 'pengajuan'])['ids'];
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => $this->writer->deleteLeaves($prodi, array_values($ids)).' pengajuan cuti dihapus.']));
|
||||
}
|
||||
|
||||
public function keluarStore(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate(['nim' => ['required', 'string', 'max:20'], 'status' => ['required', 'integer']], [], ['nim' => 'NIM', 'status' => 'status mahasiswa']);
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => 'Mahasiswa ditandai keluar.', 'id' => $this->writer->markLeaver($prodi, $in['nim'], (int) $in['status'])], 201));
|
||||
}
|
||||
|
||||
public function keluarUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$in = $request->validate(['status' => ['required', 'integer']], [], ['status' => 'status mahasiswa']);
|
||||
|
||||
return $this->attempt(function () use ($prodi, $id, $in): JsonResponse {
|
||||
$this->writer->changeLeaver($prodi, $id, (int) $in['status']);
|
||||
|
||||
return response()->json(['message' => 'Status mahasiswa keluar diperbarui.']);
|
||||
});
|
||||
}
|
||||
|
||||
public function keluarDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->writableScope($request);
|
||||
$ids = $this->ids($request, 'mahasiswa');
|
||||
|
||||
return $this->attempt(fn (): JsonResponse => response()->json(['message' => $this->writer->restoreLeavers($prodi, $ids).' mahasiswa dikembalikan sebagai masih kuliah.']));
|
||||
}
|
||||
|
||||
/** @return list<int> program studi akun (404 bila akun bukan DB lama atau belum dipetakan) */
|
||||
private function writableScope(Request $request): array
|
||||
{
|
||||
return $this->scope($request, false)[0];
|
||||
}
|
||||
|
||||
/** @return list<int> */
|
||||
private function ids(Request $request, string $label): array
|
||||
{
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['integer']], [], ['ids' => $label])['ids'];
|
||||
|
||||
return array_map('intval', array_values($ids));
|
||||
}
|
||||
|
||||
/** Pesan PortalException dikembalikan sebagai 422 berbahasa Indonesia. */
|
||||
private function attempt(callable $action): JsonResponse
|
||||
{
|
||||
try {
|
||||
return $action();
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sesuaikan tombol/kolom katalog dengan aksi yang sungguh bekerja: flags baru; kolom '#' dan 'Aksi' mengikuti. */
|
||||
private function withTools(array $page, string $flags, bool $actions): array
|
||||
{
|
||||
$page['flags'] = $flags;
|
||||
$page['columns'] = array_values(array_filter($page['columns'], fn (string $c): bool => $c !== 'Aksi' && ($c !== '#' || str_contains($flags, 'H'))));
|
||||
if ($actions) {
|
||||
$page['columns'][] = 'Aksi';
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
// ---- Bagian bersama ---------------------------------------------------------------------------------------
|
||||
|
||||
/** @return array{0: array<string, mixed>, 1: Collection<int, string>, 2: list<int>, 3: Collection<int, string>, 4: ?int} */
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Http\Controllers\Operator;
|
||||
|
||||
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\EmployeeDirectory;
|
||||
use App\Support\Legacy\EmployeeRecords;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -18,11 +21,14 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
*/
|
||||
class EmployeeListController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
|
||||
private const string SLUG = 'list_pegawai';
|
||||
|
||||
public function __construct(
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly EmployeeDirectory $directory,
|
||||
private readonly EmployeeRecords $records,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
@@ -35,7 +41,7 @@ class EmployeeListController extends Controller
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => ['Beranda' => route('operator.dashboard')] + array_fill_keys(Catalog::trail(self::SLUG), null) + [$page['title'] => null],
|
||||
'note' => 'Data pegawai asli dari SIAKAD untuk program studi dan fakultas yang Anda kelola. Tombol aksi belum mengubah data.',
|
||||
'note' => 'Data pegawai asli dari SIAKAD untuk program studi dan fakultas yang Anda kelola. Ubah dan hapus langsung tersimpan di basis data; pegawai yang masih dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun login tidak dapat dihapus.',
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar pegawai tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.pegawai.data'),
|
||||
'filters' => [
|
||||
@@ -55,9 +61,100 @@ class EmployeeListController extends Controller
|
||||
],
|
||||
'perPage' => EmployeeDirectory::PER_PAGE,
|
||||
'data' => $programs->isEmpty() ? null : $this->payload($this->search($request, $iduser, $programs->keys()->all())),
|
||||
'form' => $programs->isEmpty() ? null : $this->form(),
|
||||
'destroyUrl' => $programs->isEmpty() ? null : route('operator.list-pegawai.destroy'),
|
||||
'destroy' => ['title' => 'Hapus pegawai?', 'message' => 'Hanya pegawai yang tidak dirujuk jabatan, jadwal, bimbingan, skripsi, atau akun login yang dapat dihapus.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
{
|
||||
[$prodi, $faculties] = $this->scope($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$this->records->update($prodi, $faculties, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Data pegawai diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa pegawai (POST {ids}). */
|
||||
public function destroy(Request $request): JsonResponse
|
||||
{
|
||||
[$prodi, $faculties] = $this->scope($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1', 'max:100'], 'ids.*' => ['integer']], [], ['ids' => 'pegawai'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->records->delete($prodi, $faculties, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} pegawai dihapus."]);
|
||||
}
|
||||
|
||||
/** @return array{0: list<int>, 1: list<int>} prodi dan fakultas akun */
|
||||
private function scope(Request $request): array
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$iduser = (int) $request->user()->getKey();
|
||||
$prodi = $this->overview->programs($iduser)->keys()->all();
|
||||
abort_if($prodi === [], 404);
|
||||
|
||||
return [$prodi, $this->directory->faculties($iduser)];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function validated(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'nip' => ['required', 'string', 'max:20'],
|
||||
'nama' => ['required', 'string', 'max:50'],
|
||||
'gelardepan' => ['nullable', 'string', 'max:20'],
|
||||
'gelarbelakang' => ['nullable', 'string', 'max:25'],
|
||||
'kelamin' => ['nullable', 'integer', 'in:1,2'],
|
||||
'nidn' => ['nullable', 'string', 'max:25'],
|
||||
'hp' => ['nullable', 'string', 'max:20'],
|
||||
'telepon' => ['nullable', 'string', 'max:15'],
|
||||
'email' => ['nullable', 'string', 'email', 'max:125'],
|
||||
'status' => ['nullable', 'integer'],
|
||||
'aktif' => ['required', 'integer', 'in:0,1'],
|
||||
], [], [
|
||||
'nip' => 'NIP', 'nama' => 'nama', 'gelardepan' => 'gelar depan', 'gelarbelakang' => 'gelar belakang', 'kelamin' => 'jenis kelamin',
|
||||
'nidn' => 'NIDN', 'hp' => 'no. HP', 'telepon' => 'no. telepon', 'email' => 'email', 'status' => 'status kepegawaian', 'aktif' => 'status aktif',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formulir ubah (modal); template SATU tidak punya tombol Tambah untuk Pegawai.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function form(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'pegawai',
|
||||
'storeUrl' => null,
|
||||
'updateUrl' => route('operator.list-pegawai.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nip', 'label' => 'NIP', 'type' => 'text', 'required' => true, 'max' => 20],
|
||||
['name' => 'nama', 'label' => 'Nama', 'type' => 'text', 'required' => true, 'max' => 50],
|
||||
['name' => 'gelardepan', 'label' => 'Gelar depan', 'type' => 'text', 'max' => 20],
|
||||
['name' => 'gelarbelakang', 'label' => 'Gelar belakang', 'type' => 'text', 'max' => 25],
|
||||
['name' => 'kelamin', 'label' => 'Jenis kelamin', 'type' => 'select', 'options' => EmployeeRecords::GENDER],
|
||||
['name' => 'nidn', 'label' => 'NIDN', 'type' => 'text', 'max' => 25],
|
||||
['name' => 'hp', 'label' => 'No. HP', 'type' => 'text', 'max' => 20],
|
||||
['name' => 'telepon', 'label' => 'No. telepon', 'type' => 'text', 'max' => 15],
|
||||
['name' => 'email', 'label' => 'Email', 'type' => 'text', 'max' => 125],
|
||||
['name' => 'status', 'label' => 'Status kepegawaian', 'type' => 'select', 'options' => $this->records->statusOptions()],
|
||||
['name' => 'aktif', 'label' => 'Status aktif', 'type' => 'select', 'options' => EmployeeRecords::ACTIVE, 'required' => true, 'default' => 1],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** JSON untuk tabel (satuRemoteTable). Hanya akun DB lama yang memegang prodi. */
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
@@ -98,6 +195,7 @@ class EmployeeListController extends Controller
|
||||
return [
|
||||
'rows' => collect($rows->items())->map(fn (array $p): array => [
|
||||
'id' => $p['id'],
|
||||
'form' => $p['form'],
|
||||
'nip' => $dash($p['nip']),
|
||||
'nama' => $p['nama'],
|
||||
'kelamin' => $dash($p['kelamin']),
|
||||
|
||||
@@ -6,7 +6,9 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Operator\Concerns\ServesLegacyList;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\ClassSchedule;
|
||||
use App\Support\Legacy\ClassWriter;
|
||||
use App\Support\Legacy\Curriculum;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -16,7 +18,8 @@ use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Perkuliahan > Data Kelas > Kelas Kuliah (slug list_kelas) dan Pemutihan Nilai (slug set_pemutihannilai) untuk akun DB lama:
|
||||
* kelas asli t_jadwal prodi akun per periode, hanya baca; Lihat membuka rincian kelas (pengajar, jadwal, ujian, peserta).
|
||||
* kelas asli t_jadwal prodi akun per periode; Lihat membuka rincian kelas (pengajar, jadwal, ujian, peserta). Kelas Kuliah bisa
|
||||
* ditambah, diubah (nama kelas, kapasitas), dan dihapus selagi kosong; Pemutihan Nilai tetap hanya baca (tidak ada tabelnya).
|
||||
*/
|
||||
class KelasController extends Controller
|
||||
{
|
||||
@@ -32,6 +35,7 @@ class KelasController extends Controller
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly ClassSchedule $schedule,
|
||||
private readonly Curriculum $curriculum,
|
||||
private readonly ClassWriter $writer,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
@@ -46,7 +50,7 @@ class KelasController extends Controller
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG, $page),
|
||||
'note' => 'Kelas kuliah asli program studi yang Anda kelola: pengajar, jadwal mingguan, kapasitas, peserta (KRS disetujui), dan status kunci nilai. Tombol tambah, ubah, dan hapus belum mengubah data.',
|
||||
'note' => 'Kelas kuliah asli program studi yang Anda kelola: pengajar, jadwal mingguan, kapasitas, peserta (KRS disetujui), dan status kunci nilai. Tambah, ubah (nama kelas dan kapasitas), dan hapus langsung tersimpan; kelas yang sudah punya peserta, pengajar, jadwal, ujian, atau nilai terkunci tidak bisa dihapus.',
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar kelas tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.kelas-kuliah.data'),
|
||||
'viewUrl' => route('operator.kelas-kuliah.show', '__ID__'),
|
||||
@@ -69,9 +73,65 @@ class KelasController extends Controller
|
||||
],
|
||||
'perPage' => ClassSchedule::PER_PAGE,
|
||||
'data' => $prodi === [] || $default === null ? null : $this->payload($this->search($request, $prodi, $periods, $default)),
|
||||
'form' => $prodi === [] || $default === null ? null : [
|
||||
'title' => 'kelas',
|
||||
'storeUrl' => route('operator.kelas-kuliah.store'),
|
||||
'updateUrl' => route('operator.kelas-kuliah.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'mk', 'label' => 'Mata kuliah', 'type' => 'select', 'options' => $this->curriculum->courseOptions($prodi)->all(), 'required' => true, 'hint' => 'Mata kuliah dan periode tidak dapat diubah setelah kelas dibuat.'],
|
||||
['name' => 'periode', 'label' => 'Periode akademik', 'type' => 'select', 'options' => $periods->all(), 'required' => true, 'default' => $default],
|
||||
['name' => 'kelas', 'label' => 'Nama kelas', 'type' => 'text', 'required' => true, 'max' => 5],
|
||||
['name' => 'kapasitas', 'label' => 'Kapasitas', 'type' => 'number', 'required' => true, 'min' => 0, 'max' => 999, 'default' => 0],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => $prodi === [] || $default === null ? null : route('operator.kelas-kuliah.destroy'),
|
||||
'destroy' => ['title' => 'Hapus kelas?', 'message' => 'Kelas dihapus bila belum punya peserta, pengajar, jadwal, ujian, atau nilai.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$id = $this->writer->create($prodi, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Kelas ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$this->writer->update($prodi, $id, $input);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Kelas diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa kelas (POST {ids}). */
|
||||
public function destroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['integer']], [], ['ids' => 'kelas'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->writer->delete($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} kelas dihapus."]);
|
||||
}
|
||||
|
||||
/** Pemutihan Nilai: kelas yang sama dengan kolom nilai default (tidak tercatat di DB lama) dan status kunci. */
|
||||
public function pemutihan(Request $request): View
|
||||
{
|
||||
@@ -85,7 +145,8 @@ class KelasController extends Controller
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG_PEMUTIHAN, $page),
|
||||
'note' => 'Kelas asli program studi yang Anda kelola beserta status kunci nilai. Nilai default tidak tercatat di sumber data; tombol ubah dan hapus belum mengubah data.',
|
||||
'note' => 'Kelas asli program studi yang Anda kelola beserta status kunci nilai. Nilai default tidak tercatat di sumber data, sehingga pemutihan nilai belum dapat disetel dari halaman ini.',
|
||||
'strict' => true,
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar kelas tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.pemutihan-nilai.data'),
|
||||
'viewUrl' => route('operator.kelas-kuliah.show', '__ID__'),
|
||||
@@ -134,6 +195,27 @@ class KelasController extends Controller
|
||||
] + $detail);
|
||||
}
|
||||
|
||||
/** @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([
|
||||
'mk' => ['required', 'integer'],
|
||||
'periode' => ['required', 'integer'],
|
||||
'kelas' => ['required', 'string', 'max:5'],
|
||||
'kapasitas' => ['required', 'integer', 'min:0', 'max:999'],
|
||||
], [], ['mk' => 'mata kuliah', 'periode' => 'periode akademik', 'kelas' => 'nama kelas', 'kapasitas' => 'kapasitas']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $prodi
|
||||
* @param Collection<int, string> $periods
|
||||
|
||||
@@ -5,14 +5,20 @@ 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\ClassSchedule;
|
||||
use App\Support\Legacy\Curriculum;
|
||||
use App\Support\Legacy\CurriculumWriter;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/** Perkuliahan > Manajemen Kurikulum > Kurikulum Prodi (slug list_kurikulum) untuk akun DB lama: t_kurikulum + distribusi SKS, dan rinciannya. */
|
||||
/**
|
||||
* Perkuliahan > Manajemen Kurikulum > Kurikulum Prodi (slug list_kurikulum) untuk akun DB lama: t_kurikulum + distribusi SKS, dan rinciannya.
|
||||
* Kurikulum prodi akun bisa ditambah, diubah, dan dihapus selagi belum dipakai mata kuliah, kelas, atau mahasiswa.
|
||||
*/
|
||||
class KurikulumController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
@@ -21,7 +27,9 @@ class KurikulumController extends Controller
|
||||
|
||||
public function __construct(
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly ClassSchedule $schedule,
|
||||
private readonly Curriculum $curriculum,
|
||||
private readonly CurriculumWriter $writer,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
@@ -34,7 +42,7 @@ class KurikulumController extends Controller
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG, $page),
|
||||
'note' => 'Kurikulum asli program studi yang Anda kelola. SKS pilihan dihitung dari kelompok mata kuliah berketerangan "pilihan" (MKP); sisanya wajib.',
|
||||
'note' => 'Kurikulum asli program studi yang Anda kelola. SKS pilihan dihitung dari kelompok mata kuliah berketerangan "pilihan" (MKP); sisanya wajib. Tambah, ubah, dan hapus langsung tersimpan; kurikulum yang sudah punya mata kuliah, kelas, atau mahasiswa tidak bisa dihapus.',
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar kurikulum tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.kurikulum.data'),
|
||||
'viewUrl' => route('operator.kurikulum.show', '__ID__'),
|
||||
@@ -53,9 +61,90 @@ class KurikulumController extends Controller
|
||||
],
|
||||
'perPage' => Curriculum::PER_PAGE,
|
||||
'data' => $prodi === [] ? null : $this->payload($this->search($request, $prodi)),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'kurikulum',
|
||||
'storeUrl' => route('operator.kurikulum.store'),
|
||||
'updateUrl' => route('operator.kurikulum.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'prodi', 'label' => 'Program studi', 'type' => 'select', 'options' => $programs->all(), 'required' => true],
|
||||
['name' => 'program', 'label' => 'Sistem kuliah', 'type' => 'select', 'options' => $this->writer->programOptions()->all(), 'required' => true],
|
||||
['name' => 'periode', 'label' => 'Periode berlaku', 'type' => 'select', 'options' => $this->schedule->periods()->all(), 'required' => true, 'hint' => 'Program studi, sistem kuliah, dan periode tidak dapat diubah setelah kurikulum dipakai.'],
|
||||
['name' => 'nama', 'label' => 'Nama kurikulum', 'type' => 'text', 'required' => true, 'max' => 30],
|
||||
['name' => 'deskripsi', 'label' => 'Deskripsi', 'type' => 'text', 'max' => 255],
|
||||
['name' => 'aktif', 'label' => 'Status', 'type' => 'select', 'options' => [1 => 'Aktif', 0 => 'Tidak aktif'], 'required' => true, 'default' => 1],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => $prodi === [] ? null : route('operator.kurikulum.destroy'),
|
||||
'destroy' => ['title' => 'Hapus kurikulum?', 'message' => 'Kurikulum dihapus bila belum punya mata kuliah, kelas, atau mahasiswa.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$id = $this->writer->create($prodi, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Kurikulum ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request);
|
||||
|
||||
try {
|
||||
$this->writer->update($prodi, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Kurikulum diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa kurikulum (POST {ids}). */
|
||||
public function destroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['integer']], [], ['ids' => 'kurikulum'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->writer->delete($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} kurikulum 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([
|
||||
'prodi' => ['required', 'integer'],
|
||||
'program' => ['required', 'integer'],
|
||||
'periode' => ['required', 'integer'],
|
||||
'nama' => ['required', 'string', 'max:30'],
|
||||
'deskripsi' => ['nullable', 'string', 'max:255'],
|
||||
'aktif' => ['required', 'boolean'],
|
||||
], [], ['prodi' => 'program studi', 'program' => 'sistem kuliah', 'periode' => 'periode berlaku', 'nama' => 'nama kurikulum', 'deskripsi' => 'deskripsi', 'aktif' => 'status']);
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Support\Legacy\Curriculum;
|
||||
use App\Support\Legacy\LegacyFormat;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\ShortSemester;
|
||||
use App\Support\Legacy\ShortSemesterWriter;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -30,6 +31,7 @@ class SemesterPendekController extends Controller
|
||||
private readonly Administration $admin,
|
||||
private readonly Curriculum $curriculum,
|
||||
private readonly AcademicPeriods $periods,
|
||||
private readonly ShortSemesterWriter $writer,
|
||||
) {}
|
||||
|
||||
public function periode(Request $request): View
|
||||
@@ -152,8 +154,8 @@ class SemesterPendekController extends Controller
|
||||
[$labelPeriode, $labelUnit, $labelKurikulum, $labelStatus] = $page['filters'];
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_mkpendek', $page),
|
||||
'note' => 'Mata kuliah dan kelas semester pendek asli (t_jadwal pada periode pendek) program studi yang Anda kelola; pendaftar dan peserta dari KRS. Minimal pendaftar dan peminat tidak tercatat. Tombol aksi belum mengubah data.',
|
||||
'page' => ['flags' => 'TH'] + $page, 'crumbs' => $this->crumbs('list_mkpendek', $page),
|
||||
'note' => 'Mata kuliah dan kelas semester pendek asli (t_jadwal pada periode pendek) program studi yang Anda kelola; pendaftar dan peserta dari KRS. Minimal pendaftar dan peminat tidak tercatat. Tombol Aksi diganti Tambah dan Hapus yang langsung tersimpan: buka kelas dari kurikulum prodi Anda, ubah kapasitas semua kelas MK, hapus kelas yang belum punya peserta, pengajar, atau jadwal.',
|
||||
'empty' => self::EMPTY,
|
||||
'url' => route('operator.mk-pendek.data'),
|
||||
'filters' => [
|
||||
@@ -175,9 +177,68 @@ class SemesterPendekController extends Controller
|
||||
],
|
||||
'perPage' => ShortSemester::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->pendek->courses($prodi, $this->courseFilter($request, $prodi, $periods, $default), $this->perPage($request, ShortSemester::PER_PAGE))),
|
||||
'form' => $default === null ? null : [
|
||||
'title' => 'kelas semester pendek',
|
||||
'storeUrl' => route('operator.mk-pendek.store'),
|
||||
'updateUrl' => route('operator.mk-pendek.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'periode', 'label' => 'Periode semester pendek', 'type' => 'select', 'options' => $periods->all(), 'required' => true, 'default' => $default, 'hint' => 'Tidak berubah saat Ubah.'],
|
||||
['name' => 'matakuliah', 'label' => 'Mata kuliah', 'type' => 'select', 'options' => $this->curriculum->courseOptions($prodi)->all(), 'required' => true, 'hint' => 'Dari kurikulum program studi Anda; tidak berubah saat Ubah.'],
|
||||
['name' => 'kelas', 'label' => 'Nama kelas', 'type' => 'text', 'max' => 5, 'default' => 'A', 'hint' => 'Hanya untuk Tambah.'],
|
||||
['name' => 'kapasitas', 'label' => 'Kapasitas', 'type' => 'number', 'min' => 0, 'default' => 0, 'hint' => '0 = tanpa batas. Saat Ubah berlaku untuk semua kelas mata kuliah ini.'],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => route('operator.mk-pendek.destroy'),
|
||||
'destroy' => ['title' => 'Hapus kelas semester pendek?', 'message' => 'Kelas yang sudah punya peserta, pengajar, jadwal pertemuan, atau ujian akan ditolak.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function mataKuliahStore(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $request->validate([
|
||||
'periode' => ['required', 'integer'], 'matakuliah' => ['required', 'integer'],
|
||||
'kelas' => ['required', 'string', 'max:5'], 'kapasitas' => ['nullable', 'integer', 'min:0', 'max:9999'],
|
||||
], [], ['periode' => 'periode semester pendek', 'matakuliah' => 'mata kuliah', 'kelas' => 'nama kelas', 'kapasitas' => 'kapasitas']);
|
||||
|
||||
try {
|
||||
$id = $this->writer->openCourse($prodi, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Kelas semester pendek dibuka.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function mataKuliahUpdate(Request $request, string $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $request->validate(['kapasitas' => ['required', 'integer', 'min:0', 'max:9999']], [], ['kapasitas' => 'kapasitas']);
|
||||
|
||||
try {
|
||||
$this->writer->updateCourse($prodi, $id, (int) $input['kapasitas'], (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Kapasitas kelas diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa kelompok MK pendek (POST {ids} berbentuk "periode-mk-prodi"). */
|
||||
public function mataKuliahDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['string', 'max:40']], [], ['ids' => 'mata kuliah'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->writer->deleteCourses($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} mata kuliah semester pendek dihapus."]);
|
||||
}
|
||||
|
||||
public function mataKuliahData(Request $request): JsonResponse
|
||||
{
|
||||
[$prodi, $periods, $default] = $this->scope($request);
|
||||
@@ -191,8 +252,8 @@ class SemesterPendekController extends Controller
|
||||
[$labelPeriode, $labelUnit, $labelMasuk, $labelKrs, $labelBayar] = $page['filters'];
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_pesertapendek', $page),
|
||||
'note' => 'Peserta semester pendek asli = mahasiswa program studi Anda yang mengisi KRS pada periode pendek, dengan SKS diajukan, status semester, status KRS, dan kontak. SKS penawaran dan status pembayaran tidak tercatat. Tombol aksi belum mengubah data.',
|
||||
'page' => ['flags' => 'TH'] + $page, 'crumbs' => $this->crumbs('list_pesertapendek', $page),
|
||||
'note' => 'Peserta semester pendek asli = mahasiswa program studi Anda yang mengisi KRS pada periode pendek, dengan SKS diajukan, status semester, status KRS, dan kontak. SKS penawaran dan status pembayaran tidak tercatat. Tombol Aksi diganti Tambah dan Hapus yang langsung tersimpan: daftarkan mahasiswa aktif ke kelas pendek, ubah status KRS, atau hapus KRS yang belum bernilai.',
|
||||
'empty' => self::EMPTY,
|
||||
'url' => route('operator.peserta-pendek.data'),
|
||||
'filters' => [
|
||||
@@ -214,9 +275,78 @@ class SemesterPendekController extends Controller
|
||||
],
|
||||
'perPage' => ShortSemester::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->pendek->participants($prodi, $this->participantFilter($request, $prodi, $periods, $default), $this->perPage($request, ShortSemester::PER_PAGE))),
|
||||
'form' => $default === null ? null : [
|
||||
'title' => 'peserta semester pendek',
|
||||
'storeUrl' => route('operator.peserta-pendek.store'),
|
||||
'updateUrl' => route('operator.peserta-pendek.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM mahasiswa', 'type' => 'text', 'required' => true, 'max' => 30, 'hint' => 'Mahasiswa aktif program studi Anda; tidak berubah saat Ubah.'],
|
||||
['name' => 'jadwal', 'label' => 'Kelas semester pendek', 'type' => 'select', 'options' => $this->pendek->classOptions($prodi), 'hint' => 'Wajib saat Tambah; saat Ubah, mengisi berarti menambah kelas.'],
|
||||
['name' => 'status', 'label' => 'Status KRS', 'type' => 'select', 'options' => ShortSemesterWriter::KRS_STATUS, 'required' => true, 'default' => '0', 'hint' => 'Saat Ubah berlaku untuk seluruh KRS peserta pada periode ini.'],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => route('operator.peserta-pendek.destroy'),
|
||||
'destroy' => ['title' => 'Hapus KRS semester pendek?', 'message' => 'Seluruh KRS mahasiswa pada periode ini dihapus; yang sudah bernilai akan ditolak.'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function pesertaStore(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $request->validate([
|
||||
'nim' => ['required', 'string', 'max:30'], 'jadwal' => ['required', 'integer'], 'status' => ['required', 'integer', 'in:0,1'],
|
||||
], [], ['nim' => 'NIM', 'jadwal' => 'kelas semester pendek', 'status' => 'status KRS']);
|
||||
|
||||
try {
|
||||
$id = $this->writer->addParticipant($prodi, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Peserta semester pendek ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function pesertaUpdate(Request $request, string $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $request->validate([
|
||||
'nim' => ['nullable', 'string', 'max:30'], 'jadwal' => ['nullable', 'integer'], 'status' => ['required', 'integer', 'in:0,1'],
|
||||
], [], ['nim' => 'NIM', 'jadwal' => 'kelas semester pendek', 'status' => 'status KRS']);
|
||||
|
||||
try {
|
||||
$this->writer->updateParticipant($prodi, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Peserta semester pendek diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus KRS satu atau beberapa peserta (POST {ids} berbentuk "mahasiswa-periode"). */
|
||||
public function pesertaDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['string', 'max:40']], [], ['ids' => 'peserta'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->writer->removeParticipants($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "KRS {$deleted} peserta 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;
|
||||
}
|
||||
|
||||
public function pesertaData(Request $request): JsonResponse
|
||||
{
|
||||
[$prodi, $periods, $default] = $this->scope($request);
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
namespace App\Http\Controllers\Operator;
|
||||
|
||||
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;
|
||||
@@ -20,11 +24,15 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class StudentListController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
|
||||
private const string SLUG = 'list_mahasiswa';
|
||||
|
||||
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
|
||||
@@ -37,7 +45,7 @@ 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. Tombol tambah, ubah, dan hapus belum mengubah data.',
|
||||
'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.',
|
||||
'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'),
|
||||
'filters' => [
|
||||
@@ -60,9 +68,121 @@ 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
|
||||
{
|
||||
@@ -104,7 +224,8 @@ class StudentListController extends Controller
|
||||
{
|
||||
return [
|
||||
'rows' => collect($rows->items())->map(fn (array $m): array => [
|
||||
'id' => $m['nim'],
|
||||
'id' => $m['id'],
|
||||
'form' => $m['form'],
|
||||
'nim' => $m['nim'],
|
||||
'nama' => $m['nama'],
|
||||
'jenjang' => $m['jenjang'] ?? '–',
|
||||
|
||||
@@ -27,6 +27,7 @@ class TahunKurikulumController extends Controller
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG, $page),
|
||||
'note' => 'Tahun kurikulum diturunkan dari periode berlaku setiap kurikulum (seluruh universitas). Tanggal awal/akhir tidak tercatat di sumber data.',
|
||||
'strict' => true, // ringkasan turunan dari t_kurikulum, tidak ada tabel sendiri untuk ditulis
|
||||
'empty' => ['icon' => 'calendar', 'title' => 'Belum ada kurikulum', 'description' => 'Tahun kurikulum tampil setelah ada kurikulum dengan periode berlaku.'],
|
||||
'url' => route('operator.thnkurikulum.data'),
|
||||
'filters' => [],
|
||||
|
||||
@@ -7,13 +7,15 @@ use App\Http\Controllers\Operator\Concerns\ServesLegacyList;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\Administration;
|
||||
use App\Support\Legacy\Graduation;
|
||||
use App\Support\Legacy\GraduationWriter;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/** Perkuliahan > Data Tugas Akhir > Daftar Tugas Akhir (slug list_ta) untuk akun DB lama: t_skripsi prodi akun, hanya baca. */
|
||||
/** Perkuliahan > Data Tugas Akhir > Daftar Tugas Akhir (slug list_ta) untuk akun DB lama: t_skripsi prodi akun; tambah, ubah, hapus. */
|
||||
class TugasAkhirController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
@@ -24,6 +26,7 @@ class TugasAkhirController extends Controller
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly Graduation $graduation,
|
||||
private readonly Administration $admin,
|
||||
private readonly GraduationWriter $writer,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
@@ -36,7 +39,7 @@ class TugasAkhirController extends Controller
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG, $page),
|
||||
'note' => 'Tugas akhir asli (t_skripsi) mahasiswa program studi yang Anda kelola: judul, pembimbing, penguji, tahap (lulus ujian bila tanggal lulus terisi), nilai dari mata kuliah tugas akhir. Tombol aksi belum mengubah data.',
|
||||
'note' => 'Tugas akhir asli (t_skripsi) mahasiswa program studi yang Anda kelola: judul, pembimbing, penguji, tahap (lulus ujian bila tanggal lulus terisi), nilai dari mata kuliah tugas akhir. Tambah, ubah, dan hapus langsung tersimpan di basis data (tugas akhir yang sudah lulus ujian tidak bisa dihapus).',
|
||||
'empty' => ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar tugas akhir tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.'],
|
||||
'url' => route('operator.tugas-akhir.data'),
|
||||
'filters' => [
|
||||
@@ -58,9 +61,103 @@ class TugasAkhirController extends Controller
|
||||
],
|
||||
'perPage' => Graduation::PER_PAGE,
|
||||
'data' => $prodi === [] ? null : $this->payload($this->search($request, $prodi)),
|
||||
'form' => $prodi === [] ? null : $this->form($prodi),
|
||||
'destroyUrl' => route('operator.tugas-akhir.destroy'),
|
||||
'destroy' => ['title' => 'Hapus tugas akhir terpilih?', 'message' => 'Tugas akhir yang sudah lulus ujian akan ditolak.'],
|
||||
]);
|
||||
}
|
||||
|
||||
/** @param list<int> $prodi */
|
||||
private function form(array $prodi): array
|
||||
{
|
||||
$lecturers = $this->graduation->lecturerOptions($prodi);
|
||||
|
||||
return [
|
||||
'title' => 'tugas akhir',
|
||||
'storeUrl' => route('operator.tugas-akhir.store'),
|
||||
'updateUrl' => route('operator.tugas-akhir.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM mahasiswa', 'type' => 'text', 'required' => true, 'max' => 30, 'hint' => 'Mahasiswa program studi Anda; tidak berubah saat Ubah.'],
|
||||
['name' => 'judul', 'label' => 'Judul tugas akhir', 'type' => 'text', 'required' => true, 'max' => 1000],
|
||||
['name' => 'pembimbing1', 'label' => 'Pembimbing 1', 'type' => 'select', 'options' => $lecturers],
|
||||
['name' => 'pembimbing2', 'label' => 'Pembimbing 2', 'type' => 'select', 'options' => $lecturers],
|
||||
['name' => 'penguji1', 'label' => 'Penguji 1', 'type' => 'select', 'options' => $lecturers],
|
||||
['name' => 'penguji2', 'label' => 'Penguji 2', 'type' => 'select', 'options' => $lecturers],
|
||||
['name' => 'mulai', 'label' => 'Tanggal mulai', 'type' => 'date'],
|
||||
['name' => 'lulus', 'label' => 'Tanggal lulus ujian', 'type' => 'date', 'hint' => 'Diisi bila ujian sudah lulus.'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request, true);
|
||||
|
||||
try {
|
||||
$id = $this->writer->createThesis($prodi, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Tugas akhir ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validated($request, false);
|
||||
|
||||
try {
|
||||
$this->writer->updateThesis($prodi, $id, $input, (string) $request->user()->username, $request->ip());
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Tugas akhir diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa tugas akhir (POST {ids}). */
|
||||
public function destroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['integer']], [], ['ids' => 'tugas akhir'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->writer->deleteTheses($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} tugas akhir dihapus."]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function validated(Request $request, bool $creating): array
|
||||
{
|
||||
return $request->validate([
|
||||
'nim' => [$creating ? 'required' : 'nullable', 'string', 'max:30'],
|
||||
'judul' => ['required', 'string', 'max:1000'],
|
||||
'pembimbing1' => ['nullable', 'integer'], 'pembimbing2' => ['nullable', 'integer'],
|
||||
'penguji1' => ['nullable', 'integer'], 'penguji2' => ['nullable', 'integer'],
|
||||
'mulai' => ['nullable', 'date_format:Y-m-d'],
|
||||
'lulus' => ['nullable', 'date_format:Y-m-d'],
|
||||
], [], [
|
||||
'nim' => 'NIM', 'judul' => 'judul tugas akhir', 'pembimbing1' => 'pembimbing 1', 'pembimbing2' => 'pembimbing 2',
|
||||
'penguji1' => 'penguji 1', 'penguji2' => 'penguji 2', 'mulai' => 'tanggal mulai', 'lulus' => 'tanggal lulus ujian',
|
||||
]);
|
||||
}
|
||||
|
||||
/** @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;
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Support\Legacy\AcademicCalendar;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\Administration;
|
||||
use App\Support\Legacy\Graduation;
|
||||
use App\Support\Legacy\GraduationWriter;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
@@ -16,8 +17,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Perkuliahan > Data Yudisium dan Data Wisuda untuk akun DB lama (hanya baca): Eligible Yudisium, Penomoran Dokumen,
|
||||
* Daftar Yudisium, Periode Yudisium, Periode Wisuda, Peserta Wisuda.
|
||||
* Perkuliahan > Data Yudisium dan Data Wisuda untuk akun DB lama: Eligible Yudisium dan Penomoran Dokumen (hanya baca),
|
||||
* Daftar Yudisium dan Peserta Wisuda (daftarkan, ubah, keluarkan lulusan dari periode), Periode Yudisium dan Periode Wisuda (CRUD periode).
|
||||
*/
|
||||
class YudisiumController extends Controller
|
||||
{
|
||||
@@ -32,6 +33,7 @@ class YudisiumController extends Controller
|
||||
private readonly AcademicCalendar $calendar,
|
||||
private readonly Administration $admin,
|
||||
private readonly Graduation $graduation,
|
||||
private readonly GraduationWriter $writer,
|
||||
) {}
|
||||
|
||||
// ---- Eligible / Pengajuan Yudisium (list_eligibleyudisium) ---------------------------------------------------
|
||||
@@ -45,8 +47,9 @@ class YudisiumController extends Controller
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_eligibleyudisium', $page),
|
||||
'note' => 'Kelayakan yudisium dari rekap evaluasi asli (t_evaluasi_rekap: SKS lulus, mutu, nilai tugas akhir) dibandingkan beban SKS minimal jenjang; mahasiswa yang layak tampil lebih dulu. Sisa MK wajib dan bebas tagihan tidak tercatat.',
|
||||
'note' => 'Kelayakan yudisium dari rekap evaluasi asli (t_evaluasi_rekap: SKS lulus, mutu, nilai tugas akhir) dibandingkan beban SKS minimal jenjang; mahasiswa yang layak tampil lebih dulu. Sisa MK wajib dan bebas tagihan tidak tercatat. Halaman ini turunan rekap evaluasi (tanpa penulisan data); pendaftaran peserta dilakukan di Daftar Yudisium.',
|
||||
'empty' => self::EMPTY,
|
||||
'strict' => true,
|
||||
'url' => route('operator.eligible-yudisium.data'),
|
||||
'filters' => [
|
||||
['name' => 'periode', 'label' => $labelPeriode, 'options' => $periods->all(), 'value' => $default],
|
||||
@@ -146,7 +149,7 @@ class YudisiumController extends Controller
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_yudisium', $page),
|
||||
'note' => 'Lulusan asli yang terdaftar pada periode yudisium (t_mahasiswa.idperiodewisuda) dengan SKS dan IPK dari transkrip serta predikat menurut rentang IPK t_predikatkelulusan. Filter Status Mahasiswa dan Predikat tidak menyaring (semua lulus; predikat dihitung per baris). Tombol aksi belum mengubah data.',
|
||||
'note' => 'Lulusan asli yang terdaftar pada periode yudisium (t_mahasiswa.idperiodewisuda) dengan SKS dan IPK dari transkrip serta predikat menurut rentang IPK t_predikatkelulusan. Filter Status Mahasiswa dan Predikat tidak menyaring (semua lulus; predikat dihitung per baris). Tambah, ubah, dan hapus (keluarkan dari periode) langsung tersimpan di t_mahasiswa; hanya lulusan prodi Anda yang dapat didaftarkan dan ijazah yang sudah bernomor tidak bisa dikeluarkan.',
|
||||
'empty' => $prodi === [] ? self::EMPTY : self::NO_GRADUATES,
|
||||
'url' => route('operator.daftar-yudisium.data'),
|
||||
'filters' => [
|
||||
@@ -170,6 +173,21 @@ class YudisiumController extends Controller
|
||||
],
|
||||
'perPage' => Graduation::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->graduation->yudisium($prodi, $this->graduationFilter($request, $prodi, $periods, $default), $this->perPage($request, Graduation::PER_PAGE))),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'peserta yudisium',
|
||||
'storeUrl' => route('operator.daftar-yudisium.store'),
|
||||
'updateUrl' => route('operator.daftar-yudisium.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM lulusan', 'type' => 'text', 'required' => true, 'max' => 30, 'hint' => 'Lulusan program studi Anda yang belum punya periode; tidak berubah saat Ubah.'],
|
||||
['name' => 'periode', 'label' => 'Periode yudisium', 'type' => 'select', 'options' => $this->graduation->periodOptions(), 'required' => true],
|
||||
['name' => 'tgl_yudisium', 'label' => 'Tanggal yudisium', 'type' => 'date'],
|
||||
['name' => 'sk', 'label' => 'No. SK yudisium', 'type' => 'text', 'max' => 100],
|
||||
['name' => 'tgl_sk', 'label' => 'Tanggal SK', 'type' => 'date'],
|
||||
['name' => 'ijazah', 'label' => 'No. ijazah', 'type' => 'text', 'max' => 100],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => route('operator.daftar-yudisium.destroy'),
|
||||
'destroy' => ['title' => 'Keluarkan dari periode yudisium?', 'message' => 'Status lulus tetap; ijazah yang sudah bernomor akan ditolak.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -346,7 +364,7 @@ class YudisiumController extends Controller
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_pesertawisuda', $page),
|
||||
'note' => 'Peserta wisuda = lulusan asli per periode wisuda/yudisium (t_mahasiswa.idperiodewisuda) dengan IPK transkrip. Kelompok wisuda, persetujuan, validasi, dan kehadiran tidak tercatat di DB lama.',
|
||||
'note' => 'Peserta wisuda = lulusan asli per periode wisuda/yudisium (t_mahasiswa.idperiodewisuda) dengan IPK transkrip. Kelompok wisuda, persetujuan, validasi, dan kehadiran tidak tercatat di DB lama. Tambah, ubah (pindah periode), dan hapus (keluarkan dari periode) langsung tersimpan; hanya lulusan prodi Anda, dan ijazah yang sudah bernomor tidak bisa dikeluarkan.',
|
||||
'empty' => $prodi === [] ? self::EMPTY : self::NO_GRADUATES,
|
||||
'url' => route('operator.peserta-wisuda.data'),
|
||||
'filters' => [
|
||||
@@ -368,6 +386,17 @@ class YudisiumController extends Controller
|
||||
],
|
||||
'perPage' => Graduation::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->graduation->participants($prodi, $this->participantFilter($request, $prodi, $periods, $default), $this->perPage($request, Graduation::PER_PAGE))),
|
||||
'form' => $prodi === [] ? null : [
|
||||
'title' => 'peserta wisuda',
|
||||
'storeUrl' => route('operator.peserta-wisuda.store'),
|
||||
'updateUrl' => route('operator.peserta-wisuda.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'nim', 'label' => 'NIM lulusan', 'type' => 'text', 'required' => true, 'max' => 30, 'hint' => 'Lulusan program studi Anda yang belum punya periode; tidak berubah saat Ubah.'],
|
||||
['name' => 'periode', 'label' => 'Periode wisuda', 'type' => 'select', 'options' => $this->graduation->periodOptions(), 'required' => true],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => route('operator.peserta-wisuda.destroy'),
|
||||
'destroy' => ['title' => 'Keluarkan dari periode wisuda?', 'message' => 'Status lulus tetap; ijazah yang sudah bernomor akan ditolak.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -385,6 +414,87 @@ class YudisiumController extends Controller
|
||||
return ['periode' => $periode ?? $this->graduationPeriode($request, $periods, $default)] + $this->graduationFilter($request, $prodi, $periods, $default);
|
||||
}
|
||||
|
||||
// ---- Penulisan peserta yudisium (list_yudisium) dan peserta wisuda (list_pesertawisuda) -----------------------
|
||||
|
||||
public function daftarStore(Request $request): JsonResponse
|
||||
{
|
||||
return $this->graduateStore($request, true, 'Peserta yudisium ditambahkan.');
|
||||
}
|
||||
|
||||
public function daftarUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
return $this->graduateUpdate($request, $id, true, 'Peserta yudisium diperbarui.');
|
||||
}
|
||||
|
||||
public function pesertaStore(Request $request): JsonResponse
|
||||
{
|
||||
return $this->graduateStore($request, false, 'Peserta wisuda ditambahkan.');
|
||||
}
|
||||
|
||||
public function pesertaUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
return $this->graduateUpdate($request, $id, false, 'Peserta wisuda diperbarui.');
|
||||
}
|
||||
|
||||
/** Keluarkan satu atau beberapa lulusan dari periode (POST {ids}); dipakai Daftar Yudisium dan Peserta Wisuda. */
|
||||
public function graduateDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['integer']], [], ['ids' => 'peserta'])['ids'];
|
||||
|
||||
try {
|
||||
$removed = $this->writer->unregisterGraduates($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$removed} peserta dikeluarkan dari periode."]);
|
||||
}
|
||||
|
||||
private function graduateStore(Request $request, bool $details, string $message): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validatedGraduate($request, true, $details);
|
||||
|
||||
try {
|
||||
$id = $this->writer->registerGraduate($prodi, $input);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => $message, 'id' => $id], 201);
|
||||
}
|
||||
|
||||
private function graduateUpdate(Request $request, int $id, bool $details, string $message): JsonResponse
|
||||
{
|
||||
$prodi = $this->prodiOrFail($request);
|
||||
$input = $this->validatedGraduate($request, false, $details);
|
||||
|
||||
try {
|
||||
$this->writer->updateGraduate($prodi, $id, $input);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => $message]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function validatedGraduate(Request $request, bool $creating, bool $details): array
|
||||
{
|
||||
$rules = ['nim' => [$creating ? 'required' : 'nullable', 'string', 'max:30'], 'periode' => ['required', 'integer']];
|
||||
$names = ['nim' => 'NIM', 'periode' => 'periode'];
|
||||
if ($details) {
|
||||
$rules += [
|
||||
'tgl_yudisium' => ['nullable', 'date_format:Y-m-d'], 'sk' => ['nullable', 'string', 'max:100'],
|
||||
'tgl_sk' => ['nullable', 'date_format:Y-m-d'], 'ijazah' => ['nullable', 'string', 'max:100'],
|
||||
];
|
||||
$names += ['tgl_yudisium' => 'tanggal yudisium', 'sk' => 'nomor SK yudisium', 'tgl_sk' => 'tanggal SK', 'ijazah' => 'nomor ijazah'];
|
||||
}
|
||||
|
||||
return $request->validate($rules, [], $names);
|
||||
}
|
||||
|
||||
// ---- Bagian bersama ---------------------------------------------------------------------------------------
|
||||
|
||||
/** @return array{0: array<string, mixed>, 1: Collection<int, string>, 2: list<int>} */
|
||||
|
||||
Reference in New Issue
Block a user