From 90fa15a65dbe2725deea286b8e6c63efc63e4631 Mon Sep 17 00:00:00 2001 From: mikhailkusuma Date: Sat, 20 Jan 2024 12:04:15 +0700 Subject: [PATCH] Update: Diskon --- .../views/pages/Kasir/transaksi.blade.php | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/resources/views/pages/Kasir/transaksi.blade.php b/resources/views/pages/Kasir/transaksi.blade.php index c8504ee..d359bcc 100644 --- a/resources/views/pages/Kasir/transaksi.blade.php +++ b/resources/views/pages/Kasir/transaksi.blade.php @@ -437,18 +437,19 @@ var total = table.rows[index].getAttribute('data-total'); qty = parseInt(qty) + 1; + var totalLama = parseInt(total) + parseInt(menuPrice); diskonSatuan = parseInt(diskonSatuan); total = (parseInt(total) + parseInt(menuPrice)) - ((parseInt(total) + parseInt(menuPrice)) * (diskonSatuan / 100)); table.rows[index].setAttribute('data-qty', qty); 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 = ` ${params.nama_produk}
- ${(diskonSatuan > 0) ? 'Rp. ' + harga + ' | Rp. ' + total + '' : 'Rp. ' + total + ''} + ${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
@@ -470,7 +471,7 @@ table.rows[index].cells[2].innerHTML = `
- +
`; @@ -507,7 +508,7 @@
- +
@@ -585,18 +586,19 @@ var harga = table.rows[index].getAttribute('data-harga'); qty = parseInt(qty) + 1; + var totalLama = parseInt(total) + parseInt(harga); diskonSatuan = parseInt(diskonSatuan); total = (parseInt(total) + parseInt(harga)) - ((parseInt(total) + parseInt(harga)) * (diskonSatuan / 100)); table.rows[index].setAttribute('data-qty', qty); 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 = ` ${nama_produk}
- ${(diskonSatuan > 0) ? 'Rp. ' + harga + ' | Rp. ' + total + '' : 'Rp. ' + total + ''} + ${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
@@ -640,18 +642,19 @@ if (qty > 1) { qty = parseInt(qty) - 1; + var totalLama = parseInt(total) - parseInt(harga); diskonSatuan = parseInt(diskonSatuan); total = (parseInt(total) - parseInt(harga)) - ((parseInt(total) - parseInt(harga)) * (diskonSatuan / 100)); table.rows[index].setAttribute('data-qty', qty); 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 = ` ${nama_produk}
- ${(diskonSatuan > 0) ? 'Rp. ' + harga + ' | Rp. ' + total + '' : 'Rp. ' + total + ''} + ${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
@@ -676,6 +679,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 = ` + + ${nama_produk} +
+ ${(diskonSatuan >= 1) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''} +
+ +
+ + `; + + calculateTotal(); + // } + } + // diskon use keyup document.getElementsByName('diskon')[0].addEventListener('keyup', function() { var diskon = document.getElementsByName('diskon')[0].value;