Penambahan menu Perkuliahan
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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\ClassSchedule;
|
||||
use App\Support\Legacy\EmployeeDirectory;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Perkuliahan > Data Kelas > Monitoring Ruang (slug data_monitorruang) untuk akun DB lama: pemakaian ruang unit akun
|
||||
* pada satu tanggal (perkuliahan dari jadwal mingguan periode terpilih, ujian dari tanggal ujian). Formulir GET, dimuat di tempat.
|
||||
*/
|
||||
class MonitorRuangController extends Controller
|
||||
{
|
||||
use ServesLegacyList;
|
||||
|
||||
private const string SLUG = 'data_monitorruang';
|
||||
|
||||
public const array STATUS_OPTIONS = ['kosong' => 'Kosong', 'terpakai' => 'Terpakai'];
|
||||
|
||||
public function __construct(
|
||||
private readonly AcademicOverview $overview,
|
||||
private readonly EmployeeDirectory $employees,
|
||||
private readonly ClassSchedule $schedule,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): View
|
||||
{
|
||||
$page = Catalog::page(self::SLUG);
|
||||
$iduser = (int) $request->user()->getKey();
|
||||
$programs = $this->overview->programs($iduser);
|
||||
$prodi = $programs->keys()->all();
|
||||
$units = $this->schedule->roomUnits($this->employees->faculties($iduser), $programs);
|
||||
$periods = $this->schedule->periods();
|
||||
$default = $prodi === [] ? null : $this->schedule->defaultPeriod($prodi, $periods);
|
||||
|
||||
$unit = $request->filled('unit') && $units->has($request->integer('unit')) ? $request->integer('unit') : $units->keys()->first();
|
||||
$periode = $request->filled('periode') && $periods->has($request->integer('periode')) ? $request->integer('periode') : $default;
|
||||
$tanggal = rescue(fn () => Carbon::createFromFormat('Y-m-d', (string) $request->string('tanggal'))->startOfDay(), now()->startOfDay(), false);
|
||||
$status = isset(self::STATUS_OPTIONS[(string) $request->string('status')]) ? (string) $request->string('status') : null;
|
||||
$kapasitas = $request->filled('kapasitas') ? max(0, $request->integer('kapasitas')) : null;
|
||||
$jenis = $request->has('jenis') ? array_intersect((array) $request->input('jenis'), ['kuliah', 'ujian']) : ['kuliah', 'ujian'];
|
||||
[$labelUnit, $labelDosen, $labelKapasitas, $labelStatus, $labelJenis] = $page['filters'];
|
||||
|
||||
return view('operator.satu.ruang-monitor', [
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG, $page),
|
||||
'note' => 'Pemakaian ruang asli unit yang Anda kelola pada tanggal terpilih: perkuliahan mengikuti jadwal mingguan periode terpilih, ujian mengikuti tanggal ujian.',
|
||||
'labels' => ['unit' => $labelUnit, 'dosen' => $labelDosen, 'kapasitas' => $labelKapasitas, 'status' => $labelStatus, 'jenis' => $labelJenis],
|
||||
'units' => $units,
|
||||
'periods' => $periods,
|
||||
'values' => ['unit' => $unit, 'periode' => $periode, 'tanggal' => $tanggal->toDateString(), 'status' => $status, 'kapasitas' => $kapasitas, 'dosen' => mb_substr(trim((string) $request->string('dosen')), 0, 60), 'jenis' => array_values($jenis), 'q' => $this->query($request)],
|
||||
'statusOptions' => self::STATUS_OPTIONS,
|
||||
'tanggalLabel' => $tanggal->translatedFormat('l, j F Y'),
|
||||
'rooms' => $unit === null || $periode === null ? [] : $this->schedule->roomMonitor([
|
||||
'unit' => $unit, 'tanggal' => $tanggal, 'periode' => $periode, 'status' => $status, 'kapasitas' => $kapasitas,
|
||||
'dosen' => mb_substr(trim((string) $request->string('dosen')), 0, 60), 'kuliah' => in_array('kuliah', $jenis, true), 'ujian' => in_array('ujian', $jenis, true), 'q' => $this->query($request),
|
||||
]),
|
||||
'ready' => $unit !== null && $periode !== null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user