-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaksi-cari-periode.php
110 lines (109 loc) · 4.24 KB
/
transaksi-cari-periode.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
<?php
session_start();
include "koneksi.php";
$no = 1;
$id_pegawai = $_SESSION['id_pegawai'];
$jabatan = $_SESSION['jabatan'];
$periodeDari = $_POST['periodeDari'];
$periodeSampai = $_POST['periodeSampai'];
$idPeg = $_POST['idPegawai'];
?>
<table class="table table-bordered table-hover table-sm" id="tblTransaksi2">
<thead>
<tr class="text-center">
<th width="5%">No.</th>
<th>Tgl</th>
<th>No Transaksi</th>
<th>Detail</th>
<th>Total</th>
<th>Meja</th>
<?php
if($jabatan!="Kasir"){?>
<th>Kasir</th>
<?php
}?>
<th>Aksi</th>
</tr>
</thead>
<tbody>
<?php
if($idPeg=="" && $jabatan!="Kasir"){
$sql = "SELECT * FROM tbl_transaksi a INNER JOIN tbl_pegawai b ON a.id_pegawai = b.id_pegawai ORDER BY a.tgl_transaksi DESC, a.no_transaksi";
}else if($idPeg!="" && $jabatan!="Kasir"){
$sql = "SELECT * FROM tbl_transaksi a INNER JOIN tbl_pegawai b ON a.id_pegawai = b.id_pegawai WHERE a.id_pegawai = '$idPeg' ORDER BY a.tgl_transaksi DESC, a.no_transaksi";
}else{
$sql = "SELECT * FROM tbl_transaksi a INNER JOIN tbl_pegawai b ON a.id_pegawai = b.id_pegawai WHERE a.id_pegawai = '$id_pegawai' ORDER BY a.tgl_transaksi DESC, a.no_transaksi";
}
$query = mysqli_query($koneksi, $sql);
if($a=mysqli_num_rows($query)>0){
while($data = mysqli_fetch_array($query)){
$tgl = $data['tgl_transaksi'];
if(($tgl >= $periodeDari && $tgl <= $periodeSampai) || ($periodeDari == "" && $periodeSampai == "")){
$nama_pegawai = $data['nama_pegawai'];
$no_transaksi = $data['no_transaksi'];
$tanggal = date_create($data['tgl_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>
<?php
if($jabatan=="Manajer"){?>
<th>Aksi</th>
<?php
}?>
</tr>
</thead>
<tbody>
<?php
$nomer = 1;
$sql1 = "SELECT * 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>
<?php
if($jabatan=="Manajer"){?>
<td align="center"><i class="fas fa-trash text-danger transaksiAksi2" id=<?= $data1['id_detail'];?> title="hapus"></i></td>
<?php
}?>
</tr>
<?php
}?>
</tbody>
</table>
</td>
<td align="right"><?= number_format($data['total_transaksi']);?></td>
<td align="center"><?= $data['no_meja'];?></td>
<?php
if($jabatan!="Kasir"){?>
<td ><?= $nama_pegawai; ?></td>
<?php
}?>
<td align="center">
<a href="cetak_struk.php?no_transaksi=<?= $no_transaksi;?>" class="btn btn-success btn-sm" target="_blank"><i class="fa fa-print"></i> CETAK</a>
</td>
</tr>
<?php
}
}
}?>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#tblTransaksi2').dataTable();
});
</script>