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
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user