87 lines
4.5 KiB
PHP
87 lines
4.5 KiB
PHP
<?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\Administration;
|
|
use App\Support\Legacy\Graduation;
|
|
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. */
|
|
class TugasAkhirController extends Controller
|
|
{
|
|
use ServesLegacyList;
|
|
|
|
private const string SLUG = 'list_ta';
|
|
|
|
public function __construct(
|
|
private readonly AcademicOverview $overview,
|
|
private readonly Graduation $graduation,
|
|
private readonly Administration $admin,
|
|
) {}
|
|
|
|
public function __invoke(Request $request): View
|
|
{
|
|
$page = Catalog::page(self::SLUG);
|
|
$programs = $this->overview->programs((int) $request->user()->getKey());
|
|
$prodi = $programs->keys()->all();
|
|
[$labelUnit, $labelMasuk, $labelStatus, $labelTahap, $labelPembimbing, $labelPenguji] = $page['filters'];
|
|
|
|
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.',
|
|
'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' => [
|
|
['name' => 'prodi', 'label' => $labelUnit, 'options' => $programs->all()],
|
|
['name' => 'angkatan', 'label' => $labelMasuk, 'options' => $this->admin->cohorts($prodi)->all()],
|
|
['name' => 'status', 'label' => $labelStatus, 'options' => Graduation::THESIS_STATUS],
|
|
['name' => 'tahap', 'label' => $labelTahap, 'options' => Graduation::THESIS_STAGE],
|
|
['name' => 'pembimbing', 'label' => $labelPembimbing, 'options' => $this->graduation->examiners($prodi)->all()],
|
|
['name' => 'penguji', 'label' => $labelPenguji, 'options' => $this->graduation->examiners($prodi, false)->all()],
|
|
],
|
|
'columns' => [
|
|
['key' => 'mahasiswa', 'label' => 'Nama Mahasiswa'],
|
|
['key' => 'prodi_masuk', 'label' => 'Prodi dan Periode Masuk'],
|
|
['key' => 'judul', 'label' => 'Judul Tugas Akhir'],
|
|
['key' => 'dosen', 'label' => 'Dosen Pembimbing dan Penguji'],
|
|
['key' => 'tahap', 'label' => 'Tahap Tugas Akhir'],
|
|
['key' => 'nilai', 'label' => 'Nilai'],
|
|
['key' => 'status', 'label' => 'Status', 'badge' => true],
|
|
],
|
|
'perPage' => Graduation::PER_PAGE,
|
|
'data' => $prodi === [] ? null : $this->payload($this->search($request, $prodi)),
|
|
]);
|
|
}
|
|
|
|
public function data(Request $request): JsonResponse
|
|
{
|
|
$this->legacyOnly($request);
|
|
$prodi = $this->overview->programs((int) $request->user()->getKey())->keys()->all();
|
|
abort_if($prodi === [], 404);
|
|
|
|
return response()->json($this->payload($this->search($request, $prodi)));
|
|
}
|
|
|
|
/** @param list<int> $prodi */
|
|
private function search(Request $request, array $prodi): LengthAwarePaginator
|
|
{
|
|
return $this->graduation->theses($prodi, [
|
|
'prodi' => $request->filled('prodi') && in_array($request->integer('prodi'), $prodi, true) ? $request->integer('prodi') : null,
|
|
'angkatan' => $request->filled('angkatan') ? $request->integer('angkatan') : null,
|
|
'status' => isset(Graduation::THESIS_STATUS[(string) $request->string('status')]) ? (string) $request->string('status') : null,
|
|
'tahap' => isset(Graduation::THESIS_STAGE[(string) $request->string('tahap')]) ? (string) $request->string('tahap') : null,
|
|
'pembimbing' => $request->filled('pembimbing') ? $request->integer('pembimbing') : null,
|
|
'penguji' => $request->filled('penguji') ? $request->integer('penguji') : null,
|
|
'q' => $this->query($request),
|
|
], $this->perPage($request, Graduation::PER_PAGE));
|
|
}
|
|
}
|