<?php
    // $ct_no = "2511630060";
    $ct_no = $_GET['ct_no'];
?>

<title>ชำระด้วย BARCODE</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>
        <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style media="screen">
    body{
        font-family:"Angsana New";
        font-size:5px;
        background-image: url("img/xBG01.jpg");
        background-repeat: no-repeat;
        background-size: 210%;
    }
</style>
<style>
    .buttonx {
        /* background-color: yellow; /* Green */
        border: none;
        color: black;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        /* font-size: 15px; */
        margin: 4px 2px;
        cursor: pointer;
    }
    .button1 {padding: 10px 24px;}
    .button2 {padding: 12px 28px;}
    .button3 {padding: 14px 40px;}
    .button4 {padding: 32px 16px;}
    .button5 {padding: 5px;}
</style>
</head>
<body>
<center>
<b>ชำระเงินผ่าน BARCODE</b>

</center>
<div id="overlay" onclick="off()"></div>
    <input type="text" id="tbsearch" class="form-control" style="width: %;" value="<?php echo $ct_no; ?>"> <br>
    <input type="button" id="btsearch" value="ค้นหา" class="buttonx button5" style="background-color: Gold;" onclick="setTimeout(getbarcode, 2000); on();">
<div id="searchresult" align="center"></div>

</body>


<script>
function on() {
  document.getElementById("overlay").style.display = "block";
}

function off() {
  document.getElementById("overlay").style.display = "none";
}
</script>
<script type="text/javascript">
    function getbarcode(){
            if(document.getElementById('tbsearch').value==""){
                return;
            }
            $.ajax({
                url:"https://barcode.ezmember.org/getpsdata.php"                
                ,Accept : "application/json; charset=utf-8"
                ,type:"POST"
                ,data:"text="+document.getElementById('tbsearch').value
            ,success : function(obj){
                // var obj = jQuery.parseJSON(result);
                console.log(obj);
				off();
                if(obj.status=="ไม่พบ"){
                    $('#searchresult').html("ไม่พบลูกค้า");
                }else if(obj.status=="โปรดระบุชื่อ-นามสกุล ให้ถูกต้อง"){
                    $('#searchresult').html("โปรดระบุชื่อ-นามสกุล ให้ถูกต้อง");
                }else{
                    var str="";
                    for(var i=0;i<obj.datalist.length;i++){
                        str+="เลขที่อ้างอิง "+obj.datalist[i].ct_no+"<br>";
                        str+="ชื่อ "+obj.datalist[i].ps_name+"<br>";
                        str+="สินค้า "+obj.datalist[i].product_name+"<br>";
                        str+="<b><h3><font color='red'>ค่างวด "+parseInt(obj.datalist[i].due_amnt)+" บาท</font></h3><b><hr><br>";
                        str+="<img src='genbarcode.php?cnsvref="+obj.datalist[i].cnsvrefcode+"' style='border:5px solid white; width:80%;'><br>";
                        str+="|346200003800 "+obj.datalist[i].cnsvrefcode+" 0<br>";

                    }
                    $('#searchresult').html(str);
                }
				}
            });
        };
</script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/lightbox-plus-jquery.min.js"></script>
</html>
