
<style>

    .table tr .bifurcate >td{
        border-top:2px solid #808080;
    }
</style>
<div class="wrapper">
    <div class="container-full">
        <div class="row m-t-20">
            <div class="col-md-12">
                <div class="panel panel-default m-t-20">
                    <div class="panel-body">
                        <div class="row">
                            <div class="pull-left" >
                                <h3 class="logo invoice-logo"><?php
                                    if (isset($business)) {
                                        echo "<img src='" . base_url() . 'assets/images/business/' . $business[0]['business_logo'] . "' alt='" . $business[0]['business_name'] . "' class='img-responsive' />";
                                    } else {
                                        echo 'SkedWise';
                                    }
                                    ?></h3>
                            </div>
                            <div class="pull-right m-t-20" >   
                            <?php if(DOWNLOAD == true || $this->session->userdata('role') == 'Admin' || $this->session->userdata('role')=='Super User'){ ?>                            
                                <button onclick="tableToExcel('sheet1', 'customer_profile')" class="btn btn-warning pull-right btn-sm m-l-5">Export to Excel</button>
                            <?php } ?>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                        <!-- end row -->

                        <div class="row">
                            <h5>Customer Loyalty Points</h5>

                                        <table class="table table-bordered"  id='sheet1'>
                                            <thead>

                                                <tr>
                                                    <th>Name</th>
                                                    <th>Cell</th>
                                                    <th>Card</th>
                                                    <th>Address</th>
                                                    <th>Birthday</th>
                                                    <th>Anniversary</th>
                                                    <th>Points Earned</th>
                                                    <th>Points Used</th>
                                                    <th>Available Points</th>
                                                    <th>Alerts</th>
                                                    <th>Allergies</th>
                                                    <th>Invoices</th>
                                                    <th>Discount Given</th>
                                                    <th>Credit Given</th>

                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php foreach ($customers as $customer) { ?>

                                                    <tr> 
                                                        <td>
                                                            <a target="_blank" href="<?php echo base_url();?>customer_previous_visit/<?php echo $customer['id_customers'] ?>">
                                                            <?php echo $customer['customer_name']; ?>
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['customer_cell']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['card']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['customer_address']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['customer_birthday']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['customer_anniversary']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['earned']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['used']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['loyalty_points']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['customer_alert']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['customer_allergies']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['invoices']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['Discounts']; ?>
                                                        </td>
                                                        <td>
                                                            <?php echo $customer['balance']; ?>
                                                        </td>

                                                    </tr>

                                                <?php } ?>
                                            </tbody>

                                        </table>
                                    </td>
                              
                        </div>
                        <!-- end row -->
                    </div>
                </div>

                <script>
                    
                    $(document).ready(function(){
                        $('#sheet1').DataTable({
                            lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
                            stateSave: true, fixedHeader: {header: true},
                            <?php if(DOWNLOAD == true || $this->session->userdata('role') == 'Admin' || $this->session->userdata('role')=='Super User'){ ?>
                            dom: "Bfrtlip",
                            buttons: [{extend: "copy", className: "btn-sm btn-custom btn-trans"},
                                {extend: "csv", className: "btn-sm btn-pink btn-trans"},
                                {extend: "pdf", className: "btn-sm btn-purple btn-trans"},                    
                                {extend: "print", className: "btn-sm btn-warning btn-trans"}
                            ],
                            <?php } else { ?>
                                dom: "frtlip",
                            <?php } ?> 
                            responsive: 0,
                            ordering: true
                        });
                    });
                                            // var tableToExcel = (function () {
                                            
                                            // var uri = 'data:application/vnd.ms-excel;base64,'
                                            //         , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'
                                            //                             , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
                                            //                     , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
                                            //                     return function (table, name) {
                                            //                     if (!table.nodeType) table = document.getElementById(table)
                                            //                             var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
                                            //                     var link = document.createElement("a");
                                            //                     var d = new Date();
                                            //                     var datestring = ("0" + d.getDate()).slice( - 2) + "-" + ("0" + (d.getMonth() + 1)).slice( - 2) + "-" +
                                            //                             d.getFullYear() + " " + ("0" + d.getHours()).slice( - 2) + ":" + ("0" + d.getMinutes()).slice( - 2);
                                            //                     link.download = ctx.worksheet;
                                            //                     link.href = uri + base64(format(template, ctx));
                                            //                     link.click();
                                            //                     //window.location.href = uri + base64(format(template, ctx))
                                            //                     }
                                            //                     })()




                                            //                     $(document).ready(function() {
                                            //             $("#category_id").select2();
                                            //             $("#category").html($("#category_id option:selected").text());
                                                        
                                                        //        $('#datatable-buttons1').DataTable({
                                                        //            lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
                                                        //            stateSave: true,
                //            fixedHeader: {header: true},
                //            dom: "Bfrtlip",
                //                buttons: [{extend: "copy", className: "btn-sm btn-custom btn-trans"}, {extend: "csv", className: "btn-sm btn-pink btn-trans"}, {
                //                        extend: "excel",
                //                        className: "btn-sm btn-warning btn-trans"
                //                    }, {extend: "pdf", className: "btn-sm btn-purple btn-trans"}],
                //                responsive: !0
                //        });
        
                    // });     
                </script>