komoditi
This commit is contained in:
@@ -977,14 +977,18 @@
|
||||
}
|
||||
|
||||
function editmarhun(e){
|
||||
let norujuk = $('#norujukan').val();let selectedrow = $(e).closest('tr');let recno = tablemarhun.row(selectedrow).data();
|
||||
let nm = recno[3];let karat = recno[4];let berat = recno[5];
|
||||
let norujuk = $('#norujukan').val();
|
||||
let selectedrow = $(e).closest('tr');
|
||||
let recno = tablemarhun.row(selectedrow).data();
|
||||
let nm = recno[3];
|
||||
let karat = recno[4];
|
||||
let berat = recno[5];
|
||||
let harga = recno[7];
|
||||
|
||||
|
||||
$('#sltkarat').val(karat);
|
||||
$('#berat').val(berat);
|
||||
$('#nilaimarhun').val(nm.substring(2));
|
||||
$('#nilaimarhun').val(nm);
|
||||
$('#harga1').val(harga);
|
||||
$('#norujukedit').val(norujuk);
|
||||
$('#recno').val(recno[1]);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Dashboard') }}</div>
|
||||
<div class="card-header">{{ __('Harga Emas Sandaran') }}</div>
|
||||
|
||||
<div class="card-body text-center">
|
||||
|
||||
@@ -106,7 +106,6 @@
|
||||
'harga2' : harga
|
||||
},
|
||||
success:function(data){
|
||||
console.log(data);
|
||||
if(data == 1){
|
||||
Swal.fire(
|
||||
'Berjaya!',
|
||||
@@ -115,6 +114,12 @@
|
||||
).then(function(){
|
||||
location.reload();
|
||||
});
|
||||
}else{
|
||||
Swal.fire(
|
||||
'Tidak Berjaya',
|
||||
'Emas Baru Tidak Berjaya Ditambah',
|
||||
'error'
|
||||
)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Komuditi') }}</div>
|
||||
<div class="card-header">{{ __('Komoditi') }}</div>
|
||||
<div class="card-body text-center">
|
||||
<div class="row">
|
||||
<div class="col-2 justify-content-start">
|
||||
@@ -40,23 +40,51 @@
|
||||
</div>
|
||||
<div class="row justify-content-center" id="tiada_komuditi">
|
||||
<div class="col-12">
|
||||
<p>Tiada Komuditi</p>
|
||||
<p>Tiada Komoditi</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group justify-content-center">
|
||||
<input type="hidden" value="{{ $user_name }}" id="user_name" name="user_name">
|
||||
<button class="btn btn-primary" id="pembelian">Pembelian Komuditi</button>
|
||||
<button class="btn btn-primary mr-2" id="pembelian">Pembelian Komoditi</button>
|
||||
<button class="btn btn-danger" id="penjualan">Penjualan Komoditi</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Rekod Pembelian/Penjualan Komoditi') }}</div>
|
||||
<div class="card-body text-center">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table id="rekod_komuditi">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bil</th>
|
||||
<th>No Sijil</th>
|
||||
<th>Tarikh</th>
|
||||
<th>Masa</th>
|
||||
<th>Nilai Komoditi</th>
|
||||
<th>Transaksi Oleh</th>
|
||||
<th>Transaksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="pembelian_modal" tabindex="-1" data-backdrop="static" aria-labelledby="ModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="ModalLabel">Pembelian Komuditi</h5>
|
||||
<h5 class="modal-title" id="ModalLabel">Pembelian Komoditi</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
@@ -112,8 +140,40 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="detail_komuditi" tabindex="-1" data-backdrop="static" aria-labelledby="ModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="ModalLabel">Detail Komoditi</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row form-group">
|
||||
<div class="col-md-4">Kod Produk / Diskripsi : </div>
|
||||
<div class="col-md-8"><span id="produk_span_modal"></span></div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<div class="col-md-4">Unit : </div>
|
||||
<div class="col-md-8"><span id="unit_span_modal"></span></div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<div class="col-md-4">Harga : </div>
|
||||
<div class="col-md-8"><span id="harga_span_modal"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="form-group row">
|
||||
<button type="button" class="btn btn-danger" name="tutup_komuditi" id="tutup_komuditi" data-dismiss="modal">Tutup</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
let api_url = "{{ $api_url }}";
|
||||
|
||||
var tablerekod = $('#rekod_komuditi').DataTable();
|
||||
|
||||
$(document).ready( function () {
|
||||
checkKomuditi();
|
||||
});
|
||||
@@ -126,6 +186,37 @@
|
||||
$('#pembelian_modal').modal('show');
|
||||
});
|
||||
|
||||
$('#penjualan').on('click',function(){
|
||||
var nosijil = $('#nosijil_span').text();
|
||||
console.log(nosijil);
|
||||
$.ajax({
|
||||
method:'post',
|
||||
url: api_url + '/api/komuditi/jual',
|
||||
datatype:'json',
|
||||
data:{
|
||||
'purchased_by': "{{ $user_name }}",
|
||||
'nosijil': nosijil
|
||||
},
|
||||
success:function(data){
|
||||
if(data == 1){
|
||||
checkKomuditi();
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berjaya!',
|
||||
text: 'Penjualan Unit Komuditi Berjaya'
|
||||
});
|
||||
}else{
|
||||
checkKomuditi();
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Penjualan Unit Komuditi Tidak Berjaya'
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$('#produk').change(function(){
|
||||
var produk = $('#produk').val();
|
||||
$.ajax({
|
||||
@@ -156,13 +247,22 @@
|
||||
},
|
||||
success:function(description){
|
||||
var komuditi_semasa = Object.keys(description).length
|
||||
console.log(komuditi_semasa);
|
||||
|
||||
if(komuditi_semasa == 0){
|
||||
$('#maklumat_komuditi').hide();
|
||||
$('#tiada_komuditi').show();
|
||||
$('#penjualan').prop('disabled', true);
|
||||
$('#pembelian').prop('disabled', false);
|
||||
}else{
|
||||
$('#maklumat_komuditi').show();
|
||||
$('#tiada_komuditi').hide();
|
||||
if(data['unit_komuditi'] == 0){
|
||||
$('#penjualan').prop('disabled', true);
|
||||
$('#pembelian').prop('disabled', false);
|
||||
}else{
|
||||
$('#penjualan').prop('disabled', false);
|
||||
$('#pembelian').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
$('#nosijil_span').text(data['no_sijil'])
|
||||
$('#harga_span').text('RM ' + formatter.format(data['nilai']))
|
||||
@@ -173,8 +273,48 @@
|
||||
})
|
||||
}
|
||||
});
|
||||
tablerekod.clear().draw();
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api_url + '/api/komuditi/rekodkomuditi',
|
||||
success:function(rekod){
|
||||
var bilcount = 0;
|
||||
$.each(rekod,function(index,rekod_transaksi){
|
||||
bilcount ++
|
||||
tablerekod.row.add([
|
||||
bilcount,
|
||||
"<a data-toggle='modal' data-kodproduk='"+ rekod_transaksi['kodproduk'] +"' data-harga='" + rekod_transaksi['harga'] +"' data-target='#detail_komuditi' >"+rekod_transaksi['nosijil'] + '</a>',
|
||||
rekod_transaksi['date_purchase'],
|
||||
rekod_transaksi['time_purchase'],
|
||||
formatter.format(rekod_transaksi['unit_komuditi']),
|
||||
rekod_transaksi['transaction_by'],
|
||||
rekod_transaksi['transaction_type']
|
||||
]).draw();
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$('#detail_komuditi').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var kodproduk = button.data('kodproduk');
|
||||
var harga = button.data('harga');
|
||||
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url : api_url + '/api/komuditi/description',
|
||||
dataType : 'json',
|
||||
data:{
|
||||
'kodproduk': kodproduk
|
||||
},
|
||||
success:function(description){
|
||||
$('#harga_span_modal').text('RM ' + formatter.format(harga));
|
||||
$('#produk_span_modal').text(description['kodproduk'] + ' / ' + description['description']);
|
||||
$('#unit_span_modal').text(description['unit']);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$('#terima_komuditi').on('click',function(){
|
||||
var nosijil = $('#nosijil').val();
|
||||
var produk = $('#produk').val();
|
||||
|
||||
Reference in New Issue
Block a user