From 46c7cc08a7444a73040753c3a4c89cf6a80f9287 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Thu, 12 Mar 2026 12:20:40 +0800 Subject: [PATCH] 1. added homepage for laporan audit in operasi. 2. bug fix when table 0 marhun must cannot press papar margin. 3. bug fix when in papar margin display must cannot press daftar marhun. 4. change bersih to bersih in editmarhun --- app/Http/Controllers/OperasiController.php | 77 ++++++ resources/views/gadaian/v2/index.blade.php | 21 +- .../views/homepage/operasi/home.blade.php | 4 +- .../homepage/operasi/laporan-audit.blade.php | 46 +++ resources/views/modal/editmarhun.blade.php | 2 +- .../laporan_audittrail_operasi.blade.php | 261 ++++++++++++++++++ routes/web.php | 3 + 7 files changed, 410 insertions(+), 4 deletions(-) create mode 100644 resources/views/homepage/operasi/laporan-audit.blade.php create mode 100644 resources/views/print/laporan_audittrail_operasi.blade.php diff --git a/app/Http/Controllers/OperasiController.php b/app/Http/Controllers/OperasiController.php index 001324f..4cad65d 100644 --- a/app/Http/Controllers/OperasiController.php +++ b/app/Http/Controllers/OperasiController.php @@ -338,4 +338,81 @@ class OperasiController extends Controller return view('operasi.edit_marginmutu', compact('cawangan_info', 'api_url')); } + + public function laporanAudit() + { + $auth_user = Auth::user(); + $api_url = config('api.url'); + $cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json(); + + return view('homepage.operasi.laporan-audit', compact('cawangan_info', 'api_url')); + } + + public function cetakLaporanAuditTrail(Request $request) + { + $api_url = config('api.url'); + $auth_user = Auth::user(); + $current = Carbon::now(); + $current = new Carbon(); + $tarikh_cetak = $current->toDateString(); + + if($request->dateaudit == null){ + $date = $current->toDateString(); + }else{ + $split_date = explode('-', $request->dateaudit); + $date = $split_date[0] . '-' . $split_date[1] . '-' . $split_date[2]; + } + + if($request->dateaudit_till == null){ + $date_till = $current->toDateString(); + }else{ + $split_date_till = explode('-', $request->dateaudit_till); + $date_till = $split_date_till[0] . '-' . $split_date_till[1] . '-' . $split_date_till[2]; + } + + $audittrail_raw = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/reports/audittrail/operasi',['date' => $date,'date_till' => $date_till])->json(); + if(!$audittrail_raw){ + return redirect()->back()->with('errormessage', 'Tiada data pada tarikh tersebut.'); + } + + // Transform the data to match view format + $audittrail = []; + foreach($audittrail_raw as $item) { + $created_at = \Carbon\Carbon::parse($item['created_at']); + + // Format differences for display + $differences_text = '-'; + if (isset($item['differences']) && !empty($item['differences'])) { + $diff_parts = []; + foreach ($item['differences'] as $field => $changes) { + $old = $changes['old'] ?? 'null'; + $new = $changes['new'] ?? 'null'; + $diff_parts[] = "{$field}: {$old} → {$new}"; + } + $differences_text = implode('; ', $diff_parts); + } + + $audittrail[] = [ + 'tarikh' => $created_at->format('d/m/Y'), + 'masa' => $created_at->format('H:i:s'), + 'users' => $item['users'], + 'actions' => $item['actions'], + 'differ' => $differences_text + ]; + } + + $cawangan_detail = [ + 'kodcaw' => 'operasi', + 'namacaw' => 'Operasi Ar-Rahn', + 'alamat1' => 'Lot 107, Jalan Parit Dalam,', + 'alamat2' => 'Seksyen 8', + 'poskod' => '15000', + 'bandar' => 'Kota Bahru', + 'negeri' => 'Kelantan', + 'notel' => '03-12345678', + 'nofaks' => '03-12345678', + ]; + + return view('print.laporan_audittrail_operasi', compact('audittrail','cawangan_detail','tarikh_cetak','date','date_till','api_url')); + } } diff --git a/resources/views/gadaian/v2/index.blade.php b/resources/views/gadaian/v2/index.blade.php index ce1d84f..3cf5f94 100644 --- a/resources/views/gadaian/v2/index.blade.php +++ b/resources/views/gadaian/v2/index.blade.php @@ -107,8 +107,8 @@ Nilai Marhun Margin Teller (%) Margin PC (%) - Nilai Marhun Teller - Nilai Marhun PC + Pembiayaan Teller + Pembiayaan PC @@ -1915,18 +1915,35 @@ $('#toggleTableBtn').on('click', function() { if (!isMarginTableVisible) { + // Check if main table has data before showing margin table + let tableData = $('#myTable').DataTable().data(); + if (tableData.length === 0) { + Swal.fire({ + icon: 'warning', + title: 'Amaran!', + text: 'Tiada data marhun untuk papar margin. Sila daftar marhun terlebih dahulu.' + }); + return; + } + // Show margin table, hide main table $('#myTable_wrapper').hide(); $('#marginTable').show(); $(this).html(' Papar Marhun'); loadMarginData(); isMarginTableVisible = true; + + // Disable Daftar Marhun button when margin table is visible + $('button[data-target="#daftar_marhun"]').prop('disabled', true); } else { // Show main table, hide margin table $('#marginTable_wrapper').hide(); $('#myTable_wrapper').show(); $(this).html(' Papar Margin'); isMarginTableVisible = false; + + // Enable Daftar Marhun button when main table is visible + $('button[data-target="#daftar_marhun"]').prop('disabled', false); } }); diff --git a/resources/views/homepage/operasi/home.blade.php b/resources/views/homepage/operasi/home.blade.php index a86275b..b327950 100644 --- a/resources/views/homepage/operasi/home.blade.php +++ b/resources/views/homepage/operasi/home.blade.php @@ -3,7 +3,7 @@ @section('content')
-
+
+
diff --git a/resources/views/homepage/operasi/laporan-audit.blade.php b/resources/views/homepage/operasi/laporan-audit.blade.php new file mode 100644 index 0000000..afffb68 --- /dev/null +++ b/resources/views/homepage/operasi/laporan-audit.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.app_operasi') + +@section('content') +
+
+
+
+ + +
+

Laporan Audit

+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/modal/editmarhun.blade.php b/resources/views/modal/editmarhun.blade.php index a40407c..5b95402 100644 --- a/resources/views/modal/editmarhun.blade.php +++ b/resources/views/modal/editmarhun.blade.php @@ -63,7 +63,7 @@ @endforeach
-
Berat
+
Berat Bersih
Harga
diff --git a/resources/views/print/laporan_audittrail_operasi.blade.php b/resources/views/print/laporan_audittrail_operasi.blade.php new file mode 100644 index 0000000..bb19ab3 --- /dev/null +++ b/resources/views/print/laporan_audittrail_operasi.blade.php @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + {{-- --}} + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
LAPORAN AUDIT TRAIL OPERASI (arOS V3)
TARIKH CETAK: + @php + $myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh_cetak); + $formattedweddingdate = $myDateTime->format('d-m-Y'); + echo($formattedweddingdate); + @endphp +
TARIKH MULA:@php + $myDateTime = DateTime::createFromFormat('Y-m-d', $date); + $formattedweddingdate = $myDateTime->format('d-m-Y'); + echo($formattedweddingdate); + @endphp HINGGA:@php + $myDateTime = DateTime::createFromFormat('Y-m-d', $date_till); + $formattedweddingdate = $myDateTime->format('d-m-Y'); + echo($formattedweddingdate); + @endphp
+ +
+ + + + + + + + + + @php $counter = 1; @endphp + @foreach($audittrail as $index=>$item) + + + + + + + + + @php $counter++;@endphp + @endforeach +
BilTarikhMasaPenggunaTindakanPerbezaan
{{ $counter }}{{ $item['tarikh'] }}{{ $item['masa'] }}{{ $item['users'] }}{{ $item['actions'] }}{{ $item['differ'] }}
+

