-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathregistro-de-ventas.php
162 lines (161 loc) · 6.18 KB
/
registro-de-ventas.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
<?php session_start();
include ('sistema/configuracion.php');
$usuario->LoginCuentaConsulta();
$usuario->VerificacionCuenta();
$usuario->ZonaAdministrador();
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title><?php echo TITULO ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" href="<?php echo ESTATICO ?>img/favicon.ico">
<link rel="stylesheet" type="text/css" href="<?php echo ESTATICO ?>css/dataTables.bootstrap.css">
<?php include(MODULO.'Tema.CSS.php');?>
</head>
<body>
<?php
// Menu inicio
if($usuarioApp['id_perfil']==2){
include (MODULO.'menu_vendedor.php');
}elseif($usuarioApp['id_perfil']==1){
include (MODULO.'menu_admin.php');
}else{
echo'<meta http-equiv="refresh" content="0;url='.URLBASE.'cerrar-sesion"/>';
}
//Menu Fin
?>
<div id="wrap">
<div class="container">
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-8 col-md-7 col-sm-6">
<h1>Registro de Ventas</h1>
</div>
</div>
</div>
<?php
if(isset($_POST['CancelarFactura'])){
$Idfactura = $_POST['Idfactura'];
$actulizarFactura = $db->SQL("UPDATE `factura` SET `habilitado` = '0' WHERE `id` = '{$Idfactura}'");
$actulizarNumeros = $db->SQL("UPDATE `ventas` SET `habilitada` = '0' WHERE `idfactura` = '{$Idfactura}'");
if($actulizarFactura == true AND $actulizarNumeros==true){
echo'
<div class="alert alert-dismissible alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>¡Bien hecho!</strong> La Factura ha sido cancelada con exito.
</div>
<meta http-equiv="refresh" content="2;url='.URLBASE.'registro-de-ventas"/>';
}else{
echo'
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>¡Lo Sentimos!</strong> A ocurrido un error al cancelar la factura, intentalo de nuevo.
</div>
<meta http-equiv="refresh" content="2;url='.URLBASE.'registro-de-ventas"/>';
}
}
?>
<div class="row">
<div class="col-sm-12">
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered table-condensed" id="example" data-sort-name="id" data-sort-order="desc">
<thead>
<tr>
<td><strong>Id Factura</strong></td>
<td><strong>Total</strong></td>
<td><strong>Fecha</strong></td>
<td><strong>vendedor</strong></td>
<td><strong>Estado</strong></td>
<td><strong>Comprobante</strong></td>
</tr>
</thead>
<tbody>
<?php
$cajatmpSql = $db->SQL("SELECT * FROM factura WHERE id ORDER BY id ASC");
while($cajatmp = $cajatmpSql->fetch_array()){
?>
<tr>
<td data-sort-order="desc"> <?php echo $cajatmp['id']; ?></td>
<td> <?php echo $cajatmp['total']; ?></td>
<td> <?php echo $cajatmp['fecha'].' '.$cajatmp['hora']; ?></td>
<td>
<?php
$vendedorSQLQuery = $db->SQL("SELECT nombre, apellido1, apellido2 FROM `vendedores` WHERE id='{$cajatmp['usuario']}'");
$vendedorNombre = $vendedorSQLQuery->fetch_assoc();
echo $vendedorNombre['nombre'].' '.$vendedorNombre['apellido1'].' '.$vendedorNombre['apellido2'];
?></td>
<td> <?php if($cajatmp['habilitado'] == 1){
echo'<span class="label label-success">Activa</span>';
}else{
echo'<span class="label label-danger">Cancelada</span>';
}?>
</td>
<td>
<a href="<?php echo URLBASE ?>reimprimir/<?php echo $cajatmp['id']; ?>" class="btn btn-primary btn-sm">Ver venta</a>
<?php
if($cajatmp['habilitado']==1){
?>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#CancelarApuesta<?php echo $cajatmp['id']; ?>">Cancelar Factura</button>
<!-- Modal -->
<div class="modal fade" id="CancelarApuesta<?php echo $cajatmp['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Cancelar Factura</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" method="post" action="">
<input type="hidden" name="Idfactura" value="<?php echo $cajatmp['id']; ?>">
<div class="form-group">
<div class="col-sm-12">
<div class="input-group">
¿Está seguro que desea cancelar la factura #<?php echo $cajatmp['id']; ?>?
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="submit" name="CancelarFactura" class="btn btn-primary">Si, Cancelar</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Final -->
<?php
}else{
?>
<button type="button" class="btn btn-primary btn-sm disabled" data-toggle="modal">Factura Cancelada</button>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include (MODULO.'footer.php'); ?>
<!-- Cargado archivos javascript al final para que la pagina cargue mas rapido -->
<?php include(MODULO.'Tema.JS.php');?>
<script type="text/javascript" language="javascript" src="<?php echo ESTATICO ?>js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo ESTATICO ?>js/dataTables.bootstrap.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable({"order":[0, 'desc']});
} );
</script>
<!-- Cargado archivos javascript al final para que la pagina cargue mas rapido Fin -->
</body>
</html>