-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
193 lines (151 loc) · 5.35 KB
/
index.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
<?php
include "Configuracion/config.php";
include "Configuracion/funciones.php";
if(!isset($p)){
$p = "principal";
}else{
$p = $p;
}
?>
<!DOCTYPE html>
<HTML>
<HEAD>
<meta charset="utf-8"/>
<link rel="stylesheet" href="Recursos/css/estilo.css"/>
<link rel="stylesheet" href="Recursos/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="Recursos/fontawesome/css/all.css"/>
<script type="text/javascript" src="Recursos/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="Recursos/fontawesome/js/all.js"></script>
<script type="text/javascript" src="Recursos/js/jquery.js"></script>
<script type="text/javascript" src="Recursos/js/app.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<!-- <script src="https://code.jquery.com/jquery-3.4.1.js"></script> -->
<title>Tienda Online</title>
</HEAD>
<BODY>
<nav>
<div class="logo">
<img src="Recursos/img/28.png">
</div>
<ul>
<li><a href="?p=principal" class="active">Home</a></li>
<li><a href="?p=productos">Productos</a></li>
<li><a href="?p=ofertas">Ofertas</a></li>
<?php
if(isset($_SESSION['id_cliente'])){
?>
<li><a href="?p=carrito">Mi Carrito</a></li>
<li><a href="?p=miscompras">Mis compras</a></li>
<li><a href="#"><?=nombre_cliente($_SESSION['id_cliente'])?></a></li>
<li><a href="?p=salir">Salir</a></li>
<?php
}else{
?>
<li><a href="?p=contacto">Contactanos</a></li>
<li><a href="?p=login">Login</a></li>
<?php
}
?>
</ul>
</nav>
<section class="sec1">
<h1>Tienda Online de ropa M&M</h1>
</section>
<section class="content">
<?php
if(file_exists("Modulos/".$p.".php")){
include "Modulos/".$p.".php";
}else{
echo "<i>No se ha encontrado el modulo<a href='./'>Regresar</a></i>";
}
?> </section>
<div class="carritot" onclick="minimizer()">
Ver carrito de compras
<input type="hidden" id="minimized" value=0/>
</div>
<div class="carritob">
<table class="table table-striped">
<tr>
<th>Nombre del producto</th>
<th>Cantidad</th>
<th>Precio total</th>
</tr>
<?php
$id_cliente = clear($_SESSION['id_cliente']);
$q = $mysqli->query("SELECT * FROM carro WHERE id_cliente= '$id_cliente'");
$monto_total = 0;
while($r = mysqli_fetch_array($q)){
$q2 = $mysqli->query("SELECT * FROM productos WHERE id= '".$r['id_producto']."'");
$r2 = mysqli_fetch_array($q2);
$preciototal = 0;
if($r2['oferta']>0){
if(strlen($r2['oferta'])==1){
$desc = "0.0".$r2['oferta'];
}else{
$desc = "0.".$r2['oferta'];
}
$preciototal = $r2['price'] -($r2['price'] * $desc);
}else{
$preciototal = $r2['price'];
}
$nombre_producto = $r2['name'];
$cantidad = $r['cant'];
$precio_unidad = $r2['price'];
$precio_total = $preciototal * $cantidad;
$imagen_producto = $r2['imagen'];
$monto_total = $monto_total + $precio_total;
?>
<tr>
<td><?=$nombre_producto ?></td>
<td><?= $cantidad ?></td>
<td><?= $precio_total ?> <?= $divisa ?> </td>
</tr>
<?php
}
?>
</table>
<br>
<span>El monto total es de: <b class="text-green"> <?= $monto_total?> <?=$divisa?> </b></span>
<br><br>
<form method="post" action="?p=carrito">
<div align="center">
<input type="hidden" name="monto_total" value="<?= $monto_total ?> "/>
<button onclick ='carrito.php' class="btn btn-sucess" type="submit" name="revisar"><i class="fa fa-check"></i>Revisar Compra</button>
<button class="btn btn-primary" type="submit" name="finalizar"><i class="fa fa-check"></i>Finalizar Compra</button>
</div>
</form>
</div>
<div class="footer">
Copyright Jeans M&M © <?=date("y")?>
</div>
</BODY>
</HTML>
<script type="text/javascript">
$(window).on('scroll', function(){
if($(window).scrollTop()){
$('nav').addClass('black');
}else{
$('nav').removeClass('black');
}
})
</script>
<script type="text/javascript">
function minimizer(){
var minimized = $("#minimized").val();
if(minimized == 0){
//mostrar
$(".carritot").css("bottom","350px");
$(".carritob").css("bottom","0px");
$("#minimized").val('1');
}else{
//minimizar
$(".carritot").css("bottom","0px");
$(".carritob").css("bottom","-350px");
$("#minimized").val('0');
}
}
</script>