<?php
    session_start();
    include '_connect.php';
    // include 'qrcode/qrlib.php';
    $ct_no = $_GET['ct_no'];
    $cnsvbarcode = $_GET['cnsvbarcode'];
    $cnsvrefcode = $_GET['cnsvrefcode'];
    $cnsvrefno = $_GET['cnsvrefno'];
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
	<head>
		<meta charset="utf-8">
		<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>
        <?php
            include 'css.php';
        ?>
        <style media="screen">
            body{
                /* font-family:"Angsana New"; */
                font-size:30px;
                background-image: url("img/xBG01.jpg");
                background-repeat: no-repeat;
                background-size: 210%;
            }
        </style>
	</head>
	<body>
        <center>
            <br>
            <h1>ชำระเงินผ่าน BARCODE</h1> <br>

            <table border="0" id="table_4" style='width: 100%'>
                <thead>
                    <tr></tr>
                </thead>
                <tbody style='text-align:center;'></tbody>
            </table>
        </center>
        
        <input type="text" value="" id="userId" hidden>
        <img src="" id="pictureUrl" alt="" hidden>
        <input type="text" value="" id="displayName" hidden>
        <input type="text" value="" id="statusMessage" hidden>

        <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
        <script charset="utf-8" src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
        <script src="_liffid.js"></script>	

        <?php 
            // include '_index_linejson_1.php' 
            echo '<script type="text/javascript">';
            echo "var ct_no = '$ct_no';"; // ส่งค่า $data จาก PHP ไปยังตัวแปร data ของ Javascript
            echo '</script>';
        ?>
        <script>
        // ส่งข้อมูล ผ่าน ajax
        $.ajax({
            url: '_index_linebarcodejson.php?ct_no='+ct_no,
            type: 'GET',
            dataType: 'JSON',
            // แสดงข้อมูล
            success: function(response){
                var len = response.length;
                for(var i=0; i<len; i++){
                var ct_no = response[i].ct_no;
                var ps_name = response[i].ps_name;
                var product_name = response[i].product_name;
                var due_amnt = response[i].due_amnt;

                var cnsvbarcode = response[i].cnsvbarcode;
                var cnsvrefcode = response[i].cnsvrefcode;
                var cnsvrefno = response[i].cnsvrefno;


                var tr_str = 
                    "<tr>" +
                        "<td>" + 
                        "ชื่อ-นามสกุล : " + ps_name + "<br>" +
                        "สินค้า : " + product_name + "<br>" +
                        "ค่าชำระ : " + due_amnt + "<br>" + "<hr>" + 
                        "<img src='https://ehongmd.com/genbarcode.php?cnsvref=" + cnsvrefcode +"' width='95%'><br>" +
                        cnsvbarcode +
                        "</td>" +
                    "</tr>";
                $("#table_4 tbody").append(tr_str);
                }
            } 
        });
        </script>

    </body>
</html>


