-
Notifications
You must be signed in to change notification settings - Fork 0
/
modificar_compras.php
122 lines (106 loc) · 6.93 KB
/
modificar_compras.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
<?php
include "model/conexion.php";
//Recolectar el id
$id = $_GET["id"];
$consulta_datos = $conexion->query("SELECT cantidad_comprada, descripcion_producto, nombre_proveedor FROM detallecompras
INNER JOIN proveedores ON detallecompras.id_proveedor = proveedores.id_proveedor
WHERE id_detallecompra = $id;");
//Verifica si la consulta se ejecutó correctamente
if(!$consulta_datos){
die("Error en la consulta: " . mysqli_error($conexion));
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🛠️ Ferreteria | Modificar Compras</title>
<!--Bootstrap CSS-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<!--Hoja de estilos-->
<link rel="stylesheet" href="./src/css/style_productos.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light color_navbar p-3">
<div class="container-fluid d-flex align-items-center justify-content-between">
<a class="navbar-brand" href="#" style="color:#843C0C; font-size:1rem;">
<img src="./src/images/logo_ferreteria.png" alt="" width="50" height="50" class="d-inline-block align-text-center">
Ferrexpress | Modificar Compras
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav d-flex align-items-center justify-content-center">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="compras.php" style="color:#843C0C;">Salir</a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid columns d-flex align-items-center justify-content-center">
<form class="col-sm-3 col-md-3 pt-1" method="POST">
<h3 class="text-center color_h3">Modificar Compras</h3>
<input type="hidden" name="id" value="<?php echo $_GET["id"]; ?>">
<?php
include "controller/modificar_compras.php";
?>
<?php
//Obtener una sola fila de resultados
while($datos=$consulta_datos->fetch_object()){
?>
<div class="mb-1">
<label for="exampleInputEmail1" class="form-label">Producto:</label>
<select class="form-select" aria-label="Default select" name="descripcion_producto">
<option value="0" selected="">--Seleccione--</option>
<?php
$sqlProductos = "SELECT DISTINCT descripcion FROM productos;";
$resultadoProductos = mysqli_query($conexion, $sqlProductos);
while ($consultaProducto = mysqli_fetch_array($resultadoProductos)) {
$selected = ($consultaProducto['descripcion'] == $datos->descripcion_producto) ? 'selected' : '';
echo '<option value="' . $consultaProducto['descripcion'] . '" ' . $selected . '>' . $consultaProducto['descripcion'] . '</option>';
}
?>
</select>
</div>
<div class="mb-1 mt-3">
<label for="exampleInputEmail1" class="form-label">Cantidad:</label>
<input type="numer" class="form-control" name="cantidad_comprada" value="<?= $datos->cantidad_comprada ?>" onkeyup="mayus(this);">
</div>
<div class="mb-1">
<label for="exampleInputEmail1" class="form-label">Proveedor:</label>
<select class="form-select" aria-label="Default select" name="nombre_proveedor">
<option value="0" selected="">--Seleccione--</option>
<?php
$sqlProveedores = "SELECT proveedores.nombre_proveedor FROM proveedores;";
$resultadoProveedores = mysqli_query($conexion, $sqlProveedores);
while ($consultaProveedor = mysqli_fetch_array($resultadoProveedores)) {
$selected = ($consultaProveedor['nombre_proveedor'] == $datos->nombre_proveedor) ? 'selected' : '';
echo '<option value="' . $consultaProveedor['nombre_proveedor'] . '" ' . $selected . '>' . $consultaProveedor['nombre_proveedor'] . '</option>';
}
?>
</select>
</div>
<?php
}
?>
<div class="mb-1 d-flex align-items-center justify-content-center">
<button type="submit" class="btn mt-2 col-4" name="btnactualizar" value="ok" style="background-color:#813B0C; color:#ffffff;">Actualizar</button>
</div>
</form>
</div>
<!--Bootstrap JS-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!--CDN Iconicons-->
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
<!--Script para los inputs pasarlos a MAYUSCULAS-->
<script>
function mayus(e) {
e.value = e.value.toUpperCase();
}
</script>
</body>
</html>