125 lines
3.9 KiB
PHP
125 lines
3.9 KiB
PHP
@extends('layouts.app_operasi')
|
|
|
|
@include('modal.hargaemas')
|
|
|
|
@section('content')
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-header">{{ __('Dashboard') }}</div>
|
|
|
|
<div class="card-body text-center">
|
|
|
|
<h2>Harga Emas Sandaran</h2>
|
|
|
|
<div class="mt-5">
|
|
|
|
<table class='table mt-4' id='table-emas' style="width:100%;">
|
|
<thead>
|
|
<tr>
|
|
<th>Bil</th>
|
|
<th>Mutu Emas</th>
|
|
<th>Karat</th>
|
|
<th>Harga/Gram</th>
|
|
<th>Tarikh Ubah</th>
|
|
<th>Tindakan</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($harga_emas as $index=>$he)
|
|
<tr>
|
|
<td>{{ $loop->iteration }}</td>
|
|
<td>{{ $he['keterangan'] }}</td>
|
|
<td>{{ $he['karat'] }}</td>
|
|
<td>{{ $he['harga'] }}</td>
|
|
<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="#" onclick="hapusharga(this)" data-recno="{{ $he['recno'] }}" class="btn btn-danger"><i class="fas fa-trash-alt"></i></a>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
<div class="row mt-5 col-12 d-flex justify-content-end">
|
|
|
|
<a href="#" data-toggle="modal" data-target="#createHargaModal" data-backdrop="static" data-keyboard="false" class="btn btn-info col-3 mr-2">Tambah Harga Emas</a>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
|
|
let api_url = "{{ $api_url }}";
|
|
|
|
var tableemas = $('#table-emas').DataTable({
|
|
"scrollX": true
|
|
});
|
|
|
|
|
|
function editharga(e)
|
|
{
|
|
let rec_no = $(e).data('recno');
|
|
let keterangan = $(e).closest('tr').find('td:eq(1)').text();
|
|
let karat = $(e).closest('tr').find('td:eq(2)').text();
|
|
let harga = $(e).closest('tr').find('td:eq(3)').text();
|
|
|
|
$('#recno').val(rec_no);
|
|
$('#keterangan').val(keterangan);
|
|
$('#karat').val(karat);
|
|
$('#harga').val(harga);
|
|
|
|
$('#kemaskiniHargaModal').modal();
|
|
|
|
}
|
|
|
|
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
|