-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathkasir.php
More file actions
executable file
·126 lines (114 loc) · 3.79 KB
/
Copy pathkasir.php
File metadata and controls
executable file
·126 lines (114 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
include 'config.php';
session_start();
include 'authcheckkasir.php';
$barang = mysqli_query($dbconnect, 'SELECT * FROM barang');
// print_r($_SESSION);
$sum = 0;
if (isset($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $key => $value) {
$sum += ($value['harga'] * $value['qty']) - $value['diskon'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Kasir</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Kasir</h1>
<h2>Hai <?=$_SESSION['nama']?></h2>
<a href="logout.php">Logout</a> |
<a href="keranjang_reset.php">Reset Keranjang</a> |
<a href="riwayat.php">Riwayat Transaksi</a>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-8">
<form method="post" action="keranjang_act.php">
<div class="form-group">
<input type="text" name="kode_barang" class="form-control" placeholder="Masukkan Kode Barang" autofocus>
</div>
</form>
<br>
<form method="post" action="keranjang_update.php">
<table class="table table-bordered">
<tr>
<th>Nama</th>
<th>Harga</th>
<th>Qty</th>
<th>Sub Total</th>
<th></th>
</tr>
<?php if (isset($_SESSION['cart'])): ?>
<?php foreach ($_SESSION['cart'] as $key => $value) { ?>
<tr>
<td>
<?=$value['nama']?>
<?php if ($value['diskon'] > 0): ?>
<br><small class="label label-danger">Diskon <?=number_format($value['diskon'])?></small>
<?php endif;?>
</td>
<td align="right"><?=number_format($value['harga'])?></td>
<td class="col-md-2">
<input type="number" name="qty[<?=$key?>]" value="<?=$value['qty']?>" class="form-control">
</td>
<td align="right"><?=number_format(($value['qty'] * $value['harga'])-$value['diskon'])?></td>
<td><a href="keranjang_hapus.php?id=<?=$value['id']?>" class="btn btn-danger"><i class="glyphicon glyphicon-remove"></i></a></td>
</tr>
<?php } ?>
<?php endif; ?>
</table>
<button type="submit" class="btn btn-success">Perbaruhi</button>
</form>
</div>
<div class="col-md-4">
<h3>Total Rp. <?=number_format($sum)?></h3>
<form action="transaksi_act.php" method="POST">
<input type="hidden" name="total" value="<?=$sum?>">
<div class="form-group">
<label>Bayar</label>
<input type="text" id="bayar" name="bayar" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Selesai</button>
</form>
</div>
</div>
</div>
<script type="text/javascript">
//inisialisasi inputan
var bayar = document.getElementById('bayar');
bayar.addEventListener('keyup', function (e) {
bayar.value = formatRupiah(this.value, 'Rp. ');
// harga = cleanRupiah(dengan_rupiah.value);
// calculate(harga,service.value);
});
//generate dari inputan angka menjadi format rupiah
function formatRupiah(angka, prefix) {
var number_string = angka.replace(/[^,\d]/g, '').toString(),
split = number_string.split(','),
sisa = split[0].length % 3,
rupiah = split[0].substr(0, sisa),
ribuan = split[0].substr(sisa).match(/\d{3}/gi);
if (ribuan) {
separator = sisa ? '.' : '';
rupiah += separator + ribuan.join('.');
}
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
}
//generate dari inputan rupiah menjadi angka
function cleanRupiah(rupiah) {
var clean = rupiah.replace(/\D/g, '');
return clean;
// console.log(clean);
}
</script>
</body>
</html>