<!DOCTYPE html>
<?php include '../config/_globle.php'; ?>
<html>
<head>
    <meta charset="utf-8">
    <link rel="shortcut icon" type="image/x-icon" href="<?=$app_url;?>img/logo_sm.png" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>SPEED LINK</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style type="text/css">
        @media print {
            table { page-break-inside:auto }
            tr { page-break-inside:avoid; page-break-after:auto }
            thead { display:table-header-group;}
            tfoot { display:table-footer-group }
        }

        @page {
            size: auto;
            margin: 0;
        }

        html, body {
            width: 183mm !important;
            height: 127mm !important;
            margin-left: 25px;
            margin-top: 5px;
        }

        body {
            width: 100%;
            height: 100%;
            font-size: 14px;
            font-family: 'Century Gothic';
            font-weight: bold;
        }

        header {
            text-align: center;
            padding: 10px;
        }

        header h1 {
            margin: 0;
            font-size: 18px;
        }

        header p {
            margin: 5px 0 0;
            font-size: 12px;
        }

        header .myanmar-text {
            font-size: 14px;
            line-height: 1.2;
        }

        header .contact-info {
            font-size: 12px;
            margin-top: 5px;
        }

        #slip-container {
            width: 80%;
            margin: 20px auto;
            padding: 20px;
            border: 1px solid #000;
        }

        button {
            display: block;
            margin: 20px auto;
            padding: 10px;
            cursor: pointer;
        }

        pre {
            white-space: pre-wrap;
            font-size: 14px;
        }
    </style>
</head>

