tambah function notis peringatan dalam arcc dan blast wasap dan sms
This commit is contained in:
@@ -36,8 +36,8 @@ use App\Jobs\SMSPelangganSAGLAMA;
|
||||
use Illuminate\Http\Request;
|
||||
use App\CawanganDetail;
|
||||
use App\BlastSMS;
|
||||
use App\Jobs\WhatsappPelangganSAGLAMAbysag;
|
||||
use App\Jobs\SMSPelangganSAGLAMAbysag;
|
||||
use App\Jobs\ARCCWhatsappPelangganSAGLAMAbysag;
|
||||
use App\Jobs\ARCCSMSPelangganSAGLAMAbysag;
|
||||
|
||||
use App\Services\OnePercentServices;
|
||||
|
||||
@@ -47,9 +47,22 @@ use Carbon\Carbon;
|
||||
|
||||
class CallCenterController extends Controller
|
||||
{
|
||||
public function showAllCawangans()
|
||||
public function showAllCawangans(Request $request)
|
||||
{
|
||||
return response()->json(Cawangan::on('mysql7')->orderBy('details_caw','ASC')->get());
|
||||
$daritempoh = $request->daritempoh;
|
||||
$hinggatempoh = $request->hinggatempoh;
|
||||
$checkcawangannotis = Cawangan::on('mysql7')
|
||||
// ->whereNotExists(function($query) use($daritempoh,$hinggatempoh)
|
||||
// {
|
||||
// $query->select(DB::raw(1))
|
||||
// ->from('cawangan_notis')
|
||||
// ->whereRaw('cawangan_notis.kodcaw = arrahn_master_db.kodcaw')
|
||||
// ->where('daritempoh','=',$daritempoh)
|
||||
// ->where('hinggatempoh','=',$hinggatempoh);
|
||||
// } )
|
||||
->orderBy('details_caw','ASC')->get();
|
||||
// dd($checkcawangannotis);
|
||||
return response()->json($checkcawangannotis);
|
||||
}
|
||||
public function datagadai($kodcaw,Request $request)
|
||||
{
|
||||
@@ -58,7 +71,7 @@ class CallCenterController extends Controller
|
||||
$hinggatempoh = $request->hinggatempoh;
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$datagadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0]])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0],['tagnotis','=',0]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC');
|
||||
// ->get();
|
||||
@@ -100,7 +113,7 @@ class CallCenterController extends Controller
|
||||
// ]);
|
||||
|
||||
$datagadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0]])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0],['tagnotis','=',0]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC');
|
||||
// ->get();
|
||||
@@ -143,6 +156,11 @@ class CallCenterController extends Controller
|
||||
$notis_to_be_inserted->percent = $surat->percentpinj;
|
||||
$notis_to_be_inserted->peringatan = '1';
|
||||
$notis_peringatan_arr[] = $notis_to_be_inserted->attributesToArray();
|
||||
|
||||
//updatetagnotisdlmgadai
|
||||
$updateTagNotis = Gadai::on($cawangan['mysql'])->where('norujukan',$surat->norujukan)->update([
|
||||
'tagnotis'=> 1
|
||||
]);
|
||||
}
|
||||
|
||||
$notis_peringatan_collection = collect($notis_peringatan_arr);
|
||||
@@ -214,31 +232,140 @@ class CallCenterController extends Controller
|
||||
|
||||
public function getcawnotisbycaw(Request $request)
|
||||
{
|
||||
$notisid = $request->notisid;
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$arraybatch = [];
|
||||
$batchnotis = Notis::on('mysql7')->where('id',$notisid)->get();
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
$cawnotis_all = [];
|
||||
|
||||
$notis = CawanganNotis::on('mysql7')
|
||||
->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notis.kodcaw')
|
||||
->where('notis_id',$notisid)->get();
|
||||
|
||||
foreach ($notis as $index => $cawangan){
|
||||
// dd($cawangan['kodcaw']);
|
||||
// dd($cawangan);
|
||||
$notisbycaw = NotisPeringatan::on('mysql7')
|
||||
->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$cawangan['kodcaw'])
|
||||
->distinct()
|
||||
->get();
|
||||
// dd($notisbycaw);
|
||||
|
||||
$totalsag = $notisbycaw->count('norujukan');
|
||||
$totalbakipjm = $notisbycaw->sum('pinjaman');
|
||||
|
||||
// if(sizeof($notis) != 0){
|
||||
array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalbakipjm' =>$totalbakipjm]);
|
||||
// }
|
||||
}
|
||||
return response()->json($cawnotis_all);
|
||||
}
|
||||
|
||||
public function bycawnotisperingatan($kodcaw,$notisid)
|
||||
{
|
||||
$cawnotis_all = [];
|
||||
|
||||
$notisbycaw = NotisPeringatan::on('mysql7')
|
||||
->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw)
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
$notisbycawarray = $notisbycaw->toArray();
|
||||
|
||||
foreach($notisbycawarray as $index=>$cal){
|
||||
$customer = Customer::where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
|
||||
$notisbycawarray[$index]['namacust'] = $customer;
|
||||
}
|
||||
|
||||
array_push($notisbycawarray);
|
||||
return response()->json($notisbycawarray);
|
||||
}
|
||||
|
||||
public function blastwasapbysag(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$kodcaw = $request->kodcaw;
|
||||
$notisid = $request->notisid;
|
||||
|
||||
$arraybatch = [];
|
||||
$batchnotis = CawanganNotis::on('mysql7')->where('id',$notisid)->where('kodcaw',$kodcaw)->get();
|
||||
$cawnotis_all = [];
|
||||
foreach ($batchnotis as $index => $cawangan){
|
||||
$notis = NotisPeringatan::on('mysql7')
|
||||
->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'notisperingatan.kodcaw')
|
||||
->join('cawangan_notis', 'cawangan_notis.kodcaw', '=', 'notisperingatan.kodcaw')
|
||||
->where('cawangan_notis.notis_id',$notisid)->where('cawangan_notis.kodcaw',$kodcaw)->get();
|
||||
$namapengguna = $request->namapengguna;
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
$cawangan_detail = CawanganDetail::on($cawangan['mysql'])->first();
|
||||
$caw_name = $cawangan->details_caw;
|
||||
$nofoncaw = $cawangan_detail->notel;
|
||||
|
||||
$totalsag = $notis->count('norujukan');
|
||||
// dd($totalsag);
|
||||
if(sizeof($notis) != 0){
|
||||
array_push($cawnotis_all,$notis);
|
||||
$statusblast = CawanganNotis::where('notis_id','=',$notisid)
|
||||
->where('kodcaw','=',$kodcaw)
|
||||
->first();
|
||||
if($statusblast->status == '1'){
|
||||
|
||||
$notisbycaw = NotisPeringatan::on('mysql7')
|
||||
->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw)
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
$arraynorujukan = $notisbycaw->pluck('norujukan')->toArray();
|
||||
|
||||
$gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->get();
|
||||
$gadai_all_groupby_nokp = $notisbycaw->groupBy('nokp');
|
||||
|
||||
foreach($gadainokp as $index1=>$cal){
|
||||
if($gadai_all_groupby_nokp[$cal->nokp]){
|
||||
$gadainokp[$index1]['gadai'] = $gadai_all_groupby_nokp[$cal->nokp];
|
||||
}
|
||||
$customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
$nokp=$cal['nokp'];
|
||||
// dd($customer);
|
||||
if($customer->telefon != 'null'){
|
||||
$telefon=$customer->telefon;
|
||||
//log auditrail
|
||||
$audit = new Audit();
|
||||
$audit->users = $namapengguna;
|
||||
$audit->actions = 'ARCC Blast Whatsapp & SMS: Notis ID'.$notisid;
|
||||
$audit->norujukan = $cal->norujukan;
|
||||
$audit->new_data = $customer->telefon;
|
||||
$audit->old_data = $nokp;
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $current;
|
||||
$audit->updated_at = $current;
|
||||
$audit->save();
|
||||
|
||||
$today = $current->toDateString();
|
||||
$harini = date('Y-m-d',strtotime($today));
|
||||
|
||||
//update tarikh dlm table notisperingatan
|
||||
$updatenotis=NotisPeringatan::on('mysql7')
|
||||
->where('norujukan','=', $cal->norujukan)
|
||||
->update(
|
||||
array('tarikhnotis1'=> $harini));
|
||||
|
||||
dispatch(new ARCCWhatsappPelangganSAGLAMAbysag($nokp,$customer->telefon,$caw_name,$nofoncaw,$kodcaw,$cal->norujukan,$cal->tempoh,$cal->t_matang,$cal->t_matang1,$cal->lelong_tawarruq,$namapengguna));
|
||||
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');
|
||||
}
|
||||
else{
|
||||
return response()->json('failed');
|
||||
}
|
||||
}
|
||||
// dd($cawnotis_all);
|
||||
|
||||
$arrayrekod = ['rekod' => $cawnotis_all,'totalsag' =>$totalsag];
|
||||
return response()->json($arrayrekod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user