diff --git a/app/Http/Controllers/PenebusanController.php b/app/Http/Controllers/PenebusanController.php index fad382b..3abad3e 100644 --- a/app/Http/Controllers/PenebusanController.php +++ b/app/Http/Controllers/PenebusanController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Auth; class PenebusanController extends Controller { @@ -11,7 +13,24 @@ class PenebusanController extends Controller $this->middleware('auth'); } - public function index(){ - return view('penebusan.index'); + public function index($norujukan){ + $auth_user = Auth::user(); + $api_url = config('api.url'); + $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json(); + + $gadaidetail = Http::get(config('api.url') . '/api/gadai/norujukan/'. $norujukan)->json(); + $noic = $gadaidetail[0][0]['nokp']; + $customerdetail = Http::get(config('api.url') . '/api/customers/'. $noic)->json(); + $marhundetail = Http::get(config('api.url') . '/api/marhun/'. $norujukan)->json(); + + // dd($marhundetail[0]); + + $marhun = $marhundetail[0]; + $nama = $customerdetail[0]['nama']; + + $gadai = $gadaidetail[0][0]; + + + return view('penebusan.index',compact('cawangan_info','api_url','gadai','marhun','nama')); } } diff --git a/resources/views/customers/info.blade.php b/resources/views/customers/info.blade.php index 37b76f8..ad48070 100644 --- a/resources/views/customers/info.blade.php +++ b/resources/views/customers/info.blade.php @@ -220,6 +220,47 @@ + + {{-- Sudah Tebus --}} + + + + + + + + + + + + + + + + + + +
BilNo RujukanTarikh GadaiPembiayaanNilai MarhunTempohKeuntunganTarikh MatangMarginKos KeuntunganHapus Gadai
+ + + + + + + + + + + + + + + + + + +
BilNo RujukanTarikh GadaiPembiayaanNilai MarhunTempohKeuntunganTarikh MatangMarginKos KeuntunganHapus Gadai
+ @@ -232,40 +273,105 @@ "scrollX": true }); + var tabledahtebus = $('#dahtebusTable').DataTable({ + "scrollX": true + }); + + var tablelelong = $('#lelongTable').DataTable({ + "scrollX": true + }); + const formatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2 }) - function gadaiTable(data){ + function gadaiTable(data,jenistebus){ var counter = 1; + tablegadai.clear().draw(); + tabledahtebus.clear().draw(); + tablelelong.clear().draw(); + $.each(data,function(index,gadai){ $.each(gadai, function(index,gadai_detail){ - var keuntungan_semasa = (gadai_detail['kadarupah']/100)*gadai_detail['bakipjm']*gadai_detail['jbg']; - tablegadai.row.add([ - counter, - gadai_detail['norujukan'], - gadai_detail['t_gadai'], - 'RM '+formatter.format(gadai_detail['pinjaman']), - 'RM '+ formatter.format(gadai_detail['nilaimarhun']), - gadai_detail['jbg'], - 'RM '+ formatter.format(keuntungan_semasa), - gadai_detail['t_matang'], - (((Number(gadai_detail['pinjaman'])/Number(gadai_detail['nilaimarhun']))*100).toFixed(2)).toLocaleString("en-GB") + '%', - 'RM ' + formatter.format((Number(gadai_detail['kadarupah'])*Number(gadai_detail['pinjaman'])).toFixed(2)), - '' - ]).draw(); + + if(jenistebus == "belum_tebus") + { + var keuntungan_semasa = (gadai_detail['kadarupah']/100)*gadai_detail['bakipjm']*gadai_detail['jbg']; + + var urlroute = '{{ route("penebusan", ":id") }}'; + urlroute = urlroute.replace(':id', gadai_detail["norujukan"]); + + tablegadai.row.add([ + counter, + '' + gadai_detail['norujukan'] + '', + gadai_detail['t_gadai'], + 'RM '+formatter.format(gadai_detail['pinjaman']), + 'RM '+ formatter.format(gadai_detail['nilaimarhun']), + gadai_detail['jbg'], + 'RM '+ formatter.format(keuntungan_semasa), + gadai_detail['t_matang'], + (((Number(gadai_detail['pinjaman'])/Number(gadai_detail['nilaimarhun']))*100).toFixed(2)).toLocaleString("en-GB") + '%', + 'RM ' + formatter.format((Number(gadai_detail['kadarupah'])*Number(gadai_detail['pinjaman'])).toFixed(2)), + '' + ]).draw(); + } + else if(jenistebus == "sudah_tebus") + { + var keuntungan_semasa = (gadai_detail['kadarupah']/100)*gadai_detail['bakipjm']*gadai_detail['jbg']; + tabledahtebus.row.add([ + counter, + gadai_detail['norujukan'], + gadai_detail['t_gadai'], + 'RM '+formatter.format(gadai_detail['pinjaman']), + 'RM '+ formatter.format(gadai_detail['nilaimarhun']), + gadai_detail['jbg'], + 'RM '+ formatter.format(keuntungan_semasa), + gadai_detail['t_matang'], + (((Number(gadai_detail['pinjaman'])/Number(gadai_detail['nilaimarhun']))*100).toFixed(2)).toLocaleString("en-GB") + '%', + 'RM ' + formatter.format((Number(gadai_detail['kadarupah'])*Number(gadai_detail['pinjaman'])).toFixed(2)), + '' + ]).draw(); + } + else if(jenistebus == "lelong") + { + var keuntungan_semasa = (gadai_detail['kadarupah']/100)*gadai_detail['bakipjm']*gadai_detail['jbg']; + tablelelong.row.add([ + counter, + gadai_detail['norujukan'], + gadai_detail['t_gadai'], + 'RM '+formatter.format(gadai_detail['pinjaman']), + 'RM '+ formatter.format(gadai_detail['nilaimarhun']), + gadai_detail['jbg'], + 'RM '+ formatter.format(keuntungan_semasa), + gadai_detail['t_matang'], + (((Number(gadai_detail['pinjaman'])/Number(gadai_detail['nilaimarhun']))*100).toFixed(2)).toLocaleString("en-GB") + '%', + 'RM ' + formatter.format((Number(gadai_detail['kadarupah'])*Number(gadai_detail['pinjaman'])).toFixed(2)), + '' + ]).draw(); + } + + counter = counter + 1; }); }); + + + + } $(document).ready( function () { + $('#myTable').parents('div.dataTables_wrapper').first().hide(); + $('#dahtebusTable').parents('div.dataTables_wrapper').first().hide(); + $('#lelongTable').parents('div.dataTables_wrapper').first().hide(); + var noic = $("#noic").val(); $.ajax({ method:"GET", url: api_url + "/api/customers/"+noic+"/gadai/belum_tebus", success: function(data){ - gadaiTable(data); + $('#myTable').parents('div.dataTables_wrapper').first().show(); + gadaiTable(data,"belum_tebus"); } }); $("input[name='options']").click(function(){ @@ -276,30 +382,44 @@ function gadaiOptionButton(noic){ tablegadai.clear().draw(); if($("input[name='options']:checked").val() == 'belum_tebus'){ + + $('#myTable').parents('div.dataTables_wrapper').first().show(); + $('#dahtebusTable').parents('div.dataTables_wrapper').first().hide(); + $('#lelongTable').parents('div.dataTables_wrapper').first().hide(); $.ajax({ method:"GET", url: api_url + "/api/customers/"+noic+"/gadai/belum_tebus", success: function(data){ - gadaiTable(data); + gadaiTable(data,"belum_tebus"); } }); } if($("input[name='options']:checked").val() == 'sudah_tebus'){ + + $('#myTable').parents('div.dataTables_wrapper').first().hide(); + $('#dahtebusTable').parents('div.dataTables_wrapper').first().show(); + $('#lelongTable').parents('div.dataTables_wrapper').first().hide(); + $.ajax({ method:"GET", url: api_url + "/api/customers/"+noic+"/gadai/sudah_tebus", success: function(data){ - gadaiTable(data); + gadaiTable(data,"sudah_tebus"); } }); } if($("input[name='options']:checked").val() == 'lelong'){ + + $('#myTable').parents('div.dataTables_wrapper').first().hide(); + $('#dahtebusTable').parents('div.dataTables_wrapper').first().hide(); + $('#lelongTable').parents('div.dataTables_wrapper').first().show(); + $.ajax({ method:"GET", url: api_url + "/api/customers/"+noic+"/gadai/lelong", success: function(data){ - gadaiTable(data); + gadaiTable(data,"lelong"); } }); } diff --git a/resources/views/penebusan/index.blade.php b/resources/views/penebusan/index.blade.php index a6f0d80..9f00a8c 100644 --- a/resources/views/penebusan/index.blade.php +++ b/resources/views/penebusan/index.blade.php @@ -4,15 +4,17 @@
-

gadaian

+

PENEBUSAN

+ + {{-- {{ dd($gadai) }} --}}
NAMA
- +
@@ -22,7 +24,7 @@ NO PELANGGGAN
- +
@@ -32,7 +34,7 @@ NO RUJUKAN
- +
@@ -42,7 +44,7 @@ NO KAD PENGENALAN
- +
@@ -52,12 +54,17 @@ JENIS TEBUS
- +
-
+
-
+
+
- +
- - - + - + + @foreach ($marhun as $index=>$m) + {{-- {{ dd($m) }} --}} + + + @php + $marhunperibadi = Http::get(config('api.url') .'/api/jemas/nama_marhun/',["marhun" => $m['marhun']])->json(); + @endphp + + + + + + @endforeach +
BilNo RujukanTarikh Gadai MarhunBerat Nilai MarhunBerat/gram KaratPinjaman
{{ $index+1 }}{{ $marhunperibadi['descpt'] }}RM {{ number_format($m['n_marhuns'],2) }}{{ $m['berat'] }}{{ $m['karat'] }}
+ {{-- {{dd($gadai)}} --}}
-
-
+ {{--
--}} +
- PINJAMAN + PINJAMAN(RM)
- +
-
+
- JUMLAH UPAH + JUMLAH UPAH(RM)
- +
-
-
+
- TELAH DIBAYAR + BAYARAN(RM)
- +
-
+
- PERLU DIBAYAR + TELAH DIBAYAR(RM)
- + +
+
+
+
+
+
+ PERLU DIBAYAR(RM) +
+
+
- +
@@ -152,4 +182,246 @@
+ + @endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 704a77d..d8d26b9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -33,7 +33,7 @@ Route::get('/pelanggan','CustomersController@index')->middleware('auth','teller' Route::get('/customer_info',['as'=>'customer_info','uses'=>'CustomersController@info'])->middleware('auth','teller'); Route::get('/gadaian',['as'=>'gadaian','uses'=>'GadaianController@index'])->middleware('auth','teller'); Route::get('/daftar_marhun',['as'=>'daftar_marhun','uses'=>'MarhunController@index'])->middleware('auth','teller'); -Route::get('/penebusan','PenebusanController@index')->middleware('auth','teller'); +Route::get('/penebusan/{norujukan}',['as'=>'penebusan','uses' => 'PenebusanController@index'])->middleware('auth','teller'); Route::get('/aliran_tunai','AliranTunaiController@index')->middleware('auth','teller'); Route::get('/harga_emas','HargaEmasController@index')->middleware('auth','teller'); Route::get('/profile',['as'=>'profile','uses'=>'UserController@index'])->middleware('auth','teller');