<body>
    <div class="wrapper">
        <section>
            <div class="col-xs-12" style="padding-left:0px; padding-right: 0px;">
                <center>
                    <h2 class="page-header" style="margin:0px;">
                        <header>
                            <h1>Speed Link Solutions</h1>
                            <p>09-407888894, 09-697888894, 09-798888780, 09-988418882</p>
                            <p class="myanmar-text">သစ္စာလမ်း (ကုတင်-၁၀၀ပြည်သူ့ဆေးရုံနောက်ကျောလမ်း၊ အောက်စီဂျင်စက်ရုံအနီး၊ ဟုမ္မလင်းမြို့။</p>
                            <p class="contact-info">Email: speedlink.hml@gmail.com | Facebook: SPEED LINK FTTH Homalin</p>
                        </header>
                    </h2>
                </center>
            </div>
            <div class="col-xs-12" style="padding-left:0px; padding-right: 0px;padding-top: 12px;color: black;padding-bottom: 9px;">
                <div class="col-xs-5" style="padding-right: 0px;padding-left: 25px;">
                    <div class="row">
                        <div class="col-xs-6" style="padding-top: 4px;">Date:</div><div class="col-xs-6" id="txtDate" style="padding-left:0; padding-top: 4px;font-size:13px;"><p style="border-bottom: 1px dashed #ed1c31;">-</p></div>
                    </div>
                </div>
                <div class="col-xs-2"></div>
                <div class="col-xs-5">
                    <div class="row">
                        <div class="col-xs-6" style="padding-top: 4px;">Invoice NO.:</div><div class="col-xs-6" id="txtInvoiceNo" style="padding-left:0; padding-top: 4px;font-size:13px;"><p style="border-bottom: 1px dashed #ed1c31;">-</p></div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12" style="padding-left:0px; padding-right: 0px;">
                <table class="table table-bordered" id="myTable" style="margin-bottom:0px;border: 1px solid #ddd">
                    <thead>
                        <tr style="background-color: #5d8af6;color: #fff;">
                            <th style="font-size: 14px;text-align: center;">No.</th>
                            <th style="font-size: 14px;text-align: center;">Internet Plan</th>
                            <th style="font-size: 14px;text-align: center;">Monthly Price</th>
                            <th style="font-size: 14px;text-align: center;">Month</th>
                            <th style="font-size: 14px;text-align: center;">Fee</th>
                            <th style="font-size: 14px;text-align: center;">Start Date</th>
                            <th style="font-size: 14px;text-align: center;">End Date</th>
                            <th style="font-size: 14px;text-align: center;">Amount</th>
                        </tr>
                    </thead>
                    <tbody id="tbody">
                    </tbody>
                </table>
            </div>
            <div class="col-xs-12" style="padding-left:0;padding-right:0;padding-bottom: 9px;padding-top: 15px;color: black;">
                <div class="row">
                    <div class="col-xs-5">    
                        <div class="row">
                            <div class="col-xs-6" style="text-align:right;">Customer ID: </div><span class="col-xs-6" id="txtCustomerID" style="text-align:right;padding-right:23px;"></span>
                        </div>
                        <div class="row">
                            <div class="col-xs-6" style="text-align:right;">Customer Name: </div><span class="col-xs-6" id="txtCustomerName" style="text-align:right;padding-right:23px;"></span>
                        </div>
                        <div class="row">
                            <div class="col-xs-6" style="text-align:right;">Phone: </div><span class="col-xs-6" id="txtPhone" style="text-align:right;padding-right:23px;"></span>
                        </div>
                        <div class="row">
                            <div class="col-xs-6" style="text-align:right;">Address: </div><span class="col-xs-6" id="txtAddress" style="text-align:right;padding-right:23px;"></span>
                        </div>
                    </div>
                    <div class="col-xs-7">    
                        <div class="row">
                            <div class="col-xs-9" style="text-align:right;">Total: </div><span class="col-xs-3" id="txtTotalAmount" style="text-align:right;padding-right:23px;"></span>
                        </div>
                        <div class="row">
                            <div class="col-xs-9" style="text-align:right;">Discount: </div><span class="col-xs-3" id="txtDiscount" style="text-align:right;padding-right:23px;"></span>
                        </div>
                        <div class="row">
                            <div class="col-xs-9" style="text-align:right;">Advance: </div><span class="col-xs-3" id="txtAdvance" style="text-align:right;padding-right:23px;"></span>
                        </div>
                        <div class="row">
                            <div class="col-xs-9" style="text-align:right;">Balance: </div><span class="col-xs-3" id="txtBalance" style="text-align:right;padding-right:23px;"></span>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-3"></div><span class="col-xs-6" id="txtInvoiceRemark" style="text-align:left;padding-top:20px; font-size:19px;"></span>
                </div>
            </div>
        </section>
    </div>
    <div style="page-break-before: always;"></div>
    <button id="print-btn">Print Slip</button>
    <script src="../plugins/jquery/jquery.min.js"></script>
    <script src="script.js"></script>
</body>
</html>

<script type="text/javascript">
    var APP_URL = '<?=$app_url;?>';
    var id = "<?=$id;?>";
    $(function(){
        // window.print();
        if(id){
            getOnePrint();
        }
    });

    function getOnePrint(){
        $("#myTable").find("tbody").find("tr").remove();
        $.ajax({
            url: APP_URL + "api/sales/get_one_row.php",
            type: "POST",
            data: JSON.stringify({ id: id  })
        }).done(function(data) {    
            $("#invoice_logo").attr("src", APP_URL + "api/city/upload/" + data.profile_picture);
            $("#txtCAddress").text(data.caddress);
            $("#txtDate").text(data.date);
            $("#txtInvoiceNo").text(data.invoice_no);
            $("#txtInvoiceRemark").text(data.invoice_remark);
            // getAllCustomer(data.customer_id,data.sales_no);
            
            // $.each(data, function(i, v) {
                $("#myTable").find("tbody")
                .append($('<tr>')
                    .append("<td style='text-align:right;'>" + 1 + "</td>")
                    .append("<td>" + data.package + "</td>")
                    .append("<td style='text-align:right;'>" + data.price + "</td>")
                    .append("<td style='text-align:right;'>" + data.months + "</td>")
                    .append("<td style='text-align:right;'>" + data.fee + "</td>")
                    .append("<td style='text-align:right;'>" + data.start_date + "</td>")
                    .append("<td style='text-align:right;'>" + data.end_date + "</td>")
                    .append("<td style='text-align:right;'>" + data.total_amount + "</td>")

                );
            // });  

            $("#txtCustomerName").text(data.name);
            $("#txtCustomerID").text(data.id_no);
            $("#txtPhone").text(data.phone);
            $("#txtAddress").text(data.address);

            $("#txtTotalAmount").text(data.total_amount);
            $("#txtDiscount").text(data.all_discount);
            $("#txtAdvance").text(data.payment);
            $("#txtBalance").text(data.balance);
            window.print();
        });
    }


</script>

