-
Notifications
You must be signed in to change notification settings - Fork 0
/
producto.php
186 lines (168 loc) · 11.6 KB
/
producto.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
<?php
//Listado de producto
include 'function/prod_list.php';
?>
<!-- CABECERA - HEADER -->
<?php include './function/header.php'; ?>
<body>
<!-- NavBar-->
<?php include './function/menu.php'; ?>
<div class="container">
<br><br>
<div class="starter-template">
<h1>Lista de Producto</h1>
<!-- Modal Registrar Producto -->
<button type="button" class="btn btn-success" data-toggle="modal" data-target=".agregar">Agregar producto</button>
<div class = "modal fade agregar" tabindex = "-1" role = "dialog" aria-labelledby = "mySmallModalLabel" aria-hidden = "true">
<div class = "modal-dialog modal-sm">
<div class = "modal-content">
<div class = "starter-template">
<h1 style = "font-size: 1em;
font-weight: bold;
" class = "text-uppercase text-center">ingrese un nuevo producto</h1>
<form id = "categoria" name = "categoria" method = "POST" action = "function/prod_add.php">
<label>DESCRIPCION</label>
<div id = "descripcion1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "descproducto" name = "descproducto" required="" type = "text" value = "" maxlength="35" onkeypress = "return soloLetras(event)" onblur = "limpia()" id = "miInput">
</div>
</div>
<label>STOCK</label>
<div id = "stock1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "cantproducto" name = "cantproducto" required="" type = "text" value = "" maxlength="3" onkeypress = "return solonum()">
</div>
</div>
<label>PRECIO</label>
<div id = "precio1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "precioproducto" name = "precioproducto" required="" type = "text" value = "" maxlength="10" onkeypress = "return solonum()">
</div>
</div>
<label class="text-uppercase">Categoria del producto</label><br>
<?php
echo "<select name='catproducto'";
echo "<option value=''></option>";
while ($fila = mysql_fetch_array($rescategoria)) {
echo "<option value='" . $fila['idcategoria'] . "'>" . $fila['descripcionprod'] . "</option>";
}
echo "</select><br><br>";
?>
<div class="text-center">
<input type = "submit" class="btn btn-default text-center" name = "producto" id = "producto" value = "Agregar producto" onclick="separador(1)">
</div><br>
</form>
</div>
</div>
</div>
</div>
<!-- / Modal Registrar Producto -->
<?php include('function/notificacion.php') ?>
<!-- Table Listado de productos -->
<table class="table table-hover">
<tr>
<td><b>DESCRIPCION</b></td>
<td><b>STOCK</b></td>
<td><b>PRECIO</b></td>
<td><b>CATEGORIA</b></td>
<td><b>ACCION</b></td>
</tr>
<tr>
<tr>
<?php while ($fila = mysql_fetch_array($resultado, MYSQL_ASSOC)) { ?>
<td> <?php echo $fila['descproducto']; ?> </td>
<td> <?php echo $fila['cantprod']; ?> </td>
<td><?php echo $fila['precio']; ?></td>
<td> <?php echo $fila['descripcionprod']; ?> </td>
<td>
<button type="button" class="btn btn-warning" data-toggle="modal" data-target=".<?php echo $fila['idproducto']; ?>">Editar</button>
<a href="function/prod_del.php?id=<?php echo $fila['idproducto']; ?>&prod=<?php echo $fila['descproducto']; ?>" class="btn btn-danger" role="button" onclick="return confirmation()">Eliminar</a>
</td>
</tr>
<?php } ?>
</tr>
</table>
<!-- / Table Listado de productos-->
<!-- Modal Editar Producto-->
<?php while ($fila = mysql_fetch_array($resultados, MYSQL_ASSOC)) { ?>
<div class = "modal fade <?php echo $fila['idproducto']; ?>" tabindex = "-1" role = "dialog" aria-labelledby = "mySmallModalLabel" aria-hidden = "true">
<div class = "modal-dialog modal-sm">
<div class = "modal-content">
<div class = "starter-template">
<h1 style = "font-size: 1em;
font-weight: bold;
" class = "text-uppercase text-center">Editar producto</h1>
<form id = "fproducto" name = "fproducto" method = "post" action = "function/prod_edit.php">
<div class="oculto">
<label>ID</label>
<div id = "id1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "id" name = "id" type = "text" value = "<?php echo $fila['idproducto']; ?>" maxlength="35" onkeypress = "return soloLetras(event)" onblur = "limpia()" id = "miInput">
</div>
</div></div>
<label>DESCRIPCION</label>
<div id = "descripcion1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "descproductos[<?php echo $fila['idproducto']; ?>]" name = "descproducto" required="" type = "text" value = "<?php echo $fila['descproducto']; ?>" maxlength="35" onkeypress = "return soloLetras(event)" onblur = "limpia()" id = "miInput">
</div>
</div>
<label>STOCK</label>
<div id = "stock1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "cantproductos[<?php echo $fila['idproducto']; ?>]" name = "cantproducto" required="" type = "text" value = "<?php echo $fila['cantprod']; ?>" maxlength="3" onkeypress = "return solonum()">
</div>
</div>
<label>PRECIO</label>
<div id = "precio1" class = "error4">
<div class = "form-group">
<input class = "form-control" id = "precioproductos[<?php echo $fila['idproducto']; ?>]" name = "precioproducto" required="" type = "text" value = "<?php echo $fila['precio']; ?>" maxlength="10" onclick="return blanco(<?php echo $fila['idproducto']; ?>)" onkeypress = "return solonum()">
</div>
</div>
<div class="oculto">
<label>ORIGINAL/label>
<div>
<div class = "form-group">
<input class = "form-control" id = "original[<?php echo $fila['idproducto']; ?>]" name = "original" type = "text" value = "<?php echo $fila['precio']; ?>">
</div>
</div>
</div>
<label class="text-uppercase">Listado de Categorias</label><br>
<?php
echo "<select name='catproducto'<option value=''></option>";
while ($filas = mysql_fetch_array($rescategorias, MYSQL_ASSOC)) {
echo "<option value='" . $filas['idcategoria'] . "'>" . $filas['descripcionprod'] . "</option>";
}
echo "</select><br><br>";
?>
<div class="text-center">
<input type = "submit" class="btn btn-default" name = "actualizar" id = "actualizar" value = "Editar producto" onclick="separadorr(<?php echo $fila['idproducto']; ?>)">
</div><br>
</form>
</div>
</div>
</div>
</div>
<?php } ?>
<!-- / Modal Editar Producto-->
</div>
</div>
<?php include('function/footer.php') ?>
<script>
function blanco(z) {
document.getElementById("precioproductos[" + z + "]").value = "";
}
function separadorr(z) {
var b = document.getElementById("descproductos[" + z + "]").value;
var b1 = document.getElementById("cantproductos[" + z + "]").value;
var b2 = document.getElementById("precioproductos[" + z + "]").value;
var o = document.getElementById("original[" + z + "]").value;
if (b == null || b.length == 0 || b == "" || b1 == null || b1.length == 0 || b1 == "" || b2 == null || b2.length == 0 || b2 == "") {
document.getElementById("precioproductos[" + z + "]").value = "";
} else if (b2 == o) {
} else {
document.getElementById("precioproductos[" + z + "]").value = formatNumber.new(b2, "BsF ");
}
}
</script>
</body>
</html>