update kemaskini notis peringatan by caw

This commit is contained in:
Nur Izzati Zulkifli
2024-01-11 16:54:07 +08:00
parent da9fb99c66
commit ff7d058b06
2 changed files with 187 additions and 40 deletions
+186 -40
View File
@@ -203,16 +203,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 +238,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);
}
@@ -259,13 +299,21 @@ class CallCenterController extends Controller
->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);
@@ -605,33 +653,91 @@ class CallCenterController extends Controller
->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 == ''){
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']);
}
// dd($response);
$updatedata = NotisPeringatan::on('mysql7')
->where('norujukan',$notis['norujukan'])
->where('notis_id','=', $notisid)
->where('kodcaw','=', $kodcaw)
->update([
'jbg'=> $checkgadai->tempoh,
'pinjaman'=> $checkgadai->bakipjm,
'bakiupah'=> $response
]);
$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
]);
}
}
}
}
@@ -651,7 +757,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'])
@@ -660,7 +765,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'])
@@ -730,11 +835,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);
@@ -987,4 +1100,37 @@ class CallCenterController extends Controller
return response()->json($notis);
}
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);
}
}
+1
View File
@@ -870,6 +870,7 @@ $router->group(['prefix'=>'arcc'], function () use ($router){
$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']);
});