
<?php

session_start();


require_once ("connection_sql.php");
header('Content-Type: text/xml');
date_default_timezone_set('Asia/Colombo');
if ($_POST["Command"] == "upbattery") {
    try {
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $conn->beginTransaction();
        

        $sql = "UPDATE warrenty_details set status='YES'  where barcode='" . $_POST['id'] . "'"; 
        $result = $conn->query($sql); 
        
        $sqllog = "insert into entry_log(refno, username, docname, trnType, stime, sdate) values ('" . trim($_POST['id']) . "', '" . $_SESSION["CURRENT_USER"] . "', 'UPDATED', 'UPDATE', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d") . "')";
        $resultlog = $conn->query($sqllog);
        
        $conn->commit();
        echo "UPDATED";

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



?>