<style>
    .table thead tr th{
        border-top:2px solid #eee;
        border-bottom:2px solid #eee;
        background: #fcfcfc;
    }
    .table tfoot tr th{
        border-top:2px solid #eee;
        border-bottom:2px solid #eee;
        background: #fcfcfc;
    }
</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" >
                                <div class="col-md-6 hidden-print m-t-20">
                                    <form method="POST" action='<?php echo base_url(); ?>marketing-summary'>
                                        <input type="hidden" name="csrf_test_name" id="daily_sheet_csrf" value=""/>
                                        <div class="col-md-10">
                                            <input type="month" autocomplete="off" class="form-control inline m-r-5" name="calendar_date" id="datepicker-autoclose1">
                                        </div>
                                        <div class="col-md-2">
                                            <button type='submit' onclick="$('#daily_sheet_csrf').val($('#cook').val());" class="btn btn-pink btn-bordred waves-effect w-md waves-light m-b-5">Run</button>
                                        </div>
                                    </form>
                                </div>
                                <div class="col-md-6 hidden-print m-t-20">
<!--                                    <a class="btn btn-warning m-l-10" onclick="tableToExcel('sheet1', 'Marketing Summary Sheet')" style="float:right">Export to Excel</a>
                                    <a href="javascript:window.print()" class="btn btn-inverse waves-effect waves-light hidden-print pull-right" id="btnprint"><i class="fa fa-print"></i></a>-->
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                        <!-- end row -->

                        <div class="row">
                            <table class="table m-t-10"  id='sheet1'>
                                <tr>
                                        <td colspan="4"><strong>Marketing Summary Sheet <u> <?php echo isset($date) && !empty($date) ? date('M-Y', strtotime($date)) : date('M-Y'); ?></u></strong></td>
                                </tr>
                                <tr>
                                    <td colspan="3">
                                        <table class="table" border="1" id='datatable-buttons'>
                                            <thead>
                                                <tr>
                                                    <th>S.No</th>
                                                    <th>Staff Name</th>
                                                    <th>Account Payment</th>
                                                    <th>Service</th>
                                                    <th>Product</th>
                                                    <th>Grand Total</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                if(isset($invoices) && !empty($invoices)){
                                                    $count = 1;
                                                    $service_staff = "";
                                                    $product_staff = "";
                                                    $service_total = 0;
                                                    $product_total = 0;
                                                    $data = [];
                                                    $data2 = [];
                                                    
                                                    foreach ($invoices as $invoice) {
                                                        
                                                        ?>
                                                        <tr>
                                                            <td><?php echo $count++; ?></td>
                                                            <td>
                                                                <?php echo $invoice['staff_fullname']; ?>
                                                            </td>
                                                            <td>
                                                                <?php //echo number_format($invoice['service_price'], 2); ?>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <?php echo number_format($invoice['service_price'], 2); ?>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <?php echo number_format($invoice['product_price'], 2); ?>
                                                            </td>
                                                            
                                                            <td style="text-align: right;">
                                                                <?php echo number_format($invoice['service_price']+$invoice['product_price'], 2); ?>
                                                            </td>
                                                        </tr>
                                                        <?php
                                                        
                                                    }
                                                    
                                                   
                                                }else{
                                                ?>
                                                        <tr>
                                                            <td colspan="6">Data not found</td>
                                                        </tr>     
                                                <?php } ?>
                                            </tbody>
                                            <tfoot>

                                            </tfoot>
                                        </table>
                                    </td>
                                    <td>

                                    </td>
                                </tr>

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

<script>
    $(document).ready(function(){
        $('#datatable-buttons').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: "excel",
                    className: "btn-sm btn-warning btn-trans"
                }, {extend: "pdf", className: "btn-sm btn-purple btn-trans"}],
                <?php } else { ?>
                    dom: "frtlip",
                <?php } ?> 
            responsive: !0
        });
    });


</script>