
<?php

session_start();


require_once ("connection_sql.php");
 

if ($_POST["Command"] == "sendreject") {
    try {
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $conn->beginTransaction();
        

        $sql = "UPDATE dag_item set reject='1'  where refno='" . $_POST['refno'] . "' and  serialno='".$_POST['serialno']."' and cancel='0'"; 
        $result = $conn->query($sql); 
        $sqllog = "insert into entry_log(refno, username, docname, trnType, stime, sdate) values ('" . trim($_POST['refno']) . "', '" . $_SESSION["CURRENT_USER"] . "', 'SEND RECEIVED LIST  TO REJECT', 'Save', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d") . "')";
            $resultlog = $conn->query($sqllog);
        $conn->commit();
        echo "SEND TO REJECT";

    } catch (Exception $e) {
        $conn->rollBack();
        echo $e;
    }
}