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 --}}
+
+
+
+
+ | Bil |
+ No Rujukan |
+ Tarikh Gadai |
+ Pembiayaan |
+ Nilai Marhun |
+ Tempoh |
+ Keuntungan |
+ Tarikh Matang |
+ Margin |
+ Kos Keuntungan |
+ Hapus Gadai |
+
+
+
+
+
+
+
+
+ | Bil |
+ No Rujukan |
+ Tarikh Gadai |
+ Pembiayaan |
+ Nilai Marhun |
+ Tempoh |
+ Keuntungan |
+ Tarikh Matang |
+ Margin |
+ Kos Keuntungan |
+ Hapus 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 @@
@@ -32,7 +34,7 @@
NO RUJUKAN
-
+
@@ -42,7 +44,7 @@
NO KAD PENGENALAN
-
+
@@ -52,12 +54,17 @@
JENIS TEBUS
-
+
-
+
-
+
+ {{-- {{dd($gadai)}} --}}