<style>
     tr.strikethrough > td {text-decoration:line-through !important; color:red;} 
      /* enable absolute positioning */
    .inner-addon { 
        position: relative; 
    }

    /* style icon */
    .inner-addon .glyphicon {
        position: absolute;
        padding: 10px;
        pointer-events: none;
    }

    /* align icon */
    .left-addon .glyphicon  { left:  0px;}
    .right-addon .glyphicon { right: 0px;}

    /* add padding  */
    .left-addon input  { padding-left:  30px; }
    .right-addon input { padding-right: 30px; }

    .loader {
        position: fixed;
        left: 0px;
        top: 0px;
        width: 100%;
        height: 100%;
        z-index: 9999;
        background: url('http://localhost/projects/salon-git/salons/assets/images/page-loader-1.gif') 50% 50% no-repeat ;
        display: none;
</style>
<div class="wrapper">
            <div class="container">
                <!-- Page-Title -->
                <div class="row">
                    <div class="col-sm-12">
                        <div class="btn-group pull-right m-t-15">
                            
                        </div>
                        <h4 class="page-title">Franchise Invoice Aging:</h4>
                    </div>
                </div>
                
                 <div class="row">
                    <div class="col-sm-12">
                        <div class="card-box table-responsive">
                            <h4 class="header-title m-t-0 m-b-30">Orders</h4>
                            <table id="tblfranchiseorders" class="table table-striped table-bordered dt-responsive nowrap">
                                <thead>
                                    <tr>
                                        <th>Franchise ID</th>
                                        <th>Franchise</th>
                                         <th>Product</th>
                                        <th>Order ID</th>
                                        <th>Invoice#</th>
                                        <th>Invoice Date</th>
                                       
                                        <th style="text-align: right">Days</th>
                                        <th style="text-align: right"> < 10</th>
                                        <th style="text-align: right">10-19</th>
                                        <th style="text-align: right">20-39</th>
                                        <th style="text-align: right">40-59</th>
                                        <th style="text-align: right">60-90</th>
                                        <th style="text-align: right"> > 90</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if(isset($orders)){ $total_rec=[]; $x=0; foreach($orders as $order){?>
                                    <tr>
                                        <td><?php echo $order['franchise_id'];?></td>
                                        <td><?php echo $order['franchise_name'].' ('.$order['franchise_order_extra'].')';?></td>
                                        <td><?php echo $order['product_name'];?></td>
                                        <td><?php echo $order['id_franchise_orders'];?></td>
                                        <td><?php echo $order['invoice_number'];?></td>
                                        <td><?php echo $order['invoice_date'];?></td>
                                        
                                        <td style="text-align: right"><?php echo $order['lapsed_days'];?></td>
                                        <?php if($order['lapsed_days']<10){ if(isset($total_rec[0])){ $total_rec[0]=$total_rec[0]+$order['invoice_total_receivable'];}else{$total_rec[0]=$order['invoice_total_receivable'];} ?>
                                        
                                        <td style="text-align: right"><?php echo number_format($order['invoice_total_receivable'],2);?></td>
                                        <?php } else {echo "<td></td>";}?>
                                        <?php if($order['lapsed_days']>=10 && $order['lapsed_days']<20){ if(isset($total_rec[1])){ $total_rec[1]=$total_rec[1]+$order['invoice_total_receivable'];}else{$total_rec[1]=$order['invoice_total_receivable'];} ?>
                                        <td style="text-align: right"><?php echo number_format($order['invoice_total_receivable'],2);?></td>
                                        <?php } else {echo "<td></td>";}?>
                                        <?php if($order['lapsed_days']>=20 && $order['lapsed_days']<40){ if(isset($total_rec[2])){ $total_rec[2]=$total_rec[2]+$order['invoice_total_receivable'];}else{$total_rec[2]=$order['invoice_total_receivable'];} ?>
                                        <td style="text-align: right"><?php echo number_format($order['invoice_total_receivable'],2);?></td>
                                        <?php } else {echo "<td></td>";}?>
                                        <?php if($order['lapsed_days']>=40 && $order['lapsed_days']<59){ if(isset($total_rec[3])){ $total_rec[3]=$total_rec[3]+$order['invoice_total_receivable'];}else{$total_rec[3]=$order['invoice_total_receivable'];} ?>
                                        <td style="text-align: right"><?php echo number_format($order['invoice_total_receivable'],2);?></td>
                                        <?php } else {echo "<td></td>";}?>
                                        <?php if($order['lapsed_days']>=60 && $order['lapsed_days']<90){ if(isset($total_rec[4])){ $total_rec[4]=$total_rec[4]+$order['invoice_total_receivable'];}else{$total_rec[4]=$order['invoice_total_receivable'];} ?>
                                        <td style="text-align: right"><?php echo number_format($order['invoice_total_receivable'],2);?></td>
                                        <?php } else {echo "<td></td>";}?>
                                        <?php if($order['lapsed_days']>=90 ){ if(isset($total_rec[5])){ $total_rec[5]=$total_rec[5]+$order['invoice_total_receivable'];}else{$total_rec[5]=$order['invoice_total_receivable'];} ?>
                                        <td style="text-align: right"><?php echo number_format($order['invoice_total_receivable'],2);?></td>
                                        <?php } else {echo "<td></td>";}?>
                                    </tr>
                                    <?php $x++;} }?>
                                    
                                </tbody>
                                <tfoot>
                                    <th colspan="7"></th>
                                    <th style="text-align: right"><?php if(isset($total_rec[0])){ echo number_format($total_rec[0],2);} ?></th>
                                    <th style="text-align: right"><?php if(isset($total_rec[1])){ echo number_format($total_rec[1],2); }?></th>
                                    <th style="text-align: right"><?php if(isset($total_rec[2])){ echo number_format($total_rec[2],2);} ?></th>
                                    <th style="text-align: right"><?php if(isset($total_rec[3])){ echo number_format($total_rec[3],2); }?></th>
                                    <th style="text-align: right"><?php if(isset($total_rec[4])){ echo number_format($total_rec[4],2);} ?></th>
                                    <th style="text-align: right"><?php if(isset($total_rec[5])){ echo number_format($total_rec[5],2);} ?></th>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                 </div>
                
            </div> <!-- End Container-->
            
<script>
    var startdate = '';
     var enddate = '';
     
    $(document).ready(function() {
        
        $("#selected_franchise").select2();
        
         $('#tblfranchiseorders').DataTable({
            lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
            stateSave: 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
        });
        
        
        $("#startdate").datepicker({autoclose:true, format:'yyyy-mm-dd'});
        $("#enddate").datepicker({autoclose:true, format:'yyyy-mm-dd'});


        
    });

</script>