Compare commits
2 Commits
137eb42ac7
...
1b58f36d9f
Author | SHA1 | Date |
---|---|---|
|
1b58f36d9f | |
|
90fa15a65d |
|
@ -336,18 +336,13 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-bordered table-striped" id="order-menus" width="100%">
|
<table class="table table-bordered table-striped" id="order-menus" width="100%">
|
||||||
<thead style="background-color: lightgray">
|
<thead style="background-color: lightgray">
|
||||||
{{-- <tr>
|
|
||||||
<th width="60%" class="text-center">Menu</th>
|
|
||||||
<th>Qty</th>
|
|
||||||
<th width="10%" style="text-align: center">
|
|
||||||
<i class="fas fa-cog"></i>
|
|
||||||
</th>
|
|
||||||
</tr> --}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center">Menu</th>
|
<th class="text-center">Menu</th>
|
||||||
<th class="text-center" width="100px">Qty</th>
|
<th class="text-center" width="110px">Qty</th>
|
||||||
<th class="text-center" width="60px">(%)</th>
|
<th class="text-center" width="65px">(%)</th>
|
||||||
<th class="text-center" width="30px">⚙️</th>
|
<th class="text-center" width="30px">
|
||||||
|
<i class="fas fa-cog"></i>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="tbody-order-menus">
|
<tbody id="tbody-order-menus">
|
||||||
|
@ -519,19 +514,21 @@
|
||||||
var total = table.rows[index].getAttribute('data-total');
|
var total = table.rows[index].getAttribute('data-total');
|
||||||
|
|
||||||
qty = parseInt(qty) + 1;
|
qty = parseInt(qty) + 1;
|
||||||
|
var totalLama = parseInt(total) + parseInt(menuPrice);
|
||||||
diskonSatuan = parseInt(diskonSatuan);
|
diskonSatuan = parseInt(diskonSatuan);
|
||||||
total = (parseInt(total) + parseInt(menuPrice)) - ((parseInt(total) + parseInt(menuPrice)) * (diskonSatuan /
|
total = (parseInt(total) + parseInt(menuPrice)) - ((parseInt(total) + parseInt(menuPrice)) * (diskonSatuan /
|
||||||
100));
|
100));
|
||||||
|
|
||||||
table.rows[index].setAttribute('data-qty', qty);
|
table.rows[index].setAttribute('data-qty', qty);
|
||||||
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
||||||
table.rows[index].setAttribute('data-total', total);
|
table.rows[index].setAttribute('data-total', totalLama);
|
||||||
|
|
||||||
|
var harga = menuPrice;
|
||||||
table.rows[index].cells[0].innerHTML = `
|
table.rows[index].cells[0].innerHTML = `
|
||||||
<td>
|
<td>
|
||||||
${params.nama_produk}
|
${params.nama_produk}
|
||||||
<br>
|
<br>
|
||||||
${(diskonSatuan > 0) ? '<small class="text-primary"><s>Rp. ' + harga + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + total + '</small>'}
|
${(diskonSatuan > 0) ? '<small class="text-primary"><s>Rp. ' + (harga * qty) + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + totalLama + '</small>'}
|
||||||
<div class="input-group input-group-sm mt-1">
|
<div class="input-group input-group-sm mt-1">
|
||||||
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
||||||
</div>
|
</div>
|
||||||
|
@ -553,7 +550,7 @@
|
||||||
table.rows[index].cells[2].innerHTML = `
|
table.rows[index].cells[2].innerHTML = `
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<div class="input-group input-group-sm">
|
<div class="input-group input-group-sm">
|
||||||
<input type="number" name="diskon_satuan" class="form-control rounded-0" value="0">
|
<input type="number" name="diskon_satuan" class="form-control rounded-0" value="${diskonSatuan}" onkeyup="diskonSatuanMenu(${params.id}, '${params.nama_produk}', this.value)">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
|
@ -590,7 +587,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<div class="input-group input-group-sm">
|
<div class="input-group input-group-sm">
|
||||||
<input type="number" name="diskon_satuan" class="form-control rounded-0" value="0">
|
<input type="number" name="diskon_satuan" class="form-control rounded-0" value="0" onkeyup="diskonSatuanMenu(${params.id}, '${params.nama_produk}', this.value)">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
|
@ -668,18 +665,19 @@
|
||||||
var harga = table.rows[index].getAttribute('data-harga');
|
var harga = table.rows[index].getAttribute('data-harga');
|
||||||
|
|
||||||
qty = parseInt(qty) + 1;
|
qty = parseInt(qty) + 1;
|
||||||
|
var totalLama = parseInt(total) + parseInt(harga);
|
||||||
diskonSatuan = parseInt(diskonSatuan);
|
diskonSatuan = parseInt(diskonSatuan);
|
||||||
total = (parseInt(total) + parseInt(harga)) - ((parseInt(total) + parseInt(harga)) * (diskonSatuan / 100));
|
total = (parseInt(total) + parseInt(harga)) - ((parseInt(total) + parseInt(harga)) * (diskonSatuan / 100));
|
||||||
|
|
||||||
table.rows[index].setAttribute('data-qty', qty);
|
table.rows[index].setAttribute('data-qty', qty);
|
||||||
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
||||||
table.rows[index].setAttribute('data-total', total);
|
table.rows[index].setAttribute('data-total', totalLama);
|
||||||
|
|
||||||
table.rows[index].cells[0].innerHTML = `
|
table.rows[index].cells[0].innerHTML = `
|
||||||
<td>
|
<td>
|
||||||
${nama_produk}
|
${nama_produk}
|
||||||
<br>
|
<br>
|
||||||
${(diskonSatuan > 0) ? '<small class="text-primary"><s>Rp. ' + harga + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + total + '</small>'}
|
${(diskonSatuan > 0) ? '<small class="text-primary"><s>Rp. ' + (harga * qty) + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + totalLama + '</small>'}
|
||||||
<div class="input-group input-group-sm mt-1">
|
<div class="input-group input-group-sm mt-1">
|
||||||
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
||||||
</div>
|
</div>
|
||||||
|
@ -723,18 +721,19 @@
|
||||||
|
|
||||||
if (qty > 1) {
|
if (qty > 1) {
|
||||||
qty = parseInt(qty) - 1;
|
qty = parseInt(qty) - 1;
|
||||||
|
var totalLama = parseInt(total) - parseInt(harga);
|
||||||
diskonSatuan = parseInt(diskonSatuan);
|
diskonSatuan = parseInt(diskonSatuan);
|
||||||
total = (parseInt(total) - parseInt(harga)) - ((parseInt(total) - parseInt(harga)) * (diskonSatuan / 100));
|
total = (parseInt(total) - parseInt(harga)) - ((parseInt(total) - parseInt(harga)) * (diskonSatuan / 100));
|
||||||
|
|
||||||
table.rows[index].setAttribute('data-qty', qty);
|
table.rows[index].setAttribute('data-qty', qty);
|
||||||
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
||||||
table.rows[index].setAttribute('data-total', total);
|
table.rows[index].setAttribute('data-total', totalLama);
|
||||||
|
|
||||||
table.rows[index].cells[0].innerHTML = `
|
table.rows[index].cells[0].innerHTML = `
|
||||||
<td>
|
<td>
|
||||||
${nama_produk}
|
${nama_produk}
|
||||||
<br>
|
<br>
|
||||||
${(diskonSatuan > 0) ? '<small class="text-primary"><s>Rp. ' + harga + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + total + '</small>'}
|
${(diskonSatuan > 0) ? '<small class="text-primary"><s>Rp. ' + (harga * qty) + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + totalLama + '</small>'}
|
||||||
<div class="input-group input-group-sm mt-1">
|
<div class="input-group input-group-sm mt-1">
|
||||||
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
||||||
</div>
|
</div>
|
||||||
|
@ -759,6 +758,51 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// diskon satuan menu ordered
|
||||||
|
function diskonSatuanMenu(params, nama_produk, diskon = 0) {
|
||||||
|
var table = document.getElementById("order-menus");
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
|
for (var i = 1, row; row = table.rows[i]; i++) {
|
||||||
|
var id = row.getAttribute('data-id');
|
||||||
|
|
||||||
|
if (id == params) {
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var qty = table.rows[index].getAttribute('data-qty');
|
||||||
|
var diskonSatuan = parseInt(diskon);
|
||||||
|
var total = table.rows[index].getAttribute('data-total');
|
||||||
|
var harga = table.rows[index].getAttribute('data-harga');
|
||||||
|
|
||||||
|
|
||||||
|
// if (diskonSatuan >= 1) {
|
||||||
|
console.log(diskonSatuan);
|
||||||
|
var totalLama = total;
|
||||||
|
qty = parseInt(qty);
|
||||||
|
diskonSatuan = parseInt(diskonSatuan);
|
||||||
|
total = (parseInt(total)) - ((parseInt(total)) * (diskonSatuan / 100));
|
||||||
|
|
||||||
|
table.rows[index].setAttribute('data-qty', qty);
|
||||||
|
table.rows[index].setAttribute('data-diskon-satuan', diskonSatuan);
|
||||||
|
table.rows[index].setAttribute('data-total', totalLama);
|
||||||
|
|
||||||
|
table.rows[index].cells[0].innerHTML = `
|
||||||
|
<td>
|
||||||
|
${nama_produk}
|
||||||
|
<br>
|
||||||
|
${(diskonSatuan >= 1) ? '<small class="text-primary"><s>Rp. ' + (harga * qty) + '</s></small> | <small class="text-danger">Rp. ' + total + '</small>' : '<small class="text-primary">Rp. ' + totalLama + '</small>'}
|
||||||
|
<div class="input-group input-group-sm mt-1">
|
||||||
|
<input type="text" name="keterangan_satuan" class="form-control rounded-0" placeholder="Keterangan..">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
`;
|
||||||
|
|
||||||
|
calculateTotal();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
// diskon use keyup
|
// diskon use keyup
|
||||||
document.getElementsByName('diskon')[0].addEventListener('keyup', function() {
|
document.getElementsByName('diskon')[0].addEventListener('keyup', function() {
|
||||||
var diskon = document.getElementsByName('diskon')[0].value;
|
var diskon = document.getElementsByName('diskon')[0].value;
|
||||||
|
|
Loading…
Reference in New Issue