<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><?php echo $title;?></h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <!-- /.box -->
                <div class="box box-primary">
                    <div class="box-body table-responsive">
                        <form name="get_data_search" action="<?php echo $form_action;?>" method="post" class="search_form validate_form">
                        <input type="hidden" name="hidden_id" class="hidden_id" value="<?php echo (!empty($hidden_id)) ? $hidden_id : '';?>" />
                            <div class="col-xs-12">
                                <div class="col-md-2">&nbsp;</div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label >Start Date</label>
                                        <div class="input-group">
                                            
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="start_date" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;" id="start_date" name="start_date" value="<?php echo (!empty($start_date)) ? $start_date : date('d-m-Y');?>" autocomplete="off" >
                                            
                                        </div>
                                    </div>
                                    
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label >End Date</label>
                                        <div class="input-group">
                                            
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="end_date" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;"  id="end_date" name="end_date" value="<?php echo (!empty($end_date)) ? $end_date : date('d-m-Y');?>" autocomplete="off" >
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">&nbsp;</div>
                            </div>
                            <div class="col-xs-12">
                                <div class="col-md-5">&nbsp;</div>
                                <div class="col-md-4">
                                    <input type="submit" value="Get Data" name="submit" class="btn btn-danger btn-sm" style="background-color: #e33739;
    border-color: #e33739;" />&nbsp;&nbsp;
                                
                                    <input type="submit" value="Print Data" name="submit" class="btn btn-primary btn-sm get_print_data"/>
                                </div>
                                <div class="col-md-2">&nbsp;</div>
                            </div>
                        
                    
                    <div class="col-xs-12" style="margin-bottom:4%;">
                       <div class="col-xs-12 blck" style="margin-bottom: -35px;">
                            <div class="sub-title" style="color:#0B45B3; background:#f3f3f3 !important;" ><h4><i class="fa fa-fire" style="font-size: 14px;"></i> Payment Types</h4><i class="ctrl opener opened fa fa-chevron-up" style="float: right; margin-top: -25px;"></i></div>
                            <div class="blck-content col-xs-12" style="border-bottom: 1px inset rgba(209, 216, 216, 0.6); background: rgba(3, 12, 11, 0.05); margin-top: -15px;">
                                <div id="grpChkBox">
                                    <?php foreach($types as $key=>$value) {?>
                                        <div class="col-md-2" style="margin: 1%;">
                                            <input type="hidden" name="payment_type[]" value="<?php echo str_replace(' ','_',$value->payment_name);?>" />
                                            
                                            <input type="checkbox" class="check" value="<?php echo $value->payment_name;?>" name="<?php echo str_replace(' ','_',$value->payment_name);?>" <?php echo ((!empty($pay_type)) && (in_array($value->payment_name,$pay_type))) ? 'checked' : '';?> />&nbsp;<?php echo $value->payment_name;?>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    </form>
                    </div>
                    
                    <div class="box-body table-responsive body_content">
                        <table class="table table-bordered table-striped data_table" id="someTable">
                            <thead>
                                <tr>
                                    <th>S.No</th>
                                    <!--<th>Cash Id</th>-->
                                    <th>Cash Date</th>
                                    <?php foreach($types as $key=>$value) {?>
                                        <th class="align-center <?php echo str_replace(' ','_',$value->payment_name);?>"><?php echo $value->payment_name;?></th>
                                    <?php } ?>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach($results as $k=>$row) { ?>
                                    <tr>
                                        <td><?php echo ++$k;?></td>
                                        <!--<td><?php echo $row->id;?></td>-->
                                        <td><?php echo date('d-m-Y',strtotime($row->created_on));?></td>
                                        <?php foreach($types as $key=>$value) {?>
                                            <?php $pay_details = $this->cash_log_report_model->get_pay_amount_by_type($row->pay_ref_type,$row->pay_ref_id,$start_date,$end_date);?>
                                                <td class="align-right <?php echo str_replace(' ','_',$value->payment_name);?>" >
                                                    <?php $paid_amt = 0;
                                                    foreach($pay_details as $i=>$pay) { 
                                                        if($value->id == $pay->pay_type_id) {  $paid_amt += $pay->pay_amount; }
                                                    } 
                                                    echo number_format($paid_amt,2,'.','');?>
                                                </td>
                                        <?php } ?>
                                    </tr>
                                <?php } ?>
                            </tbody>
                            <tfoot>
                            </tfoot>
                        </table>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->

<script type="text/javascript">
     $(document).ready(function() {
        $('.start_date').bootstrapMaterialDatePicker({ 
            time: false, 
            format: 'DD-MM-YYYY'
        }). on('change', function(e, date) {
            if($('.end_date').val() != '') {
                $('.end_date').val('');
                var cur_date = new Date(date);
                $('.end_date').val(getTwoDigits(cur_date.getDate()) + '-'+ getTwoDigits((cur_date.getMonth() + 1)) + '-'+ cur_date.getFullYear());
                change_todate(getTwoDigits(cur_date.getDate()) + '-'+ getTwoDigits((cur_date.getMonth() + 1)) + '-'+ cur_date.getFullYear());
            }
        });
        
        $('.end_date').bootstrapMaterialDatePicker({ 
            time: false, 
            format: 'DD-MM-YYYY'
        });
        
        var date = $('.start_date').val();
        change_todate(date);
        $('.dataTables_wrapper .pagination').delegate( 'li', 'click', function () {
            alert('sdfds');
        });
    });
   
    function change_todate(date) {
       $('.end_date').bootstrapMaterialDatePicker('setMinDate', date);
    }
    
    $(function () {
        var $chk = $("#grpChkBox input[type='checkbox']");
        var $tbl = $("#someTable");
        
        if($('.hidden_id').val() == '') {
            $("#grpChkBox > div:nth-child(-n+8) input[type='checkbox']").prop('checked', true);
        }
        
        $(".check").each(function() {
            if($(this).is(':checked')) {
                var colToShow = $("#someTable").find("." + $(this).attr("name"));
                $(colToShow).show();
            } else {
                var colToHide = $("#someTable").find("." + $(this).attr("name"));
                $(colToHide).hide();
            }
        });
        
        $chk.on('ifUnchecked', function(event){
            var colToHide = $tbl.find("." + $(this).attr("name"));
            $(colToHide).hide();
        });
        
        $chk.on('ifChecked', function(event){
            var colToShow = $tbl.find("." + $(this).attr("name"));
            $(colToShow).show();
        });
    });
     
    
</script>