-
Notifications
You must be signed in to change notification settings - Fork 0
/
pago.php
319 lines (266 loc) · 12.6 KB
/
pago.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
<?php
session_start();
require "BackEnd/conecta.php";
$isLoggedIn = isset($_SESSION['username']);
$currentUsername = $_SESSION['username'];
if ($isLoggedIn && isset($_POST['logout'])) {
$_SESSION = array();
session_destroy();
header('Location: index.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FlipArt</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/flatly/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap">
<style>
body {
font-family: 'Ubuntu', sans-serif;
}
</style>
<link rel="stylesheet" href="Styles/footer.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="index.php">FlipART</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="products.php">Productos</a>
</li>
<?php
if ($isLoggedIn) {
$con = conecta();
$usuario = $_SESSION['username'];
$sql = "SELECT * FROM pedidos WHERE status = 1 AND client_id = '$usuario'";
$res = $con->query($sql);
echo '
<li class="nav-item">
<a class="nav-link" href="#" data-toggle="modal" data-target="#cartModal">
<i class="fas fa-shopping-cart"></i> Carrito
<span class="badge badge-pill badge-danger">0</span>
</a>
</li>
';
}
else{
echo '
<li class="nav-item">
<a class="nav-link" href="#" data-toggle="modal" data-target="#cartModal">
<i class="fas fa-shopping-cart"></i> Carrito
<span class="badge badge-pill badge-danger"> 0 </span>
</a>
</li>
';
}
?>
<li class="nav-item">
<a class="nav-link" href="contact.php">Contactanos</a>
</li>
<?php
if ($isLoggedIn) {
echo '<li class="nav-item"><a class="nav-link" href="profile.php">' . $_SESSION['username'] . '</a></li>';
echo '<form method="post" class="nav-item"><button type="submit" name="logout" class="btn btn-link nav-link">Logout</button></form>';
} else {
echo '<li class="nav-item"><a class="nav-link" href="login.php">Login/Sign-up</a></li>';
}
?>
</ul>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="invoice-title">
<h2>FlipART</h2><h3 class="pull-right">orden # 12345</h3>
<h6><strong>FlipArt</strong> agradece tu compra, seguiremos rompiendola para darte el mejor servicio. <STRONG>#ARTEURBANO</STRONG></h6>
</div>
<hr>
<div class="row">
<div class="col-xs-6">
<?php
$User = "SELECT * FROM Users WHERE userName = '$currentUsername' AND status = 1 AND deleted = 0";
$res = $con->query($User);
while($row = $res->fetch_array()) {
$fullName = $row['fullName'];
$email = $row['email'];
$phoneNumber = $row['phone'];
$birthday = $row['birthday'];
?>
<address>
<strong>Cargo:</strong><br>
<?php echo $fullName?><br>
#1421 Blvd. Gral. Marcelino García Barragán<br>
Col. Olimpica<br>
44430 Guadalajara, Jal.
</address>
</div>
<div class="col-xs-6 text-right">
<address>
<strong>Enviado:</strong><br>
#976 Av. Juárez<br>
Col Americana,<br>
44100 Guadalajara, Jal.
</address>
</div>
</div>
<div class="row"> <br>
<div class="col-xs-6">
<address>
<strong>Payment Method:</strong><br>
Visa Terminacion **** 4242<br>
<?php echo $email ?>
</address>
</div>
<div class="col-xs-6 text-right">
<address>
<strong>Fecha de orden:</strong><br>
<?php echo date('Y-m-d ');?> <br><br>
</address>
</div>
</div>
<?php }?>
</div>
</div>
<?PHP ?>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>Tu order</strong></h3>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-condensed">
<thead>
<tr>
<td><strong>Item</strong></td>
<td class="text-center"><strong>Precio</strong></td>
<td class="text-center"><strong>Cant.</strong></td>
<td class="text-right"><strong>Total</strong></td>
</tr>
</thead>
<tbody>
<!-- foreach ($order->lineItems as $line) or some such thing here -->
<?php
$con = conecta();
$usuario = $_SESSION['username'];
$sql = "SELECT * FROM pedidos WHERE status = 1 AND client_id = '$usuario'";
$res = $con->query($sql);
$total = 0;
while($row = $res->fetch_array()) {
$userOrderId = $row["id"];
$productoQuery = "SELECT * FROM items_orders WHERE order_id = '$userOrderId'";
$productoANS = $con->query($productoQuery);
while($productrow = $productoANS->fetch_array()) {
$invoiceNumber = $productrow['id'];
$productID = $productrow['product_id'];
$productAmount = $productrow['amount'];
$productPrice = $productrow['price'];
//Obten Detalles del Producto
$tablaDeProductos = "SELECT * FROM Products WHERE id = '$productID' AND deleted = 0";
$tablaDeProductosANS = $con->query($tablaDeProductos);
while($tablaDeProductosROW = $tablaDeProductosANS->fetch_array()) {
$itemName = $tablaDeProductosROW['product_name'];
$itemCode = $tablaDeProductosROW['product_code'];
$itemDescr = $tablaDeProductosROW['product_description'];
$itemStock = $tablaDeProductosROW['product_stock'];
$file = $tablaDeProductosROW["archivo"];
$finalFile = substr($file, 3);
$total += ($productPrice * $productAmount);
?>
<tr>
<td><?php echo $itemName ?></td>
<td class="text-center">$<?php echo $productPrice ?>.00</td>
<td class="text-center"><?php echo $productAmount ?></td>
<td class="text-right">$<?php $quantityPrice = $productPrice * $productAmount; echo $quantityPrice; $total+=$quantityPrice;?>.00</td>
</tr>
<?php }}}?>
<tr>
<td class="thick-line"></td>
<td class="thick-line"></td>
<td class="thick-line text-center"><strong>Subtotal</strong></td>
<td class="thick-line text-right">$<?php echo $total?>.00</td>
</tr>
<tr>
<td class="no-line"></td>
<td class="no-line"></td>
<td class="no-line text-center"><strong>Envio</strong></td>
<td class="no-line text-right">$0 </td>
</tr>
<tr>
<td class="no-line"></td>
<td class="no-line"></td>
<td class="no-line text-center" ><strong>I.V.A</strong> <h14 style="font-size: 10px">0.16%</h14></td>
<td class="no-line text-right">$<?php $iva = $total* 0.16;$total+=$iva ;echo $iva?> </td>
</tr>
<tr>
<td class="no-line"></td>
<td class="no-line"></td>
<td class="no-line text-center"><strong>Total</strong></td>
<td class="no-line text-right"><?php echo $total?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="cartModal" tabindex="-1" role="dialog" aria-labelledby="cartModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="cartModalLabel">Carrito de Compras</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="media">
<div class="media-body">
<h5 class="mt-0">Acualmente no tienes productos en el carrito</h5>
<div id="productDescription">Empieza a agregar productos aqui <strong>HOY MISMO</strong>!</div>
</div>
</div>
<hr>
<div>
<strong>Total:</strong>
<span id="totalPrice">$0.00</span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
<button type="button" class="btn btn-primary">Realizar Compra</button>
</div>
</div>
</div>
</div>
<footer class="bg-dark text-white text-center py-3">
<div class="container">
<p>© 2023 FlipArt Todos los derechos reservados.</p>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="Js/carrito.js"></script>
<script src="Js/logIn.js"></script>
<?php
$con = conecta();
$usuario = $_SESSION['username'];
$sql = "UPDATE pedidos SET status = 0 WHERE client_id = '$usuario'";
$res = $con->query($sql);
?>
</body>
</html>