[PHP] </div>
<br><div align="right" id="ventas-right-down">
<label for="total">Total: <input type="text" name="total" id="total" value="0"/><br/>
<input type="submit" value="INGRESAR VENTA"></form>
</div>
</div>
<?}?>
</div>
</div>
guardar/venta.php
Código PHP:
<?
include("../calamardo.php");
$fecha=date("Y-m-d");
$hora=date("H:i:s");
//--------------------------------------------------HACE UN INSERT FICTICIO--------------------------------------------
$insert_venta_real="insert into venta_real (valor,fecha,hora)values('1','1111-11-11','11:11:11')";
$res_insert_venta_real=mysqli_query($patricio,$insert_venta_real);
$max_venta= mysqli_insert_id($patricio);
//--------------------------------------------------ACTUALIZA EL INSERT------------------------------------------------
$update_venta_real="update venta_real set
valor='".$_POST["total"]."',
fecha='".$fecha."',
hora='".$hora."'
where id='".$max_venta."'";
mysqli_query($patricio,$update_venta_real);
$max1_venta=$_POST["max_venta_real"]+1;
//---------------------------------------------------------------------------------------------------------------------
$co0=$_POST["cantidad1"];
$co1=$_POST["cantidad2"];
$co2=$_POST["cantidad3"];
$co3=$_POST["cantidad4"];
$co4=$_POST["cantidad5"];
$co5=$_POST["cantidad6"];
$co6=$_POST["cantidad7"];
$co7=$_POST["cantidad8"];
$co8=$_POST["cantidad9"];
$co9=$_POST["cantidad10"];
$co10=$_POST["cantidad11"];
$subt0=$_POST["subtotal1"];
$subt1=$_POST["subtotal2"];
$subt2=$_POST["subtotal3"];
$subt3=$_POST["subtotal4"];
$subt4=$_POST["subtotal5"];
$subt5=$_POST["subtotal6"];
$subt6=$_POST["subtotal7"];
$subt7=$_POST["subtotal8"];
$subt8=$_POST["subtotal9"];
$subt9=$_POST["subtotal10"];
$subt10=$_POST["subtotal11"];
//------------------------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------------------
$query = "select id,id_stock,max_venta_real from ventas where max_venta_real='".$_POST["max_venta_real"]."'";
if($result = mysqli_query($patricio, $query)){
if(!empty($result)){
//------------------------------------------------------------------------------------------------------------------------------------------------------
mysqli_data_seek($result, 0);
$row0 = mysqli_fetch_row($result);
$id_stock0=$row0[1];
//------------------------------------------------------------------------------------------------------------------------------------------------------
$sc0="select id_stock,cantidad from stock where id_stock='".$id_stock0."'";
echo $sc0;
$rc0= mysqli_query($patricio,$sc0);
while ($fc0=mysqli_fetch_array($rc0))
{$c0=$fc0["cantidad"];
$cant0=$c0-$co0;
}
$uco0="update stock set
cantidad='".$cant0."'
where id_stock='".$id_stock0."'";
mysqli_query($patricio,$uco0);
$uvo0="update ventas set
cantidad='".$co0."',
subtotal='".$subt0."'
where id_stock='".$id_stock0."' AND max_venta_real='".$_POST["max_venta_real"]."'";
mysqli_query($patricio,$uvo0);
//echo 'unco0: '.$uco0.'<br>';
//------------------------------------------------------------------------------------------------------------------------------------------------------
mysqli_data_seek($result, 1);
$row1 = mysqli_fetch_row($result);
$id_stock1=$row1[1];
//------------------------------------------------------------------------------------------------------------------------------------------------------
$sc1="select id_stock,cantidad from stock where id_stock='".$id_stock1."'";
$rc1= mysqli_query($patricio,$sc1);
while ($fc1=mysqli_fetch_array($rc1))
{$c1=$fc1["cantidad"];
$cant1=$c1-$co1;}
$uco1="update stock set
cantidad='".$cant1."'
where id_stock='".$id_stock1."'";
mysqli_query($patricio,$uco1);
$uvo1="update ventas set
cantidad='".$co1."',
subtotal='".$subt1."'
where id_stock='".$id_stock1."' AND max_venta_real='".$_POST["max_venta_real"]."'";
mysqli_query($patricio,$uvo1);
//echo 'unco1: '.$uco1.'<br>';
//------------------------------------------------------------------------------------------------------------------------------------------------------