-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlivraison.php
239 lines (234 loc) · 14.3 KB
/
livraison.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
<?php
if (!isset($_SESSION) && empty($_SESSION)) {
session_start();
}
require('req/catalog.php');
require('req/myFunctions.php');
require('req/cost.php');
$choice = [];
$bookChoiced = [];
if (isset($_POST) && !empty($_POST)) {
if (isset($_POST['qtyBook0']) && !empty($_POST['qtyBook0'])) {
$qty = intval(htmlspecialchars($_POST['qtyBook0']), 10);
$id = htmlspecialchars(preg_replace('/[^0-9]/', '', 'qtyBook0'));
array_push($bookChoiced, $id);
array_push($choice, $qty);
}
if (isset($_POST['qtyBook1']) && !empty($_POST['qtyBook1'])) {
$qty = intval(htmlspecialchars($_POST['qtyBook1']), 10);
$id = htmlspecialchars(preg_replace('/[^0-9]/', '', 'qtyBook1'));
array_push($bookChoiced, $id);
array_push($choice, $qty);
}
if (isset($_POST['qtyBook2']) && !empty($_POST['qtyBook2'])) {
$qty = intval(htmlspecialchars($_POST['qtyBook2']), 10);
$id = htmlspecialchars(preg_replace('/[^0-9]/', '', 'qtyBook2'));
array_push($bookChoiced, $id);
array_push($choice, $qty);
}
}
if (empty($_SESSION)) {
$_SESSION['open'] = 'yes';
$_SESSION['selectedBooks'] = $bookChoiced;
$_SESSION['quantityBooks'] = $choice;
}
?>
<!DOCTYPE html>
<html lang="fr-FR">
<head>
<meta charset="utf-8">
<title>livraison et réduction</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<?php
include "inc/bootstrapLinks.php";
include "inc/fontawesomeLinks.php";
?>
</head>
<body>
<?php
include "inc/header.php";
?>
<div class="container mt-2 mb-5">
<div class="contentbar">
<!-- Start row -->
<?php
if (isset($_POST) && !empty($_POST)) {
?>
<div class="row">
<!-- Start col -->
<div class="col-md-12 col-lg-12 col-xl-12">
<div class="card m-b-30">
<div class="card-header">
<h5 class="card-title">Cart</h5>
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col-lg-10 col-xl-8">
<div class="cart-container">
<div class="cart-head">
<div class="table-responsive">
<table class="table table-borderless">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col">Product</th>
<th scope="col">Qty</th>
<th scope="col">Price</th>
<th scope="col" class="text-right">Total</th>
</tr>
</thead>
<tbody style="vertical-align: middle">
<?php
if (!empty($choice)) {
popBuyBooks($books, $bookChoiced, $choice);
} else {
?>
<div class="alert alert-warning alert-success" role="alert">
<h4 class=" alert-heading">HO ho (づ ̄ ³ ̄)づ</h4>
<p>Apparemment il y a eu un problème avec ton formulaire :</p>
<hr>
<p class="mb-0">tu n'as pas choisi de live...</p>
</div>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div class="cart-body">
<!-- <form reduction> -->
<div class="row">
<div class="col-md-12 order-2 order-lg-1 col-lg-5 col-xl-6">
<form method="get">
<?php
if (!empty($choice)) {
?>
<div class="form-group">
<div class="input-group">
<input type="search" class="form-control" placeholder="Coupon Code" aria-label="Search" aria-describedby="button-addonTags">
<div class="input-group-append">
<button class="input-group-text" id="button-addonTags">Apply</button>
</div>
</div>
</div>
<?php
}
?>
</form>
</div>
</div>
<!-- </form reduction > -->
<!-- <form submit> -->
<form method="post" action="validation.php">
<div class="row">
<div class="col-md-12 order-2 order-lg-1 col-lg-5 col-xl-6">
<?php
if (!empty($choice)) {
?>
<div class="order-note">
<div class="form-group">
<select id="selectCost" name="selectCost" class="form-select" aria-label="Default select example" style="margin: 13px 0;">
<option id="select0" value="0">Expedition's choice</option>
<?php
$value = 1;
foreach ($transporters as $key => $carrer) {
echo '<option id="select' . $value . '" value="' . $key . '">' . $carrer["name"] . '</option>';
$value++;
}
?>
</select>
</div>
</div>
<?php
}
$over = false;
asort($books);
$booksArray = [];
foreach($books as $book) {
array_push($booksArray, $book) ;
}
foreach($bookChoiced as $key => $book) {
if ($booksArray[$book]['quantity']<$choice[$key]) {
$over = true;
break;
}
}
if ($over){
?>
<div class="order-note">
<div class="form-group">
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Oups... ¯\_(ツ)_/¯</h4>
<p>Désolé vous voulliez :</p>
<?php
foreach($bookChoiced as $key => $book) {
//echo $booksArray[$book]['quantity'];
if ($booksArray[$book]['quantity']<$choice[$key]) {
//$string+=
echo "<hr>";
echo '<p class="mb-0"> <b>'. $choice[$key].'</b> <i>'. $booksArray[$book]['name'].'</i> nous n\'en avons que <b>'.$booksArray[$book]['quantity'].'</b>.</p>';
}
}
?>
</div>
</div>
</div>
<?php
}
?>
</div>
<div class="col-md-12 order-1 order-lg-2 col-lg-7 col-xl-6">
<div class="order-total table-responsive ">
<table class="table table-borderless text-right">
<tbody>
<?php
sendInputHidden($choice, $bookChoiced);
popTotalPrices($choice, $books, $bookChoiced);
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="cart-footer text-right">
<button type="submit" name="submit" class="btn btn-secondary my-1 bg-secondary bg-gradient" style="color: white; border-color: #000;">
Confirmation <i class="fa-solid fa-angles-right"></i>
</button>
</div>
</form>
<!-- </form submit> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End col -->
</div>
<!-- End row -->
<?php
}
else {
?>
<div class="alert alert-warning alert-danger" role="alert">
<h4 class=" alert-heading">Whaaaaat (╯°□°)╯︵ ┻━┻</h4>
<p>Ton formulaire :</p>
<hr>
<p class="mb-0">EST VIIIIIIIIDE...</p>
</div>
<?php
}
?>
</div>
</div>
<?php
include "inc/footer.php";
?>
<script src="public/js/cost.js"></script>
</body>
</html>
<!--JP Lemonias-->
<!------Pe@cE---->