1378 lines
62 KiB
PHP
1378 lines
62 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Services\CustomerService;
|
|
use Illuminate\Support\Facades\Session;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Carbon\Carbon;
|
|
use PDF;
|
|
|
|
|
|
class CallCenterController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
public function notisperingatan(Request $request){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
|
|
return view('callcenter.notisperingatan',compact('cawangan_info','api_url'));
|
|
}
|
|
public function notisperingatanpertama(Request $request){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
|
|
return view('callcenter.notisperingatanpertama',compact('cawangan_info','api_url'));
|
|
}
|
|
|
|
public function cariansag(Request $request)
|
|
{
|
|
// dd($request->all());
|
|
$request->radaktif === 'aktif';
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$daritempoh = $request->daritempoh;
|
|
$hinggatempoh = $request->hinggatempoh;
|
|
|
|
|
|
$cawangan_all = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/cawangan',[
|
|
'daritempoh' => $daritempoh,
|
|
'hinggatempoh' => $hinggatempoh,
|
|
])->json();
|
|
|
|
$senarai = [];
|
|
foreach($cawangan_all as $cawangan){
|
|
$kodcaw = $cawangan['kodcaw'];
|
|
// $kodcaw = 'WCY';
|
|
$datagadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/datagadai/'.$request->radaktif.'/'.$kodcaw ,[
|
|
'daritempoh' => $daritempoh,
|
|
'hinggatempoh' => $hinggatempoh,
|
|
])->json();
|
|
|
|
$data = [
|
|
'kodcaw'=>$cawangan['kodcaw'],
|
|
'caw_name'=>$cawangan['details_caw'],
|
|
'datagadai' => $datagadai ? $datagadai : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
|
|
// dd($data);
|
|
}
|
|
|
|
return view('callcenter.listcariansag', compact(
|
|
'kodcaw',
|
|
'senarai',
|
|
'daritempoh',
|
|
'hinggatempoh',
|
|
|
|
));
|
|
}
|
|
|
|
public function cariansagnotispertama(Request $request)
|
|
{
|
|
// dd($request->all());
|
|
$request->radaktif === 'aktif';
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$fasa = $request->fasa;
|
|
|
|
|
|
$cawangan_all = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/cawangan',[
|
|
'fasa' => $fasa,
|
|
])->json();
|
|
// dd($cawangan_all );
|
|
|
|
$senarai = [];
|
|
foreach($cawangan_all as $cawangan){
|
|
$kodcaw = $cawangan['kodcaw'];
|
|
$datagadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/cariannotispertama/'.$kodcaw,[
|
|
'fasa' => $fasa
|
|
])->json();
|
|
|
|
$data = [
|
|
'kodcaw'=>$cawangan['kodcaw'],
|
|
'caw_name'=>$cawangan['details_caw'],
|
|
'datagadai' => $datagadai ? $datagadai : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
|
|
return view('callcenter.listcariansagnotispertama', compact(
|
|
'kodcaw',
|
|
'senarai',
|
|
'fasa'
|
|
));
|
|
}
|
|
|
|
public function janadatanotisperingatan(Request $request)
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$currentNow = Carbon::now();
|
|
$senarai = [];
|
|
$tarikh_savedaftarnotis = $current->toDateString();
|
|
$daritempoh = $request->daritempoh;
|
|
$hinggatempoh = $request->hinggatempoh;
|
|
$kodcaw = $request->kodcaw;
|
|
$selected_caw = $request->caw;
|
|
// dd($selected_caw);
|
|
|
|
$getbatchnotis=Http::withOptions(['verify' => config('app.api_verify')])->get( config('api.url').'/arcc/getbatchnotis',[
|
|
'daritempoh' => $daritempoh,
|
|
'hinggatempoh' => $hinggatempoh,
|
|
])->json();
|
|
|
|
$newbatchnotis=$getbatchnotis;
|
|
|
|
if(!empty($selected_caw))
|
|
{
|
|
foreach($selected_caw as $index=>$caw){
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $caw)->json();
|
|
// dd($cawangan_info);
|
|
$insertdatagadai = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/insertdatagadai/aktif/'.$caw ,[
|
|
'daritempoh' => $daritempoh,
|
|
'hinggatempoh' => $hinggatempoh,
|
|
'kodcaw' => $caw,
|
|
'notisid' => $newbatchnotis
|
|
])->json();
|
|
|
|
$data = [
|
|
'kodcaw'=>$caw,
|
|
'caw_name'=>$cawangan_info['details_caw'],
|
|
'datagadai' => $insertdatagadai ? $insertdatagadai : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
}
|
|
return redirect()->route('arcc.notisperingatan')->with('success','Berjaya Daftar Notis Peringatan.');
|
|
|
|
}
|
|
public function janadatanotispertama(Request $request)
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$currentNow = Carbon::now();
|
|
$senarai = [];
|
|
$tarikh_savedaftarnotis = $current->toDateString();
|
|
$fasa = $request->fasa;
|
|
$kodcaw = $request->kodcaw;
|
|
$selected_caw = $request->caw;
|
|
// dd($selected_caw);
|
|
if(!empty($selected_caw))
|
|
{
|
|
$getbatchnotispertama=Http::withOptions(['verify' => config('app.api_verify')])->get( config('api.url').'/arcc/getbatchnotispertama',[
|
|
'fasa' => $fasa
|
|
])->json();
|
|
$newbatchnotis=$getbatchnotispertama;
|
|
|
|
foreach($selected_caw as $index=>$caw){
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $caw)->json();
|
|
// dd($cawangan_info);
|
|
$insertnotispertama = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/insertnotispertama/'.$caw ,[
|
|
'fasa' => $fasa,
|
|
'kodcaw' => $caw,
|
|
'notisid' => $newbatchnotis
|
|
])->json();
|
|
|
|
$data = [
|
|
'kodcaw'=>$caw,
|
|
'caw_name'=>$cawangan_info['details_caw'],
|
|
'datagadai' => $insertnotispertama ? $insertnotispertama : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
return redirect()->route('arcc.notisperingatanpertama')->with('success','Berjaya Daftar Notis Peringatan Pertama.');
|
|
}else{
|
|
return redirect()->route('arcc.notisperingatanpertama')->with('failed','Maaf,Tiada Cawangan Dipilih Sila Cuba Lagi...');
|
|
}
|
|
}
|
|
|
|
public function rekodnotisperingatan()
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$arrayinfo = [];
|
|
|
|
// $notis = Notis::select('tarikh_notis','id')
|
|
// ->groupBy('tarikh_notis')
|
|
// ->get();
|
|
$notis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/senarainotisperingatan')->json();
|
|
// dd($notis);
|
|
foreach($notis as $info)
|
|
{
|
|
$getcawnotis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotis/'.$info['id'])->json();
|
|
|
|
array_push($arrayinfo, ['info'=> $info,'cawnotis' => $getcawnotis]);
|
|
}
|
|
// dd($arrayinfo);
|
|
return view('callcenter.rekodnotisperingatan',compact('notis','arrayinfo'));
|
|
}
|
|
|
|
public function detailnotisperingatan($notisid)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
|
|
$detailnotis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotis/'.$notisid)->json();
|
|
foreach($detailnotis as $info)
|
|
{
|
|
$getcawnotisbycaw = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotisbycaw', [
|
|
'kodcaw' => $info[0]['kodcaw'],
|
|
'notisid' => $notisid
|
|
])->json();
|
|
|
|
$data = [
|
|
'detailnotis' => $info ? $info : '',
|
|
'getcawnotisbycaw' => $getcawnotisbycaw ? $getcawnotisbycaw : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
return view('callcenter.detailnotisperingatan',compact('detailnotis','senarai','notisid'));
|
|
}
|
|
|
|
public function bycawnotisperingatan($kodcaw,$notisid, Request $request)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
|
|
|
|
if($request->type == 'whatsapp')
|
|
{
|
|
|
|
$blastwhatsapp = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/notis/blastwasapbysag/'.$auth_user['cawangan'],
|
|
['kodcaw' => $kodcaw,'notisid' => $notisid, 'namapengguna' => $auth_user['name'],])->json();
|
|
if($blastwhatsapp == 'success'){
|
|
return redirect()->route('arcc.bycawnotisperingatan',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
->with('success','Blast Whatsapp Dalam Proses.');
|
|
}
|
|
elseif($blastwhatsapp == 'failed'){
|
|
return redirect()->route('arcc.bycawnotisperingatan',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
->with('failed','Blast Whatsapp Tidak Berjaya, Sila Semak Semula Rekod Blasted.');
|
|
}
|
|
|
|
}
|
|
return view('callcenter.bycawdetailnotisperingatan',compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid'));
|
|
}
|
|
|
|
public function blastpertama($kodcaw,$notisid,Request $request)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
|
|
if($request->type == 'whatsapp')
|
|
{
|
|
|
|
$blastwhatsapp = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/notis/blastwasapbysag',
|
|
['kodcaw' => $kodcaw,'notisid' => $notisid, 'namapengguna' => $auth_user['name'],])->json();
|
|
if($blastwhatsapp == 'success'){
|
|
return redirect()->route('arcc.bycawnotisperingatan',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
->with('success','Blast Whatsapp Dalam Proses.');
|
|
}
|
|
elseif($blastwhatsapp == 'failed'){
|
|
return redirect()->route('arcc.bycawnotisperingatan',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
->with('failed','Blast Whatsapp Tidak Berjaya, Sila Semak Semula Rekod Blasted.');
|
|
}
|
|
|
|
}
|
|
elseif($request->type == 'pdf')
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
|
|
return view('callcenter.pdfbycawdetailnotisperingatan', compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid','cawangan_detail','tarikh_cetak'));
|
|
}
|
|
elseif($request->type == 'excel')
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
|
|
return view('callcenter.notisperingatanpertama_excel', compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid','cawangan_detail','tarikh_cetak'));
|
|
}
|
|
return view('callcenter.bycawdetailnotisperingatan',compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid'));
|
|
}
|
|
|
|
public function pelanggan()
|
|
{
|
|
$search = false;
|
|
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$idtype = 'nokp';
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bank')->json();
|
|
if($auth_user->roles == 'admin'){
|
|
return view('admin.customer_index',compact('search','cawangan_info','bank','api_url','idtype','auth_user'));
|
|
}else{
|
|
return view('callcenter.index',compact('search','cawangan_info','bank','api_url','idtype','auth_user'));
|
|
}
|
|
}
|
|
|
|
public function pelanggannew()
|
|
{
|
|
$search = false;
|
|
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$idtype = 'nokp';
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bank')->json();
|
|
if($auth_user->roles == 'admin'){
|
|
return view('admin.customer_index',compact('search','cawangan_info','bank','api_url','idtype','auth_user'));
|
|
}else{
|
|
return view('callcenter.indexnama',compact('search','cawangan_info','bank','api_url','idtype','auth_user'));
|
|
}
|
|
}
|
|
|
|
public function search(Request $request){
|
|
// dd($request->all());
|
|
$noic = $request->noic;
|
|
$idtype = $request->customerIDType;
|
|
$kodcaw = $request->cawangan;
|
|
Session::put('noic', $noic);
|
|
Session::put('kodcaw', $kodcaw);
|
|
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bank')->json();
|
|
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $noic)->json();
|
|
|
|
$request->session()->forget('page_reload');
|
|
$request->session()->forget('norujukan');
|
|
|
|
$search = true;
|
|
|
|
if($customer_info){
|
|
Session::put('customer_info_arcc',$customer_info);
|
|
return redirect()->route('arcc.customer_info', ['customer_info' => $customer_info,'cawangan_info'=>$cawangan_info,'api_url'=>$api_url]);
|
|
}else{
|
|
return redirect()->route('arcc.pelanggan')
|
|
->with('failed','Maaf,Tiada Data Pelanggan...');
|
|
}
|
|
}
|
|
|
|
public function searchnama(Request $request)
|
|
{
|
|
$noic = $request->noic;
|
|
$kodcaw = $request->cawangan;
|
|
Session::put('noic', $noic);
|
|
Session::put('kodcaw', $kodcaw);
|
|
|
|
$api_url = config('api.url');
|
|
|
|
$request->session()->forget('page_reload');
|
|
$request->session()->forget('norujukan');
|
|
|
|
if (empty($noic)) {
|
|
return redirect()->route('arcc.pelanggannew')->with('failed', 'Maaf, Tiada Data Pelanggan...');
|
|
}
|
|
|
|
// ======================
|
|
// 1️⃣ Kalau isi NOIC sahaja
|
|
// ======================
|
|
if ($noic && !$kodcaw) {
|
|
$customersWithGadai = [];
|
|
|
|
// Ambil semua cawangan
|
|
$cawanganList = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/cawangan')
|
|
->json();
|
|
|
|
|
|
if (is_array($cawanganList)) {
|
|
foreach ($cawanganList as $caw) {
|
|
$kod = $caw['kodcaw'];
|
|
|
|
// Check customer di cawangan tu
|
|
$customer = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/customers/' . $noic, ['kodcaw' => $kod])
|
|
->json();
|
|
|
|
|
|
if (!empty($customer)) {
|
|
// Check rekod gadai
|
|
$nokp = !empty($customer['kpbaru']) ? $customer['kpbaru'] : (!empty($customer['kplama']) ? $customer['kplama'] : $noic);
|
|
$gadaiData = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/arcc/rekodgadai', [
|
|
'nokp' => $nokp,
|
|
'kodcaw' => $kod
|
|
])
|
|
->json();
|
|
// dump($gadaiData);
|
|
|
|
if (!empty($gadaiData['data']) && $gadaiData['status'] === true) {
|
|
$customersWithGadai[] = [
|
|
'nama' => $customer['nama'] ?? '-',
|
|
'kpbaru' => $customer['kpbaru'] ?? null,
|
|
'kplama' => $customer['kplama'] ?? null,
|
|
'customer' => $customer,
|
|
'kodcaw' => $kod,
|
|
'nama_cawangan' => $caw['details_caw'] ?? $kod,
|
|
// 'rekod_gadai' => $gadaiData
|
|
|
|
];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// dd(true);
|
|
|
|
// Kalau lebih 1 → pilih pelanggan
|
|
if (count($customersWithGadai) >= 1) {
|
|
Session::put('customer_list', $customersWithGadai);
|
|
return redirect()->route('arcc.pilihpelanggan');
|
|
}
|
|
|
|
return redirect()->route('arcc.pelanggannew')->with('failed', 'Maaf, Tiada Data Pelanggan...');
|
|
}
|
|
|
|
// ======================
|
|
// 2️⃣ Kalau isi NOIC + Cawangan
|
|
// ======================
|
|
if ($noic && $kodcaw) {
|
|
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/customers/' . $noic, ['kodcaw' => $kodcaw])
|
|
->json();
|
|
|
|
// Check sama ada $customer_info bukan null dan ada data penting seperti 'nama' (atau key lain)
|
|
if ($customer_info && !empty($customer_info['nama'])) {
|
|
Session::put('customer_info_arcc', $customer_info);
|
|
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/cawangan/' . $kodcaw)
|
|
->json();
|
|
|
|
return redirect()->route('arcc.customer_info_nama', [
|
|
'customer_info' => $customer_info,
|
|
'cawangan_info' => $cawangan_info,
|
|
'api_url' => $api_url
|
|
]);
|
|
}
|
|
|
|
// Jika tiada data pelanggan di cawangan tu
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Maaf, Tiada Data Pelanggan di cawangan ini.');
|
|
}
|
|
|
|
|
|
// Boleh tambah kes lain (Nama sahaja, Nama + Cawangan) kalau nak
|
|
}
|
|
|
|
public function info(Request $request){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. Session::get('kodcaw'))->json();
|
|
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. Session::get('noic'))->json();
|
|
|
|
$bakilelong = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bakilelong/cawangan/' . Session::get('kodcaw') . '/' . Session::get('noic') . '/baki')->json();
|
|
$rugilelong = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bakilelong/cawangan/' . Session::get('kodcaw') . '/' . Session::get('noic') . '/rugi')->json();
|
|
|
|
$negeri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/negeri/')->json();
|
|
|
|
$request->session()->forget('page_reload');
|
|
$request->session()->forget('norujukan');
|
|
|
|
return view('callcenter.' . $cawangan_info['version'] . '.info',compact('cawangan_info','api_url','customer_info','bakilelong','rugilelong','negeri'));
|
|
}
|
|
|
|
|
|
public function infonama(Request $request)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = Session::get('api_url_arcc', config('api.url'));
|
|
|
|
$cawangan_info = Session::get('cawangan_info_arcc');
|
|
$customer_info = Session::get('customer_info_arcc');
|
|
|
|
// Kalau data kosong, fallback panggil API
|
|
if (!$cawangan_info) {
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/cawangan/' . Session::get('kodcaw'))
|
|
->json();
|
|
}
|
|
if (!$customer_info) {
|
|
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/customers/' . Session::get('noic'))
|
|
->json();
|
|
|
|
$customer_info = $response['data'] ?? [];
|
|
}
|
|
|
|
$bakilelong = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/bakilelong/cawangan/' . Session::get('kodcaw') . '/' . Session::get('noic') . '/baki')
|
|
->json();
|
|
|
|
$rugilelong = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/bakilelong/cawangan/' . Session::get('kodcaw') . '/' . Session::get('noic') . '/rugi')
|
|
->json();
|
|
|
|
$negeri = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/negeri/')
|
|
->json();
|
|
|
|
$request->session()->forget('page_reload');
|
|
$request->session()->forget('norujukan');
|
|
|
|
return view('callcenter.' . $cawangan_info['version'] . '.info', compact(
|
|
'cawangan_info',
|
|
'api_url',
|
|
'customer_info',
|
|
'bakilelong',
|
|
'rugilelong',
|
|
'negeri'
|
|
));
|
|
}
|
|
|
|
public function notisperingatankedua(Request $request){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
|
|
return view('callcenter.notisperingatankedua',compact('cawangan_info','api_url'));
|
|
}
|
|
|
|
|
|
public function kemaskininotisperingatan($notisid)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
|
|
$detailnotis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotiskemaskini/'.$notisid)->json();
|
|
foreach($detailnotis as $index=>$info)
|
|
{
|
|
$kemaskininotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/arcc/kemaskininotisperingatan', [
|
|
'kodcaw' => $info['kodcaw'],
|
|
'notisid' => $notisid
|
|
])->json();
|
|
}
|
|
if($kemaskininotisperingatan == 'success'){
|
|
return redirect()->route('arcc.detailnotisperingatan',['notisid' => $notisid])
|
|
->with('success','Data Telah Dikemaskini.');
|
|
}elseif($kemaskininotisperingatan == 'failed'){
|
|
return redirect()->route('arcc.detailnotisperingatan',['notisid' => $notisid])
|
|
->with('failed','Data Tidak Dikemaskini. Sila Semak Semula...');
|
|
}
|
|
return view('callcenter.detailnotisperingatan',compact('detailnotis','senarai','notisid'));
|
|
}
|
|
|
|
public function cariansagnotiskedua(Request $request)
|
|
{
|
|
// dd($request->all());
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$fasa = $request->fasa;
|
|
|
|
$notis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/cariannotiskedua',[
|
|
'fasa' => $fasa
|
|
])->json();
|
|
|
|
|
|
return redirect()->route('arcc.notisperingatankedua')->with('success','Berjaya Daftar Notis Peringatan Kedua.');
|
|
}
|
|
|
|
public function rekodnotisperingatankedua()
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$arrayinfo = [];
|
|
|
|
// $notis = Notis::select('tarikh_notis','id')
|
|
// ->groupBy('tarikh_notis')
|
|
// ->get();
|
|
$notis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/senarainotisperingatankedua')->json();
|
|
// dd($notis);
|
|
foreach($notis as $info)
|
|
{
|
|
$getcawnotis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotis/'.$info['id'])->json();
|
|
|
|
array_push($arrayinfo, ['info'=> $info,'cawnotis' => $getcawnotis]);
|
|
}
|
|
// dd($arrayinfo);
|
|
return view('callcenter.rekodnotisperingatankedua',compact('notis','arrayinfo'));
|
|
}
|
|
|
|
public function detailnotisperingatankedua($notisid)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
|
|
$detailnotis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotis/'.$notisid)->json();
|
|
foreach($detailnotis as $info)
|
|
{
|
|
$getcawnotiskeduabycaw = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotiskeduabycaw', [
|
|
'kodcaw' => $info[0]['kodcaw'],
|
|
'notisid' => $notisid
|
|
])->json();
|
|
|
|
$data = [
|
|
'detailnotis' => $info ? $info : '',
|
|
'getcawnotisbycaw' => $getcawnotiskeduabycaw ? $getcawnotiskeduabycaw : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
return view('callcenter.detailnotisperingatankedua',compact('detailnotis','senarai','notisid'));
|
|
}
|
|
|
|
public function bycawnotisperingatankedua($kodcaw,$notisid, Request $request)
|
|
{
|
|
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisperingatankedua = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatankedua/'.$kodcaw.'/'.$notisid)->json();
|
|
|
|
// if($request->type == 'whatsapp')
|
|
// {
|
|
|
|
// $blastwhatsapp = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/blastwasapbysag/'.$auth_user['cawangan'],
|
|
// ['kodcaw' => $kodcaw,'notisid' => $notisid, 'namapengguna' => $auth_user['name'],])->json();
|
|
// if($blastwhatsapp == 'success'){
|
|
// return redirect()->route('arcc.bycawnotisperingatankedua',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
// ->with('success','Blast Whatsapp Dalam Proses.');
|
|
// }
|
|
// elseif($blastwhatsapp == 'failed'){
|
|
// return redirect()->route('arcc.bycawnotisperingatankedua',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
// ->with('failed','Blast Whatsapp Tidak Berjaya, Sila Semak Semula Rekod Blasted.');
|
|
// }
|
|
|
|
// }
|
|
|
|
return view('callcenter.bycawdetailnotisperingatankedua',compact('cawangan_info','bycawnotisperingatankedua','kodcaw','notisid','api_url'));
|
|
}
|
|
|
|
public function blastkedua($kodcaw,$notisid,Request $request)
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisperingatankedua = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatankedua/'.$kodcaw.'/'.$notisid)->json();
|
|
if($request->type == 'whatsapp')
|
|
{
|
|
|
|
$blastwhatsappkedua = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/notis/blastwasapbysagkedua',
|
|
['kodcaw' => $kodcaw,'notisid' => $notisid, 'namapengguna' => $auth_user['name'],])->json();
|
|
if($blastwhatsappkedua == 'success'){
|
|
return redirect()->route('arcc.bycawnotisperingatankedua',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
->with('success','Blast Whatsapp Dalam Proses.');
|
|
}
|
|
elseif($blastwhatsappkedua == 'failed'){
|
|
return redirect()->route('arcc.bycawnotisperingatankedua',['kodcaw' => $kodcaw, 'notisid' => $notisid])
|
|
->with('failed','Blast Whatsapp Tidak Berjaya, Sila Semak Semula Rekod Blasted.');
|
|
}
|
|
|
|
}
|
|
elseif($request->type == 'pdf')
|
|
{
|
|
if($request->fasa == 1)
|
|
{
|
|
$datanotiskedua = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getdatanotiskedua/'. $kodcaw.'/'.$notisid. '/' . 'fasa1')->json();
|
|
$fasa = 'fasa1';
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
|
|
// return view('print.notislelong', compact('cawangan_info','notislelong','api_url','cawangan_detail','lelong','tarikh_cetak'));
|
|
// dd($datanotiskedua);
|
|
$pdf=PDF::loadView('callcenter.suratnotisperingatankeduafasa1', compact('cawangan_info','api_url','cawangan_detail','datanotiskedua','fasa','tarikh_cetak'))->setPaper('A4','potrait');
|
|
return $pdf->download('notisperingatankedua_'.$tarikh_cetak.'_'.$fasa.'.pdf');
|
|
}else{
|
|
// dd(false);
|
|
$datanotiskedua = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getdatanotiskedua/'. $kodcaw.'/'.$notisid. '/' . 'fasa2')->json();
|
|
$fasa = 'fasa2';
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
|
|
// return view('print.notislelong', compact('cawangan_info','notislelong','api_url','cawangan_detail','lelong','tarikh_cetak'));
|
|
// dd($datanotiskedua);
|
|
$pdf=PDF::loadView('callcenter.suratnotisperingatankeduafasa2', compact('cawangan_info','api_url','cawangan_detail','datanotiskedua','fasa','tarikh_cetak'))->setPaper('A4','potrait');
|
|
return $pdf->download('notisperingatankedua_'.$tarikh_cetak.'_'.$fasa.'.pdf');
|
|
}
|
|
|
|
|
|
}
|
|
elseif($request->type == 'pdflist')
|
|
{
|
|
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
$bycawnotisperingatankedua = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatankedua/'.$kodcaw.'/'.$notisid)->json();
|
|
|
|
return view('callcenter.pdfbycawdetailnotisperingatankedua', compact('cawangan_info','bycawnotisperingatankedua','kodcaw','notisid','cawangan_detail','tarikh_cetak'));
|
|
|
|
}
|
|
return view('callcenter.bycawdetailnotisperingatankedua',compact('cawangan_info','bycawnotisperingatankedua','kodcaw','notisid','api_url'));
|
|
}
|
|
|
|
|
|
public function kemaskininotisperingatankedua($notisid)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
|
|
$detailnotis = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotiskemaskini/'.$notisid)->json();
|
|
foreach($detailnotis as $info)
|
|
{
|
|
$kemaskininotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/arcc/kemaskininotisperingatan', [
|
|
'kodcaw' => $info['kodcaw'],
|
|
'notisid' => $notisid
|
|
])->json();
|
|
}
|
|
if($kemaskininotisperingatan == 'success'){
|
|
return redirect()->route('arcc.detailnotisperingatankedua',['notisid' => $notisid])
|
|
->with('success','Data Telah Dikemaskini.');
|
|
}elseif($kemaskininotisperingatan == 'failed'){
|
|
return redirect()->route('arcc.detailnotisperingatan',['notisid' => $notisid])
|
|
->with('failed','Data Tidak Dikemaskini. Sila Semak Semula...');
|
|
}
|
|
return view('callcenter.detailnotisperingatankedua',compact('detailnotis','senarai','notisid'));
|
|
}
|
|
|
|
public function kemaskininotisperingatanbycaw($kodcaw,$notisid)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
|
|
$kemaskininotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/arcc/kemaskininotisperingatan', [
|
|
'kodcaw' => $kodcaw,
|
|
'notisid' => $notisid
|
|
])->json();
|
|
if($kemaskininotisperingatan == 'success'){
|
|
return view('callcenter.bycawdetailnotisperingatan',compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid'));
|
|
// return redirect()->route('arcc.detailnotisperingatan',['notisid' => $notisid])
|
|
// ->with('success','Data Telah Dikemaskini.');
|
|
}elseif($kemaskininotisperingatan == 'failed'){
|
|
return redirect()->route('arcc.detailnotisperingatan',['notisid' => $notisid])
|
|
->with('failed','Data Tidak Dikemaskini. Sila Semak Semula...');
|
|
}
|
|
|
|
// return view('callcenter.bycawdetailnotisperingatan',compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid'));
|
|
}
|
|
|
|
public function kemaskininotisperingatankeduabycaw($kodcaw,$notisid)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisperingatankedua = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatankedua/'.$kodcaw.'/'.$notisid)->json();
|
|
$kemaskininotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/arcc/kemaskininotisperingatan', [
|
|
'kodcaw' => $kodcaw,
|
|
'notisid' => $notisid
|
|
])->json();
|
|
if($kemaskininotisperingatan == 'success'){
|
|
return view('callcenter.bycawdetailnotisperingatankedua',compact('cawangan_info','bycawnotisperingatankedua','kodcaw','notisid','api_url'));
|
|
}elseif($kemaskininotisperingatan == 'failed'){
|
|
return redirect()->route('arcc.detailnotisperingatankedua',['notisid' => $notisid])
|
|
->with('failed','Data Tidak Dikemaskini. Sila Semak Semula...');
|
|
}
|
|
}
|
|
|
|
public function notisJbg(){
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$caw = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
//dd('sini');
|
|
return view('callcenter.cariangadaian',compact('api_url','caw'));
|
|
}
|
|
|
|
public function carianJbg(Request $request){
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$jbgmula = $request->jbgmula;
|
|
$jbghingga = $request->jbghingga;
|
|
$tprint = $current->toDateString();
|
|
|
|
$caw_all = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/cawangan/')->json();
|
|
$senarai = [];
|
|
foreach($caw_all as $cwgn)
|
|
{
|
|
$kodcaw = $cwgn['kodcaw'];
|
|
$datagadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/arcc/gadaian/'.$kodcaw,[
|
|
'jbgmula' => $request->jbgmula,
|
|
'jbghingga' => $request->jbghingga,
|
|
])->json();
|
|
|
|
$data = [
|
|
'kodcaw'=>$cwgn['kodcaw'],
|
|
'caw_name'=>$cwgn['details_caw'],
|
|
'datagadai'=>$datagadai ? $datagadai : '',
|
|
];
|
|
array_push($senarai,$data);
|
|
}
|
|
// dd(1);
|
|
return view('callcenter.gadaianjbg', compact('kodcaw','senarai','jbgmula','jbghingga'));
|
|
}
|
|
|
|
public function janadatanotisjbg(Request $request){
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$currentNow = Carbon::now();
|
|
$senarai = [];
|
|
$tarikh_savedaftarnotis = $current->toDateString();
|
|
$jbgmula = $request->jbgmula;
|
|
$jbghingga = $request->jbghingga;
|
|
$kodcaw = $request->kodcaw;
|
|
$selected_caw = $request->caw;
|
|
// dd($selected_caw);
|
|
|
|
$getbatchnotisjbg=Http::withOptions(['verify' => config('app.api_verify')])->get( config('api.url').'/arcc/getbatchnotisjbg',[
|
|
'jbgmula' => $jbgmula,
|
|
'jbghingga' => $jbghingga,
|
|
])->json();
|
|
|
|
$newbatchnotis=$getbatchnotisjbg;
|
|
|
|
if(!empty($selected_caw))
|
|
{
|
|
foreach($selected_caw as $index=>$caw){
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $caw)->json();
|
|
// dd($cawangan_info);
|
|
$insertdatagadai = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/arcc/insertdatagadaijbg/'.$caw ,[
|
|
'jbgmula' => $jbgmula,
|
|
'jbghingga' => $jbghingga,
|
|
'kodcaw' => $caw,
|
|
'notisid' => $newbatchnotis
|
|
])->json();
|
|
|
|
$data = [
|
|
'kodcaw'=>$caw,
|
|
'caw_name'=>$cawangan_info['details_caw'],
|
|
'datagadai' => $insertdatagadai ? $insertdatagadai : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
}
|
|
return redirect()->route('arcc.notisjbg')->with('success','Berjaya Daftar Notis Jbg.');
|
|
}
|
|
|
|
public function rekodnotisjbg(){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$arrayinfo = [];
|
|
|
|
// $notis = Notis::select('tarikh_notis','id')
|
|
// ->groupBy('tarikh_notis')
|
|
// ->get();
|
|
$notisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/senarainotisjbg')->json();
|
|
// dd($notisjbg);
|
|
foreach($notisjbg as $info)
|
|
{
|
|
$getcawnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotisjbg/'.$info['id'])->json();
|
|
|
|
array_push($arrayinfo, ['info'=> $info,'cawnotis' => $getcawnotisjbg]);
|
|
}
|
|
// dd($arrayinfo);
|
|
return view('callcenter.rekodnotisjbg',compact('notisjbg','arrayinfo'));
|
|
}
|
|
|
|
public function detailnotisjbg(Request $request){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
|
|
$senarai = [];
|
|
$notisid = $request->notisid;
|
|
|
|
$detailnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotisjbg/'.$notisid)->json();
|
|
//dd($detailnotisjbg[0]);
|
|
foreach($detailnotisjbg as $info)
|
|
{
|
|
$getcawnotisjbgbycaw = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/getcawnotisjbgbycaw', [
|
|
'kodcaw' => $info[0]['kodcaw'],
|
|
'notisid' => $notisid
|
|
])->json();
|
|
//dd($getcawnotisjbgbycaw);
|
|
$data = [
|
|
// 'kodcaw'=>$info[0]['kodcaw'],
|
|
// 'caw_name'=>$info[0]['details_caw'],
|
|
'getcawnotisjbgbycaw' => $getcawnotisjbgbycaw ? $getcawnotisjbgbycaw : '',
|
|
];
|
|
|
|
array_push($senarai,$data);
|
|
}
|
|
|
|
return view('callcenter.detailnotisjbg',compact('detailnotisjbg','senarai','notisid'));
|
|
}
|
|
|
|
public function bycawnotisjbg($kodcaw,$notisid, Request $request)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisjbg/'.$kodcaw.'/'.$notisid)->json();
|
|
|
|
return view('callcenter.bycawdetailnotisjbg',compact('cawangan_info','bycawnotisjbg','kodcaw','notisid'));
|
|
}
|
|
|
|
public function detsagcallbyjbg($kodcaw, $notisid, $id)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bysagnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/arcc/bysagnotisjbg/'.$kodcaw.'/'.$notisid.'/'.$id)->json();
|
|
$bysagnotisjbgCustomer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/arcc/bysagnotisjbgcustomer/'.$kodcaw.'/'.$notisid.'/'.$id)->json();
|
|
return view('callcenter.callnotisjbg',compact('cawangan_info','bysagnotisjbg','bysagnotisjbgCustomer'));
|
|
}
|
|
|
|
public function bycawnotisjbg2($kodcaw,$notisid, Request $request)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisjbg2/'.$kodcaw.'/'.$notisid)->json();
|
|
return view('callcenter.bycawdetailnotisjbg2',compact('cawangan_info','bycawnotisjbg','kodcaw','notisid'));
|
|
}
|
|
|
|
public function detsagcallbyjbg2($kodcaw, $notisid, $nokp)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bysagnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/arcc/bysagnotisjbg2/'.$kodcaw.'/'.$notisid.'/'.$nokp)->json();
|
|
$bysagnotisjbgCustomer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/arcc/bysagnotisjbgcustomer2/'.$kodcaw.'/'.$notisid.'/'.$nokp)->json();
|
|
return view('callcenter.callnotisjbg2',compact('cawangan_info','bysagnotisjbg','bysagnotisjbgCustomer','kodcaw','notisid','nokp','api_url'));
|
|
}
|
|
|
|
public function printnotiscall($kodcaw,$notisid,Request $request)
|
|
{
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$bycawnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisjbg2/'.$kodcaw.'/'.$notisid)->json();
|
|
|
|
if($request->type == 'pdflist')
|
|
{
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $kodcaw)->json();
|
|
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
$bycawnotisjbg = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisjbg2/'.$kodcaw.'/'.$notisid)->json();
|
|
|
|
return view('callcenter.pdfbycawdetailnotisjbg2', compact('cawangan_info','bycawnotisjbg','kodcaw','notisid','cawangan_detail','tarikh_cetak'));
|
|
}
|
|
return view('callcenter.bycawdetailnotisjbg2',compact('cawangan_info','bycawnotisjbg','kodcaw','notisid','api_url'));
|
|
}
|
|
|
|
public function history(Request $request)
|
|
{
|
|
$auth_user = Auth::user();
|
|
|
|
$norujukan = $request->norujukan;
|
|
$gadai = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get(config('api.url') . '/api/gadai/norujukan/' . $norujukan)
|
|
->json();
|
|
|
|
$arrayhist = [];
|
|
|
|
if (sizeof($gadai) > 0) {
|
|
$history = $gadai[0][0]['historygadaian'];
|
|
$dahtebus = $gadai[0][0]['sttebus'];
|
|
$kodcaw = $gadai[0][0]['kodcaw'];
|
|
// Kalau belum ada history, ambil rekod asal sahaja
|
|
if ($dahtebus == 'T') {
|
|
|
|
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get(config('api.url') . '/api/listpenebusanhistory/' . $kodcaw, [
|
|
'norujukan' => $norujukan
|
|
])
|
|
->json();
|
|
|
|
$tebus = collect($tebusList)->firstWhere('norujukan', $norujukan);
|
|
|
|
$arrayhist[] = [
|
|
"tagbaru" => $gadai[0][0]['tagbaru'] ?? 0,
|
|
"hargajualan" => $gadai[0][0]['hargajualan'] ?? '',
|
|
"pinjaman" => $tebus['pinjaman'] ?? 0,
|
|
"norujukan" => $norujukan,
|
|
"jenistebus" => $tebus['jenistebus'] ?? 0,
|
|
"jbg" => $tebus['jbg'] ?? 0,
|
|
"t_tebus" => $tebus['t_tebus'] ?? 0,
|
|
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
|
|
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
|
|
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
|
|
"trans_type" => $tebus['trans_type'] ?? 0,
|
|
];
|
|
} else {
|
|
// Loop ke belakang (rekod lepas-lepas)
|
|
while ($history != "0" && $history != '') {
|
|
$prevGadai = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get(config('api.url') . '/api/gadai/norujukan/' . $history)
|
|
->json();
|
|
|
|
$prevKodcaw = $prevGadai[0][0]['kodcaw'] ?? null;
|
|
|
|
if (!$prevKodcaw) break;
|
|
|
|
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get(config('api.url') . '/api/listpenebusanhistory/' . $prevKodcaw, [
|
|
'norujukan' => $history
|
|
])
|
|
->json();
|
|
|
|
$tebus = collect($tebusList)->firstWhere('norujukan', $history);
|
|
|
|
$arrayhist[] = [
|
|
"tagbaru" => $prevGadai[0][0]['tagbaru'] ?? 0,
|
|
"hargajualan" => $prevGadai[0][0]['hargajualan'] ?? '',
|
|
"pinjaman" => $tebus['pinjaman'] ?? 0,
|
|
"norujukan" => $history,
|
|
"jenistebus" => $tebus['jenistebus'] ?? 0,
|
|
"jbg" => $tebus['jbg'] ?? 0,
|
|
"t_tebus" => $tebus['t_tebus'] ?? 0,
|
|
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
|
|
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
|
|
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
|
|
"trans_type" => $tebus['trans_type'] ?? 0,
|
|
];
|
|
|
|
$nextHistory = $prevGadai[0][0]['historygadaian'] ?? '0';
|
|
|
|
// Elakkan infinite loop
|
|
if ($nextHistory == $history) {
|
|
break;
|
|
}
|
|
|
|
$history = $nextHistory;
|
|
}
|
|
}
|
|
}
|
|
|
|
return response()->json($arrayhist,200);
|
|
}
|
|
|
|
public function tukaranhargaemas($norujukan)
|
|
{
|
|
|
|
$marhunsaglama = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/marhun/'. $norujukan)->json();
|
|
|
|
$marhunsaglama = $marhunsaglama[0];
|
|
$totalnilaimarhun = 0;
|
|
|
|
foreach($marhunsaglama as $index=>$marhunloop)
|
|
{
|
|
$karatbaru = str_replace('.','-',$marhunloop['karat']);
|
|
$hargabaru = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/harga_emas/'. $karatbaru)->json();
|
|
|
|
$nilaimarhun = (floatval($hargabaru['harga']) * floatval($marhunloop['berat']));
|
|
|
|
$totalnilaimarhun += $nilaimarhun;
|
|
}
|
|
|
|
return $totalnilaimarhun;
|
|
}
|
|
|
|
public function tanyaupah($norujukan){
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. Session::get('kodcaw'))->json();
|
|
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. Session::get('noic'))->json();
|
|
|
|
$gadaidetail = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $norujukan)->json();
|
|
$noic = $gadaidetail[0][0]['nokp'];
|
|
$customerdetail = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $noic)->json();
|
|
$marhundetail = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/marhun/'. $norujukan)->json();
|
|
|
|
$marhun = $marhundetail[0];
|
|
$nama = $customerdetail['nama'];
|
|
|
|
$gadai = $gadaidetail[0][0];
|
|
|
|
$nilaihargasemasa = $this->tukaranhargaemas($norujukan);
|
|
|
|
$pertambahpinjaman = 0.80;
|
|
return view('callcenter.' . $cawangan_info['version'] . '.index',compact('cawangan_info','api_url','gadai','marhun','nama','nilaihargasemasa','pertambahpinjaman'));
|
|
}
|
|
|
|
|
|
public function pilihPelanggan()
|
|
{
|
|
if (!Session::has('customer_list')) {
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Tiada pelanggan untuk dipilih.');
|
|
}
|
|
|
|
$kodcaw = Session::get('kodcaw'); // Ambil dari sesi
|
|
|
|
$cawangan_info = null;
|
|
|
|
// Kalau kodcaw ada, baru ambil cawangan_info
|
|
if ($kodcaw) {
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get(config('api.url') . '/api/cawangan/' . $kodcaw)
|
|
->json();
|
|
// dd($cawangan_info );
|
|
}
|
|
|
|
return view('callcenter.pilihpelanggan', compact('cawangan_info'));
|
|
}
|
|
|
|
|
|
|
|
public function pilihPelangganProceed(Request $request)
|
|
{
|
|
$customerData = $request->input('customer');
|
|
$kodcaw = $request->input('kodcaw');
|
|
|
|
if ($customerData) {
|
|
$customer = json_decode(base64_decode($customerData), true);
|
|
|
|
// Merge data penuh supaya flat & senang guna di Blade
|
|
$customer_info = array_merge(
|
|
$customer['customer'] ?? $customer, // kalau ada sub-array 'customer', ambil dia
|
|
[
|
|
'kodcaw' => $customer['kodcaw'] ?? $kodcaw,
|
|
'nama_cawangan' => $customer['nama_cawangan'] ?? '',
|
|
]
|
|
);
|
|
|
|
// Simpan dalam session
|
|
Session::put('customer_info_arcc', $customer_info);
|
|
Session::put('kodcaw', $kodcaw);
|
|
Session::put('noic', $customer_info['kpbaru'] ?? $customer_info['kplama']);
|
|
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/cawangan/' . $kodcaw)->json();
|
|
|
|
// Simpan juga dalam session
|
|
Session::put('cawangan_info_arcc', $cawangan_info);
|
|
Session::put('api_url_arcc', $api_url);
|
|
|
|
return redirect()->route('arcc.customer_info');
|
|
}
|
|
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Pelanggan tidak sah dipilih.');
|
|
}
|
|
|
|
public function ajaxSearchCustomer(Request $request)
|
|
{
|
|
$search = strtolower($request->query('search', ''));
|
|
$customers = collect(session('customer_list', []))
|
|
->filter(function ($customer) use ($search) {
|
|
return strpos(strtolower($customer['nama']), $search) !== false ||
|
|
strpos(strtolower($customer['nokp']), $search) !== false;
|
|
});
|
|
|
|
return view('callcenter.partials.customertable', ['customers' => $customers])->render();
|
|
}
|
|
public function cariannama(Request $request)
|
|
{
|
|
$nama = $request->nama;
|
|
$api_url = config('api.url');
|
|
|
|
if (empty($nama)) {
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Maaf, Tiada Data Pelanggan...');
|
|
}
|
|
|
|
session(['last_search' => $request->all()]);
|
|
|
|
// Clear session lama
|
|
$request->session()->forget(['page_reload', 'norujukan']);
|
|
|
|
// 1. Call API carian nama
|
|
$customers = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/customers', ['nama' => $nama])
|
|
->json();
|
|
|
|
|
|
if (!is_array($customers) || empty($customers)) {
|
|
return redirect()->route('arcc.pelanggannew')->with('failed', 'Tiada pelanggan dijumpai.');
|
|
}
|
|
|
|
// 2. Ambil senarai cawangan
|
|
$cawanganList = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/cawangan')
|
|
->json();
|
|
|
|
if (!is_array($cawanganList) || empty($cawanganList)) {
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Tiada senarai cawangan.');
|
|
}
|
|
|
|
// 3. Kumpul semua IC (kpbaru / kplama) dari senarai customer
|
|
$nokpList = collect($customers)
|
|
->map(function ($customer) {
|
|
return $customer['kpbaru'] ?? $customer['kplama'] ?? null;
|
|
})
|
|
->filter()
|
|
->unique()
|
|
->values()
|
|
->toArray();
|
|
|
|
|
|
$customersWithGadai = collect();
|
|
|
|
foreach ($cawanganList as $caw) {
|
|
$kod = $caw['kodcaw'];
|
|
|
|
$response = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->post($api_url . '/arcc/rekodgadai-batch', [
|
|
'nokp_list' => $nokpList,
|
|
'kodcaw' => $kod
|
|
]);
|
|
|
|
if ($response->failed()) {
|
|
continue;
|
|
}
|
|
|
|
$data = $response->json();
|
|
|
|
if (!empty($data['data']) && is_array($data['data'])) {
|
|
foreach ($data['data'] as $rekod) {
|
|
$customer = collect($customers)->first(function ($c) use ($rekod) {
|
|
return ($c['kpbaru'] ?? $c['kplama']) === $rekod['nokp'];
|
|
});
|
|
|
|
if ($customer) {
|
|
$customersWithGadai->put(
|
|
$customer['kpbaru'] ?? $customer['kplama'], // guna IC as key
|
|
[
|
|
'nama' => $customer['nama'] ?? '-',
|
|
'kpbaru' => $customer['kpbaru'] ?? null,
|
|
'kplama' => $customer['kplama'] ?? null,
|
|
'customer' => $customer,
|
|
'kodcaw' => $kod,
|
|
'nama_cawangan' => $caw['details_caw'] ?? $kod
|
|
]
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$customersWithGadai = $customersWithGadai
|
|
->sortBy('nama') // sort ikut nama A→Z
|
|
->values(); // reset key semula
|
|
|
|
|
|
// 5. Return ikut result
|
|
if ($customersWithGadai->count() > 1) {
|
|
Session::put('customer_list', $customersWithGadai);
|
|
return redirect()->route('arcc.pilihpelanggannama');
|
|
} elseif ($customersWithGadai->count() === 1) {
|
|
$singleCustomer = $customersWithGadai->first();
|
|
Session::put('customer_info_arcc', $singleCustomer['customer']);
|
|
|
|
return redirect()->route('arcc.customer_info', [
|
|
'customer_info' => $singleCustomer['customer'],
|
|
'cawangan_info' => [
|
|
'kodcaw' => $singleCustomer['kodcaw'],
|
|
'nama_cawangan' => $singleCustomer['nama_cawangan']
|
|
],
|
|
'api_url' => $api_url
|
|
]);
|
|
}
|
|
|
|
return redirect()->route('arcc.pelanggannew')->with('failed', 'Tiada pelanggan dengan rekod gadai.');
|
|
}
|
|
|
|
public function pilihPelanggannama()
|
|
{
|
|
if (!Session::has('customer_list')) {
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Tiada pelanggan untuk dipilih.');
|
|
}
|
|
|
|
$kodcaw = Session::get('kodcaw'); // Ambil dari sesi
|
|
|
|
$cawangan_info = null;
|
|
|
|
// Kalau kodcaw ada, baru ambil cawangan_info
|
|
if ($kodcaw) {
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get(config('api.url') . '/api/cawangan/' . $kodcaw)
|
|
->json();
|
|
// dd($cawangan_info );
|
|
}
|
|
|
|
return view('callcenter.pilihpelanggannama', compact('cawangan_info'));
|
|
}
|
|
|
|
public function pilihPelangganProceednama(Request $request)
|
|
{
|
|
$customerData = $request->input('customer');
|
|
$kodcaw = $request->input('kodcaw');
|
|
|
|
if ($customerData) {
|
|
$customer = json_decode(base64_decode($customerData), true);
|
|
|
|
// Merge data penuh supaya flat & senang guna di Blade
|
|
$customer_info = array_merge(
|
|
$customer['customer'] ?? $customer, // kalau ada sub-array 'customer', ambil dia
|
|
[
|
|
'kodcaw' => $customer['kodcaw'] ?? $kodcaw,
|
|
'nama_cawangan' => $customer['nama_cawangan'] ?? '',
|
|
]
|
|
);
|
|
|
|
// Simpan dalam session
|
|
Session::put('customer_info_arcc', $customer_info);
|
|
Session::put('kodcaw', $kodcaw);
|
|
Session::put('noic', $customer_info['kpbaru'] ?? $customer_info['kplama']);
|
|
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
|
->get($api_url . '/api/cawangan/' . $kodcaw)->json();
|
|
|
|
// Simpan juga dalam session
|
|
Session::put('cawangan_info_arcc', $cawangan_info);
|
|
Session::put('api_url_arcc', $api_url);
|
|
|
|
return redirect()->route('arcc.customer_info');
|
|
}
|
|
|
|
return redirect()->route('arcc.pelanggan')->with('failed', 'Pelanggan tidak sah dipilih.');
|
|
}
|
|
}
|