<?php

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

$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');


mysqli_select_db($conn, $zdb);

$getsale = mysqli_query($conn, "SELECT * from product where barcode in (Select barcode from slonltran where vouchdt > '2022-05-31') order by code") or die(mysqli_error($conn));
while ($fsale = mysqli_fetch_array($getsale)) {

    $mrp = $fsale['mrp'];
    $barcode = $fsale['barcode'];


    mysqli_query($conn, "UPDATE `slonltran` SET `mrp`='$mrp' where `barcode` = '$barcode' and vouchdt > '2022-05-31'") or die(mysqli_error($conn));
    mysqli_query($conn, "UPDATE `transacn` SET `mrp`='$mrp' where `barcode` = '$barcode' and source = 'SLON' and vouchdt > '2022-05-31' ") or die(mysqli_error($conn));
}
browse("Sale completed successfully");

?>
