From 32a8b4b072bdaf1e4b47786c94d1becd1f941800 Mon Sep 17 00:00:00 2001 From: faiqahzaman <91926774+faiqahzaman@users.noreply.github.com> Date: Tue, 12 Apr 2022 12:20:32 +0800 Subject: [PATCH] update sah mutu operasi --- app/Http/Controllers/LelongController.php | 2 +- app/Http/Controllers/MarhunController.php | 63 ++++++++++++++++++- ...21_12_13_053311_create_cawangans_table.php | 2 + ...2_03_07_061858_create_pengesahan_table.php | 2 +- .../views/pengesahan/mutumarhun.blade.php | 17 +++-- .../pengesahan/perubahanmutumarhun.blade.php | 3 + 6 files changed, 81 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index b2f82af8..76e0f180 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -331,7 +331,7 @@ class LelongController extends Controller $lelongbidmarhun->karat = $simbidmarhun->karat; $lelongbidmarhun->berat = $simbidmarhun->berat; $lelongbidmarhun->harga = $simbidmarhun->harga; - $lelongbidmarhun->nmarhun = $simbidmarhun->n_marhun; + $lelongbidmarhun->n_marhun = $simbidmarhun->n_marhun; $lelongbidmarhun->hargaasas = $simbidmarhun->hargaasas; $lelongbidmarhun->save(); diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 222566f0..cb2338ee 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -80,7 +80,52 @@ class MarhunController extends Controller $bezaberat = $marhun->old_berat - $request->berat_emas; $bezahargaasas = $marhun->old_hargaasas - $request->harga_asas; - if($request->karat < $marhun->old_karat) + if(($request->karat < $marhun->old_karat) && ($bezaberat > $ubahberatmin)) + { + $marhun->marhun = $request->marhun; + $marhun->karat = $request->karat; + $marhun->berat = $request->berat_emas; + $marhun->harga = $request->harga; + $marhun->n_marhun = $request->nilai_marhun; + $marhun->hargaasas = $request->harga_asas; + $marhun->save(); + + $lelongbid->berat = $lelongbid->berat - ($bezaberat); + $lelongbid->hargaasas = $lelongbid->hargaasas - ($bezahargaasas); + $lelongbid->save(); + + $pengesahan = Pengesahan::where('lelongbidmarhun_id', $request->idmarhun) + ->where('lelongbid_id', $marhun->lelongbid_id) + ->get(); + + if(isset($pengesahan['id'])) + { + $pengesahan->id = $pengesahan->id; + $pengesahan->lelong_id = $lelong->id; + $pengesahan->lelongbid_id = $lelongbid->id; + $pengesahan->lelongbidmarhun_id = $marhun->id; + $pengesahan->norujukan = $lelongbid->norujukan; + $pengesahan->diminta_oleh = $user->id; + $pengesahan->diminta_pada = $currentdate; + $pengesahan->status_ubah = 5; + $pengesahan->save(); + } + else + { + $berat = new Pengesahan; + $berat->lelong_id = $lelong->id; + $berat->lelongbid_id = $lelongbid->id; + $berat->lelongbidmarhun_id = $marhun->id; + $berat->norujukan = $lelongbid->norujukan; + $berat->diminta_oleh = $user->id; + $berat->diminta_pada = $currentdate; + $berat->status_ubah = 5; + $berat->save(); + } + + } + + else if($request->karat < $marhun->old_karat) { $marhun->marhun = $request->marhun; $marhun->karat = $request->karat; @@ -357,6 +402,18 @@ class MarhunController extends Controller ->groupBy('pengesahan.norujukan') ->get()->toArray(); + foreach($mutumarhun as $index1=>$mutu) + { + $cawangan = CawanganLelong::join('cawangan', 'cawangan_lelong.caw_id', 'cawangan.id') + ->join('lelongbid', 'cawangan_lelong.lelong_id', '=', 'lelongbid.lelong_id') + ->where('lelongbid.lelong_id', $id) + ->where('lelongbid.norujukan', $mutu['norujukan']) + ->select('cawangan.caw_name') + ->first(); + // dd($cawangan); + $mutumarhun[$index1]['cawangan_name'] = $cawangan; + } + // foreach($mutumarhun as $index1=>$marhun) // { // $pengesahan = Pengesahan::where('lelong_id', $id) @@ -367,7 +424,7 @@ class MarhunController extends Controller // $mutumarhun[$index1]['pengesahan_id'] = $pengesahan; // } - return view('pengesahan.perubahanmutumarhun', compact('mutumarhun', 'id', )); + return view('pengesahan.perubahanmutumarhun', compact('mutumarhun', 'id')); } @@ -438,6 +495,8 @@ class MarhunController extends Controller $rugilelong = $rugilelong - $lelongbid->baki; } + $marhuns[$index1]['harga_gadai'] = $gadaimarhun->harga; + $marhuns[$index1]['nmarhun_gadai'] = $gadaimarhun->n_marhun; $marhuns[$index1]['old_marhun'] = $gadaimarhun->marhun; $marhuns[$index1]['status_ubah'] = $status; $marhuns[$index1]['pembiayaan'] = $lelongbid->pinjaman; diff --git a/database/migrations/2021_12_13_053311_create_cawangans_table.php b/database/migrations/2021_12_13_053311_create_cawangans_table.php index b1594c0e..0e58b8c6 100644 --- a/database/migrations/2021_12_13_053311_create_cawangans_table.php +++ b/database/migrations/2021_12_13_053311_create_cawangans_table.php @@ -223,6 +223,8 @@ class CreateCawangansTable extends Migration $table->string('nota'); $table->string('karat'); $table->decimal('berat', $precision = 7, $scale = 2); + $table->decimal('harga', $precision = 9, $scale = 2); + $table->decimal('n_marhun', $precision = 9, $scale = 2); $table->timestamps(); // $table->foreign('norujukan') diff --git a/database/migrations/2022_03_07_061858_create_pengesahan_table.php b/database/migrations/2022_03_07_061858_create_pengesahan_table.php index 649bf4b0..a1c175a3 100644 --- a/database/migrations/2022_03_07_061858_create_pengesahan_table.php +++ b/database/migrations/2022_03_07_061858_create_pengesahan_table.php @@ -24,7 +24,7 @@ class CreatePengesahanTable extends Migration $table->integer('diminta_oleh'); $table->datetime('diminta_pada'); $table->integer('status')->default(0); //1 = terima, 2 = tangguh lelong - $table->integer('status_ubah')->default(0); //1 = ubah mutu, 2 = tambah marhun, 3 = hapus marhun, 4 = ubah berat + $table->integer('status_ubah')->default(0); //1 = ubah mutu, 2 = tambah marhun, 3 = hapus marhun, 4 = ubah berat, 5 = ubah mutu & berat $table->timestamps(); $table->foreign('lelong_id') diff --git a/resources/views/pengesahan/mutumarhun.blade.php b/resources/views/pengesahan/mutumarhun.blade.php index 4c039b8b..d45dd124 100644 --- a/resources/views/pengesahan/mutumarhun.blade.php +++ b/resources/views/pengesahan/mutumarhun.blade.php @@ -19,6 +19,7 @@
Norujukan : {{ $lelongbid->norujukan }}
Pembiayaan : {{ $marhuns[0]['pembiayaan'] }}
Keuntungan :
Baki Lelong : {{ $marhuns[0]['baki_lelong'] }}
@@ -30,12 +31,13 @@