diff --git a/app/Http/Controllers/CustomersController.php b/app/Http/Controllers/CustomersController.php index d0a1155..a32c055 100644 --- a/app/Http/Controllers/CustomersController.php +++ b/app/Http/Controllers/CustomersController.php @@ -113,15 +113,50 @@ class CustomersController extends Controller $jantina = 'P'; } $split_date = explode('/',$request->tarikh_lahir); + $tarikh_lahir = $split_date[2].'-'.$split_date[1].'-'.$split_date[0]; + $tarikhlahir = Carbon::parse($tarikh_lahir); $auth_user = Auth::user(); $latest_customer = Http::get(config('api.url') . '/api/customers/latest/' . $auth_user['cawangan'])->json(); - - $nosiri_latest = $latest_customer['nosiri']+1; + + if($latest_customer == null){ + $nosiri_latest = 1; + } + else{ + $nosiri_latest = $latest_customer['nosiri']+1; + } + $count = sprintf("%08d", $nosiri_latest); $no_pelanggan = $request->bangsa . substr($request->noic,6,2).'-'.$count; // dd($tarikh_lahir); + $detail_poskod = Http::get(config('api.url') . '/api/poskod/' . $request->poskod)->json(); + // dd($auth_user); + $sent_data = [ + 'kodcaw' => $auth_user['cawangan'], + 'nopelanggan' => $no_pelanggan, + 'nokp' => $request->noic, + 'nama' => $request->name, + 't_lahir' => $tarikhlahir->toDateString(), + 'jantina' => $jantina, + 'alamat' => $request->alamat, + 'poskod' => $request->poskod, + 'koddaerah' => $detail_poskod['koddaerah'], + 'kodnegeri' => $detail_poskod['kodnegeri'], + 'telefon' => $request->main_phone, + 'bumiputra' => $bumiputera, + 'warganegara' => $warganegara, + 'bangsa' => $request->bangsa, + 'kodugama' => $request->agama, + 'kodbank' => $request->bank_name, + 'noakaun' => $request->no_akaun, + 'teller' => $auth_user['name'], + 'telefon2' => $request->alternate_phone, + 'nosiri' => $nosiri_latest + ]; + + $customer_info = Http::post(config('api.url') . '/api/customers/'. $auth_user['cawangan'],$sent_data); + dd($sent_data); Session::put('customer_info',$customer_info); return redirect()->route('customer_info')->with( ['customer_info' => $customer_info] ); diff --git a/config/session.php b/config/session.php index 4e0f66c..645d39b 100644 --- a/config/session.php +++ b/config/session.php @@ -196,6 +196,6 @@ return [ | */ - 'same_site' => 'lax', + 'same_site' => null, ]; diff --git a/resources/views/customers/index.blade.php b/resources/views/customers/index.blade.php index 3758d41..27c2acf 100644 --- a/resources/views/customers/index.blade.php +++ b/resources/views/customers/index.blade.php @@ -50,7 +50,7 @@