-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-product.php
More file actions
269 lines (249 loc) · 11 KB
/
add-product.php
File metadata and controls
269 lines (249 loc) · 11 KB
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
<!DOCTYPE html>
<html lang="en">
<?php
session_start();
include_once './database.php';
$_SESSION["active"] = false;
$database = new Database();
$db = $database->getConnection();
if (isset($_POST['btnsave'])) {
$nom = $_POST["nom"];
$prix = $_POST["prix"];
$quantite = $_POST["stock"];
$description = $_POST["description"];
$product = $db->query('SELECT * from produit')->fetchAll(PDO::FETCH_OBJ);
$size = sizeof($product);
$q="INSERT INTO produit (nom,prix, quantite_stock, description,image, id, categorie, vendeur) VALUES ('$nom', '$prix', '$quantite', '$description','', $size+1, 2, 2)";
$db->exec($q);
echo('good');
}
// if(isset($_POST["btnsave"])){
// $nom = $_POST["nom"];
// $prix = $_POST["prix"];
// $quantite = $_POST["stock"];
// $description = $_POST["description"];
// if ( isset($_FILES['image']) )
// {
// $img_blob = file_get_contents ($_FILES['image']['tmp_name']);
// $product = $db->query('SELECT * from produit')->fetchAll(PDO::FETCH_OBJ);
// $size = sizeof($product);
// $q="INSERT INTO produit (nom,prix, quantite_stock, description,image, id, categorie, vendeur) VALUES ('$nom', '$prix', '$quantite', '$description','', $size+1, 2, 2)";
// $db->exec($q);
// echo('good');
// }else{
// echo('Echec');
// }
// }
?>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Add Product - Dashboard HTML Template</title>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:400,700"
/>
<!-- https://fonts.google.com/specimen/Roboto -->
<link rel="stylesheet" href="./assets/css/fontawesome.min.css" />
<!-- https://fontawesome.com/ -->
<link rel="stylesheet" href="jquery-ui-datepicker/jquery-ui.min.css" type="text/css" />
<!-- http://api.jqueryui.com/datepicker/ -->
<link rel="stylesheet" href="./assets/css/bootstrap.min.css" />
<!-- https://getbootstrap.com/ -->
<link rel="stylesheet" href="./assets/css/templatemo-style.css">
<!--
Product Admin CSS Template
https://templatemo.com/tm-524-product-admin
-->
</head>
<body><nav class="navbar navbar-expand-xl">
<div class="container h-100">
<a class="navbar-brand" href="./homeAdmin.php">
<h1 class="tm-site-title mb-0">Admin</h1>
</a>
<button class="navbar-toggler ml-auto mr-0" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars tm-nav-icon"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-auto h-100">
<li class="nav-item">
<a class="nav-link" href="homeAdmin.php?page=dashboard">
<i class="fas fa-tachometer-alt"></i>
Dashboard
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="far fa-file-alt"></i>
<span>
Clients <i class="fas fa-angle-down"></i>
</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="homeAdmin.php?page=ajoutclient">Add Client</a>
<a class="dropdown-item" href="homeAdmin.php?page=listclient">List Client</a>
<a class="dropdown-item" href="homeAdmin.php?page=listclientacheter">Client ayant acheter</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="homeAdmin.php?page=products">
<i class="fas fa-shopping-cart"></i>
Products
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="homeAdmin.php?page=accounts">
<i class="far fa-user"></i>
Accounts
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fas fa-cog"></i>
<span>
Ventes <i class="fas fa-angle-down"></i>
</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="homeAdmin.php?page=listventes">List ventes</a>
<a class="dropdown-item" href="homeAdmin.php?page=listvendeur">List vendeurs</a>
</div>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link d-block" href="./login.php">
Admin, <b>Logout</b>
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container tm-mt-big tm-mb-big">
<div class="row">
<div class="col-xl-9 col-lg-10 col-md-12 col-sm-12 mx-auto">
<div class="tm-bg-primary-dark tm-block tm-block-h-auto">
<div class="row">
<div class="col-12">
<h2 class="tm-block-title d-inline-block">Add Product</h2>
</div>
</div>
<div class="row tm-edit-product-row">
<div class="col-xl-6 col-lg-6 col-md-12">
<form action="" class="tm-edit-product-form" method="POST">
<div class="form-group mb-3">
<label
for="name"
>Product Name
</label>
<input
id="name"
name="nom"
type="text"
class="form-control validate"
required
/>
</div>
<div class="form-group mb-3">
<label
for="description"
>Description</label
>
<textarea
class="form-control validate"
rows="3"
name="description"
required
></textarea>
</div>
<div class="form-group mb-3">
<label
for="category"
>Category</label
>
<select
class="custom-select tm-select-accounts"
id="category"
>
<option selected>Select category</option>
<?php
include_once './database.php';
$database = new Database();
$db = $database->getConnection();
$rec = $db->query("SELECT * FROM categorie ")->fetchAll(PDO::FETCH_OBJ);
foreach ($rec as $item) {
echo('<option value="'.$item->Id.'" >'.$item->nom_categorie.'</option>');
}
?>
</select>
</div>
<div class="row">
<div class="form-group mb-3 col-xs-12 col-sm-6">
<label
for="expire_date"
>Solde
</label>
<input
id="expire_date"
name="prix"
type="text"
class="form-control validate"
data-large-mode="true"
/>
</div>
<div class="form-group mb-3 col-xs-12 col-sm-6">
<label
for="stock"
>Stock
</label>
<input
id="stock"
name="stock"
type="text"
class="form-control validate"
required
/>
</div>
</div>
</div>
<div class="col-xl-6 col-lg-6 col-md-12 mx-auto mb-4">
<div class="tm-product-img-dummy mx-auto">
<input type="file" name="image" size=50 />
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary btn-block text-uppercase" name="btnsave">Add Product Now</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer class="tm-footer row tm-mt-small">
<div class="col-12 font-weight-light">
<p class="text-center text-white mb-0 px-4 small">
Copyright © <b>2018</b> All rights reserved.
Design: <a rel="nofollow noopener" href="https://templatemo.com" class="tm-footer-link">Template Mo</a>
</p>
</div>
</footer>
<script src="./assets/js/jquery-3.3.1.min.js"></script>
<!-- https://jquery.com/download/ -->
<script src="jquery-ui-datepicker/jquery-ui.min.js"></script>
<!-- https://jqueryui.com/download/ -->
<script src="./assets/js/bootstrap.min.js"></script>
<!-- https://getbootstrap.com/ -->
<script>
$(function() {
$("#expire_date").datepicker();
});
</script>
</body>
</html>