-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
130 lines (119 loc) · 5.12 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
<?php
require 'conexion.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css">
<title>Document</title>
<style>
body {
background-color: #D3DFFF;
}
.peq {
max-width: 70px;
text-align: center;
}
.container mx-auto {
margin-top: 1%;
}
</style>
</head>
<body>
<br>
<div class="container mx-auto">
<div class="card shadow-lg">
<div class="card-body">
<form action="" method="POST">
<div class="card-body" style="background-color: #F2F2F2;">
<label for="buscar"> Buscar: </label>
<input type="text" class="peq" name="id" placeholder="id" value="<?php echo (isset($_POST['id'])) ? $_POST['id'] : '' ?>">
<input type="text" name="nombre" placeholder="Nombre producto" value="<?php echo (isset($_POST['nombre'])) ? $_POST['nombre'] : '' ?>">
<input type="text" name="categoria" placeholder="Categoria" value="<?php echo (isset($_POST['categoria'])) ? $_POST['categoria'] : '' ?>">
<input type="text" name="marca" placeholder="Marca" value="<?php echo (isset($_POST['marca'])) ? $_POST['marca'] : '' ?>">
<label>Rango precios: </label>
<input type="text" class="peq" name="precio_min" placeholder="minimo" value="<?php echo (isset($_POST['precio_min'])) ? $_POST['precio_min'] : '' ?>"> -
<input type="text" class="peq" name="precio_max" placeholder="maximo" value="<?php echo (isset($_POST['precio_max'])) ? $_POST['precio_max'] : '' ?>">
<label for="Mostrar agotados">- Mostrar agotados:</label>
<input type="checkbox" name="mostrar_agotados" <?php if ($mostrar_agotados == "1") echo "checked"; ?>>
<input type="submit" class="btn btn-success" name="buscar" value="Buscar">
</div>
<!-- <input type="submit" name="agregar" value="agregar"> -->
<br>
<label>- mostrar opciones avanzadas</label>
<input type="checkbox" id="opciones" name="opciones_avanzadas" <?php if ($mostrar_opciones == "1") echo "checked"; ?>>
<div id="div_avanzadas" class="card-body" style="background-color: #F2F2F2; display: none;">
<input type="text" class="peq" name="a_id" placeholder="id">
<input type="text" name="a_nombre" placeholder="Nombre producto">
<input type="text" name="a_categoria" placeholder="Categoria">
<input type="text" class="peq" name="a_cantidad" placeholder="cantidad">
<input type="text" name="a_marca" placeholder="Marca">
<input type="text" class="peq" name="a_precio" placeholder="precio">
<input type="submit" class="btn btn-warning" name="agregar" value="Agregar">
<input type="submit" class="btn btn-info" name="editar" value="Agregar">
</div>
</div>
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th>id</th>
<th>Nombre</th>
<th>categoria</th>
<th>cantidad</th>
<th>marca</th>
<th>precio</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($obj = pg_fetch_object($consulta)) {
?>
<tr>
<td><?php echo $obj->id; ?></td>
<td><?php echo $obj->nombre; ?></td>
<td><?php echo $obj->categoria; ?> </td>
<td><?php echo $obj->cantidad; ?> </td>
<td><?php echo $obj->marca; ?></td>
<td><?php echo $obj->precio; ?></td>
<td><button type="submit" name="eliminar" class="btn btn-danger btn-sm" onclick=eliminarfila(this)>Eliminar</button></td>
</tr>
</tbody>
<?php
}
?>
</table>
<div style="text-align: center;">
<input type="submit" name="atras" class="btn btn-info" value="anterior">
<input type="text" class="peq" name="offset" value="<?php echo (isset($_POST['offset'])) ? $_POST['offset'] : '' ?>">
<input type="submit" name="adelante" class="btn btn-info" value="siguiente">
</div>
<input id="del" name="del" style="display: none;">
</form>
</div>
</div>
</div>
</body>
<!-- <script src="index.js"></script> -->
<script>
const checkbox = document.getElementById('opciones');
checkbox.addEventListener("change", revisar);
revisar()
function revisar() {
const div = document.getElementById('div_avanzadas');
if (checkbox.checked) {
div.style.display = "block";
} else {
div.style.display = "none";
}
}
function eliminarfila(boton) {
let fila = boton.parentNode.parentNode;
let id = fila.getElementsByTagName("td")[0];
document.getElementById("del").value = id.innerHTML;
console.log("<?php echo $eliminar ?>")
}
</script>
</html>