-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathstock.php
149 lines (126 loc) · 3.63 KB
/
stock.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
<?php
/*-------------------------
Autor: Obed Alvarado
Web: obedalvarado.pw
Mail: [email protected]
---------------------------*/
session_start();
if (!isset($_SESSION['user_login_status']) AND $_SESSION['user_login_status'] != 1) {
header("location: login.php");
exit;
}
/* Connect To Database*/
require_once ("config/db.php");//Contiene las variables de configuracion para conectar a la base de datos
require_once ("config/conexion.php");//Contiene funcion que conecta a la base de datos
$active_productos="active";
$title="Inventario | Simple Stock";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("head.php");?>
</head>
<body>
<?php
include("navbar.php");
?>
<div class="container">
<div class="panel panel-success">
<div class="panel-heading">
<div class="btn-group pull-right">
<button type='button' class="btn btn-success" data-toggle="modal" data-target="#nuevoProducto"><span class="glyphicon glyphicon-plus" ></span> Agregar</button>
</div>
<h4><i class='glyphicon glyphicon-search'></i> Consultar inventario</h4>
</div>
<div class="panel-body">
<?php
include("modal/registro_productos.php");
include("modal/editar_productos.php");
?>
<form class="form-horizontal" role="form" id="datos">
<div class="row">
<div class='col-md-4'>
<label>Filtrar por código o nombre</label>
<input type="text" class="form-control" id="q" placeholder="Código o nombre del producto" onkeyup='load(1);'>
</div>
<div class='col-md-4'>
<label>Filtrar por categoría</label>
<select class='form-control' name='id_categoria' id='id_categoria' onchange="load(1);">
<option value="">Selecciona una categoría</option>
<?php
$query_categoria=mysqli_query($con,"select * from categorias order by nombre_categoria");
while($rw=mysqli_fetch_array($query_categoria)) {
?>
<option value="<?php echo $rw['id_categoria'];?>"><?php echo $rw['nombre_categoria'];?></option>
<?php
}
?>
</select>
</div>
<div class='col-md-12 text-center'>
<span id="loader"></span>
</div>
</div>
<hr>
<div class='row-fluid'>
<div id="resultados"></div><!-- Carga los datos ajax -->
</div>
<div class='row'>
<div class='outer_div'></div><!-- Carga los datos ajax -->
</div>
</form>
</div>
</div>
</div>
<hr>
<?php
include("footer.php");
?>
<script type="text/javascript" src="js/productos.js"></script>
</body>
</html>
<script>
function eliminar (id){
var q= $("#q").val();
var id_categoria= $("#id_categoria").val();
$.ajax({
type: "GET",
url: "./ajax/buscar_productos.php",
data: "id="+id,"q":q+"id_categoria="+id_categoria,
beforeSend: function(objeto){
$("#resultados").html("Mensaje: Cargando...");
},
success: function(datos){
$("#resultados").html(datos);
load(1);
}
});
}
$(document).ready(function(){
<?php
if (isset($_GET['delete'])){
?>
eliminar(<?php echo intval($_GET['delete'])?>);
<?php
}
?>
});
$( "#guardar_producto" ).submit(function( event ) {
$('#guardar_datos').attr("disabled", true);
var parametros = $(this).serialize();
$.ajax({
type: "POST",
url: "ajax/nuevo_producto.php",
data: parametros,
beforeSend: function(objeto){
$("#resultados_ajax_productos").html("Mensaje: Cargando...");
},
success: function(datos){
$("#resultados_ajax_productos").html(datos);
$('#guardar_datos').attr("disabled", false);
load(1);
}
});
event.preventDefault();
})
</script>