From 53ffaecded9929f59157d2aa553ae700188b081e Mon Sep 17 00:00:00 2001 From: Afiq Date: Wed, 30 Mar 2022 09:03:59 +0800 Subject: [PATCH 1/6] sag kb 1 --- app/Http/Controllers/GadaiController.php | 32 +++++++++-------------- app/Http/Controllers/MarhunController.php | 25 +++++++++++++----- routes/web.php | 2 +- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 7124be4..1580c50 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3260,31 +3260,25 @@ class GadaiController extends Controller } $tarikh_gadai = Carbon::parse($gadai['t_gadai']. ' 00:00:00'); - $diff_gadai = date_diff($tarikh_gadai,$current); - $year_gadai = $diff_gadai->format("%y") * 12; - $month_gadai = $diff_gadai->format("%m"); - $days_gadai = $diff_gadai->format("%d"); - $days_gadai = $days_gadai + 1; + $diff_carbon = $tarikh_gadai->diffInDays($current); - if($days_gadai >= 1 && $days_gadai <= 15){ + $year = floor($diff_carbon/356); + $day_year_minus = $year * 356; + $diff_carbon = $diff_carbon - $day_year_minus; + + $month = floor($diff_carbon/30); + $day_month_minus = $month * 30; + $diff_carbon = $diff_carbon - $day_month_minus; + + $extensivemonth_gadai = 0; + if($diff_carbon >= 1 && $diff_carbon <= 15){ $extensivemonth_gadai = 0.5; } - else if($days_gadai >= 16){ + else if($diff_carbon >= 16){ $extensivemonth_gadai = 1; } - $tempoh_gadai = $year_gadai + $month_gadai + $extensivemonth_gadai; + $tempoh_gadai = ($year*12) + $month + $extensivemonth_gadai; - $diff = date_diff($tarikh_update,$current); - $year = $diff->format("%y") * 12; - $month = $diff->format("%m"); - $days = $diff->format("%d"); - $days = $days + 1; - if($days >= 1 && $days <= 15){ - $extensivemonth = 0.5; - } - else if($days >= 16){ - $extensivemonth = 1; - } $upah_semasa = $this->kiraupahTawarruqStokAudit($tempoh_gadai,$gadai['tempohbayar'],$gadai['kadarupah'],$gadai['bakipjm']); $tempoh_update = $year + $month + $extensivemonth; Gadai::on($cawangan_mysql['mysql'])->where('norujukan','=',$gadai['norujukan'])->update(array( diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 78ba310..87c4b82 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -29,10 +29,21 @@ class MarhunController extends Controller array_push($marhun_all,$marhun); } } - + return response()->json($marhun_all); } + public function getMutuMarhun(Request $request){ + $norujukan = $request->norujukan; + $cawangan = Cawangan::on('mysql7')->where('kodcaw',$request->kodcaw)->first(); + + $marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$request->norujukan)->distinct()->pluck('karat')->toArray(); + + $mutu = HargaEmas::on('mysql7')->whereIn('karat',$marhun)->pluck('keterangan')->toArray(); + + return response()->json($mutu); + } + public function getMarhunName (Request $request){ $jemas = Jemas::on('mysql7')->where('marhun','=',$request->marhun)->first(); @@ -144,7 +155,7 @@ class MarhunController extends Controller ]); $new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first(); - + $audit = new Audit(); $audit->users = $request->teller; $audit->actions = 'Ubah Marhun'; @@ -165,11 +176,11 @@ class MarhunController extends Controller $marhun = Marhun::on($cawangan['mysql']) ->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai') ->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan') - ->rightJoin('customer', 'customer.kpbaru', '=', 'gadai.nokp') + ->rightJoin('customer', 'customer.kpbaru', '=', 'gadai.nokp') ->where('marhun.t_gadai','=',$tarikh) ->orderBy('marhun.t_gadai') ->get(); - + return response()->json($marhun); } @@ -177,19 +188,19 @@ class MarhunController extends Controller $current = Carbon::now(); $current = new Carbon(); - + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $marhun = Marhun::on($cawangan['mysql']) ->select('marhun.norujukan','gadai.sttebus','gadai.pinjaman','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai') ->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan') - ->rightJoin('customer', 'customer.kpbaru', '=', 'gadai.nokp') + ->rightJoin('customer', 'customer.kpbaru', '=', 'gadai.nokp') ->where('marhun.t_gadai','<=',$tarikh) ->whereYear('marhun.t_gadai','=',$current->year) ->where('gadai.sttebus','=','') ->orderBy('marhun.norujukan') ->get(); - + return response()->json($marhun); } } diff --git a/routes/web.php b/routes/web.php index a1e30cb..7a5d0cf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -149,7 +149,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->put('marhun/{id}', ['uses' => 'MarhunController@update']); $router->get('marhun/laporan/{kodcaw}/{tarikh}',['uses'=>'MarhunController@getLaporanMarhunHarian']); $router->get('marhunterkumpul/laporan/{kodcaw}/{tarikh}',['uses'=>'MarhunController@getLaporanMarhunTerkumpul']); - + $router->get('marhun/mutu/sag',['uses'=>'MarhunController@getMutuMarhun']); $router->get('jemas',['uses'=>'MarhunController@getAllJemas']); From 4ef73bd35487c31b5369286254130c822fbe67bc Mon Sep 17 00:00:00 2001 From: Afiq Date: Thu, 31 Mar 2022 15:35:13 +0800 Subject: [PATCH 2/6] update jbg --- app/Http/Controllers/GadaiController.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 1580c50..7fff4b2 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3279,8 +3279,19 @@ class GadaiController extends Controller } $tempoh_gadai = ($year*12) + $month + $extensivemonth_gadai; + if($tempoh_gadai > 6.0){ + if($gadai['t_matang'] <= $current){ + + $tempoh_gadai = 6.0; + } + }else if($tempoh_gadai > 12){ + if($gadai['t_matang1'] <= $current){ + $tempoh_gadai = 12.0; + } + } + $upah_semasa = $this->kiraupahTawarruqStokAudit($tempoh_gadai,$gadai['tempohbayar'],$gadai['kadarupah'],$gadai['bakipjm']); - $tempoh_update = $year + $month + $extensivemonth; + Gadai::on($cawangan_mysql['mysql'])->where('norujukan','=',$gadai['norujukan'])->update(array( 'jbg' => $tempoh_gadai, 'tempoh' => $tempoh_gadai, From a5f0d98f9a32f985d1afe14af37977d15c17bb86 Mon Sep 17 00:00:00 2001 From: Afiq Date: Thu, 31 Mar 2022 15:49:16 +0800 Subject: [PATCH 3/6] fix jbg --- app/Http/Controllers/GadaiController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 7fff4b2..40c9f7e 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3280,12 +3280,12 @@ class GadaiController extends Controller $tempoh_gadai = ($year*12) + $month + $extensivemonth_gadai; if($tempoh_gadai > 6.0){ - if($gadai['t_matang'] <= $current){ + if($gadai['t_matang'] >= $current){ $tempoh_gadai = 6.0; } }else if($tempoh_gadai > 12){ - if($gadai['t_matang1'] <= $current){ + if($gadai['t_matang1'] >= $current){ $tempoh_gadai = 12.0; } } From aa2779c49349dabeacf36ef4bf08e09fd4259690 Mon Sep 17 00:00:00 2001 From: Afiq Date: Fri, 1 Apr 2022 10:28:24 +0800 Subject: [PATCH 4/6] update jbg --- app/Http/Controllers/GadaiController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 40c9f7e..ab25a7f 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3246,8 +3246,12 @@ class GadaiController extends Controller return $upah_semasa; } - public function updateJBGsemasa(){ - $cawangan = Cawangan::on('mysql7')->get(); + public function updateJBGsemasa(Request $request){ + if($request->zone == 'all'){ + $cawangan = Cawangan::on('mysql7')->get(); + }else{ + $cawangan = Cawangan::on('mysql7')->where('zone',$request->zone)->get(); + } $current = Carbon::now(); foreach($cawangan as $cawangan_mysql){ From f6d2703f772d68183c0425e5741b46afe2430b7d Mon Sep 17 00:00:00 2001 From: Afiq Date: Sun, 3 Apr 2022 12:26:47 +0800 Subject: [PATCH 5/6] fix update jbg --- app/Http/Controllers/GadaiController.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index ab25a7f..d211ada 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3283,13 +3283,12 @@ class GadaiController extends Controller } $tempoh_gadai = ($year*12) + $month + $extensivemonth_gadai; - if($tempoh_gadai > 6.0){ - if($gadai['t_matang'] >= $current){ - + if($tempoh_gadai >= 6.0){ + if($gadai['t_matang'] >= $current->toDateString()){ $tempoh_gadai = 6.0; } - }else if($tempoh_gadai > 12){ - if($gadai['t_matang1'] >= $current){ + }else if($tempoh_gadai >= 12){ + if($gadai['t_matang1'] >= $current->toDateString()){ $tempoh_gadai = 12.0; } } From 8bfd48de37c9a784e9f9c35e33751316097e3ab7 Mon Sep 17 00:00:00 2001 From: Afiq Date: Mon, 4 Apr 2022 10:18:29 +0800 Subject: [PATCH 6/6] fix update jbg --- app/Http/Controllers/GadaiController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index d211ada..0f4dbbd 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3283,6 +3283,9 @@ class GadaiController extends Controller } $tempoh_gadai = ($year*12) + $month + $extensivemonth_gadai; + if($gadai['t_gadai'] == $current->toDateString()){ + $tempoh_gadai = 0.5; + } if($tempoh_gadai >= 6.0){ if($gadai['t_matang'] >= $current->toDateString()){ $tempoh_gadai = 6.0;