<?php
include_once("../../../../lib/konfig.php");
include_once("../../../../lib/function.php");
session_start();
$kodebrg = $_POST['ID'];

$MySQLi = new MySQLi($strDBHostName, $strDBUsername, $strDBPassword, $strDBName);

$query = "UPDATE item SET stsAktif = 0, dtUpdate = NOW(), usrUpdate='" . $_SESSION['strEmail'] . "' WHERE ID = " . $kodebrg . ";";
$MySQLi->query($query);

if ($MySQLi->affected_rows == 1) {
    $strBuffer = str_replace("'", "`", str_replace('"', '`', $query));
    $query = "INSERT INTO tpc_log 
            SET strPCHostname='" . gethostbyaddr(getIPv4()) . "', 
                strIPv4='" . getIPv4() . "', 
                strPort='" . $_SERVER['REMOTE_PORT'] . "', 
                strTable='item', 
                strQuery='" . $strBuffer . "', 
                strKeterangan='" . $_SESSION['strEmail'] . " menonaktifkan barang dengan no ID : " . $kodebrg . "', 
                dtCreate=NOW(), 
                usrCreate='" . $_SESSION['strEmail'] . "' 
            ";
    $MySQLi->query($query);
}

if ($MySQLi->affected_rows == 1) {
    echo "1";
} else {
    echo "0";
}
