From 5fcce527b48560ca13f5d9edf13d91e3c23fbba6 Mon Sep 17 00:00:00 2001 From: majid Date: Fri, 27 Sep 2024 15:08:13 +0700 Subject: [PATCH] perbaikan activity pemohonan ( seacrh filter status multiple, Penilai/Surveyor tidak tampil dan status aktivitas pada permohonan akan berjalan dari bawah ke atas) --- app/Exports/PermohonanExport.php | 4 +- app/Http/Controllers/ActivityController.php | 67 ++++--- app/Models/Penilaian.php | 25 ++- module.json | 11 ++ .../views/activity/activitydetail.blade.php | 181 +++++++++--------- .../activity/components/status.blade.php | 37 ---- resources/views/activity/index.blade.php | 118 ++++++++++-- .../activity/senior_officer/index.blade.php | 15 ++ resources/views/penilaian/form.blade.php | 2 +- routes/web.php | 27 ++- 10 files changed, 307 insertions(+), 180 deletions(-) create mode 100644 resources/views/activity/senior_officer/index.blade.php diff --git a/app/Exports/PermohonanExport.php b/app/Exports/PermohonanExport.php index c6ce0a2..4b8d74b 100644 --- a/app/Exports/PermohonanExport.php +++ b/app/Exports/PermohonanExport.php @@ -28,8 +28,8 @@ $row->branch->name, $row->tujuanPenilaian->name, $row->debiture->name, - $row->fasilitasKredit->name, - $row->plafond->name, + $row->jenisFasilitasKredit->name, + $row->nilaiPlafond->name, $row->status, $row->authorized_at, $row->authorized_status, diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index c24eee2..12bd5b3 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -8,7 +8,8 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Modules\Lpj\Models\Permohonan; use Modules\Lpj\Models\StatusPermohonan; - +use Modules\Lpj\Exports\PermohonanExport; +use Maatwebsite\Excel\Facades\Excel; class ActivityController extends Controller { public $user; @@ -25,6 +26,11 @@ class ActivityController extends Controller * Show the form for creating a new resource. */ + public function senior() + { + return view('lpj::activity.senior_officer.index'); + } + /** * Store a newly created resource in storage. */ @@ -39,7 +45,7 @@ class ActivityController extends Controller public function show($id) { - $status_permohonan = StatusPermohonan::orderBy('id')->get(); + $status_permohonan = StatusPermohonan::orderBy('id')->get()->reverse(); $permohonan = Permohonan::with( [ @@ -67,9 +73,9 @@ class ActivityController extends Controller /** * Update the specified resource in storage. - */ - public function dataForDatatables(Request $request) + */public function dataForDatatables(Request $request) { + // Check permissions if (is_null($this->user) || !$this->user->can('debitur.view')) { // abort(403, 'Sorry! You are not allowed to view users.'); } @@ -81,20 +87,19 @@ class ActivityController extends Controller 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 . '%'); - }); - } + $q->where('nomor_registrasi', 'LIKE', '%' . $search . '%') + ->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%') + ->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%') + ->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%') + ->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%') + ->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%'); - // Apply status filter if provided - if ($request->has('status') && !empty($request->get('status'))) { - $status = $request->get('status'); - $query->where('status', '=', $status); + // Split search term by comma to allow multiple statuses + $statusKeywords = explode(',', $search); + foreach ($statusKeywords as $keyword) { + $q->orWhere('status', 'LIKE', '%' . trim($keyword) . '%'); + } + }); } // Default sorting if no sort provided @@ -103,32 +108,29 @@ class ActivityController extends Controller $column = $request->get('sortField'); $query->orderBy($column, $order); } else { - $query->orderBy('nomor_registrasi', 'asc'); // Default order by nomor_registrasi + $query->orderBy('nomor_registrasi', 'asc'); } - // Get the total count of records before paginating + // Get total count of records before pagination $totalRecords = $query->count(); - // Apply pagination if provided + // Pagination if ($request->has('page') && $request->has('size')) { - $page = (int) $request->get('page', 1); // Default page is 1 - $size = (int) $request->get('size', 10); // Default size is 10 - $offset = ($page - 1) * $size; // Calculate the offset - - // Limit results based on pagination + $page = (int) $request->get('page', 1); + $size = (int) $request->get('size', 10); + $offset = ($page - 1) * $size; $query->skip($offset)->take($size); } - // Get the filtered count of records (after search & filters applied) + // Get filtered count $filteredRecords = $query->count(); - // Get the data for the current page + // Get data $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get(); - // Calculate the total number of pages + // Calculate total pages $pageCount = ceil($totalRecords / $request->get('size', 10)); - // Return the response data as a JSON object return response()->json([ 'draw' => $request->get('draw'), 'recordsTotal' => $totalRecords, @@ -141,6 +143,7 @@ class ActivityController extends Controller } + /** * Download the specified resource from storage. */ @@ -149,4 +152,10 @@ class ActivityController extends Controller $document = Permohonan::find($id); return response()->download(storage_path('app/public/' . $document->dokumen)); } + + public function export() + { + return Excel::download(new PermohonanExport, 'activity.xlsx'); + } + } diff --git a/app/Models/Penilaian.php b/app/Models/Penilaian.php index 93bd3e8..cb2f44c 100644 --- a/app/Models/Penilaian.php +++ b/app/Models/Penilaian.php @@ -10,45 +10,50 @@ use Modules\Lpj\Models\Teams; use Modules\Lpj\Models\Permohonan; use Modules\Usermanagement\Models\User; - class Penilaian extends Model { - /** * The attributes that are mass assignable. */ protected $table = 'penilaian'; protected $fillable = [ - 'jenis_penilaian_id', 'teams_id', 'user_id', 'tanggal_kunjungan', 'keterangan','nomor_registrasi','penilaian_id','surveyor_id','penilai_surveyor_id', + 'jenis_penilaian_id', 'teams_id', 'tanggal_kunjungan', 'keterangan','nomor_registrasi','penilaian_id','surveyor_id','penilai_surveyor_id', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_at', 'created_by', 'updated_at', 'updated_by', 'deleted_at', 'deleted_by' ]; - public function jenis_penilaian(){ + public function jenis_penilaian() + { return $this->belongsTo(JenisPenilaian::class, 'jenis_penilaian_id', 'id'); } - public function teams(){ + public function teams() + { return $this->belongsTo(Teams::class, 'teams_id', 'id'); } - public function users(){ + public function users() + { return $this->belongsTo(User::class, 'user_id', 'id'); } - public function userPenilai(){ + public function userPenilai() + { return $this->belongsTo(User::class, 'penilaian_id', 'id'); } - public function userSurveyor(){ + public function userSurveyor() + { return $this->belongsTo(User::class, 'surveyor_id', 'id'); } - public function userPenilaiSurveyor(){ + public function userPenilaiSurveyor() + { return $this->belongsTo(User::class, 'penilai_surveyor_id', 'id'); } - public function permohonan(){ + public function permohonan() + { return $this->belongsTo(Permohonan::class, 'nomor_registrasi', 'nomor_registrasi'); } diff --git a/module.json b/module.json index dd4d18f..bca6ad3 100644 --- a/module.json +++ b/module.json @@ -114,6 +114,17 @@ "Administrator" ] }, + { + "title": "Activity Progress", + "path": "activity", + "icon": "ki-filled ki-questionnaire-tablet text-lg", + "classes": "", + "attributes": [], + "permission": "", + "roles": [ + "Administrator" + ] + }, { "title": "Surveyor", "path": "surveyor", diff --git a/resources/views/activity/activitydetail.blade.php b/resources/views/activity/activitydetail.blade.php index ec335f0..df4b3e2 100644 --- a/resources/views/activity/activitydetail.blade.php +++ b/resources/views/activity/activitydetail.blade.php @@ -13,108 +13,115 @@ @endpush
-
-
-

- Activity Permohonan -

-
- - Back +
+
+

+ Activity Permohonan +

+
+ + Back +
+
+
+
+

+ Nomor Register Permohonan: +

+ + {{ $permohonan->nomor_registrasi }} + +
+ +
+

+ Pemohon: +

+ + {{ $permohonan->user->nik }} | {{ $permohonan->user->name }} | {{ $permohonan->user->branch->name }} + +
+ +
+

+ Tujuan Permohonan: +

+ + {{ $permohonan->tujuanPenilaian->name }} + +
+
-
-
+ +
+

- Nomor Register Permohonan: + Status Activity

- - {{ $permohonan->nomor_registrasi }} -
- -
-

- Pemohon: -

- - {{ $permohonan->user->nik }} | {{ $permohonan->user->name }} | {{ $permohonan->user->branch->name }} - -
- -
-

- Tujan Permohonan: -

- - {{ $permohonan->tujuanPenilaian->name }} - -
- -
-
- - -
-
-

- Status Activity -

-
-
-
- @foreach ($status_permohonan as $index => $status) - {{-- Cek apakah status adalah "Revisi" dan status permohonan tidak sama, maka tidak ditampilkan --}} - @if (strtolower($status->name) == 'revisi' && strtolower($status->name) != strtolower($permohonan->status)) - @continue - @endif - -
- @if ($index < count($status_permohonan) - 1) -
-
+
+
+ @foreach ($status_permohonan as $index => $status) + {{-- Cek apakah status adalah "Revisi" dan status permohonan tidak sama, maka tidak ditampilkan --}} + @if (strtolower($status->name) == 'revisi' && strtolower($status->name) != strtolower($permohonan->status)) + @continue @endif -
- @switch(strtolower($status->name)) - @case('order') - - @break +
+ @if ($index > 0) +
+
+ @endif - @case('revisi') - - @break +
+ @switch(strtolower($status->name)) + @case('order') + + @break - @case('register') - - @break + @case('revisi') + + @break - @case('assign') - - @break + @case('register') + + @break - @case('survey') - - @break + @case('assign') + + @break - @default - - @endswitch + @case('survey') + + @break + @case('proses laporan') + + @break + @case('approved') + + @break + @case('delivered') + + @break + @default + + @endswitch +
+ @include('lpj::activity.components.status')
- @include('lpj::activity.components.status') -
- @endforeach + @endforeach +
+
+
-
-
@endsection diff --git a/resources/views/activity/components/status.blade.php b/resources/views/activity/components/status.blade.php index 0952cc3..19d1107 100644 --- a/resources/views/activity/components/status.blade.php +++ b/resources/views/activity/components/status.blade.php @@ -43,47 +43,10 @@
@endif - {{-- Tampilkan informasi assign jika status 'assign' --}} @if (strtolower($status->name) == 'assign' && $isCurrentStatus)
- {{-- Informasi Penilai, Surveyor, dan Penilai Surveyor --}} -
- @isset($permohonan->penilaian) - @if ($penilai = $permohonan->penilaian->userPenilai->name ?? null) -
-

Penilai:

- {{ $penilai }} -
- @endif - @if ($surveyor = $permohonan->penilaian->userSurveyor->name ?? null) -
-

Surveyor:

- {{ $surveyor }} -
- @endif - - @if ($penilaiSurveyor = $permohonan->penilaian->userPenilaiSurveyor->name ?? null) -
-

Penilai Surveyor:

- {{ $penilaiSurveyor }} -
- @endif - @endisset -
- - {{-- Teams --}} -
-

Teams:

-
    - @foreach ($permohonan->penilaian->teams->teamsUsers as $item) -
  • {{ $item->user->name }}
  • - @endforeach -
-
- - {{-- Catatan --}}

Catatan:

{{ $permohonan->penilaian->keterangan }} diff --git a/resources/views/activity/index.blade.php b/resources/views/activity/index.blade.php index 4dd0179..72e4efc 100644 --- a/resources/views/activity/index.blade.php +++ b/resources/views/activity/index.blade.php @@ -4,16 +4,45 @@ {{ Breadcrumbs::render('activity') }} @endsection @section('content') +@push('styles') + + +@endpush
Activity
+ +
-

- {{-- Daftar {{}} --}} -

+
-
- + + +
Export to Excel @@ -203,9 +260,44 @@ dataTable.search(searchValue, true); }); - statusFilter.addEventListener('change', function() { - const selectedStatus = this.value; - dataTable.search(selectedStatus); + + const selectAllCheckbox = document.getElementById('select-all'); + const statusCheckboxes = document.querySelectorAll('.status-checkbox'); + + statusCheckboxes.forEach(checkbox => { + checkbox.addEventListener('change', applyStatusFilter); }); + + // Event listener untuk "Select All" + selectAllCheckbox.addEventListener('change', function() { + const isChecked = this.checked; + statusCheckboxes.forEach(checkbox => { + checkbox.checked = isChecked; + }); + applyStatusFilter(); + }); + + function applyStatusFilter() { + const selectedStatuses = Array.from(statusCheckboxes) + .filter(checkbox => checkbox.checked) + .map(checkbox => checkbox.value); + + + if (selectedStatuses.length === 0) { + dataTable.search(''); + console.log(selectedStatuses); + + } else { + + dataTable.search(selectedStatuses.join(','), true); + console.log(selectedStatuses); + + } + + const allChecked = Array.from(statusCheckboxes).every(cb => cb.checked); + selectAllCheckbox.checked = allChecked; + } + + @endpush diff --git a/resources/views/activity/senior_officer/index.blade.php b/resources/views/activity/senior_officer/index.blade.php new file mode 100644 index 0000000..aee45bb --- /dev/null +++ b/resources/views/activity/senior_officer/index.blade.php @@ -0,0 +1,15 @@ +@extends('layouts.main') + +{{-- @section('breadcrumbs') + {{ Breadcrumbs::render('activity') }} +@endsection --}} +@section('content') + + +
+
+ hello +
+
+ +@endsection diff --git a/resources/views/penilaian/form.blade.php b/resources/views/penilaian/form.blade.php index 63b642c..484ac33 100644 --- a/resources/views/penilaian/form.blade.php +++ b/resources/views/penilaian/form.blade.php @@ -335,7 +335,7 @@
diff --git a/routes/web.php b/routes/web.php index 34777c0..248a223 100644 --- a/routes/web.php +++ b/routes/web.php @@ -353,6 +353,11 @@ Route::middleware(['auth'])->group(function () { Route::resource('debitur', DebitureController::class); + + /** + * Route start Penilaian + */ + Route::name('penilaian.')->prefix('penilaian')->group(function () { Route::get('restore/{id}', [PenilaianController::class, 'restore'])->name('restore'); Route::get('datatables', [PenilaianController::class, 'dataForDatatables'])->name('datatables'); @@ -367,6 +372,13 @@ Route::middleware(['auth'])->group(function () { Route::post('store', [PenilaianController::class, 'store'])->name('store'); }); + /** + * Route end Penilaian + */ + + /** + * Route start activity + */ Route::name('activity.')->prefix('activity')->group(function () { Route::get('restore/{id}', [ActivityController::class, 'restore'])->name('restore'); @@ -376,8 +388,13 @@ Route::middleware(['auth'])->group(function () { Route::get('/{id}/show', [ActivityController::class, 'show'])->name('show'); Route::get('download/{id}', [ActivityController::class, 'download'])->name('download'); + Route::get('senior', [ActivityController::class, 'senior'])->name('senior'); }); + /** + * Route end activity + */ + Route::name('permohonan.')->prefix('permohonan')->group(function () { Route::get('{id}/create', [PermohonanController::class, 'createPermohonan'])->name('create.debitur'); Route::get('download/{id}', [PermohonanController::class, 'download'])->name('download'); @@ -445,7 +462,11 @@ Route::middleware(['auth'])->group(function () { }); - Route::name('surveyor.')->prefix('surveyor')->group(function () { + /** + * Route start surveyor + */ + + Route::name('surveyor.')->prefix('surveyor')->group(function () { Route::get('restore/{id}', [SurveyorController::class, 'restore'])->name('restore'); Route::get('datatables', [SurveyorController::class, 'dataForDatatables'])->name('datatables'); Route::get('export', [SurveyorController::class, 'export'])->name('export'); @@ -455,6 +476,10 @@ Route::middleware(['auth'])->group(function () { Route::get('download/{id}', [SurveyorController::class, 'download'])->name('download'); }); + /** + * Route end activity + */ + });