-
Notifications
You must be signed in to change notification settings - Fork 35
/
admin_edit_products.php
141 lines (136 loc) · 5.5 KB
/
admin_edit_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
<!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 - Edit Products</title>
<?php
require "header.php";
include "static/pages/side_nav.html";
include "static/pages/admin_nav.php";
include "includes/admin.inc.php";
$dbh = new Dbhandler();
$util = new CommonUtil();
?>
</head>
<body>
<div class="rounded-card-parent container" style="margin-top: 150px">
<div class="card rounded-card">
<a class="btn blue darken-2" href='admin_manage_products.php' style="margin-bottom: 10px;">< BACK TO MANAGE PRODUCTS</a>
<span class="card-title orange-text bold center" style="padding-left: 100px;">Edit Product - <?php echo $name; ?></span>
<form action="" method="POST" style="padding-left: 10px;">
<div class="row">
<input type="hidden" name="item_id" id="item_id" value="<?php echo $itemID;?>">
</div>
<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"
value="<?php echo $name;?>">
<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"
value="<?php echo $brand;?>">
<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">
<?php echo $description;?>
</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 your option</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"
value="<?php echo $sellingprice;?>">
<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"
value="<?php echo $quantityinstock;?>">
<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>
<div class="file-path-wrapper">
<input name="image" id="product_image" class="file-path validate white-text" type="text" onchange="update_image(this)"
value="<?php echo $image;?>">
</div>
</div>
<img class="shadow-img" id="image" src="product_images/<?php echo $image;?>" style="width: 300px;">
</div>
<div class="errormsg">
<?php
if (isset($_GET["error"]))
{
if ($_GET["error"] == "empty_input")
echo "<p>*Fill in all fields!<p>";
else if ($_GET["error"] == "none")
echo "<p class='green-text bold'>Successfully edited product.</p>";
}
?>
</div>
<button type="submit" id="update" name="update" class="btn">Update Product</button>
</form>
</div>
</div>
</body>
<script>
$(document).ready(function ()
{
var categoryId = parseInt(document.getElementById("category_id").textContent);
categoryId += 1;
var select = document.querySelector('select');
select.querySelectorAll('option')[categoryId].selected = true;
$('select').formSelect();
});
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('select');
var instances = M.FormSelect.init(elems, options);
});
function update_image(path)
{
var image = document.getElementById("image");
image.src = `product_images/${path.value}`;
}
</script>
<?php include "footer.php"; ?>
</html>