-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_product.php
370 lines (256 loc) · 13.7 KB
/
add_product.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<?php
$p="";
if(basename(__DIR__)!="bhai"){
$p="../";
}
session_start();
if(isset($_SESSION['user']) && ($_SESSION['userType']==3)){include($p."Templates/admin_loggedin_header.php");}
else {header('Location:login/login_admin.php');}
if (isset($_POST['add'])){
$itemId=0;
$product=new Product();
$lastId=$product->getLastProductId();
$itemId=$lastId[0]["product_id"];
//$_SESSION['lastProductID'] = $itemId;
$itemId++;
$product->addLog($_SESSION['user'],"Product Added",$itemId);
$imageResult=$product->fileUpload();
//print_r($_POST['dropdownUnit']);
if($imageResult[0]){
$product->addProduct(strtoupper($_POST['product_name']),$_POST['product_price'],$_POST['product_description'],$_POST['dropdownPacking'],$_POST['dropdownCategory'],$_POST['dropdownUnit'],$imageResult[1]);
}
else {
echo "Image not uploaded";
}
}
if(isset($_POST["buttonAddCategory"])){
$product = new Product();
$lastId=$product->getLastCategoryId();
$itemId=$lastId[0]["category_id"];
$itemId++;
$product->addLog($_SESSION['user'],"Category Added",$itemId);
$product->addCategory(strtoupper($_POST['inputAddCategory']),strtoupper($_POST['dropdownParentCategory']));
}
?>
<!DOCTYPE html>
<html>
<!-- Mirrored from velikorodnov.com/html/homeshop/create_an_account.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 22 Jan 2016 16:29:04 GMT -->
<head>
<script src="js/validation.js"></script>
<!-- Meta Tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Title -->
<title>HomeShop - HTML Template</title>
<!-- Fonts -->
<link href='http://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic,500,700,900,700italic,500italic' rel='stylesheet' type='text/css'>
<!-- Stylesheets -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/perfect-scrollbar.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/fontello.css">
<link rel="stylesheet" href="css/animation.css">
<link rel="stylesheet" href="css/chosen.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<link rel="stylesheet" href="css/ie.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="css/fontello-ie7.css">
<![endif]-->
</head>
<body>
<form method="post" enctype="multipart/form-data">
<!-- Content -->
<div class="row content">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="breadcrumbs">
<p><a href="admin_panel.php">Home</a> <i class="icons icon-right-dir"></i> Add Product</p>
</div>
</div>
<!-- Main Content -->
<section class="main-content col-lg-9 col-md-9 col-sm-9">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 register-account">
<div class="carousel-heading no-margin">
<h4>Add Product</h4>
</div>
<div class="page-content">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Product Name</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<input type="text" name="product_name" onKeyPress="return isCharacter(event)" maxlength="20">
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Price</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<input type="text" name="product_price" onKeyPress="return isNumber(event)" maxlength="6">
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Description</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<textarea rows="4" cols="50" name="product_description" onKeyPress="return isCharacter(event)"></textarea>
</div>
</div>
</br>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Category</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<select name="dropdownCategory">
<?php
$product=new Product();
$categoryList=$product->category();
print_r($categoryList);
foreach($categoryList as $category){
?>
<option value="<?php echo $category["category_id"];?>"><?php echo $category["category_name"]; ?> </option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Packing</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<select name="dropdownPacking">
<?php
$product=new Product();
$packingList=$product->getPacking();
foreach($packingList as $packing){
?>
<option value="<?php echo $packing["packing_id"] ;?>"><?php echo $packing["packing_name"];?></option><?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Unit</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<select name="dropdownUnit">
<option name="kg" value="Kg">KG</option>
<option name="dozen" value="Dozen">Dozen</option>
<option name="liter" value="Liter">Liter</option>
</select>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<p>Image Link</p>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<input type="file" class="form-control" name="image" />
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<input class="big" type="submit" value="Add" name="add">
<input class="big" type="reset" value="Cancel">
</div>
</div>
</div>
</div>
</div>
</section>
<!-- /Main Content -->
<!-- Sidebar -->
<!-- Compare Products -->
<div class="row sidebar-box blue">
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="sidebar-box-heading">
<i class="icons icon-docs"></i>
<h4>Add Categories</h4>
</div>
<div class="sidebar-box-content">
<table class="compare-table">
<tr>
<td class="product-thumbnail"><input type="text" name="inputAddCategory" placeholder="Enter Category Name"/></td>
</tr>
</br>
<tr>
<div class="row" style="padding-left:50px;">
<!--<div class="col-lg-4 col-md-4 col-sm-4">
<p style="padding:15px">Packing</p>
</div>-->
<div class="col-lg-8 col-md-8 col-sm-8">
<select name="dropdownParentCategory">
<option>Parent Category</option>
<?php
$product=new Product();
$packingList=$product->getCategory();
foreach($packingList as $packing){
?>
<option value="<?php echo $packing["category_id"];?>"><?php echo $packing["category_name"];?></option><?php } ?>
</select>
</div>
</div>
</tr>
</table>
<div class="padding-box">
<input class="big" type="submit" value="Add Category" name="buttonAddCategory"/>
</div>
</div>
</div>
</div>
<!-- /Compare Products -->
</aside>
<!-- /Sidebar -->
</div>
<!-- /Content -->
<!-- Banner -->
<?php include($p."Templates/footer.php")?>
<!-- Footer -->
<div id="back-to-top">
<i class="icon-up-dir"></i>
</div>
</div>
<!-- Container -->
</form>
<!-- JavaScript -->
<script src="js/modernizr.min.js"></script>
<script src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.raty.min.js"></script>
<!-- Scroll Bar -->
<script src="js/perfect-scrollbar.min.js"></script>
<!-- Cloud Zoom -->
<script src="js/zoomsl-3.0.min.js"></script>
<!-- FancyBox -->
<script src="js/jquery.fancybox.pack.js"></script>
<!-- jQuery REVOLUTION Slider -->
<script type="text/javascript" src="js/jquery.themepunch.plugins.min.js"></script>
<script type="text/javascript" src="js/jquery.themepunch.revolution.min.js"></script>
<!-- FlexSlider -->
<script defer src="js/flexslider.min.js"></script>
<!-- IOS Slider -->
<script src = "js/jquery.iosslider.min.js"></script>
<!-- noUi Slider -->
<script src="js/jquery.nouislider.min.js"></script>
<!-- Owl Carousel -->
<script src="js/owl.carousel.min.js"></script>
<!-- Cloud Zoom -->
<script src="js/zoomsl-3.0.min.js"></script>
<!-- SelectJS -->
<script src="js/chosen.jquery.min.js" type="text/javascript"></script>
<!-- Main JS -->
<script defer src="js/bootstrap.min.js"></script>
<script src="js/main-script.js"></script>
</body>
<!-- Mirrored from velikorodnov.com/html/homeshop/create_an_account.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 22 Jan 2016 16:29:04 GMT -->
</html>