-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_manage_products.php
228 lines (214 loc) · 8.68 KB
/
admin_manage_products.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
<!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>OG Tech PC - Manage Products Panel</title>
<?php
include "header.php";
include "static/pages/side_nav.html";
include "static/pages/admin_nav.php";
?>
</head>
<body>
<div class="container" style="margin-top: 150px">
<h3 class="page-title">Manage Products</h3>
<div class="rounded-card-parent center" style="margin-bottom: 100px">
<div class="card rounded-card">
<div class="card-content white-text">
<span class="orange-text" style="font-size: 24px">Products List - Sorted by quantity
<th>
<button class='deep-orange btn'><a href="admin_manage_products.php"><i class='material-icons white-text'>refresh</i></a>
</button>
</th>
</span>
<!-- search product input field start -->
<form action="admin_manage_products.php" method="POST">
<div class="row" style="margin: 0px;">
<div class="input-field col s3" style = "color:azure">
<input name="search_product" id="search_product" type="text" class="validate white-text" maxlength="20">
<label for="search_product">Search product by Name or Brand</label>
<div id="error" class="errormsg">
</div>
</div>
</div>
</form>
<!-- search product input field end -->
<!-- search product result list start -->
<form action="" method="GET">
<table class="responsive-table" id="pagination">
<thead class="text-primary">
<tr>
<th>Name</th><th>Brand</th><th class='center'>Quantity In Stock</th>
</tr>
</thead>
<tbody>
<?php
$products = new adminContr();
$products->productsList();
?>
</tbody>
</table>
<div class="col-md-12 center text-center">
<span class="left" id="total_reg"></span>
<ul class="pagination pager white-text" id="myPager"></ul>
</div>
</form>
<!-- search product result list end -->
</div>
</div>
</div>
<!-- products table end -->
<!-- selected product details start -->
<?php if (isset($_GET["inspect_product"])) { ?>
<div class="rounded-card-parent">
<div class="card rounded-card">
<div class="card-content white-text">
<span class="card-title orange-text bold">Selected Product Details</span>
<table class="responsive-table center">
<form action="admin_manage_products.php" method="GET">
<thead class="text-primary center">
<tr><th>Image</th><th>Name</th><th>Brand</th>
<th>Description</th><th>Category</th><th>Selling Price</th><th>Qty In Stock</th></tr>
</thead>
<tbody>
<?php
$showInspect = new adminContr();
$showInspect->showInspectedProduct();
?>
</tbody>
</form>
</table>
</div>
</div>
</div>
<?php }
// delete product
if (isset($_GET["delete_product"]))
{
$id = $_GET["delete_product"];
$sql = "DELETE FROM Items WHERE ItemID = $id";
$dbh = new Dbhandler();
$dbh->conn()->query($sql) or die ("<p class='red-text'>*Delete statement FAILED!</p>");
}
?>
<!-- selected member details end -->
<!-- create product start -->
<div class="rounded-card-parent" style="margin-top: 100px">
<div class="card rounded-card">
<div class="card-content">
<span class="card-title orange-text bold">Create Product</span>
<form id="create" name="create" action="" method="POST">
<div class="row">
<div class="col s6" style="padding-right: 40px;">
<div class="row">
<div class="input-field white-text">
<i class="material-icons prefix">inventory_2</i>
<input name="name" id="name" type="text" class="validate white-text">
<label for="name" class="white-text">Product Name</label>
</div>
</div>
<div class="row">
<div class="input-field white-text">
<i class="material-icons prefix">branding_watermark</i>
<input name="brand" id="brand" type="text" class="validate white-text" maxlength="20">
<label for="brand" class="white-text">Brand</label>
</div>
</div>
<div class="row">
<div class="row">
<div class="input-field white-text col s12">
<i class="material-icons prefix">description</i>
<textarea name="description" id="description" class="materialize-textarea white-text" minlength="5"></textarea>
<label for="description" class="white-text">Description</label>
</div>
</div>
</div>
</div>
<div class="col s6" style="padding-right: 40px;">
<div class="row">
<div class="input-field white-text">
<i class="material-icons prefix white-text">category</i>
<select name="category" id="category">
<option value="" disabled selected>Choose category</option>
<option value=0>PC Packages</option>
<option value=1>Monitor & Audio</option>
<option value=2>Peripherals</option>
</select>
<label class="white-text">Category</label>
</div>
</div>
<div class="row">
<div class="input-field white-text">
<i class="material-icons prefix">attach_money</i>
<input name="sellingprice" id="sellingprice" type="number" step=".01" class="validate white-text" maxlength="30">
<label for="sellingprice" class="white-text">Selling Price</label>
</div>
</div>
<div class="row">
<div class="input-field white-text">
<i class="material-icons prefix white-text">production_quantity_limits</i>
<input name="quantityinstock" id="quantityinstock" type="number" class="validate white-text" maxlength="30">
<label for="quantityinstock" class="white-text">Quantity In Stock</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="file-field col s6">
<div class="btn">
<span>File</span>
<input type="file" id="product_image">
</div>
</a>
<div class="file-path-wrapper">
<input name="image" id="product_image" class="file-path validate white-text" type="text"
placeholder="Choose Image" onchange="update_image(this)">
</div>
</div>
<img class="shadow-img" id="image" src="" style="width: 300px;">
</div>
<div id="message" class="errormsg">
</div>
<input class="btn orange btn-block z-depth-5" type="submit" name="submit_product" id="submit_product" value="Create Product">
</form>
</div>
</div>
</div>
<!-- create product end -->
</div>
</body>
<script>
$(document).ready(function(){
$('select').formSelect();
$("#create").submit(function(e) {
event.preventDefault();
var productName = $("#name").val();
var brand = $("#brand").val();
var description = $("#description").val();
var category = $("#category").val();
var sellingprice = $("#sellingprice").val();
var quantityinstock = $("#quantityinstock").val();
var image = $("#product_image").val().replace(/C:\\fakepath\\/, '');
var submit_product = $("#submit_product").val();
$("#message").load("includes/admin.inc.php", {
productName: productName,
brand: brand,
description: description,
category: category,
sellingprice: sellingprice,
quantityinstock: quantityinstock,
image: image,
submit_product: submit_product
});
})
});
function update_image(path)
{
var image = document.getElementById("image");
image.src = `product_images/${path.value}`;
}
</script>
<?php include "footer.php"; ?>
</html>