robotec/vistas/venta.php

224 lines
6.9 KiB
PHP

<?php
//activamos almacenamiento en el buffer
ob_start();
session_start();
// Obtener la IP del dispositivo que ingreso
function getIp(): string
{
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
} elseif (isset($_SERVER['REMOTE_ADDR']) === true) {
$ip = $_SERVER['REMOTE_ADDR'];
if (preg_match('/^(?:127|10)\.0\.0\.[12]?\d{1,2}$/', $ip)) {
if (isset($_SERVER['HTTP_X_REAL_IP'])) {
$ip = $_SERVER['HTTP_X_REAL_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
}
} else {
$ip = '127.0.0.1';
}
if (in_array($ip, ['::1', '0.0.0.0', 'localhost'], true)) {
$ip = '127.0.0.1';
}
$filter = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
if ($filter === false) {
$ip = '127.0.0.1';
}
return $ip;
}
$ip_autorizada ='127.0.0.1';
if (!isset($_SESSION['nombre'])) {
header("Location: login.html");
}else{
require 'header.php';
if ($_SESSION['ventas']==1) {
?>
<div class="content-wrapper">
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-header with-border">
<h1 class="box-title">Vales</h1>
<?php
if((getIp() == $ip_autorizada) || ($_SESSION['acceso']==1)) {
?>
<button class="btn btn-success" onclick="mostrarform(true)"><i class="fa fa-plus-circle"></i>Agregar</button>
<?php
}
echo 'Dirección IP: ' . getIp() . '?'; // !Echo de prueba para ver la IP, no utilizar en el programa final
?>
<div class="box-tools pull-right">
</div>
</div>
<!--box-header-->
<!--centro-->
<div class="panel-body table-responsive" id="listadoregistros">
<table id="tbllistado" class="table table-striped table-bordered table-condensed table-hover">
<thead>
<th>Opciones</th>
<th>Fecha</th>
<th>Asunto</th>
<th>Usuario</th>
<th>Documento</th>
<th>Número</th>
<th>Total Venta</th>
<th>Estado</th>
</thead>
<tbody>
</tbody>
<tfoot>
<th>Opciones</th>
<th>Fecha</th>
<th>Asunto</th>
<th>Usuario</th>
<th>Documento</th>
<th>Número</th>
<th>Total Venta</th>
<th>Estado</th>
</tfoot>
</table>
</div>
<div class="panel-body" style="height: 400px;" id="formularioregistros">
<form action="" name="formulario" id="formulario" method="POST">
<div class="form-group col-lg-8 col-md-8 col-xs-12">
<label for="">Asunto(*):</label>
<input class="form-control" type="hidden" name="idventa" id="idventa">
<select name="idcliente" id="idcliente" class="form-control selectpicker" data-live-search="true" required>
</select>
</div>
<div class="form-group col-lg-4 col-md-4 col-xs-12">
<label for="">Fecha(*): </label>
<input class="form-control" type="date" name="fecha_hora" id="fecha_hora" required>
</div>
<div class="form-group col-lg-6 col-md-6 col-xs-12">
<label for="">Tipo Comprobante(*): </label>
<select name="tipo_comprobante" id="tipo_comprobante" class="form-control selectpicker" required>
<option value="VALE">VALE</option>
<option value="DAÑO">DAÑO</option>
</select>
</div>
<div class="form-group col-lg-2 col-md-2 col-xs-6">
<label for="">Alumno: </label>
<input class="form-control" type="text" name="serie_comprobante" id="serie_comprobante" maxlength="9" placeholder="Número de control">
</div>
<div class="form-group col-lg-2 col-md-2 col-xs-6">
<label for="">Número: </label>
<input class="form-control" type="text" name="num_comprobante" id="num_comprobante" maxlength="10" placeholder="Número de vale" required>
</div>
<div class="form-group col-lg-2 col-md-2 col-xs-6" hidden>
<label for="">Impuesto: </label>
<input value="0" class="form-control" type="text" name="impuesto" id="impuesto">
</div>
<div class="form-group col-lg-3 col-md-3 col-sm-6 col-xs-12">
<a data-toggle="modal" href="#myModal">
<button id="btnAgregarArt" type="button" class="btn btn-primary"><span class="fa fa-plus"></span>Agregar Articulos</button>
</a>
</div>
<div class="form-group col-lg-12 col-md-12 col-xs-12">
<table id="detalles" class="table table-striped table-bordered table-condensed table-hover">
<thead style="background-color:#A9D0F5">
<th>Opciones</th>
<th>Articulo</th>
<th>Cantidad</th>
<th>Precio Venta</th>
<th>Descuento</th>
<th>Subtotal</th>
</thead>
<tfoot>
<th>TOTAL</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th><h4 id="total">MXN/. 0.00</h4><input type="hidden" name="total_venta" id="total_venta"></th>
</tfoot>
<tbody>
</tbody>
</table>
</div>
<div class="form-group col-lg-12 col-md-12 col-sm-12 col-xs-12">
<button class="btn btn-primary" type="submit" id="btnGuardar"><i class="fa fa-save"></i> Guardar</button>
<button class="btn btn-danger" onclick="cancelarform()" type="button" id="btnCancelar"><i class="fa fa-arrow-circle-left"></i> Cancelar</button>
</div>
</form>
</div>
<!--fin centro-->
</div>
</div>
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!--Modal-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width: 65% !important;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Seleccione un Articulo</h4>
</div>
<div class="modal-body">
<table id="tblarticulos" class="table table-striped table-bordered table-condensed table-hover">
<thead>
<th>Opciones</th>
<th>Nombre</th>
<th>Categoria</th>
<th>Código</th>
<th>Stock</th>
<th>Precio Venta</th>
<th>Imagen</th>
</thead>
<tbody>
</tbody>
<tfoot>
<th>Opciones</th>
<th>Nombre</th>
<th>Categoria</th>
<th>Código</th>
<th>Stock</th>
<th>Precio Venta</th>
<th>Imagen</th>
</tfoot>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-default" type="button" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<!-- fin Modal-->
<?php
}else{
require 'noacceso.php';
}
require 'footer.php';
?>
<script src="scripts/venta.js"></script>
<?php
}
ob_end_flush();
?>