-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_product.html
289 lines (250 loc) · 8.38 KB
/
view_product.html
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Products</title>
<style>
/* Reset default margin and padding */
body, h1, h2, h3, p, ul, li {
margin: 0;
padding: 0;
}
/* Global styles */
body {
font-family: Arial, sans-serif;
color: #8fb2c9;
margin: 0;
padding: 100px;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100px; /* Ensure the body fills the viewport height */
background-image: url(images/consturction_2.jpg);
}
.container {
width: 70%;
max-width: 800px; /* Limit container width for larger screens */
text-align: center; /* Center content within the container */
}
h2 {
text-align: center;
color: #423c89;
margin-bottom: 20px;
}
/* Header styles */
header {
background-color: #090349;
color: white;
padding: 10px 20px;
text-align: center;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.logo {
display: flex;
align-items: center;
justify-content: center;
}
.logo img {
width: 60px;
height: 60px;
margin-right: 10px;
}
.logo h1 {
font-size: 24px;
margin: 0;
}
nav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
nav a {
color: white;
text-decoration: none;
font-size: 16px;
margin: 0 10px;
}
nav a:hover {
text-decoration: underline;
}
/* Form styles */
label, select, input {
display: block;
margin: 10px auto;
font-size: 16px;
}
input[type="text"] {
padding: 8px;
width: 80%;
max-width: 300px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}
select {
padding: 8px;
width: 84%;
max-width: 300px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}
button {
padding: 10px 20px;
background-color: #423c89;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #2e2a72;
}
/* Product table styles */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
margin-left: auto;
margin-right: auto; /* Center the table */
}
table, th, td {
border: 1px solid #ddd;
font-size: 20px;
}
th, td {
padding: 10px;
text-align: left;
}
th {
background-color: #423c89;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:nth-child(odd) {
background-color: #f2f2f2;
}
/* Footer styles */
footer {
margin-top: 40px;
text-align: center;
font-size: 14px;
color: #555;
padding: 20px 0;
width: 100%;
}
</style>
</head>
<header>
<nav>
<div class="logo">
<img src="images/22-removebg-preview.png" alt="Logo">
<h1>WAREHOUSE MANAGEMENT SYSTEM</h1>
</div>
<div>
<a href="product.html">Product</a>
<a href="users/user.html">Users</a>
<a href="about.html">About</a>
<a href="contactus.html">Contact Us</a>
<button class="logout-btn" onclick="openLogoutPopup()">Logout</button>
</div>
</nav>
</header>
<body>
<div class="container">
<h2>View Products</h2>
<!-- Search Filters -->
<div>
<br><label for="search">Search:</label>
<br><input type="text" id="search" name="search" placeholder="Enter search term...">
<br><label for="filter">Filter by:</label>
<select id="filter" name="filter">
<option value="name">Product Name</option>
<option value="description">Description</option>
<option value="category">Category</option>
<option value="brand">Brand</option>
<option value="warehouse_location">City</option>
<option value="date_added">Date Added</option> <!-- Add date filter option -->
</select>
<br><label for="date">Date:</label>
<input type="date" id="date" name="date"> <!-- Add date input field -->
<button onclick="fetchProducts()">Apply Filters</button>
</div>
<!-- Container to display product details -->
<div id="productDetailsContainer"></div>
</div>
<footer>
<p>Contact us at: your.email@example.com</p>
<p>© 2024 ABC Inventory System. All rights reserved.</p>
</footer>
<script>
function fetchProducts() {
const search = document.getElementById('search').value.trim();
const filter = document.getElementById('filter').value;
const url = `view_product.php?search=${search}&filter=${filter}`;
fetch(url)
.then(response => response.json())
.then(data => {
const productContainer = document.getElementById('productDetailsContainer');
productContainer.innerHTML = ''; // Clear previous content
if (data && data.products && data.products.length > 0) {
let table = `
<table>
<thead>
<tr>
<th>Name</th>
<th>Category</th>
<th>Brand</th>
<th>Unit</th>
<th>Cost per Unit</th>
<th>Description</th>
<th>Stock</th>
<th>Date Added</th>
<th>City</th>
</tr>
</thead>
<tbody>
`;
data.products.forEach(product => {
table += `
<tr>
<td>${product.name}</td>
<td>${product.category}</td>
<td>${product.brand}</td>
<td>${product.unit}</td>
<td>${product.cost_per_unit}</td>
<td>${product.description}</td>
<td>${product.stock}</td>
<td>${product.date_added}</td>
<td>${product.warehouse_location}</td>
</tr>
`;
});
table += `
</tbody>
</table>
`;
productContainer.innerHTML = table;
} else {
productContainer.innerHTML = '<p>No products found.</p>';
}
})
.catch(error => {
console.error('Error fetching products:', error);
const productContainer = document.getElementById('productDetailsContainer');
productContainer.innerHTML = '<p>Error fetching products.</p>';
});
}
// Call fetchProducts initially (e.g., on page load)
fetchProducts();
</script>
</body>
</html>