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

$ant = $_POST['ant'];
$saldo = $_POST['saldo'];
$total = $_POST['total'];
$cod = $_POST['cod'];
$ser = substr($cod, 0,4);
	$fol = substr($cod, 4,8);

$v = mysqli_query($conexion,"SELECT * FROM Ventas WHERE Serie = '$ser' AND FolioVenta = '$fol' AND Activo = 1");
$f = mysqli_fetch_array($v);

$sa = $f['Saldo'];
$anta = $f['Anticipo'];

$totalr = $sa - $ant;

echo $totalr;

?>