-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaksi.php
247 lines (237 loc) · 13.7 KB
/
transaksi.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
session_start();
if( !isset($_SESSION["login"]) ) {
header("Location: login.php");
exit;
}
require 'config/functions.php';
$queryTransaksi = "
SELECT tb_transaksi.id_barang,
tb_barang.nama_barang,
tb_barang.merk,
tb_transaksi.jumlah,
tb_barang.harga_beli * tb_transaksi.jumlah AS 'modal',
tb_barang.harga_jual * tb_transaksi.jumlah AS 'total',
tb_transaksi.kasir,
tb_transaksi.waktu_input
FROM tb_transaksi
INNER JOIN tb_barang USING(id_barang)
";
$transaksi = query("$queryTransaksi");
$queryTotal = "
SELECT
SUM(jumlah) AS total_jumlah,
SUM(modal) AS total_modal,
SUM(total) AS total_total
FROM ($queryTransaksi) as tb_transaksibarang;
";
$total = query($queryTotal);
$keuntungan = $total[0]["total_total"] - $total[0]["total_modal"];
if(isset($_POST["laporBulanan"])){
$queryTransaksi = laporanBulanan($_POST);
$transaksi = query("$queryTransaksi");
$queryTotal = "
SELECT
SUM(jumlah) AS total_jumlah,
SUM(modal) AS total_modal,
SUM(total) AS total_total
FROM ($queryTransaksi) as tb_transaksibarang;
";
$total = query($queryTotal);
$keuntungan = $total[0]["total_total"] - $total[0]["total_modal"];
}
if(isset($_POST["laporTanggal"])){
$queryTransaksi = laporanTanggal($_POST);
$transaksi = query("$queryTransaksi");
$queryTotal = "
SELECT
SUM(jumlah) AS total_jumlah,
SUM(modal) AS total_modal,
SUM(total) AS total_total
FROM ($queryTransaksi) as tb_transaksibarang;
";
$total = query($queryTotal);
$keuntungan = $total[0]["total_total"] - $total[0]["total_modal"];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'header.php'; ?>
<title>EdgeStore - Transaksi</title>
</head>
<body class="font-[Inter] flex">
<!-- Sidebar -->
<?php include 'sidebar.php'; ?>
<!-- Content -->
<div class="content flex basis-11/12 bg-indigo-200 h-screen duration-1000">
<div class="bg-white min-w-full my-10 overflow-auto">
<div class="flex mx-12 mt-12">
<h1 class="grow text-4xl text-slate-700 font-bold ">Data Transaksi</h1>
<a href="profile.php" class="flex items-center">
<img src="<?php echo get_photos($_SESSION["username"]); ?>" alt="Profile" width="36" class="rounded-full">
<span class="ml-4 font-bold underline"><?php echo get_username($_SESSION["username"]); ?></span>
</a>
</div>
<div class="flex mb-4 px-12 flex-row ">
<div class="float-left mr-20">
<h1 class="text-xl text-slate-700 font-semibold mt-8 mb-4">Cari Laporan Per Bulan</h1>
<table class="rounded-md overflow-hidden shadow-xl">
<thead class="bg-emerald-400 text-white px-4 ">
<tr class="text-left">
<th class="p-4">Tahun</th>
<th class="p-4">Bulan</th>
<th class="p-4">Aksi</th>
</tr>
</thead>
<tbody class="text-left ">
<tr>
<form action="" method="post">
<td class="p-4">
<select name="tahun" id="tahun" class="border-2 border-slate-600 p-2 rounded-lg" required>
<option value="" selected disabled hidden>Pilih Tahun</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
</select>
</td>
<td class="p-4">
<select name="bulan" id="bulan" class="border-2 border-slate-600 p-2 rounded-lg" required>
<option value="" selected disabled hidden>Pilih Bulan</option>
<option value="01">Januari</option>
<option value="02">Februari</option>
<option value="03">Maret</option>
<option value="04">April</option>
<option value="05">Mei</option>
<option value="06">Juni</option>
<option value="07">Juli</option>
<option value="08">Agustus</option>
<option value="09">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">Desember</option>
</select>
</td>
<td colspan="3" class="p-4">
<button type="laporBulanan" name="laporBulanan" class="py-2 px-4 bg-indigo-400 rounded-2xl text-white"><i class="bi bi-search"></i> Cari </button>
</td>
</form>
</tr>
</tbody>
</table>
</div>
<div class="float-right">
<h1 class="text-xl text-slate-700 font-semibold mt-8 mb-4">Cari Laporan Per Tanggal</h1>
<table class="rounded-md overflow-hidden shadow-xl">
<thead class="bg-emerald-400 text-white px-4 ">
<tr class="text-left">
<th class="p-4">Tahun</th>
<th class="p-4">Bulan</th>
<th class="p-4">Tanggal</th>
<th class="p-4">Aksi</th>
</tr>
</thead>
<tbody class="text-left ">
<tr>
<form action="" method="post">
<td class="p-4">
<select name="tahun" id="tahun" class="border-2 border-slate-600 p-2 rounded-lg" required>
<option value="" selected disabled hidden>Pilih Tahun</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
</select>
</td>
<td class="p-4">
<select name="bulan" id="bulan" class="border-2 border-slate-600 p-2 rounded-lg" required>
<option value="" selected disabled hidden>Pilih Bulan</option>
<option value="01">Januari</option>
<option value="02">Februari</option>
<option value="03">Maret</option>
<option value="04">April</option>
<option value="05">Mei</option>
<option value="06">Juni</option>
<option value="07">Juli</option>
<option value="08">Agustus</option>
<option value="09">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">Desember</option>
</select>
</td>
<td class="p-4">
<select name="tanggal" id="tanggal" class="border-2 border-slate-600 p-2 rounded-lg" required>
<option value="" selected disabled hidden>Pilih Tanggal</option>
<option value="1">1</option>
<?php for($i = 2; $i < 32; $i++){?>
<option value="<?= $i; ?>"><?= $i; ?></option>
<?php } ?>
</select>
</td>
<td colspan="3" class="p-4">
<button type="laporTanggal" name="laporTanggal" class="py-2 px-4 bg-indigo-400 rounded-2xl text-white"><i class="bi bi-search"></i> Cari </button>
</td>
</form>
</tr>
</tbody>
</table>
</div>
</div>
<div class="px-12 border-collapse mt-12 mb-6">
<div class="flex">
<h1 class="text-xl text-slate-700 font-semibold float-left grow">Data Transaksi</h1>
<button class="bg-emerald-400 rounded-md py-1 px-2 text-white text-sm float-left">
<a href="transaksi-kasir.php">Lihat Daftar Kasir</a>
</button>
</div>
<table class="min-w-full shadow-xl rounded-t-md overflow-hidden h-full mt-4">
<thead class="bg-emerald-400 text-white">
<tr class="">
<th class="py-4">No</th>
<th class="py-4">ID Barang</th>
<th class="py-4">Nama Barang</th>
<th class="py-4">Merk</th>
<th class="py-4">Jumlah</th>
<th class="py-4">Modal</th>
<th class="py-4">Total</th>
<th class="py-4">Kasir</th>
<th class="py-4">Waktu Input</th>
</tr>
</thead>
<tbody class="text-center ">
<?php $i = 1;?>
<?php foreach( $transaksi as $row ) : ?>
<tr>
<td class="px-2 py-4"><?= $i?></td>
<td class="px-2 py-4"><?= $row["id_barang"]; ?></td>
<td class="px-2 py-4"><?= $row["nama_barang"]; ?></td>
<td class="px-2 py-4"><?= $row["merk"]; ?></td>
<td class="px-2 py-4"><?= $row["jumlah"]; ?></td>
<td class="px-2 py-4"><?= $row["modal"] + 0; ?></td>
<td class="px-2 py-4"><?= $row["total"] + 0; ?></td>
<td class="px-2 py-4"><?= $row["kasir"]; ?></td>
<td class="px-2 py-4"><?= $row["waktu_input"]; ?></td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
<tr class="font-bold">
<td colspan="4">Total Terjual</td>
<td class="px-2 py-4"><?= $total[0]["total_jumlah"] + 0; ?></td>
<td class="px-2 py-4"><?= $total[0]["total_modal"] + 0; ?></td>
<td class="px-2 py-4"><?= $total[0]["total_total"] + 0; ?></td>
<td class="px-2 py-4 bg-emerald-400">Keuntungan</td>
<td class="px-2 py-4 bg-emerald-400"><?= $keuntungan; ?></td>
</tr>
</tbody>
</table>
<div class="bg-emerald-400 p-0.5 rounded-b-md"></div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>
</body>
</html>