diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index b42635e..b1665ae 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -24,19 +24,19 @@ class HomeController extends Controller public function index() { $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(); @@ -61,26 +61,26 @@ class HomeController extends Controller $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'); - return view('includes.home',compact('api_url','belum_tebus','hargaemasterdahulu','bilangan','sixmonths','total','bilanganlelong')); + return view('includes.home',compact('api_url','bilangan','sixmonths','total','bilanganlelong')); } } diff --git a/app/Http/Controllers/InformationController.php b/app/Http/Controllers/InformationController.php index 8ec9fc7..7580401 100644 --- a/app/Http/Controllers/InformationController.php +++ b/app/Http/Controllers/InformationController.php @@ -20,7 +20,9 @@ class InformationController extends Controller $pembiayaansemasa = $CustomerInfo['gadai']; } - return view('includes.information.pembiayaansemasa',compact('pembiayaansemasa')); + return response()->json($pembiayaansemasa,200); + + // return view('includes.information.pembiayaansemasa',compact('pembiayaansemasa')); } public function pembiayaanaktif() @@ -35,7 +37,8 @@ class InformationController extends Controller $pembiayaansemasa = $CustomerInfo['gadai']; } - return view('includes.information.pembiayaanaktif',compact('pembiayaansemasa')); + return response()->json($pembiayaansemasa,200); + // return view('includes.information.pembiayaanaktif',compact('pembiayaansemasa')); } public function pembiayaanmelebihi6bulan() @@ -56,7 +59,8 @@ class InformationController extends Controller } } - return view('includes.information.melebihi6bulan',compact('melebihi6bulan')); + return response()->json($melebihi6bulan,200); + // return view('includes.information.melebihi6bulan',compact('melebihi6bulan')); } public function pembiayaanakandilelong() @@ -71,6 +75,8 @@ class InformationController extends Controller $lelong += $CustomerInfo['lelong']; } - return view('includes.information.lelongan',compact('lelong')); + + return response()->json($lelong,200); + // return view('includes.information.lelongan',compact('lelong')); } } diff --git a/app/Http/Controllers/TacController.php b/app/Http/Controllers/TacController.php new file mode 100644 index 0000000..36f522c --- /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) + ->whereTime('expired_at','>=',$currentDateTime->toDateTimeString()) + ->where('created_at','<=',$currentDateTime->toDateTimeString()) + ->latest() + ->first(); + + 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 @@ +Tetap Semula Kata Laluan
diff --git a/resources/views/auth/pertama-kali/firsttime2.blade.php b/resources/views/auth/pertama-kali/firsttime2.blade.php index 819b5a6..2842c28 100644 --- a/resources/views/auth/pertama-kali/firsttime2.blade.php +++ b/resources/views/auth/pertama-kali/firsttime2.blade.php @@ -104,28 +104,49 @@
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 -Log-Masuk @@ -165,13 +186,13 @@ Koperasi Permodalan Kelantan Berhad