Problema para guardar
Publicado por Enin Baqueros (3 intervenciones) el 10/12/2019 02:55:03
tengo este codigo en una pagina, que la idea es guardar las compras de productos ya registrados
sin enbargo en esta parte:
que no se como llevarla a guardar a la base de datos. alguna ayuda por favor
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
<?php
$page_title = 'Registrar Compra';
require_once('includes/load.php');
include_once ('base_de_datos.php');
// Checkin What level user has permission to view this page//
page_require_level(3);
$all_proveedor = find_all('proveedor');
session_start();
if(!isset($_SESSION["compra"]))
$_SESSION["compra"] = [] ;
?>
<?php include_once('layouts/header.php'); ?>
<div class="col-xs-12">
<h1>Comprar</h1>
<?php
$granTotal = 0;
if(isset($_GET["status"])){
if($_GET["status"] === "1"){
?>
<div class="alert alert-success">
<strong>¡Correcto!</strong> Compra realizada correctamente
</div>
<?php
}else if($_GET["status"] === "2"){
?>
<div class="alert alert-info">
<strong>Compra cancelada</strong>
</div>
<?php
}else if($_GET["status"] === "3"){
?>
<div class="alert alert-info">
<strong>Ok</strong> Producto quitado de la lista
</div>
<?php
}else if($_GET["status"] === "4"){
?>
<div class="alert alert-warning">
<strong>Error:</strong> El producto que buscas no existe
</div>
<?php
}else if($_GET["status"] === "5"){
?>
<?php
}else{
?>
<div class="alert alert-danger">
<strong>Error:</strong> Algo salió mal mientras se realizaba la venta
</div>
<?php
}
}
?>
<select class="form-control" name="product-categorie">
<option value="">Selecciona un Proveedor</option>
<?php foreach ($all_proveedor as $cat): ?>
<option value="<?php echo (int)$cat['id'] ?>">
<?php echo $cat['name'] ?></option>
<?php endforeach; ?>
</select>
<select class="form-control" name="product-categorie">
<option value="">Tipo de Compra</option>
<?php foreach ($all_proveedor as $cat): ?>
<option value="<?php echo (int)$cat['id'] ?>">
<?php echo $cat['name'] ?></option>
<?php endforeach; ?>
</select>
<br>
<form method="post" action="agregarAlCarritocom.php">
<input name="cnit" type="hidden" value="<?php echo $c_nit;?>" >
<input name="razonsocial" type="hidden" value="<?php echo $razonsocial;?>" >
<label for="codigo">Código de barras:</label>
<input autocomplete="on" autofocus class="form-control" name="codigo" required type="text" id="codigo" placeholder="Escribe el código">
</form>
<br><br>
<table class="table table-bordered">
<thead>
<tr>
<th style="background-color:#2a3542"><font color="white">ID</th>
<th style="background-color:#2a3542"><font color="white">Código</th>
<th style="background-color:#2a3542"><font color="white">Descripción</th>
<th style="background-color:#2a3542"><font color="white">Precio de venta</th>
<th style="background-color:#2a3542"><font color="white">Cantidad</th>
<th style="background-color:#2a3542"><font color="white">Total</th>
<th style="background-color:#2a3542"><font color="white">Quitar</th>
</tr>
</thead>
<tbody>
<?php foreach($_SESSION["compra"] as $indice => $producto){
$granTotal += $producto->total;
?>
<tr>
<td><?php echo $producto->id ?></td>
<td><?php echo $producto->codigo ?></td>
<td><?php echo $producto->descripcion ?></td>
<td><?php echo $producto->precioVenta ?></td>
<td><input type="decimal" name="test"></td>
<td><?php echo $producto->total ?></td>
<td><a class="btn btn-danger" href="<?php echo "quitarDelcompra.php?indice=" . $indice ."&cnit=$c_nit&rsocial=$razonsocial"?>"><i class="fa fa-trash"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
<h3>Total: <?php echo $granTotal; ?></h3>
<form action="./terminar_gasto.php?status=20&control=0" method="POST">
<button type="submit" class="btn btn-success">Realizar Compra</button>
<a href="./cancelarVenta.php?&cnit=0&rsocial=''" class="btn btn-danger">Cancelar Compra</a>
</form>
</div>
<?php include_once('layouts/footer.php'); ?>
sin enbargo en esta parte:
1
2
3
<td><?php echo $producto->precioVenta ?></td>
<td><input type="decimal" name="test"></td>
<td><?php echo $producto->total ?></td>
que no se como llevarla a guardar a la base de datos. alguna ayuda por favor
Valora esta pregunta


0