diff --git a/app/Http/Controllers/CawanganCallCenterController.php b/app/Http/Controllers/CawanganCallCenterController.php new file mode 100644 index 0000000..0ebb577 --- /dev/null +++ b/app/Http/Controllers/CawanganCallCenterController.php @@ -0,0 +1,181 @@ +join('notis', 'notis.id', '=', 'cawangan_notis.notis_id') + ->where('kodcaw',$kodcaw)->get(); + return response()->json($batchnotis); + } + + public function getcawnotis($kodcaw,$notisid) + { + $current = Carbon::now(); + $current = new Carbon(); + + $arraybatch = []; + $batchnotis = Notis::on('mysql7')->where('id',$notisid)->get(); + $cawangan_all = Cawangan::on('mysql7')->get(); + $cawnotis_all = []; + foreach ($batchnotis as $index => $cawangan){ + $notis = CawanganNotis::on('mysql7') + ->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notis.kodcaw') + ->where('notis_id',$notisid)->where('cawangan_notis.kodcaw',$kodcaw)->get(); + if(sizeof($notis) != 0){ + array_push($cawnotis_all,$notis); + } + } + return response()->json($cawnotis_all); + } + + public function getcawnotisall(Request $request) + { + $kodcaw = $request->kodcaw; + $current = Carbon::now(); + $current = new Carbon(); + + $arraybatch = []; + $cawangan_all = Cawangan::on('mysql7')->get(); + $cawnotis_all = []; + + $notis = CawanganNotis::on('mysql7') + ->join('notis', 'notis.id', '=', 'cawangan_notis.notis_id') + ->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notis.kodcaw') + ->where('cawangan_notis.kodcaw',$kodcaw)->get(); + foreach ($notis as $index => $cawangan){ + // dd($cawangan['kodcaw']); + // dd($cawangan); + $notisbycaw = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$cawangan['notis_id']) + ->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + // ->where('notisperingatan.tarikhnotis1','=', NULL) + ->distinct() + ->get(); + + $notispertamabycaw = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$cawangan['notis_id']) + ->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + ->where('notisperingatan.peringatan','=', 1) + ->distinct() + ->get(); + + $notiskeduabycaw = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$cawangan['notis_id']) + ->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + ->where('notisperingatan.peringatan','=', 2) + ->distinct() + ->get(); + + $totalsag = $notisbycaw->count('norujukan'); + $totalsagpertama = $notispertamabycaw->count('norujukan'); + $totalsagkedua = $notiskeduabycaw->count('norujukan'); + $totalbakipjm = $notisbycaw->sum('pinjaman'); + + // if(sizeof($notis) != 0){ + array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalsagpertama' =>$totalsagpertama,'totalsagkedua' =>$totalsagkedua,'totalbakipjm' =>$totalbakipjm]); + // } + } + // dd($cawnotis_all); + return response()->json($cawnotis_all); + } + + public function bycawnotisperingatan($kodcaw,$notisid) + { + $cawnotis_all = []; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + $notisbycaw = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$notisid) + ->where('notisperingatan.kodcaw',$kodcaw) + // ->where('notisperingatan.peringatan', '=', 1) + ->distinct() + ->get(); + + $notisbycawarray = $notisbycaw->toArray(); + + foreach($notisbycawarray as $index=>$cal){ + $customer = Customer::where('kpbaru','=',$cal['nokp']) + ->orWhere('kplama','=',$cal['nokp']) + ->first(); + + $datagadai = Gadai::on($cawangan['mysql']) + ->where('norujukan','=',$cal['norujukan']) + ->first(); + // dd( $datagadai); + + if($datagadai->tagbaru == '0'){ + $keuntungan = 'asal'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraUpahTawarruq($kodcaw,$cal['norujukan'],$jeniskeuntungan); + }elseif($datagadai->tagbaru == '1'){ + $keuntungan = 'onepercent'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraupahUjrahOnePercent($kodcaw,$cal['norujukan']); + } + + $notisbycawarray[$index]['namacust'] = $customer; + $notisbycawarray[$index]['datagadai'] = $datagadai; + $notisbycawarray[$index]['keuntungan'] = $response; + } + + array_push($notisbycawarray); + return response()->json($notisbycawarray); + } +} diff --git a/routes/web.php b/routes/web.php index 997cbd7..01336d6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -616,7 +616,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('/cawangan/getcawnotis/{kodcaw}/{notisid}',['uses'=>'CawanganCallCenterController@getcawnotis']); $router->get('/cawangan/senarainotisperingatan/{kodcaw}',['uses'=>'CawanganCallCenterController@senarainotisperingatan']); $router->get('/cawangan/getcawnotisall/{kodcaw}',['uses'=>'CawanganCallCenterController@getcawnotisall']); - + $router->get('/cawangan/bycawnotisperingatan/{kodcaw}/{notisid}',['uses'=>'CawanganCallCenterController@bycawnotisperingatan']); });