<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];

$shift = $_REQUEST["shift"];
$vouchno = $_REQUEST["vouchno"];
$sale = $_REQUEST["sale"];
$prodcode = $_REQUEST["prodcode"];
$prodname = $_REQUEST["prodname"];
$vouchdt = $_REQUEST["vouchdt"];
$pumpno = $_REQUEST["pumpno"];
$rate = $_REQUEST["rate"];
$cost = $_REQUEST["cost"];
$srno = $_REQUEST["srno"];

mysqli_query($conn, "Delete from `save_stkread_temp` where vouchno = '$vouchno'  and prodcode='$prodcode'");
if ($sale > 0) {
    mysqli_query($conn, "INSERT INTO `save_stkread_temp`(`srl`, `vouchno`, `netsale`, `prodcode`, `prodname`, `mastrate`, `mastcost`, shift, vouchdt, pumpno)
                                    VALUES( '$srno', '$vouchno', '$sale', '$prodcode', '$prodname', '$rate', '$cost', '$shift', '$vouchdt', '$pumpno')") or die(mysqli_error($conn));
}
?>
