tambah carian nama arcc
This commit is contained in:
@@ -338,50 +338,154 @@ class CallCenterController extends Controller
|
||||
}
|
||||
|
||||
public function search(Request $request){
|
||||
// dd($request->all());
|
||||
$noic = $request->noic;
|
||||
$nama = $request->nama;
|
||||
$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...');
|
||||
// Simpan ke session hanya jika ada input
|
||||
if ($noic) {
|
||||
Session::put('noic', $noic);
|
||||
}
|
||||
if ($kodcaw) {
|
||||
Session::put('kodcaw', $kodcaw);
|
||||
}
|
||||
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
|
||||
// Dapatkan maklumat cawangan jika kodcaw ada
|
||||
$cawangan_info = null;
|
||||
if ($kodcaw) {
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/cawangan/' . $kodcaw)
|
||||
->json();
|
||||
}
|
||||
|
||||
// Dapatkan senarai bank (jika perlu)
|
||||
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/api/bank')->json();
|
||||
|
||||
// Bersihkan session yang tidak perlu
|
||||
$request->session()->forget('page_reload');
|
||||
$request->session()->forget('norujukan');
|
||||
|
||||
$customer_info = null;
|
||||
|
||||
// Cari ikut IC jika diisi
|
||||
if ($noic) {
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customers/' . $noic)
|
||||
->json();
|
||||
}
|
||||
|
||||
// Kalau nama diberi & IC tidak jumpa
|
||||
elseif ($nama) {
|
||||
$queryParams = ['nama' => $nama];
|
||||
if ($kodcaw) {
|
||||
$queryParams['kodcaw'] = $kodcaw;
|
||||
}
|
||||
|
||||
$response = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customers', $queryParams);
|
||||
|
||||
if ($response->successful()) {
|
||||
$customers = $response->json();
|
||||
|
||||
// Jika lebih dari satu pelanggan dijumpai
|
||||
if (is_array($customers) && count($customers) > 1) {
|
||||
Session::put('customer_list', $customers);
|
||||
return redirect()->route('arcc.pilihpelanggan');
|
||||
}
|
||||
|
||||
// Jika satu pelanggan dijumpai
|
||||
$customer_info = $customers[0] ?? null;
|
||||
} else {
|
||||
logger('API carian nama gagal: ' . $response->body());
|
||||
}
|
||||
}
|
||||
|
||||
// Jika berjaya jumpa pelanggan
|
||||
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
|
||||
]);
|
||||
}
|
||||
|
||||
// Gagal jumpa pelanggan
|
||||
return redirect()->route('arcc.pelanggan')
|
||||
->with('failed', 'Maaf, Tiada Data Pelanggan...');
|
||||
}
|
||||
|
||||
public function info(Request $request){
|
||||
$auth_user = Auth::user();
|
||||
|
||||
|
||||
public function info(Request $request)
|
||||
{
|
||||
$customer = $request->input('customer_info');
|
||||
|
||||
if (!$customer || !isset($customer['kodcaw'])) {
|
||||
return redirect()->route('arcc.pelanggan')->with('failed', 'Maklumat pelanggan tidak lengkap.');
|
||||
}
|
||||
|
||||
$kodcaw = $customer['kodcaw'];
|
||||
$nokp = $customer['kpbaru'] ?? $customer['kplama'] ?? null;
|
||||
|
||||
if (!$nokp) {
|
||||
return redirect()->route('arcc.pelanggan')->with('failed', 'No KP pelanggan tidak dijumpai.');
|
||||
}
|
||||
|
||||
Session::put('noic', $nokp);
|
||||
|
||||
$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();
|
||||
// Maklumat cawangan
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/cawangan/' . $kodcaw)
|
||||
->json();
|
||||
|
||||
$negeri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/negeri/')->json();
|
||||
if (!isset($cawangan_info['version'])) {
|
||||
return redirect()->route('arcc.pelanggan')->with('failed', 'Maklumat cawangan tidak dijumpai.');
|
||||
}
|
||||
|
||||
// Maklumat pelanggan
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customers/' . $nokp)
|
||||
->json();
|
||||
|
||||
if (!$customer_info || isset($customer_info['error'])) {
|
||||
return redirect()->route('arcc.pelanggan')->with('failed', 'Pelanggan tidak wujud dalam sistem.');
|
||||
}
|
||||
|
||||
// Data lelong
|
||||
$bakilelong = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/bakilelong/cawangan/' . $kodcaw . '/' . $nokp . '/baki')
|
||||
->json();
|
||||
|
||||
$rugilelong = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/bakilelong/cawangan/' . $kodcaw . '/' . $nokp . '/rugi')
|
||||
->json();
|
||||
|
||||
// Negeri
|
||||
$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'));
|
||||
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');
|
||||
@@ -966,4 +1070,67 @@ class CallCenterController extends Controller
|
||||
$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');
|
||||
|
||||
|
||||
if ($customerData) {
|
||||
$customer = json_decode(base64_decode($customerData), true);
|
||||
$kodcaw = $customer['kodcaw'];
|
||||
Session::put('customer_info_arcc', $customer);
|
||||
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/cawangan/' . $kodcaw)->json();
|
||||
|
||||
return redirect()->route('arcc.customer_info', [
|
||||
'customer_info' => $customer,
|
||||
'cawangan_info' => $cawangan_info,
|
||||
'api_url' => $api_url
|
||||
]);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,16 @@
|
||||
<div class="card-body">
|
||||
<div class="text-center">
|
||||
<h5 class="text-uppercase">Pilih Cawangan Dan Masukkan nombor kad pengenalan</h5>
|
||||
<form name="frmsearch" onsubmit="verifynokp()" action="{{ route('arcc.searchpelanggan') }}" method="GET">
|
||||
<form name="frmsearch" onsubmit="return verifynokp(event)" action="{{ route('arcc.searchpelanggan') }}" method="GET">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-9">
|
||||
<div class="input-group my-3">
|
||||
<div class='col-md-4'>
|
||||
<!-- Cawangan dropdown tetap sama -->
|
||||
<div class="col-md-4">
|
||||
@php
|
||||
$cawangan_all = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/arcc/cawangan')->json();
|
||||
@endphp
|
||||
<select class="form-control" name="cawangan" data-placeholder="Pilih Cawangan" id="cawangan">
|
||||
<select class="form-control" name="cawangan" id="cawangan">
|
||||
<option disabled selected value>--Cawangan--</option>
|
||||
@foreach($cawangan_all as $cawangan)
|
||||
<option value="{{ $cawangan['kodcaw'] }}">{{ $cawangan['details_caw'] }}</option>
|
||||
@@ -38,20 +39,28 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- KP atau Passport -->
|
||||
<input type="text" class="form-control" id="noic" name="noic" placeholder="No.KP/Passport"
|
||||
value="{{ $search == false ? '' : $noic ?? '' }}" autocomplete="off">
|
||||
|
||||
<input type="text" class="form-control" id="noic" name="noic" placeholder="No.KP Pelanggan" aria-label="No Kad Pengenalan Pelanggan" autocomplete="off" value="{{$search == false ? '' : $noic ?? ''}}" aria-describedby="button-addon2">
|
||||
<!-- Jenis ID -->
|
||||
<div class="input-group-append">
|
||||
<select class="form-select" id="customerIDType" name="customerIDType" class="form-control">
|
||||
<option value="nokp" {{ $idtype == 'nokp' ? 'selected' : ''}}>No.KP</option>
|
||||
<option value="passport" {{ $idtype == 'passport' ? 'selected' : ''}}>Passport</option>
|
||||
<select class="form-select" id="customerIDType" name="customerIDType">
|
||||
<option value="nokp" {{ $idtype == 'nokp' ? 'selected' : '' }}>No.KP</option>
|
||||
<option value="passport" {{ $idtype == 'passport' ? 'selected' : '' }}>Passport</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-primary" type="submit" id="button-addon2">Cari</button>
|
||||
</div>
|
||||
<br>
|
||||
<!-- Nama pelanggan -->
|
||||
<div class="input-group my-2">
|
||||
<input type="text" class="form-control" id="nama" name="nama" placeholder="Nama Pelanggan"
|
||||
value="{{ $search == false ? '' : $nama ?? '' }}">
|
||||
</div>
|
||||
|
||||
<!-- Butang cari -->
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-primary" type="submit">Cari</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -832,25 +841,27 @@
|
||||
function verifynokp(){
|
||||
var id_type = $('#customerIDType').val();
|
||||
var nokp = $('#noic').val();
|
||||
if(id_type=='nokp'){
|
||||
if($.isNumeric(nokp) == false){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Sila Masukkan Nombor Sahaja Pada No KP Pelanggan'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
if(nokp.length != 12){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Sila Periksa No KP Pelanggan'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
if(id_type === 'nokp'){
|
||||
if(!$.isNumeric(nokp)){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Sila Masukkan Nombor Sahaja Pada No KP Pelanggan'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(nokp.length != 12){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Sila Periksa No KP Pelanggan'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else if(id_type=='passport'){
|
||||
// if(nokp.length < 5){
|
||||
// Swal.fire({
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
@if(count($customers) > 0)
|
||||
<table class="table table-bordered table-hover" style="background-color: #f9f9f9;">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Nama</th>
|
||||
<th>No KP</th>
|
||||
<th>Kod Cawangan</th>
|
||||
<th>Tindakan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($customers as $customer)
|
||||
<tr>
|
||||
<td>{{ $customer['nama'] }}</td>
|
||||
<td>{{ $customer['kpbaru'] ?? $customer['kplama'] ?? '-' }}</td>
|
||||
<td>{{ $customer['kodcaw'] }}</td>
|
||||
<td>
|
||||
<form action="{{ route('arcc.pilihpelanggan.proceed') }}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="customer" value="{{ base64_encode(json_encode($customer)) }}">
|
||||
<input type="hidden" name="kodcaw" value="{{ $customer['kodcaw'] }}">
|
||||
<input type="hidden" name="nokp" value="{{ $customer['kpbaru'] ?? $customer['kplama'] ?? '-' }}">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Pilih</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@else
|
||||
<div class="alert alert-warning">Tiada pelanggan dijumpai.</div>
|
||||
@endif
|
||||
@@ -0,0 +1,39 @@
|
||||
@extends('layouts.app_callcenter')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h4 class="text-center mb-4">Senarai Pelanggan Dijumpai</h4>
|
||||
@if(session('customer_list') && count(session('customer_list')) > 0)
|
||||
<table class="table table-bordered table-hover" style="background-color: #f9f9f9;">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Nama</th>
|
||||
<th>No KP</th>
|
||||
<th>Kod Cawangan</th>
|
||||
<th>Tindakan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(session('customer_list') as $customer)
|
||||
<tr>
|
||||
<td>{{ $customer['nama'] }}</td>
|
||||
<td>{{ $customer['kpbaru'] ?? $customer['kplama'] ?? '-' }}</td>
|
||||
<td>{{ $customer['kodcaw'] }}</td>
|
||||
<td>
|
||||
<form action="{{ route('arcc.pilihpelanggan.proceed') }}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="customer" value="{{ base64_encode(json_encode($customer)) }}">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Pilih</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@else
|
||||
<div class="alert alert-warning">Tiada pelanggan dijumpai.</div>
|
||||
@endif
|
||||
|
||||
<a href="{{ route('arcc.pelanggan') }}" class="btn btn-secondary mt-3">Kembali</a>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -437,6 +437,9 @@ Route::get('/kemaskininotisperingatankedua/{notisid}',['as'=>'arcc.kemaskininoti
|
||||
Route::get('/kemaskininotisperingatanbycaw/{kodcaw}/{notisid}',['as'=>'arcc.kemaskininotisperingatanbycaw','uses'=>'CallCenterController@kemaskininotisperingatanbycaw'])->middleware('auth','callcenter');
|
||||
Route::get('/kemaskininotisperingatankeduabycaw/{kodcaw}/{notisid}',['as'=>'arcc.kemaskininotisperingatankeduabycaw','uses'=>'CallCenterController@kemaskininotisperingatankeduabycaw'])->middleware('auth','callcenter');
|
||||
Route::get('/arcc/tanyaupah/{norujukan}',['as'=>'tanyaupah','uses' => 'CallCenterController@tanyaupah'])->middleware('auth','callcenter');
|
||||
Route::get('/pilihpelanggan',['as'=>'arcc.pilihpelanggan','uses' => 'CallCenterController@pilihPelanggan'])->middleware('auth','callcenter');
|
||||
Route::post('/pilihpelanggan/proceed', ['as'=>'arcc.pilihpelanggan.proceed','uses' => 'CallCenterController@pilihPelangganProceed'])->middleware('auth','callcenter');
|
||||
Route::get('/ajax/search-customer',['as'=>'arcc.ajaxSearchCustomer','uses' => 'CallCenterController@ajaxSearchCustomer'])->middleware('auth','callcenter');
|
||||
|
||||
//taraf pc atau ppc
|
||||
Route::get('/cawangan/notisperingatan',['as'=>'laporan.notisperingatan','uses'=>'KhazanahController@notisperingatan'])->middleware('auth','khazanah');
|
||||
|
||||
Reference in New Issue
Block a user