<?php
    include_once 'opendb.php';
    
    if (isset($_POST["Web_Entry_No"]) && isset($_POST["newStatus"]) & isset($_POST["DocType"]))
    {
        $Web_Entry_No=$_POST["Web_Entry_No"] ;
        $DocType=$_POST["DocType"] ;
        $newStatus=$_POST["newStatus"] ;
        if($DocType=="STI"){
            $tablename="stock_issue";
        }
        elseif ($DocType=="STR") {
            $tablename="stock_return";        
        }
        $sql = "update $tablename set  EXPORTED=$newStatus WHERE WebEntry_No = $Web_Entry_No;";
        if ($conn->query($sql) === TRUE)
        {
           $mess="OK";
        } else
        {
           $mess= "Error: " . $sql . "<br>" . $conn->error;
        } 
    }
    else
    {
        $mess= "Error : No parameters!";
    }
    echo $mess;
    $conn->close();
?>