<!doctype html>
<html lang="en" dir="ltr">

<head>

    <!-- META DATA -->
    <meta charset="UTF-8">
    <meta name='viewport' content='width=device-width, initial-scale=1.0, user-scalable=0'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="Payment slip confirm">
    <meta name="author" content="Payment slip confirm">
    <meta name="keywords" content="Payment slip confirm">

    <!-- FAVICON -->
    <link rel="shortcut icon" type="image/x-icon" href="assets/images/brand/favicon.ico" />

    <!-- TITLE -->
    <title>Payment slip confirm</title>

    <!-- BOOTSTRAP CSS -->
    <link id="style" href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    <!-- STYLE CSS -->
    <link href="assets/css/style.css" rel="stylesheet" />
    <link href="assets/css/dark-style.css" rel="stylesheet" />
    <link href="assets/css/transparent-style.css" rel="stylesheet">
    <link href="assets/css/skin-modes.css" rel="stylesheet" />

    <!--- FONT-ICONS CSS -->
    <link href="assets/css/icons.css" rel="stylesheet" />

    <!-- COLOR SKIN CSS -->
    <link id="theme" rel="stylesheet" type="text/css" media="all" href="assets/colors/color1.css" />


</head>

<body class="app sidebar-mini ltr light-mode">

    <!-- GLOBAL-LOADER -->
    <div id="global-loader">
        <img src="assets/images/loader.svg" class="loader-img" alt="Loader">
    </div>
    <!-- /GLOBAL-LOADER -->

    <!-- PAGE -->
    <div class="page">
        <div class="page-main">




            <!--app-content open-->
            <div class="main-content  mt-0">
                <div class="side-app">

                    <!-- CONTAINER -->
                    <div class="container">

                        <!-- PAGE-HEADER -->

                        <!-- PAGE-HEADER END -->

                        <!-- Row -->
                        <br>
                        <!-- End Row-->
                        <div class="row">
                            <input type="hidden" id="cback" value="<?php echo $_REQUEST['cback']; ?>">
                            <div class="col-md-12 col-xl-12">
                                <div class="card">
                                    <div class="card-header">
                                        <h3 class="card-title mb-0">ชำระค่าบริการ</h3>
                                        <div class="card-options">
                                            <button type="button" class="btn btn-success" onclick="call_back()">กลับไป หน้าหลัก</button>
                                        </div>
                                    </div>
                                    <div class="card-body pt-4">
                                        <div class="grid-margin">
                                            <div class="">
                                                <div class="panel panel-primary">

                                                    <div class="panel-body tabs-menu-body border-0 pt-0">
                                                        <div class="tab-content">
                                                            <div class="tab-pane active" id="tab5">
                                                                <div class="table-responsive">
                                                                    <table id="data-table" class="table table-bordered text-nowrap mb-0">
                                                                        <thead class="border-top">
                                                                            <tr>
                                                                                <th class="bg-transparent border-bottom-0" style="width: 5%;">No</th>
                                                                                <th class="bg-transparent border-bottom-0" style="text-align:center">User</th>
                                                                                <th class="bg-transparent border-bottom-0" style="text-align:center;width: 5%;">วันคงเหลือ</th>
                                                                                <th class="bg-transparent border-bottom-0" style="text-align:center">ประเภท</th>
                                                                                <th class="bg-transparent border-bottom-0" style="text-align:center">ค่าบริการ</th>

                                                                                <th class="bg-transparent border-bottom-0" style="text-align:center">กำหนดชำระรอบหน้า</th>
                                                                                <th class="bg-transparent border-bottom-0" style="text-align:center">ชำระล่าสุด</th>

                                                                               
                                                                            </tr>
                                                                        </thead>

                                                                        <tbody>
                                                                            <?php
                                                                            include 'function.php';
                                                                            include 'connect.php';
                                                                            $username = $_REQUEST['user'];
                                                                            $sql = $con->prepare('select a.*,b.dbuser,b.dbpass,b.ipaddress,c.img,c.bank_number from (sub a left outer join host b on a.host_id = b.id) left outer join bank c on a.bank_id=c.id where a.user = ?');
                                                                            $sql->execute(array($username));
                                                                            $row = 0;
                                                                            $select = 0;
                                                                            $amount = 0;
                                                                            foreach ($sql as $c) {
                                                                                $webtype = $c['type'];
                                                                                $ip = $c['ipaddress'];
                                                                                $dbuser = $c['dbuser'];
                                                                                $dbpass = $c['dbpass'];
                                                                                $tbuser = $c['tbuser'];
                                                                                $subdomain = $c['subdomain'];

                                                                                $con1 = new PDO('mysql:host=' . $c['ipaddress'] . '; dbname=' . $c['dbname'] . '; charset=utf8;', $c['dbuser'], $c['dbpass']);
                                                                                $sql1 = $con1->prepare('select * from ' . $c['tbuser'] . ' where priroot = (select id from ' . $c['tbuser'] . ' where Username=?) order by id');
                                                                                $sql1->execute(array($username));

                                                                                foreach ($sql1 as $c1) {
                                                                                    $priroot = $c1['priroot'];
                                                                                    $row++;
                                                                                    $timecycle = (strtotime($c1['timecycle']) - strtotime(date('Y-m-d'))) /  (60 * 60 * 24);

                                                                                    if ($c1['id'] == $c1['priroot']) {
                                                                                        $bank_id = $c['bank_id'];
                                                                                        $day_show = $timecycle;
                                                                                        $type = 'User หลัก';
                                                                                        if ($day_show < 1) $day_show = 0;
                                                                                    } else {
                                                                                        $type = 'ช่วยกรอก';
                                                                                    }

                                                                                    if ($timecycle < 1) {
                                                                                        $timecycle = 0;
                                                                                        $cyclecolor = 'color:red;';
                                                                                    } else {
                                                                                        $cyclecolor = 'color:blue;';
                                                                                    }



                                                                                    if (is_null($c1['date_pay'])) {
                                                                                        $t1 = '-';
                                                                                        $t2 = '-';
                                                                                    } else {
                                                                                        $t1 = date_th($c1['timecycle']);
                                                                                        $t2 = date_th(substr($c1['date_pay'], 0, 10)) . ' ' . substr($c1['date_pay'], 11, 8);
                                                                                    }

                                                                                    $sql3 = $con->prepare('delete from prepare_payment where userid=? and user=? and priroot=? and ip=? and status=? and isue_date < ?');
                                                                                    $sql3->execute(array($c1['id'], $c1['Username'], $c1['priroot'], $ip, 'รอชำระ',date('Y-m-d')));
                                                                                    
                                                                                    
                                                                                    $sql3 = $con->prepare('select userid,amount from prepare_payment where userid=? and user=? and priroot=? and ip=? and status=?');
                                                                                    $sql3->execute(array($c1['id'], $c1['Username'], $c1['priroot'], $ip, 'รอชำระ'));
                                                                                    $me = 0;
                                                                                    $tik = '';
                                                                                    foreach ($sql3 as $c3) {
                                                                                        $me = 1;
                                                                                    }
                                                                                    if ($me == 0) {
                                                                                        $tik = '';
                                                                                    } else {
                                                                                        $tik = 'checked';
                                                                                        $amount = $amount + $c3['amount'];
                                                                                        $select++;
                                                                                    }



                                                                                    if($c['type']==0)
                                                                                    {
                                                                            ?>
                                                                                    <tr class="border-bottom">
                                                                                        <td style="padding: 0px 0px 0px 5px;text-align:center">

                                                                                            <label class="custom-control custom-checkbox-md">
                                                                                                <input type="checkbox" class="custom-control-input" id="chk<?php echo $row; ?>" onchange="setamount(this.id,'<?php echo $row; ?>')" <?php echo $tik; ?>>
                                                                                                <span class="custom-control-label"></span>
                                                                                            </label>


                                                                                        </td>
                                                                                        <td style="padding: 5px 0px 0px 5px;font-weight: bold;"><?php echo $c1['Username']; ?>
                                                                                            <input type="hidden" id="userid<?php echo $row; ?>" value="<?php echo $c1['id']; ?>">
                                                                                            <input type="hidden" id="user<?php echo $row; ?>" value="<?php echo $c1['Username']; ?>">
                                                                                            <input type="hidden" id="type_pay<?php echo $row; ?>" value="<?php echo $c1['type_pay']; ?>">
                                                                                            <input type="hidden" id="timecycle<?php echo $row; ?>" value="<?php echo $c1['timecycle']; ?>">
                                                                                            <input type="hidden" id="priroot<?php echo $row; ?>" value="<?php echo $c1['priroot']; ?>">
                                                                                        </td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center;<?php echo $cyclecolor; ?>"><?php echo $timecycle; ?></td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo $type; ?></td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo number_format($c1['price']); ?><input type="hidden" id="price<?php echo $row; ?>" value="<?php echo $c1['price']; ?>"></td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo $t1; ?></td>

                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo $t2; ?>
                                                                                        </td>

                                                                                       
                                                                                    </tr>

                                                                            <?php
                                                                                    }else if($c['type']==1 && $c1['type']=='Main')
                                                                                    {
                                                                                        ?>
                                                                                        <tr class="border-bottom">
                                                                                        <td style="padding: 0px 0px 0px 5px;text-align:center">

                                                                                            <label class="custom-control custom-checkbox-md">
                                                                                                <input type="checkbox" class="custom-control-input" id="chk<?php echo $row; ?>" onchange="setamount(this.id,'<?php echo $row; ?>')" <?php echo $tik; ?>>
                                                                                                <span class="custom-control-label"></span>
                                                                                            </label>


                                                                                        </td>
                                                                                        <td style="padding: 5px 0px 0px 5px;font-weight: bold;"><?php echo $c1['Username']; ?>
                                                                                            <input type="hidden" id="userid<?php echo $row; ?>" value="<?php echo $c1['id']; ?>">
                                                                                            <input type="hidden" id="user<?php echo $row; ?>" value="<?php echo $c1['Username']; ?>">
                                                                                            <input type="hidden" id="type_pay<?php echo $row; ?>" value="<?php echo $c1['type_pay']; ?>">
                                                                                            <input type="hidden" id="timecycle<?php echo $row; ?>" value="<?php echo $c1['timecycle']; ?>">
                                                                                            <input type="hidden" id="priroot<?php echo $row; ?>" value="<?php echo $c1['priroot']; ?>">
                                                                                        </td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center;<?php echo $cyclecolor; ?>"><?php echo $timecycle; ?></td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo 'แพคเกจ ' . $c1['agent'] . ' เครื่อง'; ?></td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo number_format($c1['price']); ?><input type="hidden" id="price<?php echo $row; ?>" value="<?php echo $c1['price']; ?>"></td>
                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo $t1; ?></td>

                                                                                        <td style="padding: 5px 0px 0px 5px;text-align:center"><?php echo $t2; ?>
                                                                                        </td>

                                                                                       
                                                                                    </tr>
                                                                                        <?php
                                                                                    }
                                                                                }
                                                                            }
                                                                            ?>


                                                                        </tbody>
                                                                    </table>
                                                                    <br>
                                                                    <input type="hidden" id="ip" value="<?php echo $ip; ?>">
                                                                    <input type="hidden" id="select" value="<?php echo $select; ?>">
                                                                    <input type="hidden" id="dbuser" value="<?php echo $dbuser; ?>">
                                                                    <input type="hidden" id="dbpass" value="<?php echo $dbpass; ?>">
                                                                    

                                                                    <input type="hidden" id="tbuser" value="<?php echo $tbuser; ?>">
                                                                    <div style="text-align:center">
                                                                        <input type="hidden" id="txtamountpay" value="<?php echo $amount; ?>">


                                                                        <h3>ยอดที่ต้องชำระ <span style="font-size:30px;color:red" id="amountpay"><?php echo number_format($amount); ?></span> บาท </h3>



                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="row">


                                                                <div class="col-md-3 col-xl-3"></div>
                                                                <div class="col-md-6 col-xl-6" id="bank">



                                                                    <div class=" card-body">

                                                                        <div class="row mb-2">
                                                                            <div style="text-align:center">
                                                                                <img id="imgbank" src="<?php echo $c['img']; ?>" alt="ttb.jpg" style="width: 100%;height:auto;max-width: 400px;">

                                                                            </div>
                                                                            <input type="hidden" id="bank_number" name="bank_number" value="<?php echo $c['bank_number']; ?>">

                                                                        </div>
                                                                        <div style="text-align:center">
                                                                            <button class="btn btn-success md-4" id="btncopy" onclick="copynumber()">คัดลอกเลขบัญชี</button>
                                                                        </div>
                                                                        <br>







                                                                    </div>

                                                                </div>
                                                            </div>
                                                            <div class="row">


                                                                <div class="col-md-3 col-xl-3"></div>
                                                                <div class="col-md-6 col-xl-6" id="upslip">
                                                                    <br>
                                                                    <form id="uploadimage" action="" method="POST" enctype="multipart/form-data">



                                                                        <div class="row mb-2">


                                                                            <div class="col-lg-12 col-sm-12 mb-4 mb-lg-0">
                                                                                <input id="fileuploadInput" type="file" name="file" class="dropify" data-bs-height="180" accept=".png, .jpg, .jpeg" required />

                                                                            </div>
                                                                            <input type="hidden" id="bank_id" name="bank_id" value="<?php echo $c['bank_id']; ?>">
                                                                            <input type="hidden" id="username" name="username" value="<?php echo $username; ?>">
                                                                            <input type="hidden" id="totalamountpay" name="totalamountpay" value="<?php echo $amount; ?>">

                                                                            <input type="hidden" id="subdomain" name="subdomain" value="<?php echo $subdomain; ?>">


                                                                            <input type="hidden" id="priroot" name="priroot" value="<?php echo  $priroot; ?>">
                                                                            <input type="hidden" id="webtype" name="webtype" value="<?php echo  $webtype; ?>">

                                                                        </div>
                                                                        <div style="text-align:center">
                                                                            <button type="submit" class="btn btn-primary" id="btn_save">ตรวจสอบสลิปโอนเงิน</button>
                                                                        </div>
                                                                        <br>
                                                                    </form>

                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>






                        </div>
                        <!-- Row -->

                        <!-- /Row -->
                    </div>
                    <!-- CONTAINER CLOSED -->

                </div>
            </div>
            <!--app-content closed-->
        </div>

        <!-- Sidebar-right -->

        <!--/Sidebar-right-->

        <!-- Country-selector modal-->

        <!-- Country-selector modal-->

        <!-- FOOTER -->
        <footer class="footer">
            <div class="container">
                <div class="row align-items-center flex-row-reverse">
                    <div class="col-md-12 col-sm-12 text-center">
                        Copyright © <span><?php echo date('Y'); ?></span> <a href="javascript:void(0)">Payment</a> slip confirm All rights reserved.
                    </div>
                </div>
            </div>
        </footer>
        <!-- FOOTER END -->
    </div>

    <!-- BACK-TO-TOP -->
    <a href="#top" id="back-to-top"><i class="fa fa-angle-up"></i></a>



    <!-- JQUERY JS -->
    <script src="assets/js/jquery.min.js"></script>

    <!-- BOOTSTRAP JS -->
    <script src="assets/plugins/bootstrap/js/popper.min.js"></script>
    <script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>

    <!-- INPUT MASK JS-->
    <script src="assets/plugins/input-mask/jquery.mask.min.js"></script>

    <!-- SIDE-MENU JS-->
    <script src="assets/plugins/sidemenu/sidemenu.js"></script>

    <!-- TypeHead js -->
    <script src="assets/plugins/bootstrap5-typehead/autocomplete.js"></script>
    <script src="assets/js/typehead.js"></script>

    <!-- SIDEBAR JS -->
    <script src="assets/plugins/sidebar/sidebar.js"></script>

    <!-- Perfect SCROLLBAR JS-->
    <script src="assets/plugins/p-scroll/perfect-scrollbar.js"></script>
    <script src="assets/plugins/p-scroll/pscroll.js"></script>
    <script src="assets/plugins/p-scroll/pscroll-1.js"></script>

    <!-- FILE UPLOADES JS -->
    <script src="assets/plugins/fileuploads/js/fileupload.js"></script>
    <!-- <script src="assets/plugins/fileuploads/js/file-upload.js"></script> -->

    <!-- INTERNAL Bootstrap-Datepicker js-->
    <script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>

    <!-- INTERNAL File-Uploads Js-->
    <script src="assets/plugins/fancyuploder/jquery.ui.widget.js"></script>
    <script src="assets/plugins/fancyuploder/jquery.fileupload.js"></script>
    <script src="assets/plugins/fancyuploder/jquery.iframe-transport.js"></script>
    <script src="assets/plugins/fancyuploder/jquery.fancy-fileupload.js"></script>
    <script src="assets/plugins/fancyuploder/fancy-uploader.js"></script>

    <!-- SELECT2 JS -->
    <script src="assets/plugins/select2/select2.full.min.js"></script>
    <script src="assets/js/select2.js"></script>

    <!-- BOOTSTRAP-DATERANGEPICKER JS -->
    <script src="assets/plugins/bootstrap-daterangepicker/moment.min.js"></script>
    <script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>

    <!-- INTERNAL Bootstrap-Datepicker js-->
    <script src="assets/plugins/bootstrap-datepicker/bootstrap-datepicker.js"></script>

    <script src="assets/plugins/sweet-alert/sweetalert.min.js"></script>
    <script src="assets/js/sweet-alert.js"></script>


    <!-- INTERNAL Sumoselect js-->
    <script src="assets/plugins/sumoselect/jquery.sumoselect.js"></script>

    <!-- TIMEPICKER JS -->
    <script src="assets/plugins/time-picker/jquery.timepicker.js"></script>
    <script src="assets/plugins/time-picker/toggles.min.js"></script>

    <!-- INTERNAL intlTelInput js-->
    <script src="assets/plugins/intl-tel-input-master/intlTelInput.js"></script>
    <script src="assets/plugins/intl-tel-input-master/country-select.js"></script>
    <script src="assets/plugins/intl-tel-input-master/utils.js"></script>

    <!-- INTERNAL jquery transfer js-->
    <script src="assets/plugins/jQuerytransfer/jquery.transfer.js"></script>

    <!-- INTERNAL multi js-->
    <script src="assets/plugins/multi/multi.min.js"></script>

    <!-- DATEPICKER JS -->
    <script src="assets/plugins/date-picker/date-picker.js"></script>
    <script src="assets/plugins/date-picker/jquery-ui.js"></script>
    <script src="assets/plugins/input-mask/jquery.maskedinput.js"></script>

    <!-- COLOR PICKER JS -->
    <script src="assets/plugins/pickr-master/pickr.es5.min.js"></script>
    <script src="assets/js/picker.js"></script>

    <!-- MULTI SELECT JS-->
    <script src="assets/plugins/multipleselect/multiple-select.js"></script>
    <script src="assets/plugins/multipleselect/multi-select.js"></script>

    <!-- FORMELEMENTS JS -->
    <script src="assets/js/formelementadvnced.js"></script>
    <script src="assets/js/form-elements.js"></script>

    <!-- Color Theme js -->
    <script src="assets/js/themeColors.js"></script>

    <!-- Sticky js -->
    <script src="assets/js/sticky.js"></script>

    <!-- CUSTOM JS -->
    <script src="assets/js/custom.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gasparesganga-jquery-loading-overlay@2.1.7/dist/loadingoverlay.min.js"></script>



