-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory-customer.php
193 lines (180 loc) · 6.61 KB
/
history-customer.php
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<style>
.lebar{
width: 80px !important;
}
</style>
<?php
session_start();
$idCustomer = $_SESSION['id_customer'];
$nama = $_SESSION['nama'];
date_default_timezone_set("Asia/Jakarta");
$tglHariIni = date('Y-m-d');
$judul = "Rekapitulasi Transaksi";
include "koneksi.php";
include "header-customer.php";
include "sidebar-customer.php";
include "topbar-customer.php";
?>
<div class="container-fluid pt-3 pb-5 backGambar">
<div class="row">
<div class="col-xl-12">
<h3 class="text-center text-uppercase text-dark">Rekapituasi Transaksi</h3>
<hr class="hr">
</div>
</div>
<!-- Periode -->
<form action="cetak-transaksi.php" method="post" target="_blank">
<div class="row mb-4 mt-2">
<div class="col-xl-10">
<div class="input-group mb-1">
<span class="input-group-text lebar">Dari</span>
<input type="date" name="periodeDari" id="periodeDari" class="form-control form-control-sm lebar" value="<?= $tglHariIni; ?>">
<span class="input-group-text lebar">Sampai</span>
<input type="date" name="periodeSampai" id="periodeSampai" class="form-control form-control-sm" value="<?= $tglHariIni; ?>">
<a class="btn btn-sm btn-primary text-white" id="periodeCari"><i class="fas fa-search pt-1"></i></a>
<button class="btn btn-sm btn-success text-white" type="submit" id="periodePrint" name="cetak"><i class="fas fa-print"></i></button>
</div>
</div>
</div>
</form>
<div class="row">
<div class="col-xl-12 table-responsive">
<div id="tampilkanTransaksiPeriode">
<table class="table table-bordered table-hover table-sm" id="tblTransaksi">
<thead>
<tr class="text-center">
<th width="5%">No.</th>
<th>Tanggal</th>
<th>No Transaksi</th>
<th>Detail</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$ttl= 0;
$sql = "SELECT * FROM tbl_transaksi WHERE id_pegawai = '$idCustomer' AND total_bayar > 0 ORDER BY tgl_transaksi DESC, no_transaksi DESC";
$query = mysqli_query($koneksi, $sql);
while ($data = mysqli_fetch_array($query)) {
$no_transaksi = $data['no_transaksi'];
$tanggal = date_create($data['tgl_transaksi']);
$ttl = $ttl + $data['total_transaksi'];?>
<tr>
<td align="center"><?= $no++; ?>.</td>
<td align="center"><?= date_format($tanggal, "d-m-Y"); ?></td>
<td><?= $no_transaksi; ?></td>
<td>
<table class="table table-bordered table-sm">
<thead>
<tr class="text-center bg-success">
<th width="5%">No.</th>
<th>Nama Menu</th>
<th>Harga</th>
<th>Qty</th>
<th>Sub</th>
</tr>
</thead>
<tbody>
<?php
$nomer = 1;
$sql1 = "SELECT a.qty, a.harga, b.nama_menu FROM tbl_transaksi_detail a INNER JOIN tbl_menu b ON a.id_menu = b.id_menu WHERE a.no_transaksi = '$no_transaksi' ORDER BY a.id_detail";
$query1 = mysqli_query($koneksi, $sql1);
while ($data1 = mysqli_fetch_array($query1)) { ?>
<tr>
<td align="center"><?= $nomer++; ?>.</td>
<td><?= $data1['nama_menu']; ?></td>
<td align="right"><?= number_format($data1['harga']); ?></td>
<td align="right"><?= number_format($data1['qty']); ?></td>
<td align="right"><?= number_format($data1['harga'] * $data1['qty']); ?>
</td>
</tr>
<?php
} ?>
</tbody>
</table>
</td>
<td align="right"><?= number_format($data['total_transaksi']); ?></td>
</tr>
<?php
} ?>
<tr style="font-weight: bold;height: 40px;font-size: 20px;">
<td colspan="3" align="right">TOTAL</td>
<td colspan="2" align="right"><?= number_format($ttl); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include "sticky-footer.php"; ?>
<?php include "footer.php"; ?>
<script>
$(document).ready(function() {
$('#tblTransaksi').dataTable();
// Menampilkan Tabel Transaksi Per Periode
$(document).on('click', '#periodeCari', function() {
var periodeDari = $('#periodeDari').val();
var periodeSampai = $('#periodeSampai').val();
var idPegawai = $('[name="id_pegawai"]').val();
$.ajax({
method: 'POST',
data: {
periodeDari: periodeDari,
periodeSampai: periodeSampai,
idPegawai: idPegawai
},
url: 'transaksi-cari-periode.php',
cache: false,
success: function() {
$('#tampilkanTransaksiPeriode').load('transaksi-cari-periode.php', {
periodeDari: periodeDari,
periodeSampai: periodeSampai,
idPegawai: idPegawai
});
}
});
});
// Hapus
$(document).on('click', '.transaksiAksi2', function(e) {
var id_detail = $(this).attr('id');
var id_peg = $(this).attr('id1');
var periodeDari = "";
var periodeSampai = "";
var idPegawai = "";
e.preventDefault();
Swal.fire({
title: "Hapus Data",
text: "Data akan disimpan?",
icon: "question",
showCancelButton: true,
confirmButtonColor: "red",
cancelButtonColor: "blue",
confirmButtonText: "Hapus",
}).then((result) => {
if (result.value) {
$.ajax({
method: 'POST',
data: {
id_detail: id_detail,
id_peg: id_peg
},
url: 'transaksi-delete-ajax1.php',
cache: false,
success: function() {
$('#tampilkanTransaksiPeriode').load('transaksi-cari-periode.php', {
periodeDari: periodeDari,
periodeSampai: periodeSampai,
idPegawai:idPegawai
});
}
});
}
});
});
$('.form-control-chosen').chosen({
allow_single_deselect: true,
});
});
</script>