<div class="wrapper">
    <div class="container-full">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class=" pull-right m-t-15">                    
                </div>
                <h4 class="page-title">Head Office Dashboard</h4>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">       
                <div class="card-box ">
                    <div class="row">                        
                        <div class="col-md-6"></div>
                        <div class="col-md-6">
                            <form action='<?php echo base_url().'ho_dashboard';?>' method='post'>                               
                                <input type="hidden" name="csrf_test_name" id="booking_list_csrf" value=""/>
                                <div class="col-md-2">

                                    <input type="text" class="form-control inline datepicker-autoclose m-r-5"  placeholder="mm/dd/yyyy" name="start" id="start_date"  <?php if(isset($start)){echo "value=".$start;} ?> >

                                </div>
                                <div class="col-md-2">

                                    <input type="text" class="form-control inline datepicker-autoclose m-r-5"  placeholder="mm/dd/yyyy" name="end" id="end_date" <?php if(isset($end)){echo "value=".$end;} ?>>

                                </div>
                                <div class="col-md-2">
                                    <button type='submit'  onclick="$('#booking_list_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>                        
                </div>
            </div>         
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="card-box">
                    <table id='mtable' class="table table-responsive table-striped">
                        <thead>
                            <tr>
                                <th></th>
                                <th colspan="7" class="text-center">Income</th>
                                <th colspan="3" class="text-center">Collections</th>
                                <th colspan="3" class="text-center">Adjustments</th>
                                <th class="text-center">Receivables</th>
                                <th colspan="2" class="text-center">Payabales</th>
                            </tr>
                            <tr>
                                <th>Branch</th>
                                <th class="text-right">Service Income</tthr>
                                <th class="text-right ">Retail Income</th>
                                <th class="text-right">Training Income</th>
                                <th class="text-right text-success">Gross Income</th>
                                <th class="text-right text-danger">Discounts</th>
                                <th class="text-right">Rounding Adjustment</th>
                                <th class="text-right"><strong>Net Income</strong></th>
                                <th class="text-right"><strong>Cash</strong></th>
                                <th class="text-right"><strong>Card</strong></th>
                                <th class="text-right"><strong>Check</strong></th>
                                <th class="text-right"><strong>Voucher Used</strong></th>
                                <th class="text-right"><strong>Advance Adjusted</strong></th>
                                <th class="text-right"><strong>Advance Collected</strong></th>
                                <th class="text-right"><strong>Customer Balances</strong></th>
                                <th class="text-right"><strong>Sales Tax Payable</strong></th>
                                <th class="text-right"><strong>CC Fee Collected</strong></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach($details as $detail){?>
                                <tr>
                                    <td><?php echo $detail['business_name'];?>
                                    <td class="text-right"><?php echo $detail['Service Sale Income']; ?></td>
                                    <td class="text-right"><?php echo $detail['Retail Sale Income']; ?></td>
                                    <td class="text-right"><?php echo $detail['Training Sale Income']; ?></td>
                                    <td class="text-right text-success"><?php echo $detail['Gross Income']; ?></td>
                                    <td class="text-right text-danger"><?php echo $detail['Discount']; ?></td>
                                    <td class="text-right"><?php echo $detail['Rounding Adjustment']; ?></td>
                                    <td class="text-right"><strong><?php echo $detail['Net Income']; ?></strong></td>

                                    <td class="text-right"><?php echo $detail['Cash']; ?></td>
                                    <td class="text-right"><?php echo $detail['Card']; ?></td>
                                    <td class="text-right"><?php echo $detail['Check']; ?></td>
                                    <td class="text-right"><?php echo $detail['Voucher Used']; ?></td>
                                    <td class="text-right"><?php echo $detail['Advance Adjusted']; ?></td>
                                    <td class="text-right"><?php echo $detail['Advance Collected']; ?></td>
                                    <td class="text-right"><?php echo $detail['Receivable']; ?></td>
                                    <td class="text-right"><?php echo $detail['Sales Tax Collected']; ?></td>
                                    <td class="text-right"><?php echo $detail['CC Fee']; ?></td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>

<script>

$(document).ready(function() {

    $('#start_date').datepicker({
        autoclose: true,
        todayHighlight: true,
        
        format: 'yyyy/mm/dd'
    });
    $('#end_date').datepicker({
        autoclose: true,
        todayHighlight: true,

        format: 'yyyy/mm/dd'
    });   

        
    $('#mtable').DataTable({
        lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
        stateSave: 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>