Merge branch 'backend' into 'master'
kodcaw See merge request online-sistem1/kaunter!17
This commit is contained in:
@@ -151,12 +151,12 @@ class CustomersController extends Controller
|
||||
}
|
||||
|
||||
public function getOTP(Request $request){
|
||||
|
||||
$auth_user = Auth::user();
|
||||
$expired = Carbon::now();
|
||||
$expired = new Carbon();
|
||||
$expired = $expired->addHours(24);
|
||||
|
||||
$nokp = $request->noic_otp;
|
||||
$nokp = $request->noic;
|
||||
|
||||
//pembinaan token
|
||||
function token($length) {
|
||||
@@ -170,39 +170,34 @@ class CustomersController extends Controller
|
||||
shuffle($characters);
|
||||
return implode("", array_slice($characters, 0, $length));
|
||||
}
|
||||
$random = token(6);
|
||||
// dd($expired);
|
||||
$otp_baru = Http::post(config('url.api') . '/api/otp/generateotp/' . $nokp,[
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
]);
|
||||
// dd($otp_baru);
|
||||
return redirect()->route('customer_info');
|
||||
// $otp_token = Http::get(config('api.url') . '/api/otp/' . $nokp) ->json();
|
||||
// // dd($nokp);
|
||||
// if (is_array($otp_token) || is_object($otp_token)){
|
||||
// if($otp_token){
|
||||
// return redirect()->route('customer_info');
|
||||
// }else{
|
||||
// $random = token(6);
|
||||
|
||||
// $otp_baru = Http::post(config('url.api'). '/api/otp/create/' . $nokp,[
|
||||
// 'otptoken' => $random,
|
||||
// 'expired' => $expired
|
||||
// ]);
|
||||
|
||||
// return redirect()->route('customer_info');
|
||||
// }
|
||||
// }else{
|
||||
// $random = token(6);
|
||||
|
||||
// $otp_baru = Http::post(config('url.api'). '/api/otp/create/' . $nokp,[
|
||||
// 'otptoken' => $random,
|
||||
// 'expired' => $expired
|
||||
// ]);
|
||||
$otp_token = Http::get(config('api.url') . '/api/otp/' . $nokp) ->json();
|
||||
|
||||
// return redirect()->route('customer_info');
|
||||
// }
|
||||
if (is_array($otp_token) || is_object($otp_token)){
|
||||
if($otp_token){
|
||||
return response(['error' => "OTP Akaun Telah Di Jana"]);
|
||||
}else{
|
||||
$random = token(6);
|
||||
|
||||
$otp_baru = Http::post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
'kodcaw' => $auth_user['cawangan']
|
||||
]);
|
||||
|
||||
return response()->json(['otp'=>$random]);
|
||||
}
|
||||
}else{
|
||||
$random = token(6);
|
||||
|
||||
$otp_baru = Http::post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
'kodcaw' => $auth_user['cawangan']
|
||||
]);
|
||||
|
||||
return response()->json(['otp'=>$random]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,18 +124,15 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-7">
|
||||
<div class="input-group my-3" id="otp_form">
|
||||
<form action="{{ route('customer.otp') }}" method="post">
|
||||
@csrf
|
||||
<input type="text" class="form-control" name="noic_otp" readonly placeholder="No Kad Pengenalan Pelanggan" id="noic_otp" aria-label="No Kad Pengenalan Pelanggan" autocomplete="off" value="" aria-describedby="button-addon2">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-primary" type="submit" id="jana_otp">Jana OTP</button>
|
||||
</div>
|
||||
</form>
|
||||
<input type="text" class="form-control" name="noic_otp" readonly placeholder="No Kad Pengenalan Pelanggan" id="noic_otp" aria-label="No Kad Pengenalan Pelanggan" autocomplete="off" value="" aria-describedby="button-addon2">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-primary" type="button" id="jana_otp">Jana OTP</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="otp_generate" style="display:none;">
|
||||
<div class="row form-group">
|
||||
<div class="col-md-4">
|
||||
OTP Token
|
||||
OTP Token :
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<span id="otp_number"></span>
|
||||
@@ -446,27 +443,36 @@
|
||||
$('#opt_modal').modal('show');
|
||||
});
|
||||
|
||||
// $('#jana_otp').click(function(){
|
||||
// var noic = $('#noic_otp').val();
|
||||
$('#jana_otp').click(function(){
|
||||
var noic = $('#noic_otp').val();
|
||||
|
||||
// $.ajax({
|
||||
// method:'get',
|
||||
// url: "{{ route('customer.otp') }}",
|
||||
// data:{
|
||||
// 'noic' : noic
|
||||
// },
|
||||
// success: function(otp_token){
|
||||
// console.log(otp_token);
|
||||
// // $('#otp_form').hide();
|
||||
// // $('#otp_generate').show();
|
||||
// // $('#otp_number').text();
|
||||
// },
|
||||
// error: function(xhRequest, ErrorText, thrownError){
|
||||
// alert('Gadai Tidak Berjaya');
|
||||
// console.log(xhRequest);
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: "{{ route('customer.otp') }}",
|
||||
data:{
|
||||
'noic' : noic
|
||||
},
|
||||
dataType:'json',
|
||||
success: function(otp_token){
|
||||
console.log(otp_token['error']);
|
||||
if(otp_token['error']){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: otp_token['error']
|
||||
});
|
||||
}else if(otp_token['otp']){
|
||||
$('#otp_form').hide();
|
||||
$('#otp_generate').show();
|
||||
$('#otp_number').text(otp_token['otp']);
|
||||
}
|
||||
},
|
||||
error: function(xhRequest, ErrorText, thrownError){
|
||||
// alert('Gadai Tidak Berjaya');
|
||||
console.log(xhRequest);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ Route::post('/customer/store',['as'=>'customer.store','uses'=>'CustomersControll
|
||||
Route::post('/gadai/store',['as'=>'gadai.store','uses'=>'GadaianController@store'])->middleware('auth','teller');
|
||||
Route::get('/gadai/batal',['as'=>'gadai.batal','uses'=>'GadaianController@batal'])->middleware('auth','teller');
|
||||
Route::get('/gadai/batal',['as'=>'gadai.batal','uses'=>'GadaianController@batal'])->middleware('auth','teller');
|
||||
Route::post('/customer/otp',['as'=>'customer.otp','uses'=>'CustomersController@getOTP'])->middleware('auth','teller');
|
||||
Route::get('/customer/otp',['as'=>'customer.otp','uses'=>'CustomersController@getOTP'])->middleware('auth','teller');
|
||||
|
||||
//Penilai
|
||||
Route::get('/gadaiansemasa',['as'=>'gadaian.semasa','uses'=>'GadaianController@gadaiansemasa'])->middleware('auth','penilai');
|
||||
|
||||
Reference in New Issue
Block a user