fix stki2

This commit is contained in:
hafifierahman
2022-04-24 10:47:28 +08:00
parent 67da9779a8
commit 20a9e2764b
4 changed files with 390 additions and 131 deletions
+128
View File
@@ -0,0 +1,128 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use App\Models\tacportal;
use Carbon\Carbon;
class TacController extends Controller
{
public function TACrequest(Request $request){
$tac = tacportal::where([['icno',$request->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);
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class tacportal extends Model
{
// public $incrementing = true;
//show the primarykey of this table
// protected $primaryKey = 'recno';
//show the table of this model
protected $table = 'tac_portal';
protected $fillable = [
'tac_id',
'icno',
'notel',
'tac_no',
'created_at',
'expired_at'
];
//show that no public created been generated
public $timestamps = false;
}
@@ -104,14 +104,15 @@
<div class="col-lg-12">
<h6 class="mt-2 mb-4" style="text-align: center;">Daftar Akaun</h6>
<p>Sila isi nombor OTP yang telah di hantar ke nombor telefon bimbit anda.</p>
{{-- <p>Sila isi nomborxz OTP yang telah di hantar ke nombor telefon bimbit anda.</p> --}}
<p>Sila isi Nombor Kad Pengenalan anda di dalam kotak yang disediakan.</p>
@csrf
<div class="input-group input-group-outline mt-3 {{ $errors->has('otp') ? ' has-danger' : '' }}">
{{-- <div class="input-group input-group-outline mt-3 {{ $errors->has('otp') ? ' has-danger' : '' }}">
<input placeholder="One-Time-Password" class="form-control{{ $errors->has('otp') ? ' is-invalid' : '' }}" type="text" name="otp" value="{{ old('otp') }}" id="login-otp" required autofocus aria-required="true">
</div>
<span id="spanotp" class="text-danger" role="alert">
<small><strong id="errorotp"></strong></small>
</span>
</span> --}}
<div class="input-group input-group-outline mt-3 {{ $errors->has('icno') ? ' has-danger' : '' }}">
<input type="text" placeholder="Nombor Kad Pengenalan" class="form-control{{ $errors->has('icno') ? ' is-invalid' : '' }}" id="login-icno" name="icno" required aria-required="true">
@@ -121,11 +122,31 @@
<small><strong id="erroricno">ss</strong></small>
</span>
<div class="mt-n3 input-group input-group-outline justify-content-between">
<div class="input-group-prepend col-7">
<input type="text" id="tac" name="tac" class="form-control" placeholder="Nombor TAC" disabled/>
<span id="spantac" class="text-danger invisible" role="alert">
<small><strong>TAC yang anda masukkan salah!</strong></small>
</span>
</div>
<div class="input-group-prepend">
<button class="btn btn-secondary" onclick="generatetac()">Minta TAC</button>
</div>
</div>
<div class="row">
<span id="spanhantarnombor" class="text-dark d-none" role="alert">
<small><strong>Nombor TAC anda telah dihantar melalui SMS ke +601XXXX <b id="backphone">0569</b>. Jika anda tidak menerima TAC anda dalam masa 5 minit tekan "Mohon TAC". </strong></small>
</span>
<div id="divsahkan" class="row d-none">
<div class="text-center my-4">
<!-- <button type="button" class="btn bg-gradient-primary" data-toggle="modal" data-target="#exampleModal">modal</button> -->
<button id="seterusbtn" class="btn btn-secondary login pull-right" type="button" data-toggle="modal" data-target="#exampleModal" onclick="checkpelanggan();" style="background: #4A4E59;">Seterusnya</button>
<button id="seterusbtn" class="btn btn-secondary login pull-right" type="button" data-toggle="modal" data-target="#exampleModal" onclick="checkpelanggan();" style="background: #4A4E59;">Sahkan</button>
</div>
</div>
@@ -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: "<strong style='font-size:15px;text-align:center;margin-left:100px; color: #ffff'>Sila Masukkan Nombor Kad Pengenalan!</strong>"
}, {
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: "<strong style='font-size:15px;text-align:center;margin-left:100px; color: #ffff'>Masukkan Nombor dalam petak disediakan!</strong>"
}, {
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: "<strong style='font-size:15px;text-align:center;margin-left:100px; color: #ffff'>anda telah meminta tac kurang daripada 15minit!</strong>"
}, {
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: "<strong style='font-size:15px;text-align:center;margin-left:100px; color: #ffff'>anda telah menjadi ahli dalam ini!</strong>"
}, {
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) {
console.log(data.status);
if (data.status == 1) {
$('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);
$('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);
$.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);
}
});
$('#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
// }
</script>
</body>
+52 -62
View File
@@ -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');