From 4248bbf801b1b4d98115c91b9ca0ea5b5c3463a0 Mon Sep 17 00:00:00 2001 From: afiq Date: Sun, 6 Feb 2022 06:53:36 +0800 Subject: [PATCH 1/9] fix thousand separator --- app/Http/Controllers/GadaiController.php | 6 +++--- app/Http/Controllers/TebusController.php | 10 +++++----- app/Http/Controllers/TransactionOnlineController.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 07b422d..171d212 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -313,7 +313,7 @@ class GadaiController extends Controller $upahsemasa_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['pinjaman']); $upah_semasa_round = number_format($upahsemasa_raw,2); - $upah_semasa = (float)substr($upah_semasa_round, 0, -1); + $upah_semasa = substr($upah_semasa_round, 0, -1); // $upah_semasa = floatval(preg_replace('/[^\d.]/', '', $upah_semasa)); if(strpos($upah_semasa,',')){ $upah_semasa = str_replace(',','',$upah_semasa); @@ -335,7 +335,7 @@ class GadaiController extends Controller $upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']); $upah_rebet_round = number_format($upahrebet_raw,2); - $upah_rebet = (float)substr($upah_rebet_round, 0, -1); + $upah_rebet = substr($upah_rebet_round, 0, -1); if(strpos($upah_rebet,',')){ $upah_rebet = str_replace(',','',$upah_rebet); } @@ -3412,7 +3412,7 @@ class GadaiController extends Controller $upah6bln_raw = $gadai['bakiupah']; $upah6bln_round = number_format($upah6bln_raw,2); - $upah6bln = (float)substr($upah6bln_round, 0, -1); + $upah6bln = substr($upah6bln_round, 0, -1); $upah6bln = floatval(preg_replace('/[^\d.]/', '', $upah6bln)); if($totalbayaran >= $upah6bln){ diff --git a/app/Http/Controllers/TebusController.php b/app/Http/Controllers/TebusController.php index 64e8b4c..222b571 100644 --- a/app/Http/Controllers/TebusController.php +++ b/app/Http/Controllers/TebusController.php @@ -67,7 +67,7 @@ class TebusController extends Controller if(strpos($upah_semasa_round,',')){ $upah_semasa_round = str_replace(',','',$upah_semasa_round); } - $upah_semasa = (float)substr($upah_semasa_round, 0, -1); + $upah_semasa = substr($upah_semasa_round, 0, -1); if(strpos($upah_semasa,',')){ $upah_semasa = str_replace(',','',$upah_semasa); } @@ -92,7 +92,7 @@ class TebusController extends Controller if(strpos($upah_rebet_round,',')){ $upah_rebet_round = str_replace(',','',$upah_rebet_round); } - $upah_rebet = (float)substr($upah_rebet_round, 0, -1); + $upah_rebet = substr($upah_rebet_round, 0, -1); if(strpos($upah_rebet,',')){ $upah_rebet = str_replace(',','',$upah_rebet); } @@ -117,7 +117,7 @@ class TebusController extends Controller if(strpos($upah_rebet_round,',')){ $upah_rebet_round = str_replace(',','',$upah_rebet_round); } - $upah_rebet = (float)substr($upah_rebet_round, 0, -1); + $upah_rebet = substr($upah_rebet_round, 0, -1); if(strpos($upah_rebet,',')){ $upah_rebet = str_replace(',','',$upah_rebet); } @@ -173,7 +173,7 @@ class TebusController extends Controller $total_harga_tebus_round = round($total_harga_tebus,2); - $totalhargatebus = (float)substr($total_harga_tebus_round, 0, -1); + $totalhargatebus = substr($total_harga_tebus_round, 0, -1); return response()->json($totalhargatebus); } @@ -363,7 +363,7 @@ class TebusController extends Controller if(strpos($rebet_round,',')){ $rebet_round = str_replace(',','',$rebet_round); } - $rebet = (float)substr($rebet_round, 0, -1); + $rebet = substr($rebet_round, 0, -1); return $rebet; } diff --git a/app/Http/Controllers/TransactionOnlineController.php b/app/Http/Controllers/TransactionOnlineController.php index cc6e98e..601b2d4 100644 --- a/app/Http/Controllers/TransactionOnlineController.php +++ b/app/Http/Controllers/TransactionOnlineController.php @@ -128,7 +128,7 @@ class TransactionOnlineController extends Controller $upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']); $upah_rebet_round = number_format($upahrebet_raw,2); - $upah_rebet = (float)substr($upah_rebet_round, 0, -1); + $upah_rebet = substr($upah_rebet_round, 0, -1); if(strpos($upah_rebet,',')){ $upah_rebet = str_replace(',','',$upah_rebet); } From 959b49d7032881da28cf2646db55a99e53b47fa8 Mon Sep 17 00:00:00 2001 From: afiq Date: Wed, 9 Feb 2022 01:18:34 +0800 Subject: [PATCH 2/9] fix ubah marhun --- app/Http/Controllers/MarhunController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 140f89c..78ba310 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -127,7 +127,7 @@ class MarhunController extends Controller $current = new Carbon(); $harga = HargaEmas::on('mysql7')->where('karat',$request->karat)->first(); - $nilai_marhun = $request->berat_emas * $harga['harga']; + $nilai_marhun = $request->berat * $harga['harga']; $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); From 9eb095ebe0a8d85cd3a3c939a872ceb115d3278a Mon Sep 17 00:00:00 2001 From: fifi97 <46933637+fifi97@users.noreply.github.com> Date: Wed, 9 Feb 2022 11:50:53 +0800 Subject: [PATCH 3/9] fix skit2 --- app/Http/Controllers/AdminPageController.php | 235 ++++++++++++++----- 1 file changed, 175 insertions(+), 60 deletions(-) diff --git a/app/Http/Controllers/AdminPageController.php b/app/Http/Controllers/AdminPageController.php index 3a7809b..5d0e85f 100644 --- a/app/Http/Controllers/AdminPageController.php +++ b/app/Http/Controllers/AdminPageController.php @@ -227,53 +227,109 @@ class AdminPageController extends Controller ->whereYear('bajettahunan.tahun', '=', $current->year) ->sum('nilaibajet'); - $lelongupahsimpan = Lelong::on($cawangan['mysql']) - ->selectRaw('SUM(bakiupah) AS totalupahlelong') - ->addSelect(DB::connection($cawangan['mysql']) - ->raw('DATE_FORMAT(t_jual, "%Y-%m") as t_jual')) - ->groupBy(DB::connection($cawangan['mysql']) - ->raw("DATE_FORMAT(t_jual,'%Y%m')")) - ->whereYear('t_jual',$current->year) - // ->where([['t_jual','<=',$current->toDateString()],['t_jual','>=',$monthly_date]]) - ->orderBy('t_jual','asc') - ->get(); + $tebus_arrahn = Tebus::on($cawangan['mysql']) + ->rightJoin('gadai', 'gadai.norujukan', '=', 'tebus.norujukan') + ->selectRaw('SUM(tebus.bakiupah) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(t_tebus, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(t_tebus,'%Y%m')")) + ->whereYear('t_tebus',$current->year) + ->where([['tebus.jenistebus','=','T'],['gadai.hargajualan','=',null],['t_tebus','<=',$current->toDateString()]]) + ->orderBy('t_tebus','asc') + ->get()->toArray(); - $totallelong = 0; + $advansur = Advansur::on($cawangan['mysql']) + ->selectRaw('SUM(upahDibayar) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(tarikh, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(tarikh,'%Y%m')")) + ->whereYear('tarikh',$current->year) + ->where([['tarikh','<=',$current->toDateString()]]) + ->get()->toArray(); + + $ansuran = Transaction::on('mysql7') + ->selectRaw('SUM(trans.bayaran_keuntungan) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(transaction.created_at, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(transaction.created_at,'%Y%m')")) + ->whereYear('transaction.created_at',$current->year) + ->leftJoin('transaksi_keuntungan as trans', function($join) + { + $join->on('transaction.norujukan', '=', 'trans.norujukan'); + $join->on('transaction.created_at', '=', 'trans.tarikh_bayaran'); + }) + ->where('transaction.trans_type','=','A') + ->where([['trans.tarikh_bayaran','<=',$current->toDateString(). ' 23:59:59']]) + ->where('trans.kodcaw','=',$request->kodcaw) + ->get()->toArray(); + + $tebus_upah_tawarruq = Transaction::on('mysql7') + ->selectRaw('SUM(trans.keuntungan_rebet) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(transaction.created_at, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(transaction.created_at,'%Y%m')")) + ->whereYear('transaction.created_at',$current->year) + ->leftJoin('transaksi_keuntungan as trans', function($join) + { + $join->on('transaction.norujukan', '=', 'trans.norujukan'); + $join->on('transaction.created_at', '=', 'trans.tarikh_bayaran'); + }) + ->where('transaction.trans_type','!=','A') + ->where([['trans.tarikh_bayaran','<=',$current->toDateString() . ' 23:59:59']]) + ->where('trans.kodcaw','=',$request->kodcaw) + ->get()->toArray(); + + + $lelongupahsimpan = Lelong::on($cawangan['mysql']) + ->selectRaw('SUM(bakiupah) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(t_jual, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(t_jual,'%Y%m')")) + ->whereYear('t_jual',$current->year) + ->orderBy('t_jual','asc') + ->get()->toArray(); + + $totalall = 0; foreach($lelongupahsimpan as $index=>$lelong) { - $totallelong += $lelong['totalupahlelong']; + $totalall += $lelong['total'] + $tebus_arrahn[$index]['total'] + $advansur[$index]['total'] + $ansuran[$index]['total'] + $tebus_upah_tawarruq[$index]['total']; } - $tebus = Tebus::on($cawangan['mysql']) - ->selectRaw('SUM(bakiupah) AS totalupahsimpan') - ->addSelect(DB::connection($cawangan['mysql']) - ->raw('DATE_FORMAT(t_tebus, "%Y-%m") as t_tebus')) - ->groupBy(DB::connection($cawangan['mysql']) - ->raw("DATE_FORMAT(t_tebus,'%Y%m')")) - ->where(function($query) use ($current){ - $query - ->where([['jenistebus','=','T'],['t_tebus','<=',$current->toDateString()]]) - ->whereYear('t_tebus',$current->year); - }) - ->orWhere(function($query) use ($current){ - $query - ->where([['jenistebus','=','T'],['t_tebus','<=',$current->toDateString()]]) - ->whereYear('t_tebus',$current->year); - }) - ->orderBy('t_tebus','asc') - ->get(); + // $tebus = Tebus::on($cawangan['mysql']) + // ->selectRaw('SUM(bakiupah) AS totalupahsimpan') + // ->addSelect(DB::connection($cawangan['mysql']) + // ->raw('DATE_FORMAT(t_tebus, "%Y-%m") as t_tebus')) + // ->groupBy(DB::connection($cawangan['mysql']) + // ->raw("DATE_FORMAT(t_tebus,'%Y%m')")) + // ->where(function($query) use ($current){ + // $query + // ->where([['jenistebus','=','T'],['t_tebus','<=',$current->toDateString()]]) + // ->whereYear('t_tebus',$current->year); + // }) + // ->orWhere(function($query) use ($current){ + // $query + // ->where([['jenistebus','=','T'],['t_tebus','<=',$current->toDateString()]]) + // ->whereYear('t_tebus',$current->year); + // }) + // ->orderBy('t_tebus','asc') + // ->get(); - $totaltebus = 0; - foreach($tebus as $index=>$teb) - { - $totaltebus += $teb['totalupahsimpan']; - } + // $totaltebus = 0; + // foreach($tebus as $index=>$teb) + // { + // $totaltebus += $teb['totalupahsimpan']; + // } - $total = $totaltebus + $totallelong; + // $total = $totaltebus + $totallelong; - array_push($arrayKeuntungan,['bajet' => $bajetgroup,'total' => $total]); + array_push($arrayKeuntungan,['bajet' => $bajetgroup,'total' => $totalall]); return response()->json($arrayKeuntungan); @@ -829,47 +885,106 @@ class AdminPageController extends Controller $lelongupahsimpan = Lelong::on($cawangan['mysql']) - ->selectRaw('SUM(bakiupah) AS totalupahlelong') + ->selectRaw('SUM(bakiupah) AS total') ->addSelect(DB::connection($cawangan['mysql']) - ->raw('DATE_FORMAT(t_jual, "%Y-%m") as t_jual')) + ->raw('DATE_FORMAT(t_jual, "%Y-%m") as tarikh')) ->groupBy(DB::connection($cawangan['mysql']) ->raw("DATE_FORMAT(t_jual,'%Y%m')")) ->whereYear('t_jual',$current->year) ->where([['t_jual','<=',$current->toDateString()],['t_jual','>=',$monthly_date]]) ->orderBy('t_jual','asc') - ->get(); + ->get()->toArray(); - $tebus = Tebus::on($cawangan['mysql']) - ->selectRaw('SUM(bakiupah) AS totalupahsimpan') + $tebus_arrahn = Tebus::on($cawangan['mysql']) + ->rightJoin('gadai', 'gadai.norujukan', '=', 'tebus.norujukan') + ->selectRaw('SUM(tebus.bakiupah) AS total') ->addSelect(DB::connection($cawangan['mysql']) - ->raw('DATE_FORMAT(t_tebus, "%Y-%m") as t_tebus')) + ->raw('DATE_FORMAT(t_tebus, "%Y-%m") as tarikh')) ->groupBy(DB::connection($cawangan['mysql']) ->raw("DATE_FORMAT(t_tebus,'%Y%m')")) ->whereYear('t_tebus',$current->year) - ->where([['jenistebus','=','T'],['t_tebus','<=',$current->toDateString()],['t_tebus','>=',$monthly_date]]) - ->orWhere([['jenistebus','=','A'],['t_tebus','<=',$current->toDateString()],['t_tebus','>=',$monthly_date]]) + ->where([['tebus.jenistebus','=','T'],['gadai.hargajualan','=',null],['t_tebus','<=',$current->toDateString()],['t_tebus','>=',$monthly_date]]) ->orderBy('t_tebus','asc') - ->get(); + ->get()->toArray(); + $advansur = Advansur::on($cawangan['mysql']) + ->selectRaw('SUM(upahDibayar) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(tarikh, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(tarikh,'%Y%m')")) + ->whereYear('tarikh',$current->year) + ->where([['tarikh','<=',$current->toDateString()],['tarikh','>=',$monthly_date]]) + ->get()->toArray(); + + $ansuran = Transaction::on('mysql7') + ->selectRaw('SUM(trans.bayaran_keuntungan) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(transaction.created_at, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(transaction.created_at,'%Y%m')")) + ->whereYear('transaction.created_at',$current->year) + ->leftJoin('transaksi_keuntungan as trans', function($join) + { + $join->on('transaction.norujukan', '=', 'trans.norujukan'); + $join->on('transaction.created_at', '=', 'trans.tarikh_bayaran'); + }) + ->where('transaction.trans_type','=','A') + ->where([['trans.tarikh_bayaran','>=',$monthly_date . ' 00:00:00'],['trans.tarikh_bayaran','<=',$current->toDateString(). ' 23:59:59']]) + ->where('trans.kodcaw','=',$request->kodcaw) + ->get()->toArray(); + + $tebus_upah_tawarruq = Transaction::on('mysql7') + ->selectRaw('SUM(trans.keuntungan_rebet) AS total') + ->addSelect(DB::connection($cawangan['mysql']) + ->raw('DATE_FORMAT(transaction.created_at, "%Y-%m") as tarikh')) + ->groupBy(DB::connection($cawangan['mysql']) + ->raw("DATE_FORMAT(transaction.created_at,'%Y%m')")) + ->whereYear('transaction.created_at',$current->year) + ->leftJoin('transaksi_keuntungan as trans', function($join) + { + $join->on('transaction.norujukan', '=', 'trans.norujukan'); + $join->on('transaction.created_at', '=', 'trans.tarikh_bayaran'); + }) + ->where('transaction.trans_type','!=','A') + ->where([['trans.tarikh_bayaran','>=',$monthly_date . ' 00:00:00'],['trans.tarikh_bayaran','<=',$current->toDateString() . ' 23:59:59']]) + ->where('trans.kodcaw','=',$request->kodcaw) + ->get()->toArray(); + + + // dd($array_totalup); foreach($array_totalup as $array_index=>$totalup){ - foreach($lelongupahsimpan as $indexlelong=>$lelong_detail){ - if($totalup['tarikh'] == $lelong_detail['t_jual']){ - $total_lelong = $totalup['keuntungan']; - $total_lelong += $lelong_detail['totalupahlelong']; - $array_totalup[$array_index]['keuntungan'] = $total_lelong; - } - } + // foreach($lelongupahsimpan as $indexlelong=>$lelong_detail){ + // if($totalup['tarikh'] == $lelong_detail['t_jual']){ + // $total_lelong = $totalup['keuntungan']; + // $total_lelong += $lelong_detail['totalupahlelong']; + // $array_totalup[$array_index]['keuntungan'] = $total_lelong; + // } + // } - foreach($tebus as $indextebus=>$tebus_detail){ - if($totalup['tarikh'] == $tebus_detail['t_tebus']){ - $total_tebus = $array_totalup[$array_index]['keuntungan']; - $total_tebus += $tebus_detail['totalupahsimpan']; - $array_totalup[$array_index]['keuntungan'] = $total_tebus; - $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; + // foreach($tebus as $indextebus=>$tebus_detail){ + // if($totalup['tarikh'] == $tebus_detail['t_tebus']){ + // $total_tebus = $array_totalup[$array_index]['keuntungan']; + // $total_tebus += $tebus_detail['totalupahsimpan']; + // $array_totalup[$array_index]['keuntungan'] = $total_tebus; + // $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; + // } + // } + + foreach($lelongupahsimpan as $indexloop=>$looptambahan) + { + if($totalup['tarikh'] == $looptambahan['tarikh']){ + $total = 0; + $total = $looptambahan['total'] + $tebus_arrahn[$indexloop]['total'] + $advansur[$indexloop]['total'] + $ansuran[$indexloop]['total'] + $tebus_upah_tawarruq[$indexloop]['total']; + // $total_keuntungan = $array_totalup[$array_index]['keuntungan']; + $total_keuntungan = $total; + $array_totalup[$array_index]['keuntungan'] = $total_keuntungan; + $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; } - } + } + $goals[0]['value'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; array_push($arrayKeuntungan,['x' => $array_totalup[$array_index]['namabulan'],'y' => $array_totalup[$array_index]['keuntungan'],'goals' => (array) $goals]); } From d23650bd6bc411300cb231c019c8fc8ae2a49012 Mon Sep 17 00:00:00 2001 From: afiq Date: Sun, 13 Feb 2022 13:37:13 +0800 Subject: [PATCH 4/9] cronjob --- app/Http/Controllers/GadaiController.php | 17 ++++++++++++++++- routes/web.php | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 171d212..85ddaf8 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3408,7 +3408,7 @@ class GadaiController extends Controller foreach($cawangan_all as $index=>$cawangan){ $gadai_all = Gadai::on($cawangan['mysql'])->where([['sttebus','=',''],['hargajualan','!=','bakihargajualan'],['hargajualan','!=',null]])->get(); foreach($gadai_all as $index=>$gadai){ - $totalbayaran = Transaction::on('mysql7')->where('norujukan',$gadai['norujukan'])->sum('duit_masuk'); + $totalbayaran = $gadai['hargajualan'] - $gadai['bakihargajualan']; $upah6bln_raw = $gadai['bakiupah']; $upah6bln_round = number_format($upah6bln_raw,2); @@ -3419,10 +3419,25 @@ class GadaiController extends Controller Gadai::on($cawangan['mysql'])->where('norujukan',$gadai['norujukan'])->update([ 'lelong_tawarruq'=>0 ]); + }else{ + Gadai::on($cawangan['mysql'])->where('norujukan',$gadai['norujukan'])->update([ + 'lelong_tawarruq'=>1 + ]); } } } + } + public function upah12kosong(){ + $cawangan_all = Cawangan::on('mysql7')->get(); + $sag = []; + + foreach($cawangan_all as $index=>$cawangan){ + $gadai = Gadai::on($cawangan['mysql'])->where(['upah12',0])->get(); + array_push($sag,['cawangan'=>$cawangan['details_caw'],'sag'=>$sag]); + } + + return response()->json($sag); } public function updateTebusGadai(){ diff --git a/routes/web.php b/routes/web.php index 2e25a70..59a5585 100644 --- a/routes/web.php +++ b/routes/web.php @@ -544,6 +544,8 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('check/lelong/tawarruq',['uses'=>'GadaiController@updateLelongTawarruq']); $router->get('update/sttebus/gadaian',['uses'=>'GadaiController@updateTebusGadai']); + $route->get('check/upah12/kosong',['uses'=>'GadaiController@upah12kosong']); + $router->get('calculate/akru/bycawangan',['uses'=>'GadaiController@calculateAkru']); }); From 5ad0fbf9002d415a5acccfb5c8c91c548121dc9b Mon Sep 17 00:00:00 2001 From: afiq Date: Sun, 13 Feb 2022 13:43:23 +0800 Subject: [PATCH 5/9] fix --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 59a5585..7366695 100644 --- a/routes/web.php +++ b/routes/web.php @@ -544,7 +544,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('check/lelong/tawarruq',['uses'=>'GadaiController@updateLelongTawarruq']); $router->get('update/sttebus/gadaian',['uses'=>'GadaiController@updateTebusGadai']); - $route->get('check/upah12/kosong',['uses'=>'GadaiController@upah12kosong']); + $router->get('check/upah12/kosong',['uses'=>'GadaiController@upah12kosong']); $router->get('calculate/akru/bycawangan',['uses'=>'GadaiController@calculateAkru']); }); From 87ba58e4a1c00210a3c4b5c113d78bc14aa0e073 Mon Sep 17 00:00:00 2001 From: afiq Date: Sun, 13 Feb 2022 13:46:15 +0800 Subject: [PATCH 6/9] fix --- app/Http/Controllers/GadaiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 85ddaf8..78e255f 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3433,7 +3433,7 @@ class GadaiController extends Controller $sag = []; foreach($cawangan_all as $index=>$cawangan){ - $gadai = Gadai::on($cawangan['mysql'])->where(['upah12',0])->get(); + $gadai = Gadai::on($cawangan['mysql'])->where('upah12',0)->get(); array_push($sag,['cawangan'=>$cawangan['details_caw'],'sag'=>$sag]); } From db1f4f0e5619ef9631dff67a5570ab32be4983d1 Mon Sep 17 00:00:00 2001 From: afiq Date: Sun, 13 Feb 2022 15:07:08 +0800 Subject: [PATCH 7/9] fix --- app/Http/Controllers/GadaiController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 78e255f..dac0607 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3426,6 +3426,7 @@ class GadaiController extends Controller } } } + return response()->json('successful'); } public function upah12kosong(){ From f1156de1a5d389edd2ceb9819802cf563c33e8fa Mon Sep 17 00:00:00 2001 From: afiq Date: Sun, 13 Feb 2022 15:56:43 +0800 Subject: [PATCH 8/9] cron --- app/Http/Controllers/GadaiController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index dac0607..3ce3c31 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -3402,10 +3402,10 @@ class GadaiController extends Controller return response()->json($dataKomoditi); } - public function updateLelongTawarruq(){ - $cawangan_all = Cawangan::on('mysql7')->get(); + public function updateLelongTawarruq(Request $request){ + $cawangan = Cawangan::on('mysql7')->where('kodcaw',$request->kodcaw)->first(); - foreach($cawangan_all as $index=>$cawangan){ + // foreach($cawangan_all as $index=>$cawangan){ $gadai_all = Gadai::on($cawangan['mysql'])->where([['sttebus','=',''],['hargajualan','!=','bakihargajualan'],['hargajualan','!=',null]])->get(); foreach($gadai_all as $index=>$gadai){ $totalbayaran = $gadai['hargajualan'] - $gadai['bakihargajualan']; @@ -3425,7 +3425,7 @@ class GadaiController extends Controller ]); } } - } + // } return response()->json('successful'); } From a895e58d78ee9724a1124d1839d78482385a9d35 Mon Sep 17 00:00:00 2001 From: fifi97 <46933637+fifi97@users.noreply.github.com> Date: Sun, 20 Feb 2022 10:35:43 +0800 Subject: [PATCH 9/9] fix skit2 --- app/Http/Controllers/AdminPageController.php | 127 ++++++++++++++----- routes/web.php | 4 +- 2 files changed, 98 insertions(+), 33 deletions(-) diff --git a/app/Http/Controllers/AdminPageController.php b/app/Http/Controllers/AdminPageController.php index 5d0e85f..7098a43 100644 --- a/app/Http/Controllers/AdminPageController.php +++ b/app/Http/Controllers/AdminPageController.php @@ -21,11 +21,14 @@ use App\Bajet; use App\BajetTahunan; use App\Blacklist; use App\Pelelong; +use App\Mohon; use DB; use Carbon\Carbon; - +use Illuminate\Pagination\Paginator; +use Illuminate\Support\Collection; +use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Http\Request; class AdminPageController extends Controller @@ -295,9 +298,14 @@ class AdminPageController extends Controller ->get()->toArray(); $totalall = 0; - foreach($lelongupahsimpan as $index=>$lelong) + $variable = ['lelongupahsimpan','ansuran','tebus_arrahn','advansur','tebus_upah_tawarruq']; + + foreach($variable as $index => $var) { - $totalall += $lelong['total'] + $tebus_arrahn[$index]['total'] + $advansur[$index]['total'] + $ansuran[$index]['total'] + $tebus_upah_tawarruq[$index]['total']; + foreach(${$var} as $indextemp => $temp) + { + $totalall += $temp['total']; + } } @@ -895,6 +903,7 @@ class AdminPageController extends Controller ->orderBy('t_jual','asc') ->get()->toArray(); + $tebus_arrahn = Tebus::on($cawangan['mysql']) ->rightJoin('gadai', 'gadai.norujukan', '=', 'tebus.norujukan') @@ -952,38 +961,40 @@ class AdminPageController extends Controller ->where('trans.kodcaw','=',$request->kodcaw) ->get()->toArray(); - - // dd($array_totalup); + $variable = ['lelongupahsimpan','ansuran','tebus_arrahn','advansur','tebus_upah_tawarruq']; foreach($array_totalup as $array_index=>$totalup){ - // foreach($lelongupahsimpan as $indexlelong=>$lelong_detail){ - // if($totalup['tarikh'] == $lelong_detail['t_jual']){ - // $total_lelong = $totalup['keuntungan']; - // $total_lelong += $lelong_detail['totalupahlelong']; - // $array_totalup[$array_index]['keuntungan'] = $total_lelong; - // } - // } - // foreach($tebus as $indextebus=>$tebus_detail){ - // if($totalup['tarikh'] == $tebus_detail['t_tebus']){ - // $total_tebus = $array_totalup[$array_index]['keuntungan']; - // $total_tebus += $tebus_detail['totalupahsimpan']; - // $array_totalup[$array_index]['keuntungan'] = $total_tebus; - // $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; - // } - // } - - foreach($lelongupahsimpan as $indexloop=>$looptambahan) - { - if($totalup['tarikh'] == $looptambahan['tarikh']){ - $total = 0; - $total = $looptambahan['total'] + $tebus_arrahn[$indexloop]['total'] + $advansur[$indexloop]['total'] + $ansuran[$indexloop]['total'] + $tebus_upah_tawarruq[$indexloop]['total']; - // $total_keuntungan = $array_totalup[$array_index]['keuntungan']; - $total_keuntungan = $total; - $array_totalup[$array_index]['keuntungan'] = $total_keuntungan; - $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; + foreach($variable as $index => $var) + { + foreach(${$var} as $indextemp => $temp) + { + if($totalup['tarikh'] == $temp['tarikh']) + { + $total_tebus = $array_totalup[$array_index]['keuntungan']; + $total_tebus += $temp['total']; + $array_totalup[$array_index]['keuntungan'] = $total_tebus; + $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; + } + } } - } + + // foreach($tebus_upah_tawarruq as $indexloop=>$looptambahan) + // { + // if($totalup['tarikh'] == $looptambahan['tarikh']){ + // $total = 0; + // $tebusarrahntotal = (count($tebus_arrahn) < $indexloop) ? $tebus_arrahn[$indexloop]['total'] : 0; + // $advansurtotal = (count($advansur) < $indexloop) ? $advansur[$indexloop]['total'] ? $advansur[$indexloop]['total'] : 0 : 0; + // $ansurantotal = (count($ansuran) < $indexloop) ? $ansuran[$indexloop]['total'] : 0; + // $tebustawarruqtotal = (count($lelongupahsimpan) < $indexloop) ? $lelongupahsimpan[$indexloop]['total'] : 0; + + // $total = $looptambahan['total'] + $tebusarrahntotal + $advansurtotal + $ansurantotal + $tebustawarruqtotal; + // // $total_keuntungan = $array_totalup[$array_index]['keuntungan']; + // $total_keuntungan = $total; + // $array_totalup[$array_index]['keuntungan'] = $total_keuntungan; + // $array_totalup[$array_index]['bajetkeuntungan'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; + // } + // } $goals[0]['value'] = (sizeof($bajetkeuntungan) > 0) ? $bajetkeuntungan[$array_index] : 0; array_push($arrayKeuntungan,['x' => $array_totalup[$array_index]['namabulan'],'y' => $array_totalup[$array_index]['keuntungan'],'goals' => (array) $goals]); @@ -1620,4 +1631,58 @@ class AdminPageController extends Controller return response()->json($detailslelong, 200); } + + public function paginate($items, $perPage = 5, $page = null, $options = []) + { + $page = $page ?: (Paginator::resolveCurrentPage() ?: 1); + $items = $items instanceof Collection ? $items : Collection::make($items); + return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options); + } + + public function listoperasi() + { + $harini = Carbon::now(); + $harini = new Carbon; + + $cawangan_all = Cawangan::on('mysql7')->get(); + $arraykelulusan = []; + + foreach($cawangan_all as $index=>$cawangan){ + $kelulusan=Mohon::on($cawangan['mysql']) + ->where('tarikh','=',$harini->toDateString()) + ->where('masalulus','=','') + ->where('pelulus','=','operasi') + ->get(); + + if(sizeof($kelulusan) != 0){ + array_push($arraykelulusan,["kelulusanall" => $kelulusan,"cawangan" => $cawangan['details_caw'],"cawangankod" => $cawangan['kodcaw']]); + } + } + + $data = $this->paginate($arraykelulusan); + + return response()->json($data,200); + } + + public function listoperasikelulusan() + { + $harini = Carbon::now(); + $harini = new Carbon; + + $cawangan_all = Cawangan::on('mysql7')->get(); + $arraykelulusan = []; + + foreach($cawangan_all as $index=>$cawangan){ + $kelulusan=Mohon::on($cawangan['mysql']) + ->where('peloperasi','=','operasi') + ->where('operasi','!=','') + ->get(); + + if(sizeof($kelulusan) != 0){ + array_push($arraykelulusan,["kelulusanall" => $kelulusan,"cawangan" => $cawangan['details_caw'],"cawangankod" => $cawangan['kodcaw']]); + } + } + + return response()->json($arraykelulusan,200); + } } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 7366695..7ec81f7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -673,8 +673,8 @@ $router->group(['prefix'=>'admin'], function () use ($router){ $router->post('AddSenaraiHitam',['uses'=>'AdminPageController@AddSenaraiHitam']); $router->put('notislelong/update/{kodcaw}',['uses'=>'AdminPageController@UpdateNotisLelong']); - - + $router->get('ListOperasi/Paginate',['uses'=>'AdminPageController@listoperasi']); + $router->get('ListOperasiKelulusan/Paginate',['uses'=>'AdminPageController@listoperasikelulusan']); });