-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdaftarproduk.php
274 lines (254 loc) · 10.9 KB
/
daftarproduk.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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
session_start();
require 'class.php';
if (!isset($_SESSION['uname']) && !isset($_SESSION['pwd'])) {
header("location: login.php");
}
$username = $_SESSION['uname'];
$role = $_SESSION['role'];
$barang = new Barang();
$kategori = new Kategori();
if (isset($_GET['key'])) {
$search = "%" . $_GET['key'] . "%";
} else {
$search = "%";
}
if (isset($_GET['kategori'])) {
$kate = "%" . $_GET['kategori'] . "%";
} else {
$kate = "%";
}
$result = ($barang)->getTotalData($kate, $search);
if (isset($_GET['key'])) {
$key = $_GET['key'];
} else {
$key = "";
}
if (isset($_GET['kategori'])) {
$kate = $_GET['kategori'];
} else {
$kate = "";
}
// $resultKAdd = ($kategori)->bacaData('%');
// $resultKEdit = ($kategori)->bacaData('%');
$nourut = 1;
$resultK = ($kategori)->bacaData('%');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dapur Perdana</title>
<link rel="stylesheet" href="dashboardstyle.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" />
</head>
<body>
<div class="overlay" id="overlay"></div>
<nav class="sidebar">
<a class="logo">Dapur Perdana</a>
<div class="menu-content">
<ul class="menu-items">
<li class="item">
<a href="index.php"><i class="fa-solid fa-gauge-high"></i>Dashboard</a>
</li>
<li class="item">
<a href="supplier.php"><i class="fa-solid fa-truck-field"></i>Supplier</a>
</li>
<li class="item">
<div class="submenu-item">
<span> <i class="fa-solid fa-box"></i>Produk</span>
<i class="fa-solid fa-chevron-right"></i>
</div>
<ul class="menu-items submenu">
<div class="menu-title">
<i class="fa-solid fa-chevron-left"></i>
Produk
</div>
<li class="item">
<a href="kategoriproduk.php"> <i class="fa-solid fa-circle"></i>Kategori Produk</a>
</li>
<li class="item">
<a href="daftarproduk.php"><i class="fa-solid fa-circle"></i>Daftar Produk</a>
</li>
</ul>
</li>
<li class="item">
<a href="penyesuaian.php"> <i class="fa-solid fa-boxes-stacked"></i>Penyesuaian</a>
</li>
<li class="item">
<div class="submenu-item">
<span> <i class="fa-solid fa-book"></i>Laporan</span>
<i class="fa-solid fa-chevron-right"></i>
</div>
<ul class="menu-items submenu">
<div class="menu-title">
<i class="fa-solid fa-chevron-left"></i>
Laporan
</div>
<li class="item">
<a href="laporanpenjualan.php"> <i class="fa-solid fa-circle"></i>Laporan Penjualan</a>
</li>
</ul>
</li>
<?php
if ($role == 'pemilik') {
echo '<li class="item">';
echo '<a href="pegawai.php"> <i class="fa-solid fa-user-plus"></i>Pegawai</a>';
echo '</li>';
}
?>
<li class="item">
<a href="logout.php"> <i class="fa-solid fa-arrow-right-from-bracket"></i>Logout</a>
</li>
</ul>
<div class="user-profile">
<i class="fas fa-user-circle user-icon"></i>
<?php echo '<span class="user-name">' . $username . '</span>'; ?>
</div>
</div>
</nav>
<main class="main">
<div class="container">
<div class="add-produk">
<div class="action-buttons">
<!-- ADD -->
<a class="add-button" id="add-supp" href="addDaftarProduk.php" style='text-decoration:none;text-align:center'>Add</a>
</div>
<div class="line"></div>
</div>
<div class="title-filter-search">
<div class="title-wrapper">
<h2>Daftar Produk</h2>
</div>
<div class="filter-search">
<form action="" method="GET">
<?php
echo '<input type="text" name="kategori" placeholder="Kategori..." value="' . $kate . '">';
echo '<input type="text" name="key" placeholder="Search..." id="search" value="' . $key . '">';
?>
<button type="submit" id="search-button" name="submit"><i class="fa-solid fa-search"></i></button>
</form>
</div>
</div>
<div class="table-wrapper">
<table class="table">
<tr>
<th>Kode</th>
<th>Nama</th>
<th>Harga Jual</th>
<th>Harga Beli</th>
<th>Stok Tersedia</th>
<th>Kategori</th>
<th>Actions</th>
</tr>
<?php
while ($row = $result->fetch_assoc()) {
$kategoribarang = (new Kategori)->bacaDataById($row['id_kategori']);
$namaK = $kategoribarang->fetch_assoc();
echo "<tr>";
echo "<td>" . $nourut . "</td>";
$nourut++;
echo "<td class='left-align'>" . $row['nama'] . "</td>";
echo "<td class='right-align'>Rp" . number_format($row['harga_jual'], 0, ',', '.') . "</td>";
echo "<td class='right-align'>Rp" . number_format($row['harga_beli'], 0, ',', '.') . "</td>";
echo "<td>" . $row['stok_tersedia'] . "</td>";
echo "<td class='center-align'>" . $namaK['nama'] . "</td>";
// echo "<td>
// <button class='edit-button' onclick='openEditForm()'>Edit</button>
// <button class='delete-button' onclick='openDeleteConfirmation()'>Delete</button>
// </td>";
$idDaftarProduk = $row['id'];
echo "<td>
<a href='updateDaftarProduk.php?id=$idDaftarProduk' class='edit-button'>Edit</a>
<a href='deleteDaftarProduk.php?id=$idDaftarProduk' class='delete-button'>Delete</a>
</td>";
echo "</tr>";
}
?>
</table>
</div>
</div>
</main>
<!-- TAMBAH PRODUK -->
<!-- <div class="popup-form" id="addForm">
<div class="form-header">
<span class="form-title">Add Produk</span>
<span class="close-icon" onclick="closeAddForm()">✖</span>
</div>
<form class="form-container">
<input type="text" placeholder="Nama Barang" required />
<input type="number" placeholder="Harga Jual" required />
<input type="number" placeholder="Harga Beli" required />
<input type="number" placeholder="Stok Tersedia" required />
<select name="kategori" required>
<option value="">Select kategori</option>
// while ($rowK = $resultKAdd->fetch_assoc()) {
// echo '<option value=' . $rowK['id'] . '>' . $rowK['nama'] . '</option>';
// }
</select>
<div class="button-container">
<button type="button" class="cancel-button" onclick="closeAddForm()">Cancel</button>
<button type="submit" class="submit-button" id="submitAddForm">Add</button>
</div>
</form>
</div> -->
<!-- EDIT PRODUK -->
<!-- <div class="popup-form" id="editForm">
<div class="form-header">
<span class="form-title">Edit Produk</span>
<span class="close-icon" onclick="closeEditForm()">✖</span>
</div>
<form class="form-container">
<input type="text" placeholder="Nama Barang" required />
<input type="number" placeholder="Harga Jual" required />
<input type="number" placeholder="Harga Beli" required />
<input type="number" placeholder="Stok Tersedia" required />
<select name="kategori" required>
<?php
// while ($rowK = $resultKEdit->fetch_assoc()) {
// echo '<option value=' . $rowK['id'] . '>' . $rowK['nama'] . '</option>';
// }
?>
</select>
<div class="button-container">
<button type="button" class="cancel-button" onclick="closeEditForm()">Cancel</button>
<button type="submit" class="submit-button" id="submitEditForm">Edit</button>
</div>
</form>
</div> -->
<!-- <div class="popup-form" id="deleteConfirmation">
<div class="form-container">
<p>Apakah Anda yakin ingin menghapusnya?</p>
<div class="button-container">
<button type="submit" class="submit-button">Yes</button>
<button type="button" class="cancel-button" onclick="closeDeleteConfirmation()">No</button>
</div>
</div>
</div> -->
<!-- <div class="popup-form" id="addSuccessForm">
<div class="success-content">
<i class="fa-regular fa-circle-check success-icon"></i>
<div class="success-text">
<p>Sukses</p>
<div class="line"></div>
<p>Sukses menambah data</p>
</div>
<button class="close-button" onclick="closeAddSuccessForm()">OK</button>
</div>
</div>
<div class="popup-form" id="editSuccessForm">
<div class="success-content">
<i class="fa-regular fa-circle-check success-icon"></i>
<div class="success-text">
<p>Sukses</p>
<div class="line"></div>
<p>Sukses mengubah data</p>
</div>
<button class="close-button" onclick="closeEditSuccessForm()">OK</button>
</div>
</div> -->
<script src="js/script.js"></script>
</body>
</html>