diff --git a/app/Http/Controllers/TacController.php b/app/Http/Controllers/TacController.php new file mode 100644 index 0000000..5cdb8c8 --- /dev/null +++ b/app/Http/Controllers/TacController.php @@ -0,0 +1,128 @@ +icno],['tac_no',$request->tac]])->get()->toArray(); + + if($tac){ + $CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/' . $request->icno)->json(); + $daerah = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/daerah/' . $CustomerInfo['koddaerah'])->json(); + $negeri =Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/negeri/' . $CustomerInfo['kodnegeri'])->json(); + + return response(['status' => 1, 'customerinfo' => $CustomerInfo,'namadaerah' => $daerah['namadaerah'],'namanegeri' => $negeri['negeri']]); + }else{ + return response(['status' => 0]); + } + } + + + public function requestKadPengenalan(Request $request){ + + $currentDateTime = Carbon::now(); + $expiretac = tacportal::where('icno',$request->icno) + ->whereDate('created_at','>=',$currentDateTime) + ->whereDate('expired_at','<=',$currentDateTime) + ->where('created_at','>=',$currentDateTime->toDateTimeString()) + // ->whereTime('expired_at','<=',$currentDateTime) + // ->orderBy('tac_id','desc') + // ->latest() + ->first(); + dd($expiretac); + if($expiretac){ + return response(['notexpired' => true]); + } + + $tac = User::where('icno',$request->icno)->get()->toArray(); + + if($tac){ + return response(['message' => true]); + } + + $CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/' . $request->icno)->json(); + + if($CustomerInfo) + { + $generatestatus = $this->generateTAC($CustomerInfo); + + if($generatestatus){ + $backphone = substr($CustomerInfo['telefon'],-4); + return response(['notelefon' => $backphone,'status' => 1]); + }else{ + + } + }else{ + return response(['status' => 0],200); + } + } + + private function generateTAC($customer){ + + + $currentDateTime = Carbon::now(); + $expired_at = Carbon::now()->addMinutes(15); + + $tac_token = $this->randum_number(6,2,false); + + $tac = new tacportal; + + $tac->icno = ($customer['kpbaru']) ? $customer['kpbaru'] : $customer['kplama']; + $tac->notel = $customer['telefon']; + $tac->tac_no = $tac_token; + $tac->created_at = $currentDateTime->toDateTimeString(); + $tac->expired_at = $expired_at; + $tac->save(); + + + // $mobileno = '6' . $customer['notelefon']; + $mobileno = '601114884900'; + $messages = 'AR-RAHN PKB PORTAL : TAC: ' . $tac_token . ' ' . $currentDateTime . '. AR-RAHN CARELINE CENTRE 1300-22-4343'; + + // $status = Http::get('http://gateway.onewaysms.com.my:10001/api.aspx',[ + // 'apiusername' => 'APIUK330HDAFO', + // 'apipassword' => 'APIUK330HDAFOUK330', + // 'senderid' => 'INFO', + // 'mobileno' => $mobileno, + // 'message'=> $messages, + // 'languagetype'=> 1 + // ]); + + // return response($status); + return response(1); + } + + private function randum_number($len = 6,$dup = 1, $sort = false){ + if($dup < 1) + throw new InvalidArgumentException('Second argument is < 1'); + + $num = range(0,9); + shuffle($num); + + $num = array_slice($num, 0, ($len-$dup) + 1); + + if($dup > 0){ + $k = array_rand($num, 1); + for($i=0;$i<($dup-1);$i++) + { + $num[] = $num[$k]; + } + } + + if($sort){ + sort($num); + } + + return implode('',$num); + } + + +} diff --git a/app/Models/tacportal.php b/app/Models/tacportal.php new file mode 100644 index 0000000..fd726cf --- /dev/null +++ b/app/Models/tacportal.php @@ -0,0 +1,31 @@ +
Daftar Akaun
-

Sila isi nombor OTP yang telah di hantar ke nombor telefon bimbit anda.

+ {{--

Sila isi nomborxz OTP yang telah di hantar ke nombor telefon bimbit anda.

--}} +

Sila isi Nombor Kad Pengenalan anda di dalam kotak yang disediakan.

@csrf -
+ {{--
- + --}}
- +
+
+
+ + +
+
+ +
+
-
+ + + Nombor TAC anda telah dihantar melalui SMS ke +601XXXX 0569. Jika anda tidak menerima TAC anda dalam masa 5 minit tekan "Mohon TAC". + + + + + + +
- +
@@ -321,72 +342,180 @@ }) let api_url = "{{ config('api.url') }}"; + function generatetac() { + + let icno = $('#login-icno').val(); + + if(icno === '') + { + $("#tac").prop('disabled', true); + + $.notify({ + icon: 'fas fa-exclamation-triangle fa-2x', + newest_on_top: true, + message: "Sila Masukkan Nombor Kad Pengenalan!" + }, { + type: 'danger', + allow_dismiss: false, + placement: { + align: 'center', + from: 'bottom' + }, + animate: { + enter: 'animate__animated animate__bounce', + + exit: 'animate__animated animate__bounceOutDown' + } + }); + + }else{ + + if(isNaN(icno)) + { + $.notify({ + icon: 'fas fa-exclamation-triangle fa-2x', + newest_on_top: true, + message: "Masukkan Nombor dalam petak disediakan!" + }, { + type: 'danger', + allow_dismiss: false, + placement: { + align: 'center', + from: 'bottom' + }, + animate: { + enter: 'animate__animated animate__bounce', + exit: 'animate__animated animate__bounceOutDown' + } + }); + }else{ + var csrf_token = $('meta[name="csrf-token"]').attr('content'); + + $.ajax({ + url: '{{ route("requestic") }}', + method: 'get', + data:{ + "_token": "{{ csrf_token() }}", + "icno" : icno + }, + success: function(data) { + + if(data.notexpired){ + $.notify({ + icon: 'fas fa-exclamation-triangle fa-2x', + newest_on_top: true, + message: "anda telah meminta tac kurang daripada 15minit!" + }, { + type: 'warning', + allow_dismiss: false, + placement: { + align: 'center', + from: 'bottom' + }, + animate: { + enter: 'animate__animated animate__bounce', + exit: 'animate__animated animate__bounceOutDown' + } + }); + + return; + } + + if(data.message){ + + $.notify({ + icon: 'fas fa-exclamation-triangle fa-2x', + newest_on_top: true, + message: "anda telah menjadi ahli dalam ini!" + }, { + type: 'warning', + allow_dismiss: false, + placement: { + align: 'center', + from: 'bottom' + }, + animate: { + enter: 'animate__animated animate__bounce', + exit: 'animate__animated animate__bounceOutDown' + } + }); + + return; + } + + if(data['status'] == 1) + { + $("#tac").prop('disabled', false); + $("#spanhantarnombor").removeClass('d-none'); + $("#divsahkan").removeClass('d-none'); + $('#backphone').text(data['notelefon']); + + }else{ + console.log(data); + } + } + }); + + } + } + + + } + + function checkpelanggan() { - var otp_verify = $('#login-otp').val(); + var otp_verify = $('#tac').val(); var otp_icno = $('#login-icno').val(); var boolotp = false; var boolicno = false; if (otp_verify == null || otp_verify == '') { - $('#errorotp').text('Sila Isi Nombor OTP!'); - $('#spanotp').addClass('visible'); - $('#spanotp').removeClass('invisible'); + // $('#errorotp').text('Sila Isi Nombor OTP!'); + // $('#spanotp').addClass('visible'); + // $('#spanotp').removeClass('invisible'); boolotp = true; } else { - $('#errorotp').text(''); - $('#spanotp').addClass('invisible'); - $('#spanotp').removeClass('visible'); + // $('#errorotp').text(''); + // $('#spanotp').addClass('invisible'); + // $('#spanotp').removeClass('visible'); boolotp = false; } if (otp_icno == null || otp_icno == '') { - $('#erroricno').text('Sila Isi No Kad Pengenalan Anda!'); - $('#spanic').addClass('visible'); - $('#spanic').removeClass('invisible'); + // $('#erroricno').text('Sila Isi No Kad Pengenalan Anda!'); + // $('#spanic').addClass('visible'); + // $('#spanic').removeClass('invisible'); boolicno = true; } else { - $('#erroricno').text(''); - $('#spanic').addClass('invisible'); - $('#spanic').removeClass('visible'); + // $('#erroricno').text(''); + // $('#spanic').addClass('invisible'); + // $('#spanic').removeClass('visible'); boolicno = false; } if (boolotp === false && boolicno === false) { $.ajax({ - url: api_url + '/api/otp/check/' + otp_verify, + // url: api_url + '/api/otp/check/' + otp_verify, + url: "{{ route('requesttac') }}", + data:{ + icno: otp_icno, + tac: otp_verify + }, method: 'GET', success: function(data) { - if (data.length > 0) { - console.log(data[0].nokp); - $.ajax({ - url: api_url + '/api/customers/' + data[0].nokp, - method: 'GET', - success: function(data) { - - $('input[name="name"]').val(data.nama); - $('input[name="icno"]').val(data.kpbaru); - $('input[name="notel"]').val(data.telefon); - $('input[name="poskod"]').val(data.poskod); - $('textarea[name="alamat"]').val(data.alamat1); - - $.ajax({ - url: api_url + '/api/daerah/' + data.koddaerah, - method: 'GET', - success: function(data) { - console.log(data); - $('input[name="namadaerah"]').val(data.namadaerah); - } - }); - $.ajax({ - url: api_url + '/api/negeri/' + data.kodnegeri, - method: 'GET', - success: function(data) { - console.log(data); - $('input[name="negeri"]').val(data.negeri); - } - }); + console.log(data.status); + if (data.status == 1) { + + $('input[name="name"]').val(data.customerinfo.nama); + $('input[name="icno"]').val(data.customerinfo.kpbaru); + $('input[name="notel"]').val(data.customerinfo.telefon); + $('input[name="poskod"]').val(data.customerinfo.poskod); + $('textarea[name="alamat"]').val(data.customerinfo.alamat1); + $('input[name="namadaerah"]').val(data.namadaerah); + $('input[name="negeri"]').val(data.namanegeri); + $('#spanic').addClass('invisible'); @@ -403,10 +532,7 @@ $('#seterusnyaModal').modal({ backdrop: 'static', keyboard: false - }) - - } - }); + }); } else { $.notify({ icon: 'fas fa-exclamation-triangle', @@ -456,22 +582,6 @@ }); }); - var slideIndex = 0; - // showSlides(); - - // function showSlides() { - // var i; - // var slides = document.getElementsByClassName("mySlides"); - // for (i = 0; i < slides.length; i++) { - // slides[i].style.display = "none"; - // } - // slideIndex++; - // if (slideIndex > slides.length) { - // slideIndex = 1 - // } - // slides[slideIndex - 1].style.display = "block"; - // setTimeout(showSlides, 10000); // Change image every 2 seconds - // } diff --git a/routes/web.php b/routes/web.php index 0c42a00..64612ef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -115,77 +115,77 @@ Route::get('/bayarsag', function () { }); -Route::get('/', function () { - // return view('dashboard'); - $auth_user = Auth::user(); +// Route::get('/', function () { +// // return view('dashboard'); +// $auth_user = Auth::user(); - $harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/')->json(); +// $harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/')->json(); - $hargaemasterdahulu = array(); +// $hargaemasterdahulu = array(); - foreach($harga_emas as $index=>$harga) - { - $hargaemassandaran = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/rekod/sandaran',['karat' => $harga['karat']])->json(); +// foreach($harga_emas as $index=>$harga) +// { +// $hargaemassandaran = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/harga_emas/rekod/sandaran',['karat' => $harga['karat']])->json(); - $percentnaik = (floatval($harga['harga']) - floatval($hargaemassandaran[1]['harga'])) / ($hargaemassandaran[1]['harga']) * 100; +// $percentnaik = (floatval($harga['harga']) - floatval($hargaemassandaran[1]['harga'])) / ($hargaemassandaran[1]['harga']) * 100; - array_push($hargaemasterdahulu,['karat' => $harga['karat'],'hargasemasa' => $harga['harga'], 'hargadahulu' => $hargaemassandaran[1]['harga'],'percent' => $percentnaik]); +// array_push($hargaemasterdahulu,['karat' => $harga['karat'],'hargasemasa' => $harga['harga'], 'hargadahulu' => $hargaemassandaran[1]['harga'],'percent' => $percentnaik]); - } +// } - $CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json(); +// $CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/portal/customer/info',['ic' => $auth_user['icno']])->json(); - $total = 0.00; - $sixmonths = 0; - $bilangan = 0; - foreach($CustomerInfo['gadai'] as $index=>$gadai) - { - $bilangan++; - $total += $gadai['pinjaman']; +// $total = 0.00; +// $sixmonths = 0; +// $bilangan = 0; +// foreach($CustomerInfo['gadai'] as $index=>$gadai) +// { +// $bilangan++; +// $total += $gadai['pinjaman']; - if($gadai['tempoh'] >= 6) - { - $sixmonths++; - } - } +// if($gadai['tempoh'] >= 6) +// { +// $sixmonths++; +// } +// } - $bilanganlelong = 0; - foreach($CustomerInfo['lelong'] as $index1=>$lelong) - { - $bilanganlelong += 1; - } +// $bilanganlelong = 0; +// foreach($CustomerInfo['lelong'] as $index1=>$lelong) +// { +// $bilanganlelong += 1; +// } - $arraysag = []; - $belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json(); +// $arraysag = []; +// $belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json(); - if(is_array($belum_tebus)) - { - if(sizeof($belum_tebus) > 0) - { - foreach($belum_tebus as $index=>$bt) - { - foreach($bt as $index1=>$bet) - { - array_push($arraysag,$bet); - } - } - } - } +// if(is_array($belum_tebus)) +// { +// if(sizeof($belum_tebus) > 0) +// { +// foreach($belum_tebus as $index=>$bt) +// { +// foreach($bt as $index1=>$bet) +// { +// array_push($arraysag,$bet); +// } +// } +// } +// } - $belum_tebus = $arraysag; +// $belum_tebus = $arraysag; - $api_url = config('api.url'); +// $api_url = config('api.url'); - return view('includes.home',compact('api_url','hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong','belum_tebus')); -})->middleware(['auth','verified']); +// return view('includes.home',compact('api_url','hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong','belum_tebus')); +// })->middleware(['auth','verified']); // Route::get('/home', 'HomeController@index'); -Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); +Route::get('/', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Auth::routes(['verify' => true]); -Route::get('/home', 'App\Http\Controllers\HomeController@index')->name('home'); +// Route::get('/home', 'App\Http\Controllers\HomeController@index')->name('home'); Route::group(['middleware' => 'auth'], function () { Route::resource('user', 'App\Http\Controllers\UserController', ['except' => ['show']]); @@ -254,18 +254,8 @@ Route::get('send-mail', function () { dd("Email is Sent."); }); - - -//For Reference - -// Route::resource('user', 'App\Http\Controllers\UserController', ['except' => ['show']]); - // Route::get('profile', ['as' => 'profile.edit', 'uses' => 'App\Http\Controllers\ProfileController@edit']); - // Route::put('profile', ['as' => 'profile.update', 'uses' => 'App\Http\Controllers\ProfileController@update']); - // Route::get('upgrade', function () {return view('pages.upgrade');})->name('upgrade'); - // Route::get('map', function () {return view('pages.maps');})->name('map'); - // Route::get('icons', function () {return view('pages.icons');})->name('icons'); - // Route::get('table-list', function () {return view('pages.tables');})->name('table'); - // Route::put('profile/password', ['as' => 'profile.password', 'uses' => 'App\Http\Controllers\ProfileController@password']); +Route::get('/requestic', 'App\Http\Controllers\TacController@requestKadPengenalan')->name('requestic'); +Route::get('/requesttac', 'App\Http\Controllers\TacController@TACrequest')->name('requesttac');