Add new owner relationships and form for guarantee owners
This commit introduces the capability to select and define relationships for guarantee owners that are different from the debiture. Additionally, a dynamic form is added to manage the details of multiple guarantee owners, including their IDs and names. Adjustments have also been made to the views and controllers to support these features.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\DetailDokumenJaminan;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
use Modules\Lpj\Models\HubunganPemilikJaminan;
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
use Modules\Lpj\Models\PemilikJaminan;
|
||||
@@ -125,10 +126,18 @@
|
||||
$jenisJaminan = JenisJaminan::all();
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||
$pemilikJaminan = PemilikJaminan::where('debiture_id', $id)->get();
|
||||
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||
|
||||
return view(
|
||||
'lpj::debitur.jaminan',
|
||||
compact('debitur', 'provinces', 'jenisJaminan', 'jenisLegalitasJaminan', 'pemilikJaminan'),
|
||||
compact(
|
||||
'debitur',
|
||||
'provinces',
|
||||
'jenisJaminan',
|
||||
'jenisLegalitasJaminan',
|
||||
'pemilikJaminan',
|
||||
'hubunganPemilik',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,6 +151,49 @@
|
||||
DB::beginTransaction();
|
||||
$validate['debiture_id'] = $id;
|
||||
|
||||
if ($validate['pemilik_jaminan_id'] == 00) {
|
||||
$pemilik_jaminan = [
|
||||
'hubungan_pemilik_jaminan_id' => request()->get('hubungan_pemilik_jaminan_id'),
|
||||
'province_code' => $debitur->province_code,
|
||||
'city_code' => $debitur->city_code,
|
||||
'district_code' => $debitur->district_code,
|
||||
'village_code' => $debitur->village_code,
|
||||
'postal_code' => $debitur->postal_code,
|
||||
'address' => $debitur->address,
|
||||
'nomor_id' => request()->get('nomor_id'),
|
||||
'name' => request()->get('pemilik_name'),
|
||||
];
|
||||
|
||||
$detailSertifikat = [];
|
||||
$names = request()->input('detail_sertifikat.name', []);
|
||||
$nomorIds = request()->input('detail_sertifikat.nomor_id', []);
|
||||
|
||||
foreach ($names as $index => $name) {
|
||||
if (isset($nomorIds[$index])) {
|
||||
$detailSertifikat[] = [
|
||||
'name' => $name,
|
||||
'nomor_id' => $nomorIds[$index],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$pemilik_jaminan['detail_sertifikat'] = json_encode($detailSertifikat);
|
||||
|
||||
//dd($pemilik_jaminan);
|
||||
|
||||
try{
|
||||
$pemilikJaminan = PemilikJaminan::updateOrCreate([
|
||||
'debiture_id' => $id,
|
||||
'name' => request()->get('pemilik_name'),
|
||||
], $pemilik_jaminan);
|
||||
} catch (Exception $e){
|
||||
return redirect()->route('debitur.jaminan.index', $id)->with('error', 'Gagal update pemilik jaminan: '. $e->getMessage());
|
||||
}
|
||||
|
||||
$validate['pemilik_jaminan_id']=$pemilikJaminan->id;
|
||||
}
|
||||
|
||||
|
||||
if ($validate['pemilik_jaminan_id'] == 0) {
|
||||
$pemilik_jaminan = [
|
||||
'hubungan_pemilik_jaminan_id' => 1,
|
||||
@@ -160,11 +212,14 @@
|
||||
'debiture_id' => $id,
|
||||
'name' => $debitur->name,
|
||||
], $pemilik_jaminan);
|
||||
|
||||
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||
}
|
||||
|
||||
$document = DokumenJaminan::find($jaminan);
|
||||
$document->update($validate);
|
||||
|
||||
|
||||
if ($request->detail_dokumen_jaminan_id) {
|
||||
foreach ($request->detail_dokumen_jaminan_id as $key => $value) {
|
||||
if (isset($request->dokumen_jaminan[$key])) {
|
||||
@@ -239,6 +294,7 @@
|
||||
$jenisJaminan = JenisJaminan::all();
|
||||
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||
$pemilikJaminan = PemilikJaminan::where('debiture_id', $document->debiture_id)->get();
|
||||
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||
|
||||
return view(
|
||||
'lpj::debitur.jaminan',
|
||||
@@ -253,6 +309,7 @@
|
||||
'districts',
|
||||
'villages',
|
||||
'pemilikJaminan',
|
||||
'hubunganPemilik',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -305,11 +362,11 @@
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Failed to create ZIP file.');
|
||||
}
|
||||
|
||||
|
||||
return response()->download($zipFilePath, $zipFileName, [
|
||||
'Content-Type' => 'application/zip',
|
||||
'Content-Type' => 'application/zip',
|
||||
'Content-Disposition' => 'attachment; filename="' . $zipFileName . '"',
|
||||
'Content-Length' => filesize($zipFilePath),
|
||||
'Content-Length' => filesize($zipFilePath),
|
||||
])->deleteFileAfterSend(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user