-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifier-vente.php
More file actions
360 lines (309 loc) · 11.5 KB
/
modifier-vente.php
File metadata and controls
360 lines (309 loc) · 11.5 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
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
<?php
include('functions.php');
$pdo = pdo_connect_mysql();
$msg = '';
session_start();
if(isset($_GET['id'])){
if (!empty($_POST)) {
// Post data not empty insert a new record
// Set-up the variables that are going to be inserted, we must check if the POST variables exist if not we can default them to blank
// Check if POST variable "name" exists, if not default the value to blank, basically the same for all variables
$id = isset($_POST['id']) ? $_POST['id'] : '';
$articleid = isset($_POST['article']) ? $_POST['article'] : '';
$quantite = isset($_POST['quantite']) ? $_POST['quantite'] : '';
$datevente = isset($_POST['datevente']) ? $_POST['datevente'] : '';
$unite = isset($_POST['unite']) ? $_POST['unite'] : '';
$refvente = isset($_POST['refvente']) ? $_POST['refvente'] : '';
$client = isset($_POST['client']) ? $_POST['client'] : '';
$prixvente = isset($_POST['prixvente']) ? $_POST['prixvente'] : '';
$prixttc = isset($_POST['prixttc']) ? $_POST['prixttc'] : '';
// Insert new record into the contacts table
$stmt = $pdo->prepare('UPDATE vente SET article_id = ?, unite_id = ?, qtevendu = ?, datevente = ?, refvente = ?,
client_id = ?, prixvente = ?, montantvente = ? WHERE vente_id = ?');
$stmt->execute([$articleid, $unite, $quantite, $datevente, $refvente, $client, $prixvente, $prixttc, $_GET['id']]);
// Output message
$msg = 'Vente '.$refvente. ' éffectuée avec succès !';
header('Location: mouvement-stocks.php');
}
$stmt = $pdo->prepare('SELECT article_id, vente_id, vente.prixvente AS pv, montantvente, refvente, datevente, designation, nom, nomprenomscl, unite_id, qtevendu, client_id, montantvente
FROM vente, clients, articles, unite
WHERE articles.id = vente.article_id AND vente.client_id = clients.id AND articles.unite = unite.id AND vente_id = ?');
$stmt->execute([$_GET['id']]);
$articles = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$articles) {
exit('Cet article n\' existe pas!');
}
} else {
exit('No ID specified !');
}
$stmt1 = $pdo->prepare('SELECT * FROM clients');
$stmt1->execute();
$clients = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html>
<head>
<!-- Basic Page Info -->
<meta charset="utf-8" />
<title>Modifier une vente article</title>
<!-- Site favicon -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="vendors/images/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="vendors/images/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="vendors/images/favicon-16x16.png"
/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Mobile Specific Metas -->
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<!-- Google Font -->
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap"
rel="stylesheet"
/>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="vendors/styles/core.css" />
<link
rel="stylesheet"
type="text/css"
href="vendors/styles/icon-font.min.css"
/>
<link rel="stylesheet" type="text/css" href="vendors/styles/style.css" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-GBZ3SGGX85"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-GBZ3SGGX85");
</script>
<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != "dataLayer" ? "&l=" + l : "";
j.async = true;
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, "script", "dataLayer", "GTM-NXZMQSS");
</script>
<!-- End Google Tag Manager -->
</head>
<body>
<?php include('entete.php'); ?>
<div class="mobile-menu-overlay"></div>
<div class="main-container">
<div class="pd-ltr-20 xs-pd-20-10">
<div class="min-height-200px">
<div class="page-header">
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="title">
<h4>Articles</h4>
</div>
<nav aria-label="breadcrumb" role="navigation">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="index.php">Home</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
vendre-article
</li>
</ol>
</nav>
</div>
<div class="col-md-6 col-sm-12 text-right">
<div class="dropdown">
<a
class="btn btn-secondary dropdown-toggle"
href="#"
role="button"
data-toggle="dropdown"
>
January 2018
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#">Export List</a>
<a class="dropdown-item" href="#">Policies</a>
<a class="dropdown-item" href="#">View Assets</a>
</div>
</div>
</div>
</div>
</div>
<div class="pd-20 card-box mb-30">
<div class="clearfix">
<div class="pull-left">
<h4 class="text-blue h4">#Modifier vente <?= $articles['refvente'] ?></h4>
<p class="mb-30"></p>
</div>
</div>
<?php if($msg): ?>
<div
class="alert alert-success alert-dismissible fade show"
role="alert"
>
<?php echo $msg; ?>
<button
type="button"
class="close"
data-dismiss="alert"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<?php endif; ?>
<form action="modifier-vente.php?id=<?= $articles['vente_id'] ?>" method="POST" name="myform">
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="form-group">
<div class="form-group">
<label> <strong> Produit/Article *</strong></label>
<select
class="custom-select2 form-control"
name="article"
style="width: 100%; height: 38px;"
id = "article"
required
>
<option value = "<?= $articles['article_id'] ?>" ><?= $articles['designation'] ?></option>
</select>
</div>
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="form-group">
<label><strong>Unité de gestion</strong></label>
<select
class="custom-select2 form-control"
name="unite"
id = "unite"
style="width: 100%; height: 38px"
required
>
<option value="<?= $articles['unite_id'] ?>"><?= $articles['nom']?></option>
</select>
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="form-group">
<label><strong>Prix de vente</strong></label>
<input type="number" value="<?= $articles['pv'] ?>" name="prixvente" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-12">
<div class="form-group">
<label> <strong>Quantité *</strong></label>
<input type="number" autofocus required name="quantite" value="<?= $articles['qtevendu'] ?>" onkeyup="calculate(this.value)" class="form-control" />
</div>
</div>
<!-- <div class="col-md-3 col-sm-12">
<div class="form-group">
<label><strong>TVA (%)</strong></label>
<input type="number" value="18" name="tva" required class="form-control" />
</div>
</div> -->
<div class="col-md-3 col-sm-12">
<div class="form-group">
<label><strong>Prix TTC</strong></label>
<input type="number" value="<?= $articles['montantvente'] ?>" name="prixttc" class="form-control" />
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="form-group">
<label><strong>Date vente</strong></label>
<input type="date" required value="<?= $articles['datevente'] ?>" name="datevente" class="form-control" />
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="form-group">
<label><strong>Référence</strong></label>
<input type="text" placeholder="VTE1" value="<?= $articles['refvente'] ?>" name="refvente" required class="form-control" />
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="form-group">
<label> <strong> Choisir client *</strong></label>
<select
class="custom-select2 form-control"
name="client"
style="width: 100%; height: 38px;"
id = "client"
required
>
<option value="<?= $articles['client_id'] ?>"><?= $articles['nomprenomscl'] ?></option>
</select>
</div>
</div>
</div>
<input type="submit" class="btn" data-bgcolor="#00b489"
data-color="#ffffff" value="Modifier">
</form>
</div>
</div>
<div class="footer-wrap pd-20 mb-20 card-box">
GESTION DE STOCK EMERGER AMOUR DE DIEU
</div>
</div>
</div>
<!-- js -->
<script src="vendors/scripts/core.js"></script>
<script src="vendors/scripts/script.min.js"></script>
<script src="vendors/scripts/process.js"></script>
<script src="vendors/scripts/layout-settings.js"></script>
<!-- Google Tag Manager (noscript) -->
<noscript
><iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-NXZMQSS"
height="0"
width="0"
style="display: none; visibility: hidden"
></iframe
></noscript>
<!-- End Google Tag Manager (noscript) -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
!-- start jQuery function -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"> </script>
<script type="text/javascript">
function calculate() {
if (isNaN(document.forms["myform"]["quantite"].value) || document.forms["myform"]["quantite"].value == "") {
var text1 = 0;
} else {
var text1 = parseInt(document.forms["myform"]["quantite"].value);
}
if (isNaN(document.forms["myform"]["prixvente"].value) || document.forms["myform"]["prixvente"].value == "") {
var text2 = 0;
} else {
var text2 = parseFloat(document.forms["myform"]["prixvente"].value);
}
document.forms["myform"]["prixttc"].value = (text1 * text2);
}
</script>
</body>
</html>