diff --git a/app/Http/Controllers/PermohonanController.php b/app/Http/Controllers/PermohonanController.php
index ea6d5f3..73d6b37 100644
--- a/app/Http/Controllers/PermohonanController.php
+++ b/app/Http/Controllers/PermohonanController.php
@@ -179,4 +179,94 @@
{
return Excel::download(new PermohonanExport, 'permohonan.xlsx');
}
+
+ public function authorization()
+ {
+ return view('lpj::permohonan.authorization.index');
+ }
+
+ public function dataForAuthorization(Request $request)
+ {
+ if (is_null($this->user) || !$this->user->can('debitur.view')) {
+ //abort(403, 'Sorry! You are not allowed to view users.');
+ }
+
+ // Retrieve data from the database
+ $query = Permohonan::query();
+
+ // Apply search filter if provided
+ if ($request->has('search') && !empty($request->get('search'))) {
+ $search = $request->get('search');
+ $query->where(function ($q) use ($search) {
+ $q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
+ $q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhere('status', 'LIKE', '%' . $search . '%');
+ });
+ }
+
+ // Apply sorting if provided
+ if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
+ $order = $request->get('sortOrder');
+ $column = $request->get('sortField');
+ $query->orderBy($column, $order);
+ }
+
+ // Get the total count of records
+ $totalRecords = $query->count();
+
+ // Apply pagination if provided
+ if ($request->has('page') && $request->has('size')) {
+ $page = $request->get('page');
+ $size = $request->get('size');
+ $offset = ($page - 1) * $size; // Calculate the offset
+
+ $query->skip($offset)->take($size);
+ }
+
+ // Get the filtered count of records
+ $filteredRecords = $query->count();
+
+ // Get the data for the current page
+ $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->where('status','=','order')->get();
+
+ // Calculate the page count
+ $pageCount = ceil($totalRecords / $request->get('size'));
+
+ // Calculate the current page number
+ $currentPage = 0 + 1;
+
+ // Return the response data as a JSON object
+ return response()->json([
+ 'draw' => $request->get('draw'),
+ 'recordsTotal' => $totalRecords,
+ 'recordsFiltered' => $filteredRecords,
+ 'pageCount' => $pageCount,
+ 'page' => $currentPage,
+ 'totalCount' => $totalRecords,
+ 'data' => $data,
+ ]);
+ }
+
+ public function showAuthorization($id)
+ {
+ $permohonan = Permohonan::find($id);
+ return view('lpj::permohonan.authorization.show',compact('permohonan'));
+ }
+
+ public function updateAuthorization(Request $request, $id){
+ try {
+ $permohonan = Permohonan::find($id);
+ $permohonan->status = $request->status;
+ $permohonan->keterangan = $request->keterangan;
+ $permohonan->save();
+ }catch (Exception $e) {
+ return redirect()->route('authorization.show', $id)->with('error', 'Failed to update permohonan');
+ }
+
+ return redirect()->route('authorization.index')->with('success', 'Permohonan updated successfully');
+ }
}
diff --git a/app/Models/Permohonan.php b/app/Models/Permohonan.php
index 28b6de5..d1d4689 100644
--- a/app/Models/Permohonan.php
+++ b/app/Models/Permohonan.php
@@ -17,10 +17,12 @@ class Permohonan extends Base
'branch_id',
'tujuan_penilaian_id',
'debiture_id',
+ 'keterangan',
'status',
'authorized_at',
'authorized_status',
'authorized_by',
+
];
public function user(){
diff --git a/module.json b/module.json
index 2dbec76..c1f1567 100644
--- a/module.json
+++ b/module.json
@@ -46,7 +46,7 @@
},
{
"title": "Authorization",
- "path": "",
+ "path": "authorization",
"icon": "ki-filled ki-some-files text-lg",
"classes": "",
"attributes": [],
diff --git a/resources/views/permohonan/authorization/index.blade.php b/resources/views/permohonan/authorization/index.blade.php
new file mode 100644
index 0000000..aed62c8
--- /dev/null
+++ b/resources/views/permohonan/authorization/index.blade.php
@@ -0,0 +1,191 @@
+@extends('layouts.main')
+
+@section('breadcrumbs')
+ {{ Breadcrumbs::render(request()->route()->getName()) }}
+@endsection
+
+@section('content')
+
+@endsection
+
+@push('scripts')
+
+
+
+@endpush
diff --git a/resources/views/permohonan/authorization/show.blade.php b/resources/views/permohonan/authorization/show.blade.php
new file mode 100644
index 0000000..7a857a5
--- /dev/null
+++ b/resources/views/permohonan/authorization/show.blade.php
@@ -0,0 +1,164 @@
+@extends('layouts.main')
+
+@section('breadcrumbs')
+ {{ Breadcrumbs::render(request()->route()->getName()) }}
+@endsection
+
+@section('content')
+
+
+
+
+
+
+ Nomor Register Permohonan:
+
+
+ {{ $permohonan->nomor_registrasi }}
+
+
+
+
+
+ Pemohon:
+
+
+ {{ $permohonan->user->nik }} | {{ $permohonan->user->name }} | {{ $permohonan->user->branch->name }}
+
+
+
+
+
+ Tujan Permohonan:
+
+
+ {{ $permohonan->tujuanPenilaian->name }}
+
+
+
+
+
+
+
+
+
+
+@endsection
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php
index f39cfcc..4ea45ad 100644
--- a/routes/breadcrumbs.php
+++ b/routes/breadcrumbs.php
@@ -267,3 +267,12 @@
$trail->push('Data Permohonan');
});
+ Breadcrumbs::for('authorization.index', function (BreadcrumbTrail $trail) {
+ $trail->push('Permohonan', route('authorization.index'));
+ });
+
+ Breadcrumbs::for('authorization.show', function (BreadcrumbTrail $trail) {
+ $trail->parent('authorization.index');
+ $trail->push('Detail Permohonan');
+ });
+
diff --git a/routes/web.php b/routes/web.php
index 92a5cd3..cfa177a 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -172,6 +172,12 @@
Route::resource('permohonan', PermohonanController::class);
+ Route::get('authorization', [PermohonanController::class, 'authorization'])->name('authorization.index');
+ Route::get('authorization/datatables', [PermohonanController::class, 'dataForAuthorization'])
+ ->name('authorization.datatables');
+ Route::get('authorization/{id}/edit', [PermohonanController::class, 'showAuthorization'])->name('authorization.show');
+ Route::put('authorization/{id}', [PermohonanController::class, 'updateAuthorization'])->name('authorization.update');
+
Route::name('debitur.')->prefix('debitur')->group(function () {
Route::get('restore/{id}', [DebitureController::class, 'restore'])->name('restore');
Route::get('datatables', [DebitureController::class, 'dataForDatatables'])