<?php
require("conexion.php");

$nom = $_SESSION['nom_admin'];
$iduser = $_SESSION['id_user'];
$suc = $_SESSION['IdSuc'];
$tipou= $_SESSION['tipouser'];
$cod = $_POST['id'];
$v = mysqli_query($conexion,"SELECT * FROM Ventas WHERE IdVenta = '$cod'");
$f = mysqli_fetch_array($v);
$ser = $f['Serie'];
$fol = $f['FolioVenta'];
$cliente = $f['IdCliente'];
$total = $f['Total'];
$bono = round(($total / 1.16) * 0.05,2);
$prueba = date("Y-m-d H:i:s");
$mon = mysqli_query($conexion,"SELECT * FROM Monedero WHERE IdCliente = '$cliente'");
$m = mysqli_fetch_array($mon);
$sa = $m['SaldoActual'];
$idmon = $m['IdMonedero'];
$totalmon = $sa + $bono;



$descme = 'BONO - MONEDERO ELECTRONICO POR LA CANTIDAD DE '.$bono;
$ven = mysqli_query($conexion,"UPDATE Ventas SET BonoMonedero = '1' WHERE IdVenta ='$cod'");
$p = mysqli_query($conexion,"UPDATE Monedero SET SaldoActual = '$totalmon' WHERE IdMonedero ='$idmon'");
$umed = mysqli_query($conexion,"INSERT INTO MonederoDetalle VALUES (DEFAULT,'$ser','$fol','$idmon',1,'$bono',1,'$iduser','$prueba','$descme')");
echo '1';
?>