</body>

</html>

<script>
    $(document).ready(function() {
        let total = Number(document.getElementById('txtamountpay').value)
        if (total > 0) {
            document.getElementById("bank").style.display = ""
            document.getElementById("upslip").style.display = ""
        } else {
            document.getElementById("bank").style.display = "none"
            document.getElementById("upslip").style.display = "none"

        }
    })
    $('.dropify').dropify({
        messages: {
            'default': 'คลิ๊กแนบสลิปโอนเงิน เพื่อตรวจสอบอัตโนมัติ',
            'replace': 'คลิ๊กเพื่อเปลี่ยนสลิปใหม่',
            'remove': 'ลบ',
            'error': 'Ooops, something wrong appended.'
        },
        error: {
            'fileSize': 'The file size is too big (2M max).'
        }
    });

    function setamount(id, row) {
        let amount = Number(document.getElementById('price' + row).value)
        let total = Number(document.getElementById('txtamountpay').value)
        let ip = document.getElementById('ip').value
        let dbuser = document.getElementById('dbuser').value
        let dbpass = document.getElementById('dbpass').value
        var userid = document.getElementById('userid' + row).value
        var user = document.getElementById('user' + row).value
        var tbuser = document.getElementById('tbuser').value
        var type_pay = document.getElementById('type_pay' + row).value
        var timecycle = document.getElementById('timecycle' + row).value
        var priroot = document.getElementById('priroot' + row).value
        var subdomain = document.getElementById('subdomain').value
        var select = Number(document.getElementById('select').value)
        if (document.getElementById(id).checked == true) {
            document.getElementById("bank").style.display = ""
            document.getElementById("upslip").style.display = ""
            select = select + 1
            total = total + amount
            $.ajax({
                method: "post",
                url: 'config.php',
                data: {
                    setprepare: 'ok',
                    ip: ip,
                    dbuser: dbuser,
                    dbpass: dbpass,
                    userid: userid,
                    user: user,
                    amount: amount,
                    tbuser: tbuser,
                    type_pay: type_pay,
                    timecycle: timecycle,
                    priroot: priroot,
                    subdomain: subdomain
                },
                success: function(val) {


                },
                error: function(er) {

                }
            })
        } else {
            document.getElementById("bank").style.display = "none"
            document.getElementById("upslip").style.display = "none"
            select = select - 1
            total = total - amount
            $.ajax({
                method: "post",
                url: 'config.php',
                data: {
                    setprepare_del: 'ok',
                    ip: ip,
                    dbuser: dbuser,
                    dbpass: dbpass,
                    userid: userid,
                    user: user,
                    amount: amount,
                    tbuser: tbuser,
                    type_pay: type_pay,
                    timecycle: timecycle,
                    priroot: priroot
                },
                success: function(val) {

                },
                error: function(er) {

                }
            })
        }

        document.getElementById('select').value = select
        if (select < 1) {
            total = 0
        }else{
          if (total < 1) {
                document.getElementById(id).checked = false
                document.getElementById("bank").style.display = "none"
                document.getElementById("upslip").style.display = "none"
                swal({
                    title: 'กรุณาติดต่อแอดมิน',
                    text: 'ไม่พบยอดชำระ ',
                    type: 'error',
                    allowOutsideClick: false,
                });

            }
        }
        document.getElementById('txtamountpay').value = total
        document.getElementById('totalamountpay').value = total
        document.getElementById('amountpay').innerHTML = new Intl.NumberFormat("en-US").format(total.toFixed());
    }

    function copynumber() {

        var copyText = document.getElementById("bank_number");

        copyText.setAttribute('type', 'text');

        copyText.select();
        copyText.setSelectionRange(0, 99999); // For mobile devices
        document.execCommand("copy");

        copyText.setAttribute('type', 'hidden');

        swal({
            title: 'คัดลอก สำเร็จ',
            text: 'หมายเลขบัญชี ' + copyText.value,
            type: 'success',
            allowOutsideClick: false,
        });

    }

    $("#uploadimage").on('submit', (function(e) {
        e.preventDefault();
        /// loading();
         $.LoadingOverlay("show");
        var form = $('#uploadimage')[0];

        // Create an FormData object 
        var data = new FormData(form);

        // If you want to add an extra field for the FormData
        data.append("CustomField", "This is some extra data, testing");




        $.ajax({
            type: "POST",
            enctype: 'multipart/form-data',
            url: "slip_check.php",
            data: data,
            processData: false,
            contentType: false,
            cache: false,
            timeout: 800000,
            success: function(val) {
                console.log(val)
                var obj = JSON.parse(val)
                console.log(obj)
                 $.LoadingOverlay("hide");
                if (obj.status == 0) {

                    swal({
                        title: 'สลิปไม่ถูกต้อง',
                        text: 'ต้องโอนชำระตามเลขบัญชีที่กำหนดเท่านั้น',
                        type: 'error',
                        button: "OK",
                        allowOutsideClick: false,
                    })


                } else if (obj.status == 1) {
                    // 
                    swal({
                        title: 'สำเร็จ',
                        text: 'การชำระค่าบริการสำเร็จเรียบร้อย',
                        type: 'success',
                        button: "OK",
                        allowOutsideClick: false,
                    }, function() {
                        window.location.href = document.getElementById('cback').value;

                    })



                } else if (obj.status == 2) {

                    swal({
                        title: 'ไม่สำเร็จ',
                        text: 'ยอดเงินชำระเข้ามาไม่ถูกต้อง',
                        type: 'error',
                        button: "OK",
                        allowOutsideClick: false,
                    })
                } else if (obj.status == 3) {

                    swal({
                        title: 'สลิปนี้ถูกใช้งานไปแล้ว',
                        text: 'สลิปซ้ำ',
                        type: 'error',
                        button: "OK",
                        allowOutsideClick: false,
                    })
                } else if (obj.status == 4) {
                    swal({
                        title: 'ตรวจสอบสลิปนี้ไม่ได้ ',
                        text: 'ถ้าเป็นสลิปธนาคารกรุงเทพ' + "\n" + 'ให้แนบใหม่อีกครั้งหลังจาก 1-5 นาที',
                        type: 'error',
                        button: "OK",
                        allowOutsideClick: false,
                    })
                } else if (obj.status == 5) {
                    swal({
                        title: 'ไม่สำเร็จ',
                        text: 'สลิปเก่าเกิน 1 วัน ไม่สามารถตรวจสอบได้',
                        type: 'error',
                        button: "OK",
                        allowOutsideClick: false,
                    })
                }
            },
            error: function(e) {



            }
        });



    }));
    
     function call_back()
    {
        window.location.href = document.getElementById('cback').value;
    }
</script>