+ +
+


+ + + + + + + + + + + + + + + + + + + +
.................................................................. .................................................................. ..................................................................
Disediakan Disemak Disahkan
diff --git a/routes/web.php b/routes/web.php index b29ec1d..423f3a7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -269,6 +269,8 @@ Route::post('laporan/saghilang/cetak',['as'=>'saghilang.laporancetak','uses'=>'K // Route::get('/laporan/agingbulanan', [ 'as'=>'laporan.agingbulanan', 'uses'=>'KhazanahController@laporanAging_Bulanan'])->middleware('auth','khazanah'); // Route::post('/laporan/agingbulanan/cetak', ['as'=>'agingbulan.cetaklaporan', 'uses'=>'KhazanahController@cetaklaporang_Aging'])->middleware('auth','khazanah'); +Route::get('laporan/operasi/audittrail/cetak',['as'=>'operasi.audittrail.laporancetak','uses'=>'OperasiController@cetakLaporanAuditTrail'])->middleware('auth','operasi'); + Route::get('/laporan/stokauditbackdate',['as'=>'laporan.stokauditbackdate','uses'=>'KhazanahController@laporanStokAuditBackdate'])->middleware('auth','khazanah'); Route::get('laporan/stokauditbackdate/cetak',['as'=>'stokauditbackdate.laporancetak','uses'=>'KhazanahController@cetakLaporanStokAuditBackdate'])->middleware('auth','khazanah'); @@ -344,6 +346,7 @@ Route::post('/operasi/createkelulusan-by-khazanah',['as'=>'operasi.createkelulus Route::get('/operasi/getkelulusan',['as'=>'operasi.getkelulusan','uses'=>'OperasiController@getkelulusan'])->middleware('auth','teller'); Route::put('/operasi/updatekelulusan',['as'=>'operasi.updatekelulusan','uses'=>'OperasiController@updatekelulusan'])->middleware('auth','operasi'); Route::get('/operasi/parameter','OperasiController@parameter')->name('parameter')->middleware('auth','operasi'); +Route::get('/operasi/laporan-audit','OperasiController@laporanAudit')->name('operasi.laporan.audit')->middleware('auth','operasi'); Route::get('/operasi/hargaemas',['as'=>'operasi.hargaemas','uses'=>'OperasiController@hargaemas'])->middleware('auth','operasi'); Route::post('/operasi/hargaemas/update',['as'=>'hargaemas.update','uses'=>'OperasiController@updatehargaemas'])->middleware('auth','operasi'); Route::post('/operasi/hargaemas',['as'=>'hargaemas.create','uses'=>'OperasiController@createhargaemas'])->middleware('auth','operasi');