diff --git a/app/Http/Controllers/KhazanahController.php b/app/Http/Controllers/KhazanahController.php index 5057724..264d12d 100644 --- a/app/Http/Controllers/KhazanahController.php +++ b/app/Http/Controllers/KhazanahController.php @@ -444,10 +444,17 @@ class KhazanahController extends Controller } public function barcodescanned(Request $request){ - // dd($request); + // dd($request->all()); $auth_user = Auth::user(); + $gadai_detail = Http::get(config('api.url'). '/api/gadai/norujukan/'.$auth_user['cawangan'].'/'.$request->norujukan_barcode)->json(); + // dd($gadai_detail[0]); $gadai = Http::put(config('api.url').'/api/gadai/serah_marhun/khazanah/'. $auth_user['cawangan'] .'/' . $request->norujukan_barcode)->json(); - + $komuditi = Http::put(config('api.url').'/api/komuditi/transaksi',[ + 'unit_komuditi' => $gadai_detail[0]['pinjaman'], + 'norujukan' => $request->norujukan_barcode, + 'kodcaw' => $gadai_detail[0]['kodcaw'], + 'teller' => $gadai_detail[0]['teller'] + ]); event(new NotifikasiPembayaran('TellerkepadaKhazanah')); return redirect()->route('khazanah.gadaian'); diff --git a/app/Http/Controllers/KomuditiController.php b/app/Http/Controllers/KomuditiController.php new file mode 100644 index 0000000..4b2e312 --- /dev/null +++ b/app/Http/Controllers/KomuditiController.php @@ -0,0 +1,12 @@ + + #daftar_gadai{ + color:#fff !important; + } + @@ -251,7 +257,7 @@ No Telefon
- +
@@ -282,7 +288,7 @@
- Daftar Gadai + Daftar Gadai
@@ -355,7 +361,38 @@ @endsection diff --git a/resources/views/gadaian/edit.blade.php b/resources/views/gadaian/edit.blade.php index 2cec96a..96f36e8 100644 --- a/resources/views/gadaian/edit.blade.php +++ b/resources/views/gadaian/edit.blade.php @@ -300,8 +300,8 @@ url: api_url + '/api/harga_emas/'+karat, success:function(data){ - var nilai_marhun = data['harga2'] * berat; - $('#harga').val(data['harga2']); + var nilai_marhun = data['harga'] * berat; + $('#harga').val(data['harga']); $('#nilai_marhun').val(formatter.format(nilai_marhun)); } }) diff --git a/resources/views/gadaian/index.blade.php b/resources/views/gadaian/index.blade.php index 4ff2f8e..7000699 100644 --- a/resources/views/gadaian/index.blade.php +++ b/resources/views/gadaian/index.blade.php @@ -50,8 +50,8 @@
-
- {{-- --}} + + @csrf
@@ -293,8 +293,8 @@ url: api_url + '/api/harga_emas/'+karat, success:function(data){ - var nilai_marhun = data['harga2'] * berat; - $('#harga').val(data['harga2']); + var nilai_marhun = data['harga'] * berat; + $('#harga').val(data['harga']); $('#nilai_marhun').val(formatter.format(nilai_marhun)); } }) @@ -466,7 +466,8 @@ $('#berat_emas').val(""); $('#harga').val(""); $('#nilai_marhun').val(""); - + $('#daftar_marhun').modal('hide'); + jumlah_marhun += 1; jumlah_nilai_marhun += Number(nilai_marhun); $('#bilangan_marhun').val(formatter.format(jumlah_marhun)); @@ -579,6 +580,7 @@ }); function verifyGadai(func){ + event.preventDefault(); var kodcaw = $('#kodcaw').val(); var nokp = $('#nokp').val(); var nopelanggan = $('#nopelanggan').val(); @@ -586,13 +588,14 @@ var pinjaman = Number($('#pinjaman').val()); var total_nilai_marhun = $('#total_nilai_marhun').val(); var nilai_marhun_total = Number(total_nilai_marhun.replace(/[^0-9.-]+/g,"")); - + var count_error = 0; var pembiayaan_max_teller = $('#pembiayaan_max_teller').val(); var pembiayaan_max_teller = Number(pembiayaan_max_teller.replace(/[^0-9.-]+/g,"")); var pembiyaan_max_pelulus = $('#pembiyaan_max_pelulus').val(); var pembiyaan_max_pelulus = Number(pembiyaan_max_pelulus.replace(/[^0-9.-]+/g,"")); var min_pinjaman = nilai_marhun_total * 0.10; var max_pinjaman = nilai_marhun_total * 0.80; + if($.isNumeric(pinjaman) == false){ Swal.fire({ icon: 'error', @@ -610,8 +613,7 @@ }); event.preventDefault(); return false; - } - else if(pinjaman > max_pinjaman){ + }else if(pinjaman > max_pinjaman){ Swal.fire({ icon: 'error', title: 'Amaran!', @@ -619,250 +621,229 @@ }); event.preventDefault(); return false; - } - else{ - if(pinjaman > Number(pembiyaan_max_pelulus)+10){ - // Swal.fire({ - // icon: 'error', - // title: 'Amaran!', - // text: 'Pembiayaan Memerlukan Kelulusan Operasi' - // }); - // event.preventDefault(); - // return false; + }else{ + $.ajax({ + method:'get', + url: api_url + '/api/komuditi/check', + success:function(data){ + var check_komuditi = Object.keys(data).length; + if(check_komuditi == 0){ + Swal.fire({ + icon: 'error', + title: 'Unit Komuditi Berbaki Minumum', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + }else{ + if(Number(data['unit_komuditi']) < pinjaman){ + Swal.fire({ + icon: 'error', + title: 'Baki Unit Komuditi Tidak Mencukupi', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + } + else{ + if(pinjaman > Number(pembiyaan_max_pelulus)+10){ + const swalWithBootstrapButtons = Swal.mixin({ + customClass: { + confirmButton: 'btn btn-success', + cancelButton: 'btn btn-danger' + }, + buttonsStyling: false + }); - const swalWithBootstrapButtons = Swal.mixin - ({ - customClass: { - confirmButton: 'btn btn-success', - cancelButton: 'btn btn-danger' - }, - buttonsStyling: false - }) + swalWithBootstrapButtons.fire({ + title: 'Dapatkan Pengesahan Daripada Operasi?', + text: "Tetapan margin melebihi 75% untuk Operasi!", + icon: 'info', + showCancelButton: true, + confirmButtonText: 'Setuju!', + cancelButtonText: 'Batal', + reverseButtons: true + }).then((result) => { + if (result.isConfirmed) { + + let norujukan = $('#norujukan').val(); - swalWithBootstrapButtons.fire({ - title: 'Dapatkan Pengesahan Daripada Operasi?', - text: "Tetapan margin melebihi 75% untuk Operasi!", - icon: 'info', - showCancelButton: true, - confirmButtonText: 'Setuju!', - cancelButtonText: 'Batal', - reverseButtons: true - }).then((result) => { - if (result.isConfirmed) { - - let norujukan = $('#norujukan').val(); + Swal.fire({ + title: 'Tunggu Pengesahan Daripada Operasi.', + icon: 'info', + width: 600, + padding: '3em', + background: '#fffff', + showCancelButton: false, + showConfirmButton: false, + allowOutsideClick: false, + allowEscapeKey: false, + allowEnterKey: false + }) - Swal.fire({ - title: 'Tunggu Pengesahan Daripada Operasi.', - icon: 'info', - width: 600, - padding: '3em', - background: '#fffff', - showCancelButton: false, - showConfirmButton: false, - allowOutsideClick: false, - allowEscapeKey: false, - allowEnterKey: false - }) - - $.ajax({ - method:'post', - url: "{{ route('operasi.createkelulusan') }}", - data: { - "_token": "{{ csrf_token() }}", - "norujukan" : norujukan - // "teller" : teller, - // "dategadai" : dategadai, - // "bilgadai" : noic, - // "jumpinjam" : jumpinjam, - // "teller" : teller - - }, - success:function(data){ - - console.log(data); - - },error: function(xhr, status, error) { - var err = eval("(" + xhr.responseText + ")"); - alert(xhr.responseText); - } - }); - - //TIME INTERVAL - let timerInterval; - - timerInterval = setInterval(function() - { - $.ajax({ - method:'get', - url: "{{ route('operasi.getkelulusan') }}", - data: { - "norujukan" : norujukan - }, - success:function(data){ - - if(data != '') - { - clearInterval(timerInterval); - Swal.fire({ - icon: 'success', - title: 'Anda Berjaya Menerima Pengesahan' - }).then(function(){ - - $(func).attr("onSubmit","return true;"); - $(func).submit(); - return true; - - }); + $.ajax({ + method:'post', + url: "{{ route('operasi.createkelulusan') }}", + data: { + "_token": "{{ csrf_token() }}", + "norujukan" : norujukan + }, + success:function(data){ + console.log(data); + }, + error: function(xhr, status, error) { + var err = eval("(" + xhr.responseText + ")"); + alert(xhr.responseText); } + }); - },error: function(xhr, status, error) { - var err = eval("(" + xhr.responseText + ")"); - alert(xhr.responseText); - } - }); + //TIME INTERVAL + let timerInterval; - }, 3000); - - - } else if ( - /* Read more about handling dismissals below */ - result.dismiss === Swal.DismissReason.cancel - ) { - swalWithBootstrapButtons.fire( - 'Cancelled', - 'Your imaginary file is safe :)', - 'error' - ) - } - }); - - event.preventDefault(); - return false; + timerInterval = setInterval(function(){ + $.ajax({ + method:'get', + url: "{{ route('operasi.getkelulusan') }}", + data: { + "norujukan" : norujukan + }, + success:function(data){ + if(data != ''){ + clearInterval(timerInterval); + Swal.fire({ + icon: 'success', + title: 'Anda Berjaya Menerima Pengesahan' + }).then(function(){ + $(func).attr("onSubmit","return true;"); + $(func).submit(); + return true; + }); + } + }, + error: function(xhr, status, error) { + var err = eval("(" + xhr.responseText + ")"); + alert(xhr.responseText); + } + }); + }, 3000); + }else if (result.dismiss === Swal.DismissReason.cancel){ + swalWithBootstrapButtons.fire( + 'Cancelled', + 'Your imaginary file is safe :)', + 'error' + ) + } + }); + event.preventDefault(); + return false; + }else if(pinjaman > Number(pembiayaan_max_teller)+10){ + const swalWithBootstrapButtons = Swal.mixin({ + customClass: { + confirmButton: 'btn btn-success', + cancelButton: 'btn btn-danger' + }, + buttonsStyling: false + }); - }else if(pinjaman > Number(pembiayaan_max_teller)+10){ - + swalWithBootstrapButtons.fire({ + title: 'Dapatkan Pengesahan Daripada Khazanah?', + text: "Tetapan margin melebihi 70% untuk Khazanah!", + icon: 'info', + showCancelButton: true, + confirmButtonText: 'Setuju!', + cancelButtonText: 'Batal', + reverseButtons: true + }).then((result) => { + if (result.isConfirmed) { + + let norujukan = $('#norujukan').val(); - const swalWithBootstrapButtons = Swal.mixin - ({ - customClass: { - confirmButton: 'btn btn-success', - cancelButton: 'btn btn-danger' - }, - buttonsStyling: false - }) + Swal.fire({ + title: 'Tunggu Pengesahan Daripada Khazanah.', + icon: 'info', + width: 600, + padding: '3em', + background: '#fffff', + showCancelButton: false, + showConfirmButton: false, + allowOutsideClick: false, + allowEscapeKey: false, + allowEnterKey: false + }) - swalWithBootstrapButtons.fire({ - title: 'Dapatkan Pengesahan Daripada Khazanah?', - text: "Tetapan margin melebihi 70% untuk Khazanah!", - icon: 'info', - showCancelButton: true, - confirmButtonText: 'Setuju!', - cancelButtonText: 'Batal', - reverseButtons: true - }).then((result) => { - if (result.isConfirmed) { - - let norujukan = $('#norujukan').val(); - - Swal.fire({ - title: 'Tunggu Pengesahan Daripada Khazanah.', - icon: 'info', - width: 600, - padding: '3em', - background: '#fffff', - showCancelButton: false, - showConfirmButton: false, - allowOutsideClick: false, - allowEscapeKey: false, - allowEnterKey: false - }) - - $.ajax({ - method:'post', - url: "{{ route('khazanah.createkelulusan') }}", - data: { - "_token": "{{ csrf_token() }}", - "norujukan" : norujukan - // "teller" : teller, - // "dategadai" : dategadai, - // "bilgadai" : noic, - // "jumpinjam" : jumpinjam, - // "teller" : teller - - }, - success:function(data){ - - console.log(data); - - },error: function(xhr, status, error) { - var err = eval("(" + xhr.responseText + ")"); - alert(xhr.responseText); - } - }); - - //TIME INTERVAL - let timerInterval; - - timerInterval = setInterval(function() - { - $.ajax({ - method:'get', - url: "{{ route('khazanah.getkelulusan') }}", - data: { - "norujukan" : norujukan - }, - success:function(data){ - - if(data != '') - { - clearInterval(timerInterval); - Swal.fire({ - icon: 'success', - title: 'Anda Berjaya Menerima Pengesahan' - }).then(function(){ - - $(func).attr("onSubmit","return true;"); - $(func).submit(); - return true; - - }); + $.ajax({ + method:'post', + url: "{{ route('khazanah.createkelulusan') }}", + data: { + "_token": "{{ csrf_token() }}", + "norujukan" : norujukan + }, + success:function(data){ + console.log(data); + }, + error: function(xhr, status, error) { + var err = eval("(" + xhr.responseText + ")"); + alert(xhr.responseText); } + }); - },error: function(xhr, status, error) { - var err = eval("(" + xhr.responseText + ")"); - alert(xhr.responseText); - } - }); + //TIME INTERVAL + let timerInterval; - }, 3000); - - - } else if ( - /* Read more about handling dismissals below */ - result.dismiss === Swal.DismissReason.cancel - ) { - swalWithBootstrapButtons.fire( - 'Cancelled', - 'Your imaginary file is safe :)', - 'error' - ) - } - }); - - event.preventDefault(); - return false; - - - } - } - Swal.fire({ - icon: 'success', - title: 'Berjaya!', - text: 'Gadaian Berjaya Disimpan' - }); - return true; + timerInterval = setInterval(function(){ + $.ajax({ + method:'get', + url: "{{ route('khazanah.getkelulusan') }}", + data: { + "norujukan" : norujukan + }, + success:function(data){ + + if(data != '') + { + clearInterval(timerInterval); + Swal.fire({ + icon: 'success', + title: 'Anda Berjaya Menerima Pengesahan' + }).then(function(){ + $(func).attr("onSubmit","return true;"); + $(func).submit(); + return true; + + }); + } + + },error: function(xhr, status, error) { + var err = eval("(" + xhr.responseText + ")"); + alert(xhr.responseText); + } + }); + }, 3000); + } else if (result.dismiss === Swal.DismissReason.cancel) { + swalWithBootstrapButtons.fire( + 'Cancelled', + 'Your imaginary file is safe :)', + 'error' + ) + } + }); + event.preventDefault(); + return false; + } + Swal.fire({ + icon: 'success', + title: 'Berjaya!', + text: 'Gadaian Berjaya Disimpan' + }); + $(func).attr("onSubmit","return true;"); + $(func).submit(); + return true; + } + } + } + }); + } } @endsection diff --git a/resources/views/homepage/operasi/home.blade.php b/resources/views/homepage/operasi/home.blade.php index 362ce97..f9e1a86 100644 --- a/resources/views/homepage/operasi/home.blade.php +++ b/resources/views/homepage/operasi/home.blade.php @@ -11,6 +11,7 @@ Kelulusan Daftar Kakitangan Parameter + Komuditi
diff --git a/resources/views/homepage/penilai/home.blade.php b/resources/views/homepage/penilai/home.blade.php index df17ea2..30c813d 100644 --- a/resources/views/homepage/penilai/home.blade.php +++ b/resources/views/homepage/penilai/home.blade.php @@ -28,17 +28,18 @@
-
- +
+ @csrf +
-
- +
@@ -136,11 +137,11 @@ @php $marhun = Http::get($api_url . '/api/marhun/' . $gadaian['norujukan'] )->json(); @endphp - {{$gadaian['norujukan']}} + {{$gadaian['norujukan']}} - {{ $gadaian['pinjaman'] }} - {{ $gadaian['nilaimarhun'] }} - {{ $gadaian['berat'] }} + {{ number_format($gadaian['pinjaman'],2) }} + {{ number_format($gadaian['nilaimarhun'],2) }} + {{ number_format($gadaian['berat'],2) }} @php $count++; @endphp @endforeach @@ -179,9 +180,9 @@ @endphp {{$gadaian['norujukan']}} - {{ $gadaian['pinjaman'] }} - {{ $gadaian['nilaimarhun'] }} - {{ $gadaian['berat'] }} + {{ number_format($gadaian['pinjaman'],2) }} + {{ number_format($gadaian['nilaimarhun'],2) }} + {{ number_format($gadaian['berat'],2) }} @php $count++; @endphp @endforeach @@ -226,66 +227,6 @@ minimumFractionDigits: 2 }); - // $('#cetak_sag').click(function(){ - // var kodcaw = $('#kodcaw').val(); - // var norujukan = $('#norujukan_modal').val(); - // $.ajax({ - // url: api_url + '/api/gadai/norujukan/cetak/'+ kodcaw + '/' + norujukan, - // method: 'put', - // success: function(data){ - - // Swal.fire({ - // icon: 'success', - // title: 'Berjaya!', - // text: 'Cetak SAG Berjaya' - // }); - // }, - // error: function(xhRequest, ErrorText, thrownError){ - // Swal.fire({ - // icon: 'error', - // title: 'Amaran!', - // text: 'Cetak SAG Tidak Berjaya' - // }); - // console.log(xhRequest); - // } - // }); - // }); - - // $('#pembelian_komuditi').click(function(){ - // var kodcaw = $('#kodcaw').val(); - // var norujukan = $('#norujukan_modal').val(); - // $.ajax({ - // url: api_url + '/api/gadai/norujukan/komuditi/'+ kodcaw + '/' + norujukan, - // method: 'put', - // success: function(data){ - - // Swal.fire({ - // icon: 'success', - // title: 'Berjaya!', - // text: 'Pembelian Komuditi Berjaya' - // }); - // }, - // error: function(xhRequest, ErrorText, thrownError){ - // Swal.fire({ - // icon: 'error', - // title: 'Amaran!', - // text: 'Pembelian Komuditi Tidak Berjaya' - // }); - // console.log(xhRequest); - // } - // }); - // }); - - function cetakSAG(kodcaw,norujukan){ - $.ajax({ - url: api_url + 'gadai/norujukan/' + kodcaw + '/' + norujukan, - method:'get', - success: function(data){ - console.log(data); - } - }); - } - //modal $('#marhunModal').on('show.bs.modal', function(event) { var button = $(event.relatedTarget); // button yg trigger @@ -293,14 +234,16 @@ var norujukan = button.data('norujukan'); var kodcaw = button.data('kodcaw'); var hargajualan = button.data('hargajualan'); - - $('#pembelian_komuditi').attr('href','http://bsas-arrahn.test/pembelian/komuditi?norujukan='+norujukan); + var pinjaman = button.data('pinjaman'); + // $('#pembelian_komuditi').attr('href','http://bsas-arrahn.test/pembelian/komuditi?norujukan='+norujukan); $('#norujukan_modal').val(norujukan); - cetakSAG(kodcaw,norujukan); + $('#pinjaman_modal').val(pinjaman); $('#tablemarhun').empty(); + var bil_count = 0; $.each(arraymarhun,function(index,marhun){ - $.each(marhun, function(index,marhun_detail){ + $.each(marhun, function(index2,marhun_detail){ + bil_count++; var marhun_name; $.ajax({ method:'GET', @@ -310,7 +253,7 @@ marhun:marhun_detail['marhun'] }, success:function(marhun_ajax){ - $("#tablemarhun").append("" + marhun_detail['bil'] + "" + marhun_ajax['descpt'] +"" + marhun_detail['berat'] +"" + marhun_detail['karat'] +"RM " + marhun_detail['n_marhun'].toLocaleString(undefined,{minimumFractionDigits:2}) +""+ marhun_detail['nota'] +""); + $("#tablemarhun").append("" + bil_count + "" + marhun_ajax['descpt'] +"" + marhun_detail['berat'] +"" + marhun_detail['karat'] +"RM " + marhun_detail['n_marhun'].toLocaleString(undefined,{minimumFractionDigits:2}) +""+ marhun_detail['nota'] +""); } }); }); @@ -324,10 +267,11 @@ var norujukan = button.data('norujukan'); var kodcaw = button.data('kodcaw'); var hargajualan = button.data('hargajualan'); + var pinjaman = button.data('pinjaman'); $('#tablemarhun').empty(); $.each(arraymarhun,function(index,marhun){ - $.each(marhun, function(index,marhun_detail){ + $.each(marhun, function(index2,marhun_detail){ var marhun_name; $.ajax({ method:'GET', @@ -337,13 +281,54 @@ marhun:marhun_detail['marhun'] }, success:function(marhun_ajax){ - $("#belum_serah").append("" + marhun_detail['bil'] + "" + marhun_ajax['descpt'] +"" + marhun_detail['berat'] +"" + marhun_detail['karat'] +"RM " + marhun_detail['n_marhun'].toLocaleString(undefined,{minimumFractionDigits:2}) +""+ marhun_detail['nota'] +""); + $("#belum_serah").append("" + index2 + "" + marhun_ajax['descpt'] +"" + marhun_detail['berat'] +"" + marhun_detail['karat'] +"RM " + marhun_detail['n_marhun'].toLocaleString(undefined,{minimumFractionDigits:2}) +""+ marhun_detail['nota'] +""); } }); }); }); }); + + function verifyKomuditi(func){ + event.preventDefault(); + var norujukan = $('#norujukan_modal').val(); + var pinjaman = $('#pinjaman_modal').val(); + + $.ajax({ + method:'get', + url: api_url + '/api/komuditi/check', + success:function(data){ + var check_komuditi = Object.keys(data).length; + if(check_komuditi == 0){ + Swal.fire({ + icon: 'error', + title: 'Unit Komuditi Berbaki Minumum', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + }else{ + if(Number(data['unit_komuditi']) < pinjaman){ + Swal.fire({ + icon: 'error', + title: 'Baki Unit Komuditi Tidak Mencukupi', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + } + else{ + console.log('in'); + $(func).attr("onSubmit","return true;"); + $(func).submit(); + location.reload(); + return true; + } + } + } + }); + } + var total_marhun_pilih = 0; $(document).on('click', '#checkgadai', function(e) { if ($(this).is(':checked')) { @@ -353,7 +338,7 @@ total_marhun_pilih += Number(marhun); - $('#marhunpilih').val(total_marhun_pilih.toFixed(2)); + $('#marhunpilih').val(formatter.format(total_marhun_pilih.toFixed(2))); $("#btn-serah").prop('disabled', false); diff --git a/resources/views/khazanah/gadaian.blade.php b/resources/views/khazanah/gadaian.blade.php index e66c923..d520c2c 100644 --- a/resources/views/khazanah/gadaian.blade.php +++ b/resources/views/khazanah/gadaian.blade.php @@ -24,7 +24,6 @@ Karat Nilai Marhun Nota test - @@ -63,7 +62,7 @@
-
+ @csrf @@ -117,8 +116,8 @@ {{$gadaian['norujukan']}} - {{ $gadaian['pinjaman'] }} - {{ $gadaian['nilaimarhun'] }} + {{ number_format($gadaian['pinjaman'],2) }} + {{ number_format($gadaian['nilaimarhun'],2) }} {{ $gadaian['teller'] }} @endforeach @@ -150,7 +149,9 @@ @if (is_array($petibesi) || is_object($petibesi)) + @php $total_nm = 0; @endphp @foreach($petibesi as $index=>$marhun) + @php $total_nm += $marhun['nilaimarhun']; @endphp {{ $index+1 }} @@ -159,8 +160,8 @@ @endphp {{$marhun['norujukan']}} - {{ $marhun['pinjaman'] }} - {{ $marhun['nilaimarhun'] }} + {{ number_format($marhun['pinjaman'],2) }} + {{ number_format($marhun['nilaimarhun'],2) }} {{ $marhun['teller'] }} @endforeach @@ -174,13 +175,13 @@
- +
- Laporan Scan Barcode Gadaian + Laporan Scan Barcode Gadaian Senarai Pembatalan No Rujukan
@@ -221,6 +222,83 @@ }); + function verifyKomuditi(func){ + event.preventDefault(); + var norujukan =$('#norujukan_barcode').val(); + + $.ajax({ + method:'get', + url: api_url + '/api/gadai/norujukan/' + norujukan, + success:function(data){ + var pinjaman = data[0][0]['pinjaman']; + $.ajax({ + method:'get', + url: api_url + '/api/komuditi/check', + success:function(data){ + var check_komuditi = Object.keys(data).length; + if(check_komuditi == 0){ + Swal.fire({ + icon: 'error', + title: 'Unit Komuditi Berbaki Minumum', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + }else{ + if(Number(data['unit_komuditi']) < pinjaman){ + Swal.fire({ + icon: 'error', + title: 'Baki Unit Komuditi Tidak Mencukupi', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + } + else{ + console.log('in'); + $(func).attr("onSubmit","return true;"); + $(func).submit(); + return true; + } + } + } + }); + } + }) + $.ajax({ + method:'get', + url: api_url + '/api/komuditi/check', + success:function(data){ + var check_komuditi = Object.keys(data).length; + if(check_komuditi == 0){ + Swal.fire({ + icon: 'error', + title: 'Unit Komuditi Berbaki Minumum', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + }else{ + if(Number(data['unit_komuditi']) < pinjaman){ + Swal.fire({ + icon: 'error', + title: 'Baki Unit Komuditi Tidak Mencukupi', + text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' + }); + event.preventDefault(); + return false; + } + else{ + console.log('in'); + $(func).attr("onSubmit","return true;"); + $(func).submit(); + return true; + } + } + } + }); + } + $('#norujukan_barcode').keyup(function(){ if(this.value.length >= 14){ $('#submit_button').submit(); diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index ea305ac..cf28ea4 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -24,7 +24,7 @@ - + diff --git a/resources/views/layouts/app_operasi.blade.php b/resources/views/layouts/app_operasi.blade.php index a88420d..79e390d 100644 --- a/resources/views/layouts/app_operasi.blade.php +++ b/resources/views/layouts/app_operasi.blade.php @@ -24,7 +24,7 @@ - + @@ -89,7 +89,7 @@