diff --git a/app/Http/Controllers/GadaianController.php b/app/Http/Controllers/GadaianController.php index cdca363..bd0b5f1 100644 --- a/app/Http/Controllers/GadaianController.php +++ b/app/Http/Controllers/GadaianController.php @@ -39,8 +39,10 @@ class GadaianController extends Controller } $new_transaction = sprintf("%04d",$new_sirig); $norujukan = strtoupper($auth_user['cawangan']) . $curent_year . $curent_month . $current_day . '-' .$new_transaction; - $request->session()->put('norujukan',$norujukan); - $request->session()->put('page_reload',true); + Session::put('norujukan',$norujukan); + Session::put('nokp',$noic); + Session::put('nopelanggan',$customer_info['nopelanggan']); + Session::put('page_reload',true); $gadai = Http::post(config('api.url').'/api/gadai/'.$auth_user['cawangan'],[ 'norujukan' => $norujukan, 'nopelanggan' => $customer_info['nopelanggan'], @@ -48,7 +50,31 @@ class GadaianController extends Controller 'sirig' => $new_sirig ]); }else{ - $norujukan = $request->session()->get('norujukan'); + $norujukan = Session::get('norujukan'); + $nokp = Session::get('nokp'); + $nopelanggan = Session::get('nopelanggan'); + $gadai_session = Http::get(config('api.url') . '/api/check/sag',['kodcaw'=>$auth_user['cawangan'],'norujukan'=>$norujukan,'nokp'=>$nokp])->json(); + if($gadai_session = null){ + $gadai_transaction = Http::get(config('api.url') . '/api/gadai/'. $auth_user['cawangan'] . '/' . $current->toDateString())->json(); + if($gadai_transaction){ + $new_sirig = $gadai_transaction['sirig'] + 1; + }else{ + $new_sirig = 1; + } + $new_transaction = sprintf("%04d",$new_sirig); + $norujukan_baru = strtoupper($auth_user['cawangan']) . $curent_year . $curent_month . $current_day . '-' .$new_transaction; + Session::put('norujukan',$norujukan_baru); + Session::put('nokp',$nokp); + Session::put('nopelanggan',$nopelanggan); + Session::put('page_reload',true); + $gadai_baru = Http::post(config('api.url') .'/api/gadai/'.$auth_user['cawangan'],[ + 'norujukan' => $norujukan_baru, + 'nopelanggan' => $nopelanggan, + 'nokp' => $nokp, + 'sirig' => $new_sirig + ]); + $norujukan = $norujukan_baru; + } } diff --git a/resources/views/gadaian/index.blade.php b/resources/views/gadaian/index.blade.php index b4f046c..cf6e1bc 100644 --- a/resources/views/gadaian/index.blade.php +++ b/resources/views/gadaian/index.blade.php @@ -231,25 +231,6 @@ @else @php - $gadai_transaction = Http::get($api_url . '/api/gadai/'. $cawangan_info['kodcaw'] . '/' . $current->toDateString())->json(); - if($gadai_transaction){ - $new_sirig = $gadai_transaction['sirig'] + 1; - }else{ - $new_sirig = 1; - } - $curent_year = substr($current->year,2,2); - $curent_month = sprintf("%02d", $current->month); - $current_day = sprintf("%02d", $current->day); - $new_transaction = sprintf("%04d",$new_sirig); - $norujukan_baru = strtoupper($cawangan_info['kodcaw']) . $curent_year . $curent_month . $current_day . '-' .$new_transaction; - $_SESSION["norujukan"] = $norujukan_baru; - dd($_SESSION["norujukan"]); - $gadai_baru = Http::post($api_url .'/api/gadai/'.$cawangan_info['kodcaw'],[ - 'norujukan' => $norujukan_baru, - 'nopelanggan' => $customer_info['nopelanggan'], - 'nokp' => $customer_info['kpbaru'], - 'sirig' => $new_sirig - ]); header("Refresh:0"); @endphp @endif