diff --git a/app/Console/Commands/CawanganDebugConnections.php b/app/Console/Commands/CawanganDebugConnections.php index ecf0466..d4372f8 100644 --- a/app/Console/Commands/CawanganDebugConnections.php +++ b/app/Console/Commands/CawanganDebugConnections.php @@ -73,32 +73,57 @@ class CawanganDebugConnections extends Command $idToNameMap[$item['mysql']] = $item['db_name']; } + $tested_connection = ''; + try { $filteredArray2 = array_filter($array2, function ($item) use ($idToNameMap) { + $tested_connection = $idToNameMap[$item['mysql']]; return $idToNameMap[$item['mysql']] !== $item['database']; }); + } catch (\Throwable $th) { + dump(sprintf('Connection %s not found in table online_arrahn.arrahn_master_db but present in config. Make sure both of connection exist in both app/config and arrahn_master_db', $tested_connection)); + return; + } return $filteredArray2; } $filteredConnections = filterArraysByDatabaseNames($all_cawangan, $all_cawangan_in_config); + if($filteredConnections === null OR sizeof($filteredConnections) > 1){ + return; + } + + $isOK = true; + // checks if there is connection errors - if (Helper::getInactiveCawanganDbConnection() > 0) { + if (sizeof(Helper::getInactiveCawanganDbConnection()) > 0) { dump('Inactive cawangan connection detected : '); + dump('1. Check DB_HOST in .env status is alive and available'); + dump('2. Check database in .env exist in DB_HOST'); + dump(''); dump(Helper::getInactiveCawanganDbConnection()); + $isOK = false; } // checks if config connection do not exist referring to arrahn_master_db if (count($all_cawangan) !== count($all_cawangan_in_config)) { $db_not_config = array_diff(array_column($all_cawangan, 'db_name'), array_column($all_cawangan_in_config, 'database')); - dump(implode(', ', $db_not_config) . ' not configured in database config'); + dump(implode(', ', $db_not_config) . ' exist in arrahn_master_db but not configured in config/database.php'); + $isOK = false; } // checks if config connection databases are not tally fwith arrahn master db if (count($filteredConnections) !== 0) { dump('Database config names are not tally arrahn_master_db : '); dump($filteredConnections); + $isOK = false; } + + if($isOK == true){ + dump('Cawangan database configuration is OK'); + } + + } } diff --git a/app/Http/Controllers/CallCenterController.php b/app/Http/Controllers/CallCenterController.php index 6c31cd6..3a75943 100644 --- a/app/Http/Controllers/CallCenterController.php +++ b/app/Http/Controllers/CallCenterController.php @@ -42,6 +42,9 @@ use App\Services\MasterServices; use App\Daerah; use App\Poskod; use App\Negeri; +use App\NotisJbg; +use App\NotJbg; +use App\CawanganNotisJbg; use Log; use App\Services\OnePercentServices; @@ -203,16 +206,27 @@ class CallCenterController extends Controller $current = new Carbon(); $arraybatch = []; - $batchnotis = Notis::on('mysql7')->get(); - // $cawangan_all = Cawangan::on('mysql7')->get(); - // $cawnotis_all = []; - // foreach ($batchnotis as $index => $cawangan){ - // $notis = CawanganNotis::on('mysql7')->get(); - // if(sizeof($notis) != 0){ - // array_push($cawnotis_all,$notis); - // } - // } - return response()->json($batchnotis); + // $batchnotis = Notis::on('mysql7')->get(); + // return response()->json($batchnotis); + $batchnotis = Notis::on('mysql7') + ->get(); + $cawnotis_all = []; + foreach ($batchnotis as $index => $cawangan){ + $idnotis = $cawangan['id']; + $tarikh_notis = $cawangan['tarikh_notis']; + $daritempoh = $cawangan['daritempoh']; + $notis = CawanganNotis::on('mysql7') + ->join('notisperingatan', 'notisperingatan.kodcaw', '=', 'cawangan_notis.kodcaw') + ->where('notisperingatan.notis_id',$cawangan['id']) + ->where('notisperingatan.peringatan','1') + ->distinct() + ->get(); + $totalsag = $notis->count('norujukan'); + if(sizeof($notis) != 0){ + array_push($cawnotis_all,['id' => $idnotis, 'tarikh_notis' => $tarikh_notis, 'daritempoh' => $daritempoh,'totalsag' => $totalsag, 'detail' => $notis]); + } + } + return response()->json($cawnotis_all); } public function getcawnotis($notisid) @@ -227,7 +241,36 @@ class CallCenterController extends Controller foreach ($batchnotis as $index => $cawangan){ $notis = CawanganNotis::on('mysql7') ->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notis.kodcaw') - ->where('notis_id',$notisid)->get(); + ->where('notis_id',$notisid) + ->get(); + foreach ($notis as $index1 => $bil){ + $notisperingatanall = NotisPeringatan::on('mysql7') + ->where('notis_id',$notisid) + ->where('kodcaw',$bil['kodcaw']) + ->get(); + + $notisperingatan = NotisPeringatan::on('mysql7') + ->where('notis_id',$notisid) + ->where('kodcaw',$bil['kodcaw']) + ->where('peringatan',1) + ->get(); + + $notisperingatankedua = NotisPeringatan::on('mysql7') + ->where('notis_id',$notisid) + ->where('kodcaw',$bil['kodcaw']) + ->where('peringatan',2) + ->get(); + // dd($notisperingatan); + + $totalsag = $notisperingatanall->count('norujukan'); + $bakitotalsag = $notisperingatan->count('norujukan'); + $bakitotalsagkedua = $notisperingatankedua->count('norujukan'); + $notis[$index1]['totalsag'] = $totalsag; + $notis[$index1]['bakitotalsag'] = $bakitotalsag; + $notis[$index1]['bakitotalsagkedua'] = $bakitotalsagkedua; + // dd($bil['kodcaw'],$totalsag); + } + if(sizeof($notis) != 0){ array_push($cawnotis_all,$notis); } @@ -254,16 +297,26 @@ class CallCenterController extends Controller // dd($cawangan['kodcaw']); // dd($cawangan); $notisbycaw = NotisPeringatan::on('mysql7') - ->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + ->where('notisperingatan.notis_id',$notisid) + ->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + ->where('notisperingatan.peringatan','=', 1) + ->distinct() + ->get(); + + $notisbycawall = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$notisid) + ->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + // ->where('notisperingatan.peringatan','=', 1) ->distinct() ->get(); // dd($notisbycaw); $totalsag = $notisbycaw->count('norujukan'); + $totalsagall = $notisbycawall->count('norujukan'); $totalbakipjm = $notisbycaw->sum('pinjaman'); // if(sizeof($notis) != 0){ - array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalbakipjm' =>$totalbakipjm]); + array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalsagall' =>$totalsagall,'totalbakipjm' =>$totalbakipjm]); // } } return response()->json($cawnotis_all); @@ -274,7 +327,9 @@ class CallCenterController extends Controller $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.notis_id',$notisid) + ->where('notisperingatan.kodcaw',$kodcaw) + ->where('notisperingatan.peringatan', '=', 1) ->distinct() ->get(); @@ -567,6 +622,7 @@ class CallCenterController extends Controller public function kemaskininotisperingatan(Request $request) { + // dd($request->all()); $notisid = $request->notisid; $current = Carbon::now(); $current = new Carbon(); @@ -578,7 +634,9 @@ class CallCenterController extends Controller $notis = CawanganNotis::on('mysql7') ->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notis.kodcaw') - ->where('notis_id',$notisid)->get(); + ->where('notis_id',$notisid) + ->where('cawangan_notis.kodcaw','=', $kodcaw) + ->get(); foreach ($notis as $index => $cawangan){ $notisbycaw = NotisPeringatan::on('mysql7') @@ -591,22 +649,98 @@ class CallCenterController extends Controller $checkgadai = Gadai::on($cawangan['mysql']) ->where([['norujukan','=',$notis['norujukan']]]) ->first(); + if($checkgadai->sttebus == 'T' || $checkgadai->sttebus == 'L'){ $updatelistnotis=NotisPeringatan::on('mysql7') ->where('norujukan','=', $notis['norujukan']) ->where('notis_id','=', $notisid) ->where('kodcaw','=', $kodcaw) ->delete(); + //save log audit + $audit = new Audit(); + $audit->users = $request->kodlaluan; + $audit->actions = 'Keluar Tebus'; + $audit->norujukan = $notis['norujukan']; + $audit->kodcaw = $kodcaw; + $audit->created_at = $current; + $audit->updated_at = $current; + $audit->save(); }elseif($checkgadai->sttebus == ''){ - $updatedata = NotisPeringatan::on('mysql7') - ->where('norujukan',$notis['norujukan']) - ->where('notis_id','=', $notisid) - ->where('kodcaw','=', $kodcaw) - ->update([ - 'jbg'=> $checkgadai->tempoh, - 'pinjaman'=> $checkgadai->bakipjm, - ]); + $telahbayar = $checkgadai->hargajualan - $checkgadai->bakihargajualan; + $upah6bln_raw = $checkgadai->bakiupah - 0.5; + + if($checkgadai->lelong_tawarruq == '1'){ //fasa1 + if(bcdiv($telahbayar,1,1) >= bcdiv($upah6bln_raw,1,1)){ + //deletelist + $updatelistnotis=NotisPeringatan::on('mysql7') + ->where('norujukan','=', $notis['norujukan']) + ->where('notis_id','=', $notisid) + ->where('kodcaw','=', $kodcaw) + ->delete(); + //update tagnotis + $updatedata = Gadai::on($cawangan['mysql']) + ->where('norujukan',$notis['norujukan']) + ->update([ + 'tagnotis'=> '0' + ]); + //save log audit + $audit = new Audit(); + $audit->users = $request->kodlaluan; + $audit->actions = 'Keluar Notis'; + $audit->norujukan = $notis['norujukan']; + $audit->kodcaw = $kodcaw; + $audit->created_at = $current; + $audit->updated_at = $current; + $audit->save(); + }else{ + if($checkgadai->tagbaru == '0'){ + // dd($notis['norujukan']); + $keuntungan = 'asal'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraUpahTawarruq($kodcaw,$notis['norujukan'],$jeniskeuntungan); + }elseif($checkgadai->tagbaru == '1'){ + $keuntungan = 'onepercent'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraupahUjrahOnePercent($kodcaw,$notis['norujukan']); + } + + $updatedata = NotisPeringatan::on('mysql7') + ->where('norujukan',$notis['norujukan']) + ->where('notis_id','=', $notisid) + ->where('kodcaw','=', $kodcaw) + ->update([ + 'jbg'=> $checkgadai->tempoh, + 'pinjaman'=> $checkgadai->bakipjm, + 'bakiupah'=> $response + ]); + } + }elseif($checkgadai->lelong_tawarruq == '0'){ //fasa2 + if($checkgadai->tagbaru == '0'){ + // dd($notis['norujukan']); + $keuntungan = 'asal'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraUpahTawarruq($kodcaw,$notis['norujukan'],$jeniskeuntungan); + }elseif($checkgadai->tagbaru == '1'){ + $keuntungan = 'onepercent'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraupahUjrahOnePercent($kodcaw,$notis['norujukan']); + } + + $updatedata = NotisPeringatan::on('mysql7') + ->where('norujukan',$notis['norujukan']) + ->where('notis_id','=', $notisid) + ->where('kodcaw','=', $kodcaw) + ->update([ + 'jbg'=> $checkgadai->tempoh, + 'pinjaman'=> $checkgadai->bakipjm, + 'bakiupah'=> $response + ]); + } } } } @@ -626,7 +760,6 @@ class CallCenterController extends Controller ->where('peringatan', 1) ->where('tarikhnotis1','<>', NULL) ->get(); - // dd($listnotis,); foreach($listnotis as $index=> $notis){ $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$notis['kodcaw'])->first(); $detail = Gadai::on($cawangan['mysql']) @@ -635,7 +768,7 @@ class CallCenterController extends Controller $tarikhmatang = Carbon::parse($detail['t_matang']); if($detail['lelong_tawarruq'] == 1){ - $t_perlunotis = ($tarikhmatang->subDays(14))->format('d-m-Y'); + $t_perlunotis = ($tarikhmatang->subDays(14))->format('Y-m-d'); if($t_perlunotis <= $today){ $updatedata = NotisPeringatan::on('mysql7') ->where('norujukan',$notis['norujukan']) @@ -705,11 +838,19 @@ class CallCenterController extends Controller ->get(); // dd($notisbycaw); + $notisbycawall = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$notisid) + ->where('notisperingatan.kodcaw',$cawangan['kodcaw']) + // ->where('notisperingatan.peringatan','=', 1) + ->distinct() + ->get(); + $totalsag = $notisbycaw->count('norujukan'); + $totalsagall = $notisbycawall->count('norujukan'); $totalbakipjm = $notisbycaw->sum('pinjaman'); // if(sizeof($notis) != 0){ - array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalbakipjm' =>$totalbakipjm]); + array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalsagall' =>$totalsagall,'totalbakipjm' =>$totalbakipjm]); // } } return response()->json($cawnotis_all); @@ -892,9 +1033,13 @@ class CallCenterController extends Controller ->where('notisperingatan.tarikhnotis2','=', NULL) ->distinct() ->get(); + $notisbycawarray = $notisbycaw->toArray(); // dd($notisbycaw); - - + if(empty($notisbycawarray)){ + // dd(false); + return response()->json('failed'); + }else{ + // dd(true); $arraynorujukan = $notisbycaw->pluck('norujukan')->toArray(); $gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan) @@ -937,22 +1082,483 @@ class CallCenterController extends Controller dispatch(new ARCCSMSPelangganSAGLAMAbysag($nokp,$customer->telefon,$caw_name,$nofoncaw,$kodcaw,$cal->norujukan,$cal->tempoh,$cal->t_matang,$cal->t_matang1,$cal->lelong_tawarruq,$namapengguna)); } } - - // $updatestatusnotis=CawanganNotis::on('mysql7') - // ->where('notis_id','=', $notisid) - // ->where('kodcaw','=', $kodcaw) - // ->update( - // array('status'=> 2)); - return response()->json('success'); + } + } + + //carian untuk notis jbg + public function getJbgGadai($kodcaw,Request $request) + { + // return 1; + //$kodcaw = $request->kodcaw; + $jbgmula = $request->jbgmula; + $jbghingga = $request->jbghingga; + + // dd($jbghingga, $jbgmula); + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + $gadaian = Gadai::on($cawangan['mysql']) + ->where([['tagpalsu','=',0],['tempoh','>=',$jbgmula],['tempoh','<=',$jbghingga],['sttebus','=',''],['taglel','=',0]]) + ->orderBy('t_gadai', 'ASC') + ->orderBy('sirig', 'ASC'); + + $arraynorujukan = $gadaian->pluck('norujukan')->toArray(); + $rekodgadai = $gadaian->get(); + + $totalrekod = $gadaian->count('norujukan'); + $totalberat = $gadaian->sum('berat'); + $totalnilaimarhun = $gadaian->sum('nilaimarhun'); + $totalpinjaman = $gadaian->sum('pinjaman'); + $totalbakipjm = $gadaian->sum('bakipjm'); + $totaltunggakan = $gadaian->sum('tunggakan'); + + $arrayrekod = ['rekod' => $rekodgadai, 'totalsag' => $totalrekod,'totalberat' => $totalberat,'totalnilaimarhun' => $totalnilaimarhun,'totalpembiayaan'=>$totalpinjaman,'totalbakipjm'=>$totalbakipjm,'totaltunggakan'=>$totaltunggakan]; + //dd($arrayrekod); + return response()->json($arrayrekod,200); + } + + public function getbatchnotisjbg(Request $request){ + $currentDate = Carbon::now(); + $tarikh_daftar = $currentDate->toDateString(); + $jbgmula = $request->jbgmula; + $jbghingga = $request->jbghingga; + + $notis = NotJbg::create([ + 'tarikh_notjbg' => $tarikh_daftar, + 'daritempoh' => $jbgmula, + 'hinggatempoh' => $jbghingga, + 'sts_notis' => 1, + 'notiskali' => 1 + ]); + + $batchnotis = NotJbg::on('mysql7')->orderBy('id','desc')->first()->id; + + return response()->json($batchnotis); + } + + public function insertdatagadaijbg($kodcaw,Request $request) + { + $jbgmula = $request->jbgmula; + $jbghingga = $request->jbghingga; + $notisid = $request->notisid; + $currentDate = Carbon::now(); + // $currentDate = $currentDate->toDateString(); + $tarikh_daftar = $currentDate->toDateString(); + $sag_cawangans = []; + $bil_surat = 0; + // dd($kodcaw); + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $datagadaijbg = Gadai::on($cawangan['mysql']) + ->where([['tagpalsu','=',0],['tempoh','>=',$jbgmula],['tempoh','<=',$jbghingga],['sttebus','=',''],['taglel','=',0]]) + ->orderBy('t_gadai', 'ASC') + ->orderBy('sirig', 'ASC'); + // ->get(); + array_push($sag_cawangans,['data'=>$datagadaijbg->get()]); + //dd($sag_cawangans); + + foreach($sag_cawangans as $index=>$cawnotis){ + // dd($cawnotis); + $caw_notis = new CawanganNotisJbg; + $caw_notis->notjbg_id = $notisid; + $caw_notis->kodcaw = $kodcaw; + $caw_notis->notiskali = 1; + $caw_notis->daritempoh = $jbgmula; + $caw_notis->hinggatempoh = $jbghingga; + $caw_notis->status = 1; + $caw_notis->save(); + //dd($caw_notis); + $notiscaw = $cawnotis['data']; + + $notis_jbg_arr = []; + $now = Carbon::now(); + foreach($notiscaw as $call) + { + $notis_to_be_inserted = new NotisJbg(); + $notis_to_be_inserted->notjbg_id = $notisid; + $notis_to_be_inserted->tarikh_daftar = $tarikh_daftar; + $notis_to_be_inserted->kodcaw = $kodcaw; + $notis_to_be_inserted->norujukan = $call->norujukan; + $notis_to_be_inserted->nokp = $call->nokp; + $notis_to_be_inserted->jbg = $call->tempoh; + $notis_to_be_inserted->kadarupah = $call->kadarupah; + $notis_to_be_inserted->nilaimarhun = $call->nilaimarhun; + $notis_to_be_inserted->pinjaman = $call->bakipjm; + $notis_to_be_inserted->bakiupah = $call->bakiupah; + $notis_to_be_inserted->berat = $call->berat; + $notis_to_be_inserted->marhun = $call->marhun; + $notis_to_be_inserted->percentpinj = $call->percentpinj; + $notis_to_be_inserted->notiskali = '1'; + $notis_jbg_arr[] = $notis_to_be_inserted->attributesToArray(); + } + + $notis_jbg_collection = collect($notis_jbg_arr); + + NotisJbg::insert($notis_jbg_arr); + } + return response()->json("success"); + } + + public function senarainotisjbg() + { + $current = Carbon::now(); + $current = new Carbon(); + + $arraybatch = []; + $batchnotis = NotJbg::on('mysql7')->get(); + // $cawangan_all = Cawangan::on('mysql7')->get(); + // $cawnotis_all = []; + // foreach ($batchnotis as $index => $cawangan){ + // $notis = CawanganNotis::on('mysql7')->get(); + // if(sizeof($notis) != 0){ + // array_push($cawnotis_all,$notis); + // } + // } + return response()->json($batchnotis); + } + + public function getcawnotisjbg($notisid) + { + $current = Carbon::now(); + $current = new Carbon(); + + $arraybatch = []; + $batchnotisjbg = NotJbg::on('mysql7')->where('id',$notisid)->get(); + $cawangan_all = Cawangan::on('mysql7')->get(); + $cawnotisjbg_all = []; + foreach ($batchnotisjbg as $index => $cawangan){ + $notis = CawanganNotisJbg::on('mysql7') + ->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notisjbg.kodcaw') + ->where('cawangan_notisjbg.notjbg_id',$notisid)->get(); + if(sizeof($notis) != 0){ + array_push($cawnotisjbg_all,$notis); + } + } + return response()->json($cawnotisjbg_all); + } + + public function getcawnotisjbgbycaw(Request $request) + { + $current = Carbon::now(); + $current = new Carbon(); + + $kodcaw = $request->kodcaw; + $notisid = $request->notisid; + $cawnotis_all = []; + + $arraybatch = []; + $batchnotis = CawanganNotisJbg::on('mysql7') + ->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notisjbg.kodcaw') + ->where('cawangan_notisjbg.notjbg_id',$notisid)->get(); + + foreach ($batchnotis as $index => $cawangan){ + $notis = NotisJbg::on('mysql7') + ->where('notisjbg.notjbg_id',$notisid) + ->where('notisjbg.kodcaw',$cawangan['kodcaw']) + ->distinct() + ->get(); + + $totalsagjbg = $notis->count('norujukan'); + + //$batchnotis [$index]['totalsag'] = $notis->count('norujukan'); + //dd($totalsagjbg); + // if(sizeof($notis) != 0){ + array_push($cawnotis_all,['namacaw'=>$batchnotis, 'detailbycaw' => $notis, 'totalsagjbg' =>$totalsagjbg]); + // } + } + // dd($cawnotis_all); + + // $arrayrekod = ['rekod' => $cawnotis_all,'totalsagjbg' =>$totalsagjbg]; + return response()->json($cawnotis_all); + } + + public function bycawnotisjbg($kodcaw,$notisid) + { + $cawnotis_all = []; + + $notisjbgbycaw = NotisJbg::on('mysql7') + ->where('notisjbg.notjbg_id',$notisid)->where('notisjbg.kodcaw',$kodcaw) + ->distinct() + ->get(); + + $notisjbgbycawarray = $notisjbgbycaw->toArray(); + + foreach($notisjbgbycawarray as $index=>$cal){ + $customer = Customer::where('kpbaru','=',$cal['nokp']) + ->orWhere('kplama','=',$cal['nokp']) + ->first(); + + $notisjbgbycawarray[$index]['namacust'] = $customer; + } + + array_push($notisjbgbycawarray); + return response()->json($notisjbgbycawarray); + } + + public function bysagnotisjbg($kodcaw,$notisid,$id) + { + $notissag = NotisJbg::on('mysql7') + //->join('customer','customer.kplama','||','customer.kpbaru','=','notisjbg.nokp') + ->where('notisjbg.notjbg_id',$notisid)->where('notisjbg.kodcaw',$kodcaw)->where('notisjbg.id',$id) + ->first(); + + return response()->json($notissag); + } + + public function bysagnotisjbgCustomer($kodcaw,$notisid,$id) + { + $notissag = NotisJbg::on('mysql7') + //->join('customer','customer.kplama','||','customer.kpbaru','=','notisjbg.nokp') + ->where('notisjbg.notjbg_id',$notisid)->where('notisjbg.kodcaw',$kodcaw)->where('notisjbg.id',$id) + ->first(); + + $nokp = $notissag['nokp']; + // $notissagbyjbgarray = $notissagbyjbg->toArray(); + + // foreach($notissagbyjbgarray as $index=>$cal){ + $cust_info = Customer::where('kpbaru','=',$notissag['nokp']) + ->orWhere('kplama','=',$notissag['nokp']) + ->first(); + + // $notissagbyjbgarray[$index]['namacust'] = $customer; + // } + + return response()->json($cust_info); + } + + public function bycawnotisjbg2($kodcaw,$notisid) + { + $cawnotis_all = []; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + $notisjbgbycaw = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw) + ->where('notisperingatan.peringatan',2) + ->distinct() + ->get(); + + $arraynorujukan = $notisjbgbycaw->pluck('norujukan')->toArray(); + $notisnokp = NotisPeringatan::on('mysql7')->whereIn('norujukan', $arraynorujukan) + ->where('notisperingatan.peringatan',2) + ->select('nokp') + ->groupBy('nokp') + ->get(); + + foreach($notisnokp as $index1=>$cal){ + $customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp']) + ->orWhere('kplama','=',$cal['nokp']) + ->first(); + + $listnotis = NotisPeringatan::on('mysql7')->whereIn('norujukan', $arraynorujukan) + // ->where('nokp','=',$cal['nokp']) + ->where('nokp', 'like', '%'.$cal['nokp'].'%') + ->where('notisperingatan.peringatan',2) + ->get(); + + $listsag = Gadai::on($cawangan['mysql']) + ->whereIn('norujukan', $arraynorujukan) + ->where('nokp','=',$cal['nokp']) + ->get(); + + foreach($listsag as $index2=>$sag){ + if($sag['tagbaru'] == '0'){ + $keuntungan = 'asal'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraUpahTawarruq($kodcaw,$sag['norujukan'],$jeniskeuntungan); + //dd($response); + }elseif($sag['tagbaru'] == '1'){ + $keuntungan = 'onepercent'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraupahUjrahOnePercent($kodcaw,$sag['norujukan']); } - - //} - // else{ - // return response()->json('failed'); - // } - // } + $listsag[$index2]['keuntungan'] = $response; + } + + $notisnokp[$index1]['info'] = $customer; + $notisnokp[$index1]['listsag'] = $listsag; + $notisnokp[$index1]['listnotis'] = $listnotis; + + } + $totalrekod = $notisjbgbycaw->sum('pinjaman'); + $totalberat = $notisjbgbycaw->sum('berat'); + $totalnilaimarhun = $notisjbgbycaw->sum('nilaimarhun'); + $totalpinjaman = $notisjbgbycaw->sum('pinjaman'); + $totalbakipjm = $notisjbgbycaw->sum('bakipjm'); + $totaltunggakan = $notisjbgbycaw->sum('tunggakan'); + $arrayrekod = ['rekod' => $notisnokp, 'total' => $totalrekod,'totalberat' => $totalberat,'totalnilaimarhun' => $totalnilaimarhun,'totalpinjaman'=>$totalpinjaman,'totalbakipjm'=>$totalbakipjm,'totaltunggakan'=>$totaltunggakan]; + // dd($arrayrekod); + return response()->json($arrayrekod,200); + } + + public function bysagnotisjbg2($kodcaw,$notisid,$nokp) + { + $cawnotis_all = []; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + $notisjbgbycaw = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw) + ->where('nokp',$nokp) + ->where('notisperingatan.peringatan',2) + ->distinct() + ->get(); + + $arraynorujukan = $notisjbgbycaw->pluck('norujukan')->toArray(); + $notisnokp = NotisPeringatan::on('mysql7')->whereIn('norujukan', $arraynorujukan) + ->where('notisperingatan.peringatan',2) + ->select('nokp') + ->groupBy('nokp') + ->get(); + + // dd($notisnokp); + foreach($notisnokp as $index1=>$cal){ + + $listnotis = NotisPeringatan::on('mysql7')->whereIn('norujukan', $arraynorujukan) + // ->where('nokp','=',$cal['nokp']) + ->where('nokp', 'like', '%'.$cal['nokp'].'%') + ->where('notisperingatan.peringatan',2) + ->get(); + + $listsag = Gadai::on($cawangan['mysql']) + ->whereIn('norujukan', $arraynorujukan) + ->where('nokp','=',$cal['nokp']) + ->get(); + + foreach($listsag as $index11=>$sag){ + if($sag['tagbaru'] == '0'){ + $keuntungan = 'asal'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraUpahTawarruq($kodcaw,$sag['norujukan'],$jeniskeuntungan); + //dd($response); + }elseif($sag['tagbaru'] == '1'){ + $keuntungan = 'onepercent'; + $jeniskeuntungan = ($keuntungan == 'onepercent') ? 'onepercent' : 'asal'; + $master = new MasterServices($kodcaw); + $response = $master->kiraupahUjrahOnePercent($kodcaw,$sag['norujukan']); + } + + $listsag[$index11]['keuntungan'] = $response; + } + + $notisnokp[$index1]['listsag'] = $listsag; + $notisnokp[$index1]['listnotis'] = $listnotis; + + } + + $getstatusremark = NotisPeringatan::on('mysql7')->where('nokp', $nokp) + //->whereIn('norujukan', $arraynorujukan) + ->where('notis_id',$notisid) + ->where('notisperingatan.peringatan',2) + // ->select('statuscall,remark1') + ->groupBy('nokp') + ->get(); + + $arrayrekod = ['rekodnotis' => $notisnokp, 'getstatusremark' => $getstatusremark]; + // dd($arrayrekod); + return response()->json($arrayrekod,200); + } + + public function bysagnotisjbgCustomer2($kodcaw,$notisid,$nokp) + { + $notissag = NotisPeringatan::on('mysql7') + //->join('customer','customer.kplama','||','customer.kpbaru','=','notisjbg.nokp') + ->where('notis_id',$notisid)->where('kodcaw',$kodcaw)->where('nokp',$nokp) + ->where('peringatan',2) + ->first(); + + $nokp = $notissag['nokp']; + // $notissagbyjbgarray = $notissagbyjbg->toArray(); + + // foreach($notissagbyjbgarray as $index=>$cal){ + $cust_info = Customer::where('kpbaru','=',$notissag['nokp']) + ->orWhere('kplama','=',$notissag['nokp']) + ->first(); + + // $notissagbyjbgarray[$index]['namacust'] = $customer; + // } + + return response()->json($cust_info); + } + + public function getcawnotiskemaskini($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)->get(); + } + return response()->json($notis); + } + + public function updatecall($kodcaw,$notisid,$nokp, Request $request) + { + $current = Carbon::now(); + $current = new Carbon(); + $harini = $current->toDateString(); + $cawnotis_all = []; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + $notiscall = NotisPeringatan::on('mysql7') + ->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw) + ->where('nokp',$nokp) + //->where('notisperingatan.peringatan',2) + ->distinct() + ->get(); + + $arraynorujukan = $notiscall->pluck('norujukan')->toArray(); + + $updateNotisCall = NotisPeringatan::on('mysql7') + ->where('nokp', $nokp) + ->where('notis_id', $notisid)->update([ + 'tarikhcall1'=> $harini, + 'remark1'=> $request->nota, + 'statuscall'=> $request->statuscall, + 'caller'=>$request->caller + ]); + + return response()->json('success'); + + } + + public function senarainotisperingatankedua() + { + $current = Carbon::now(); + $current = new Carbon(); + + $arraybatch = []; + // $batchnotis = Notis::on('mysql7')->get(); + // return response()->json($batchnotis); + $batchnotis = Notis::on('mysql7') + // ->join('cawangan_notis', 'cawangan_notis.notis_id', '=', 'notis.id') + // ->distinct() + ->get(); + // $cawangan_all = Cawangan::on('mysql7')->get(); + $cawnotis_all = []; + foreach ($batchnotis as $index => $cawangan){ + $idnotis = $cawangan['id']; + $tarikh_notis = $cawangan['tarikh_notis']; + $daritempoh = $cawangan['daritempoh']; + $notis = CawanganNotis::on('mysql7') + ->join('notisperingatan', 'notisperingatan.kodcaw', '=', 'cawangan_notis.kodcaw') + ->where('notisperingatan.notis_id',$cawangan['id']) + // ->where('cawangan_notis.kodcaw',$cawangan['kodcaw']) + ->where('notisperingatan.peringatan','2') + ->distinct() + ->get(); + + $totalsag = $notis->count('norujukan'); + if(sizeof($notis) != 0){ + array_push($cawnotis_all,['id' => $idnotis, 'tarikh_notis' => $tarikh_notis, 'daritempoh' => $daritempoh,'totalsag' => $totalsag, 'detail' => $notis]); + } + } + return response()->json($cawnotis_all); + } } 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/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index e0d81d6..827e3f9 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -478,6 +478,7 @@ class GadaiController extends Controller ['cetak','=',1],['tagserah','=',1], ['semakbarcode','=','Lulus'] ]) + ->orderBy('sirig','asc') ->get(); return response()->json($gadai); diff --git a/app/Http/Controllers/TunaiController.php b/app/Http/Controllers/TunaiController.php index 6466592..904d2ec 100644 --- a/app/Http/Controllers/TunaiController.php +++ b/app/Http/Controllers/TunaiController.php @@ -143,7 +143,12 @@ class TunaiController extends Controller ->where([['kodcaw','=',$kodcaw],['tarikh','=',$current->toDateString()],['kodlaluan','=',$request->kodlaluan]]) ->orderBy('tarikh','desc') ->first(); - return response()->json($tunai); + return response()->json($tunai) + ->withHeaders([ + 'Pragma' => 'no-cache', + 'Cache-Control' => 'no-store', + 'Expires' => 'Mon, 01 Jan 1990 00:00:00 GMT', + ]); } @@ -640,5 +645,3 @@ class TunaiController extends Controller return response()->json($requestteller); } } - - diff --git a/app/Services/Reports/AnsuranService.php b/app/Services/Reports/AnsuranService.php index a81b4b3..a2bd047 100644 --- a/app/Services/Reports/AnsuranService.php +++ b/app/Services/Reports/AnsuranService.php @@ -53,7 +53,7 @@ class AnsuranService return [ 'norujukan' => $ansuran->norujukan, 'nama' => $customer_info['nama'], - 'no_kp' => $gadaian_ansuran->nokp, + 'no_kp' => $gadaian_ansuran['nokp'], 'teller' => $ansuran->teller, 'bayaran_pembiayaan' => $ansuran->bayaran_pembiayaan, 'bayaran_keuntungan' => $ansuran->bayaran_kos_keuntungan, @@ -182,10 +182,17 @@ class AnsuranService $gadaian_ansuran = Gadai::on($cawangan_connection) ->whereIn('norujukan', $list_norujukan) - ->select('norujukan', 'nokp', 'teller') + ->select('norujukan', 'nokp') ->get(); - return $gadaian_ansuran; + $norujukan_key = $gadaian_ansuran->pluck('norujukan'); + + $norujukan_dictionary = array_combine($norujukan_key->toArray(), $gadaian_ansuran->toArray()); + + return $list_norujukan->map(function($norujukan) use($norujukan_dictionary){ + return $norujukan_dictionary[$norujukan]; + }); + } } diff --git a/app/Services/Reports/RingkasanHarianService.php b/app/Services/Reports/RingkasanHarianService.php index 39bb403..aa2a3bd 100644 --- a/app/Services/Reports/RingkasanHarianService.php +++ b/app/Services/Reports/RingkasanHarianService.php @@ -104,6 +104,9 @@ class RingkasanHarianService $getUjrahSebenarKaunter = $this->getUjrahSebenarKaunter(); $getTotalOnePercentOnline = $this->getTotalOnePercentOnline(); $getTotalUjrahOnline = $this->getTotalUjrahOnline(); + $getUpahSimpanKaunterLama = $this->getUpahSimpanKaunterLama(); + $getKeuntunganSebenarKaunterLama = $this->getKeuntunganSebenarKaunterLama(); + $getTotalKeuntunganOnlineLama = $this->getTotalKeuntunganOnlineLama(); array_push($laporan_harian, [ 'total_gadai' => $total_gadai, @@ -166,6 +169,9 @@ class RingkasanHarianService 'ujrahSebenarKaunter' => $getUjrahSebenarKaunter, 'totalOnePercentOnline' => $getTotalOnePercentOnline, 'totalUjrahOnline' => $getTotalUjrahOnline, + 'upahSimpanKaunterLama' => $getUpahSimpanKaunterLama, + 'keuntunganSebenarKaunterLama' => $getKeuntunganSebenarKaunterLama, + 'totalKeuntunganOnlineLama' => $getTotalKeuntunganOnlineLama, ]); return response()->json($laporan_harian); @@ -448,6 +454,73 @@ class RingkasanHarianService } + private function getTotalKeuntunganOnlineLama() + { + $total_keuntunganansuran_data_online = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->whereDate('trans.created_at', '>=', $this->startDate)->whereDate('trans.created_at', '<=', $this->endDate) + ->where('trans.teller', '=', 'Online') + ->where('trans.trans_type', '=', 'A') + ->where('transaksi_keuntungan.margin_semasa', '=' ,0.00) + ->where('trans.kodcaw', $this->kodCawangan) + ->pluck('transaksi_keuntungan.norujukan'); + + $gadaiDataOnline = Gadai::on($this->connectionCawangan)->whereIn('norujukan', $total_keuntunganansuran_data_online)->whereNotNull('hargajualan')->pluck('norujukan'); + + $keuntunganansuran_online_query = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->whereDate('trans.created_at', '>=', $this->startDate)->whereDate('trans.created_at', '<=', $this->endDate) + ->where('trans.teller', '=', 'Online') + ->where('trans.trans_type', '=', 'A') + ->where('trans.kodcaw', $this->kodCawangan) + ->where('transaksi_keuntungan.margin_semasa', '=' ,0.00) + ->whereIn('trans.norujukan', $gadaiDataOnline) + ->whereDate('transaksi_keuntungan.tarikh_bayaran', '>=', $this->startDate)->whereDate('transaksi_keuntungan.tarikh_bayaran', '<=', $this->endDate); + + $total_keuntunganansuran_online = $keuntunganansuran_online_query->sum('bayaran_keuntungan'); + + $total_keuntunganbukanansuran_data_online = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->where('trans.trans_type', '!=', 'A') + ->where('trans.teller', '=', 'Online') + ->where('transaksi_keuntungan.margin_semasa', '=' ,0.00) + ->whereDate('trans.created_at', '>=', $this->startDate)->whereDate('trans.created_at', '<=', $this->endDate) + ->where('trans.kodcaw', '=', $this->kodCawangan) + ->pluck('transaksi_keuntungan.norujukan'); + + $gadaiDataOnline = Gadai::on($this->connectionCawangan)->whereIn('norujukan', $total_keuntunganbukanansuran_data_online)->whereNotNull('hargajualan')->pluck('norujukan'); + + $keuntunganbukanansuran_online_query = TransaksiKeuntungan::on('mysql7') + ->whereIn('norujukan', $gadaiDataOnline) + ->where('margin_semasa', '=' ,0.00) + ->whereDate('tarikh_bayaran', '>=', $this->startDate)->whereDate('tarikh_bayaran', '<=', $this->endDate); + + $total_keuntunganbukanansuran_online = $keuntunganbukanansuran_online_query->sum('keuntungan_rebet'); + + $keuntungansebenaronline = $total_keuntunganansuran_online + $total_keuntunganbukanansuran_online; + + $upahansurOnlineQuery = Advansur::on($this->connectionCawangan) + ->where('teller', '=', 'Online') + ->whereDate('tarikh', '>=', $this->startDate)->whereDate('tarikh', '<=', $this->endDate); + + $upahansurOnline = $upahansurOnlineQuery->sum('upahdibayar'); + + $upahsimpanonline = $upahansurOnline; + $total_keuntungan_online = floatval($upahsimpanonline) + floatval($keuntungansebenaronline); + + return floatval($total_keuntungan_online); + + } + private function getTotalOnePercentOnline() { $total_keuntunganansuran_data_online = TransaksiKeuntungan::on('mysql7') @@ -985,6 +1058,55 @@ class RingkasanHarianService return floatval($upahsimpanujrah); } + private function getUpahSimpanKaunterLama() + { + $keuntungan_data_kaunter = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->whereDate('transaksi_keuntungan.tarikh_bayaran', '>=', $this->startDate)->whereDate('transaksi_keuntungan.tarikh_bayaran', '<=', $this->endDate) + ->where('trans.teller', '<>', 'Online') + + ->pluck('transaksi_keuntungan.norujukan'); + + $gadaiDataKaunter = Gadai::on($this->connectionCawangan)->whereIn('norujukan', $keuntungan_data_kaunter)->whereNull('hargajualan')->pluck('norujukan'); + + $keuntungan_kaunter_query = TransaksiKeuntungan::on('mysql7') + ->whereIn('norujukan', $gadaiDataKaunter) + ->where('margin_semasa', '=' ,0.00); + + $keuntungan_kaunter = $keuntungan_kaunter_query->sum('bayaran_keuntungan'); + + // $upahtebus = Tebus::on($this->connectionCawangan) + // ->whereDate('t_tebus', '>=', $this->startDate)->whereDate('t_tebus', '<=', $this->endDate) + // ->sum('upahdibayar'); + + $upahlelong = Lelong::on($this->connectionCawangan) + ->whereDate('t_jual', '>=', $this->startDate)->whereDate('t_jual', '<=', $this->endDate) + ->sum('bakiupah'); + + + + $total_keuntunganbukanansuran_data_kaunter = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->where('trans.trans_type', '!=', 'A') + ->where('trans.teller', '<>', 'Online') + ->whereDate('trans.created_at', '>=', $this->startDate)->whereDate('trans.created_at', '<=', $this->endDate) + ->where('trans.kodcaw', '=', $this->kodCawangan) + ->where('transaksi_keuntungan.margin_semasa', '=' ,0.00); + + + $total_keuntunganbukanansuran_kaunter = $total_keuntunganbukanansuran_data_kaunter->sum('keuntungan_rebet'); + + $upahsimpankaunterlama = $keuntungan_kaunter + $upahlelong + $total_keuntunganbukanansuran_kaunter; + + return floatval($upahsimpankaunterlama); + } + private function getKeuntunganSebenarKaunter() { $total_keuntunganansuran_data_kaunter = TransaksiKeuntungan::on('mysql7') @@ -1017,6 +1139,40 @@ class RingkasanHarianService return floatval($keuntungansebenarkaunter); } + private function getKeuntunganSebenarKaunterLama() + { + $total_keuntunganansuran_data_kaunter = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->whereDate('trans.created_at', '>=', $this->startDate)->whereDate('trans.created_at', '<=', $this->endDate) + ->where('trans.teller', '<>', 'Online') + ->where('trans.trans_type', '=', 'A') + ->where('trans.kodcaw', $this->kodCawangan) + ->where('transaksi_keuntungan.margin_semasa', '=' ,0.00) + ->pluck('transaksi_keuntungan.norujukan'); + + $gadaiDataKaunter = Gadai::on($this->connectionCawangan)->whereIn('norujukan', $total_keuntunganansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan'); + + $keuntunganansuran_kaunter_query = TransaksiKeuntungan::on('mysql7') + ->leftJoin('transaction as trans', function ($join) { + $join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan'); + $join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at'); + }) + ->where('trans.teller', '<>', 'Online') + ->where('trans.trans_type', '=', 'A') + ->whereIn('transaksi_keuntungan.norujukan', $gadaiDataKaunter) + ->where('transaksi_keuntungan.margin_semasa', '=' ,0.00) + ->whereDate('transaksi_keuntungan.tarikh_bayaran', '>=', $this->startDate)->whereDate('transaksi_keuntungan.tarikh_bayaran', '<=', $this->endDate); + + $total_keuntunganansuran_kaunter = $keuntunganansuran_kaunter_query->sum('bayaran_keuntungan'); + + $keuntungansebenarkaunter = $total_keuntunganansuran_kaunter; + + return floatval($keuntungansebenarkaunter); + } + private function getOnepercentSebenarKaunter() { $total_keuntunganansuran_data_kaunter = TransaksiKeuntungan::on('mysql7') diff --git a/composer.json b/composer.json index 4acec19..e26171c 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "require": { "php": "^7.2.5", "auth0/auth0-php": "^7.4", + "doctrine/dbal": "2.13.5", "laravel/lumen-framework": "^7.0", "laravel/tinker": "^2.8", "rap2hpoutre/laravel-log-viewer": "^1.7", diff --git a/composer.lock b/composer.lock index 19f5172..bc01192 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "17aa13bd1f3c89969c4cdcce223e8172", + "content-hash": "2a35e67752107934701ceea957a4fd34", "packages": [ { "name": "auth0/auth0-php", @@ -193,6 +193,343 @@ ], "time": "2021-08-15T20:50:18+00:00" }, + { + "name": "doctrine/cache", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb", + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "symfony/cache": "^4.4 || ^5.4 || ^6", + "symfony/var-exporter": "^4.4 || ^5.4 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/2.2.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2022-05-20T20:07:39+00:00" + }, + { + "name": "doctrine/dbal", + "version": "2.13.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "d92ddb260547c2a7b650ff140f744eb6f395d8fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/d92ddb260547c2a7b650ff140f744eb6f395d8fc", + "reference": "d92ddb260547c2a7b650ff140f744eb6f395d8fc", + "shasum": "" + }, + "require": { + "doctrine/cache": "^1.0|^2.0", + "doctrine/deprecations": "^0.5.3", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.1 || ^8" + }, + "require-dev": { + "doctrine/coding-standard": "9.0.0", + "jetbrains/phpstorm-stubs": "2021.1", + "phpstan/phpstan": "1.1.1", + "phpunit/phpunit": "^7.5.20|^8.5|9.5.10", + "psalm/plugin-phpunit": "0.16.1", + "squizlabs/php_codesniffer": "3.6.1", + "symfony/cache": "^4.4", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", + "vimeo/psalm": "4.12.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlanywhere", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/2.13.5" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2021-11-11T16:27:36+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "v0.5.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "9504165960a1f83cc1480e2be1dd0a0478561314" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/9504165960a1f83cc1480e2be1dd0a0478561314", + "reference": "9504165960a1f83cc1480e2be1dd0a0478561314", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0|^7.0|^8.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v0.5.3" + }, + "time": "2021-03-21T12:59:47+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520", + "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^0.5.3 || ^1", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": "<2.9" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^10", + "phpstan/phpstan": "~1.4.10 || ^1.8.8", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.24" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/1.2.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2022-10-12T20:51:15+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.4", diff --git a/database/migrations/2024_01_02_164110_add_notiscall_to_notis_peringatan_table.php b/database/migrations/2024_01_02_164110_add_notiscall_to_notis_peringatan_table.php new file mode 100644 index 0000000..a6c60c0 --- /dev/null +++ b/database/migrations/2024_01_02_164110_add_notiscall_to_notis_peringatan_table.php @@ -0,0 +1,40 @@ +date('tarikhcall1')->nullable(); + $table->date('tarikhcall2')->nullable(); + $table->string('remark1')->nullable(); + $table->string('remark2')->nullable(); + $table->integer('statuscall')->default(0); + $table->string('caller')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // Schema::table('notisperingatan', function (Blueprint $table) { + // $table->dropColumn(['tarikhcall1']); + // $table->dropColumn(['tarikhcall2']); + // $table->dropColumn(['remark1']); + // $table->dropColumn(['remark2']); + // }); + } +} diff --git a/database/migrations/2024_01_15_114618_add_index_to_transaction_table.php b/database/migrations/2024_01_15_114618_add_index_to_transaction_table.php new file mode 100644 index 0000000..47041d7 --- /dev/null +++ b/database/migrations/2024_01_15_114618_add_index_to_transaction_table.php @@ -0,0 +1,62 @@ +table('transaction', static function (Blueprint $table) { + $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); + $indexesFound = $schemaManager->listTableIndexes('transaction'); + + if (! array_key_exists('idx_search_norujukan', $indexesFound)) { + $table->index(['created_at', 'trans_type', 'kodcaw'], 'idx_search_norujukan'); + } + }); + + Schema::connection('mysql7')->table('transaksi_keuntungan', static function (Blueprint $table) { + $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); + $indexesFound = $schemaManager->listTableIndexes('transaksi_keuntungan'); + + if (! array_key_exists('idx_tarikh_bayaran', $indexesFound)) { + $table->index('tarikh_bayaran', 'idx_tarikh_bayaran'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::connection('mysql7')->table('transaction', static function (Blueprint $table) { + $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); + $indexesFound = $schemaManager->listTableIndexes('transaction'); + + if (array_key_exists('idx_seach_norujukan', $indexesFound)) { + $table->dropIndex('idx_search_norujukan'); + } + }); + + + Schema::connection('mysql7')->table('transaksi_keuntungan', static function (Blueprint $table) { + $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); + $indexesFound = $schemaManager->listTableIndexes('transaksi_keuntungan'); + + if (array_key_exists('idx_tarikh_bayaran', $indexesFound)) { + $table->dropIndex('idx_tarikh_bayaran'); + } + }); + } +} diff --git a/routes/web.php b/routes/web.php index 012dc21..01336d6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -612,6 +612,12 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('rekodblast/{kodcaw}',['uses'=>'StokAuditController@rekodblast']); $router->get('rekodblastsms/{kodcaw}',['uses'=>'StokAuditController@rekodblastsms']); + //API notis peringatan cawangan + $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']); + }); @@ -863,7 +869,22 @@ $router->group(['prefix'=>'arcc'], function () use ($router){ $router->get('getfasa',['uses'=>'CallCenterController@getfasa']); $router->get('getdatanotiskedua/{kodcaw}/{notisid}/{fasa}',['uses'=>'CallCenterController@getdatanotiskedua']); $router->post('/notis/blastwasapbysagkedua',['uses'=>'CallCenterController@blastwasapbysagkedua']); + $router->get('getcawnotiskemaskini/{notisid}',['uses'=>'CallCenterController@getcawnotiskemaskini']); + $router->get('senarainotisperingatankedua',['uses'=>'CallCenterController@senarainotisperingatankedua']); + $router->get('gadaian/{kodcaw}',['uses'=>'CallCenterController@getJbgGadai']); + $router->get('getbatchnotisjbg',['uses'=>'CallCenterController@getbatchnotisjbg']); + $router->post('insertdatagadaijbg/{kodcaw}',['uses'=>'CallCenterController@insertdatagadaijbg']); + $router->get('senarainotisjbg',['uses'=>'CallCenterController@senarainotisjbg']); + $router->get('getcawnotisjbg/{notisid}',['uses'=>'CallCenterController@getcawnotisjbg']); + $router->get('getcawnotisjbgbycaw',['uses'=>'CallCenterController@getcawnotisjbgbycaw']); + $router->get('bycawnotisjbg/{kodcaw}/{notisid}',['uses'=>'CallCenterController@bycawnotisjbg']); + $router->get('bysagnotisjbg/{kodcaw}/{notisid}/{id}',['uses'=>'CallCenterController@bysagnotisjbg']); + $router->get('bysagnotisjbgcustomer/{kodcaw}/{notisid}/{id}',['uses'=>'CallCenterController@bysagnotisjbgCustomer']); + $router->get('bycawnotisjbg2/{kodcaw}/{notisid}',['uses'=>'CallCenterController@bycawnotisjbg2']); + $router->get('bysagnotisjbg2/{kodcaw}/{notisid}/{nokp}',['uses'=>'CallCenterController@bysagnotisjbg2']); + $router->put('updatecall/{kodcaw}/{notisid}/{nokp}', ['uses' => 'CallCenterController@updatecall']); + $router->get('bysagnotisjbgcustomer2/{kodcaw}/{notisid}/{nokp}',['uses'=>'CallCenterController@bysagnotisjbgCustomer2']); });