edit marhun
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
<td>{{ $he['tarikhupdate'] }}</td>
|
||||
<td class="text-center">
|
||||
<a href="#" onclick="editharga(this)" data-recno="{{ $he['recno'] }}" class="btn btn-primary"><i class="fas fa-edit"></i></a>
|
||||
<a href="#" id="modal_history_es" data-toggle="modal" data-target="#history_emas" data-karat="{{ $he['karat'] }}" class="btn btn-info"><i class="fas fa-info"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -54,6 +55,38 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="history_emas" tabindex="-1" data-backdrop="static" aria-labelledby="ModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="ModalLabel">Rekod Emas Sandaran</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table id="history_es">
|
||||
<thead>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>Karat</td>
|
||||
<td>Harga/Gram</td>
|
||||
<td>Tarikh Efektif</td>
|
||||
<td>Masa Efektif</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</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 }}";
|
||||
@@ -62,6 +95,12 @@
|
||||
"scrollX": true
|
||||
});
|
||||
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
|
||||
var history_es = $('#history_es').DataTable();
|
||||
|
||||
$('#terima_emas').on('click',function(){
|
||||
$('#kemaskiniHargaModal').modal('hide');
|
||||
var recno = $('#recno').val();
|
||||
@@ -124,6 +163,34 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#history_emas').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var karat = button.data('karat');
|
||||
history_es.clear().draw();
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api_url + '/api/harga_emas/rekod/sandaran',
|
||||
datatype:'json',
|
||||
data:{
|
||||
'karat':karat
|
||||
},
|
||||
success:function(rekodsandaran){
|
||||
console.log(rekodsandaran);
|
||||
var bilcount = 0;
|
||||
$.each(rekodsandaran,function(index,emassandaran){
|
||||
bilcount ++
|
||||
history_es.row.add([
|
||||
bilcount,
|
||||
emassandaran['karat'],
|
||||
formatter.format(emassandaran['harga']),
|
||||
emassandaran['t_efektif'],
|
||||
emassandaran['m_efektif']
|
||||
]).draw();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function editharga(e)
|
||||
@@ -142,45 +209,6 @@
|
||||
|
||||
}
|
||||
|
||||
function hapusharga(e)
|
||||
{
|
||||
let rec_no = $(e).data('recno');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$.ajax({
|
||||
method: 'put',
|
||||
url: api_url + '/api/harga_emas/delete/' + rec_no,
|
||||
success:function(data)
|
||||
{
|
||||
console.log(data);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Swal.fire(
|
||||
'Deleted!',
|
||||
'Your file has been deleted.',
|
||||
'success'
|
||||
).then(function(){
|
||||
|
||||
location.reload();
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user