<?php

session_start();
date_default_timezone_set('Asia/Colombo');
header('Content-Type: text/xml');   
require_once('./connection_sql.php');
 

if ($_GET["Command"] == "save_inv") {

    $ResponseXML = "";
    $ResponseXML .= "<salesdetails>";
    try {
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $conn->beginTransaction();

        $sql = "select * from a_user_mast_acc where user_name ='" . $_GET['user_name'] . "'";
        $result = $conn->query($sql);
        if ($row = $result->fetch()) {
            

            
            $sql = "update a_user_mast_acc set user_pass='" . md5($_GET['user_pass']) . "',user_pass1='" . $_GET['user_pass'] . "' where user_name ='" . $_GET['user_name'] . "'";
            $conn->exec($sql);
            
            $sqllog = "insert into a_entry_log(refno, username, docname, trnType, stime, sdate,company) values 
            ('" . $_GET["user_name"] . "', '" . $_SESSION["CURRENT_USER"] . "', 'User Pass', 'Update', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d") . "','".$_SESSION['company']."')";
            $resultlog = $conn->query($sqllog);
 
            echo "Saved";
            $conn->commit();
             
        } else {
            echo "User Not Found";
        }
    } catch (Exception $e) {
        $conn->rollBack();
        echo $e;
    }
}
?>