customer register

This commit is contained in:
Afiq
2021-01-04 08:47:43 +08:00
parent fbaadc8be7
commit b533e2de7d
6 changed files with 336 additions and 72 deletions
+37 -2
View File
@@ -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] );