Membuat Nomor KJPP menjadi otomatis

This commit is contained in:
2024-09-30 17:44:07 +07:00
parent 6558d8348b
commit 7d8d3c21e9
2 changed files with 10 additions and 2 deletions

View File

@@ -40,7 +40,15 @@ class KJPPController extends Controller
$jenis_aset = JenisJaminan::all();
$provinces = Province::all();
return view('lpj::kjpp.create', compact('branch', 'ijin_usaha', 'jenis_aset', 'provinces'));
// Generate KJPP Number
$lastKjpp = KJPP::orderBy('code', 'desc')->first();
$nextNumber = $lastKjpp ? intval(substr($lastKjpp->code, 1, 6)) + 1 : 1;
$kjppNumber = 'K' . str_pad($nextNumber, 6, '0', STR_PAD_LEFT);
// Combine KJPP number with branch code
$fullKjppNumber = $kjppNumber;
return view('lpj::kjpp.create', compact('branch', 'ijin_usaha', 'jenis_aset', 'provinces', 'fullKjppNumber'));
}
/**