-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_item_BW copy.php
213 lines (162 loc) · 7.22 KB
/
view_item_BW copy.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./Styles/Admin_Styles/add_item.css">
<STyle>
/* add_item.css */
.item-image {
max-width: 100px; /* Set your desired maximum width */
height: auto; /* Maintain aspect ratio */
border: 1px solid #ddd; /* Add a border for better visibility */
border-radius: 5px; /* Optional: Add border radius for a rounded appearance */
/* Add more styles as needed */
}
</STyle>
</head>
<body>
<?php
include("./header.php");
?>
<div class="main">
<?php
include './Includes/connection.php';
session_start();
// Create a new instance of the connection class
$db = new connection();
$conn = $db->getConnection();
// Retrieve data from the database
$stmt = $conn->prepare("SELECT * FROM clothing_items_bridal_wear");
$stmt->execute();
// Fetch all rows as an associative array
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<h2>Clothing Items</h2>
<!-- Add this code above the table, below the category filter form -->
<form action="./filtered_items_BW.php" method="get">
<div class="top-box">
<label for="category">Filter by Category:</label>
<select id="category" name="category">
<option value="" selected disabled>Select Category</option>
<?php
// Assuming $conn is your database connection object
$stmt_categories = $conn->prepare("SELECT category_name_BW FROM category_bridal_wear");
$stmt_categories->execute();
$categories = $stmt_categories->fetchAll(PDO::FETCH_ASSOC);
foreach ($categories as $category) {
echo '<option value="' . $category['category_name_BW'] . '">' . $category['category_name_BW'] . '</option>';
}
?>
</select>
<label class="searchItem" for="itemName">Search by Item Name:</label>
<input type="text" id="itemName" name="itemName" placeholder="Enter item name">
<div class="btn-apply-clear">
<button class="apply-clear" id="applyBtn" type="submit">Apply Filter</button>
<button class="apply-clear" id="clearBtn" type="button" onclick="clearFilters()">Clear</button>
</div>
</div>
<div class="addBtns">
<a id="addCategory" href="./add_new_category_BW.php">Add Category</a>
<a id="addItem" href="./add_item_BW.php">Add new item</a>
<a id="addCustomize" href="./add_Custom_Bridal _Wear.php">Add new customize item</a>
<a id="addRental" href="./add_bw_rent.php">Add new rental item</a>
</div>
<script>
function clearFilters() {
document.getElementById("category").value = "";
document.getElementById("itemName").value = "";
}
</script>
</form>
<div class="aleart">
<?php
if (isset($_SESSION['success'])) {
echo '<div class="login-status-message-success">' . $_SESSION['success'] . '</div>';
unset($_SESSION['success']);
}
if (isset($_SESSION['error'])) {
echo '<div class="login-status-message-error">' . $_SESSION['error'] . '</div>';
unset($_SESSION['error']);
}
?>
</div>
<table border="1">
<tr>
<th>Product Name</th>
<th>Category</th>
<th>Brand</th>
<th>Size Options</th>
<th>Material</th>
<th>Price</th>
<th>Quantity Available</th>
<th>Description</th>
<th>Care Instructions</th>
<th>Tags</th>
<th>Availability Status</th>
<th>Discounts</th>
<th>Images</th>
<th>Action</th>
</tr>
<?php foreach ($result as $row) : ?>
<tr>
<td><?= $row['productName'] ?></td>
<td><?= $row['category'] ?></td>
<td><?= $row['brand'] ?></td>
<td><?= $row['sizeOptions'] ?></td>
<td><?= $row['material'] ?></td>
<td><?= $row['price'] ?></td>
<td><?= $row['quantityAvailable'] ?></td>
<td><?= $row['description'] ?></td>
<td><?= $row['careInstructions'] ?></td>
<td><?= $row['tags'] ?></td>
<td><?= $row['availabilityStatus'] ?></td>
<td><?= $row['discounts'] ?></td>
<td>
<?php
$images = explode(', ', $row['images']);
if (!empty($images)) {
echo '<img class="item-image" src="' . $images[0] . '" alt="Image">';
} else {
echo 'No Image';
}
?>
</td>
<td>
<button type="button" class="updateClass" id="btnUpdate" data-bs-toggle="modal" data-bs-target="#updateFormModal" data-item-id="<?= $row['id'] ?>">Update</button>
<form action="./delete_item_BW.php" method="post">
<input type="hidden" name="item_id" value="<?= $row['id'] ?>">
<button type="submit" class="deleteClass" id="btnDelete" name="delete_item">Delete</button>
</form>
<script>
document.addEventListener('DOMContentLoaded', function() {
var updateButtons = document.querySelectorAll('.updateClass');
updateButtons.forEach(function(button) {
button.addEventListener('click', function() {
var itemId = button.getAttribute('data-item-id');
window.location.href = 'update_form_bw.php?item_id=' + itemId;
});
});
});
function showConfirmationModal() {
document.getElementById('confirmationModal').style.display = 'block';
}
function closeConfirmationModal() {
document.getElementById('confirmationModal').style.display = 'none';
}
function deleteItem() {
// Add your logic to handle item deletion here
// For example, submit the form or make an AJAX request to delete the item
document.getElementById('deleteForm').submit();
}
</script>
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
</section>
</div>
</body>
</html>