<script type="text/javascript">
    $(document).ready(function(){
        $(".DTTT").css('display','none');
        $(".dataTables_empty").attr("colspan","7");
    });
</script>
 <!-- Page Content -->
            <div class="page-content">
        
                <!-- Page Header -->
                <div class="page-header position-relative">
                     <div class="header-title">
                        <h1>
                          <?php echo $this->lang->line("PAYMENTS"); ?>
                        </h1>
                    </div>
                    <!--Header Buttons-->
                    <div class="header-buttons">
                        <a class="sidebar-toggler" href="#">
                            <i class="fa fa-arrows-h"></i>
                        </a>
                        <a class="refresh" id="refresh-toggler" href="">
                            <i class="glyphicon glyphicon-refresh"></i>
                        </a>
                        <a class="fullscreen" id="fullscreen-toggler" href="#">
                            <i class="glyphicon glyphicon-fullscreen"></i>
                        </a>
                    </div>
                    <!--Header Buttons End-->
                </div>
                <!-- /Page Header -->
                <!-- Page Body -->
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="widget">
                              
                                <div class="widget-body">
                                    <div class="table-toolbar">
                                        <div style="margin-bottom: 15px;">
                                            <span class="button-strip" style="float: left;">
                                                Group By: <select id="chngroup">
                                                  <option value="clear"><?php echo $this->lang->line("PLEASE")." ".$this->lang->line("SELECT"); ?></option>
                                                <option value="HOST"><?php echo $this->lang->line("HOST")." ".$this->lang->line("NAME"); ?></option>
                                                <option value="PAYMENT"><?php echo $this->lang->line("PAYMENT")." ".$this->lang->line("TYPE"); ?></option>
                                                <option value="ACCOUNT"><?php echo $this->lang->line("ACCOUNT"); ?></option>
                                                </select>
                                            </span>
                                            <div class="input-group" style="width: 175px;float: left;margin-left: 15px;">
                                                <input class="form-control date-picker" name="filter_begin" id="filter_begin"
                                                   type="text" placeholder="<?php echo $this->lang->line("FROM"); ?>"
                                                   data-date-format="yyyy-mm-dd" readonly value="<?php echo date("d-m-Y",strtotime("-1 month")); ?>" />
                                                <span class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </span>
                                            </div>
                                            <div class="input-group" style="width: 175px;padding-left: 15px;">
                                                <input class="form-control date-picker" name="filter_end" id="filter_end" type="text"
                                                    placeholder="<?php echo $this->lang->line("TO"); ?>"
                                                    data-date-format="yyyy-mm-dd" readonly value="<?php echo date("d-m-Y"); ?>" />
                                                    <span class="input-group-addon">
                                                        <i class="fa fa-calendar"></i>
                                                    </span>
                                            </div>
                                        </div>
                                   <div class="table-responsive">
                                 <table class="table table-striped table-hover table-bordered editable" id="paymentstable">
                                     <thead class="tabheadpayment">
                                           <tr role="row">
                                                <th style="width: 27px;">
                                                    <?php echo $this->lang->line("ID");?>
                                                </th>
                                                <th style="width: 139px;">
                                                     <?php echo $this->lang->line("PAYMENT")." ".$this->lang->line("DATE"); ?>
                                                </th>
                                                <th style="width: 27px;">
                                                    <?php echo $this->lang->line("ACCOUNTNAME");?>
                                                </th>
                                                <th style="width: 275px;">
                                                     <?php echo $this->lang->line("HOST");?>
                                                </th>
                                                <th style="width: 113px;">
                                                 <?php echo $this->lang->line("SEQUENCE");?>
                                                </th>
                                                   <th style="width: 100px;">
                                                <?php echo $this->lang->line("TYPE");?>
                                                </th>
                                                   <th style="width: 140px;">
                                                <?php echo $this->lang->line("NOTE");?>
                                                </th>
                                                <th style="width:150px;text-align: right;">
                                                <?php echo $this->lang->line("TOTAL");?>
                                                </th>
                                            </tr>
                                            </thead>
                                    </table>

                                  </div>
                                </div>
                            </div>
                        </div>
                    </div>
                   
                </div>

                
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
        </div>
        <!-- /Page Container -->
        <!-- Main Container -->

    </div>
    <script type="text/javascript">
        $( document ).ready(function() {
            settabledata();
            $('#filter_begin').datepicker().on('changeDate', function (ev) { 
                var chngroup = $('#chngroup').val();
                if(chngroup=='clear') {
                    settabledata();
                } else {
                    $('#chngroup').trigger( "change" );
                }
            });
            $('#filter_end').datepicker().on('changeDate', function (ev) { 
                var chngroup = $('#chngroup').val();
                if(chngroup=='clear') {
                    settabledata();
                } else {
                    $('#chngroup').trigger( "change" );
                }
            });
        });
        function settabledata() {
            var fromdate = $('#filter_begin').val();
            var todate = $('#filter_end').val();
            $('#paymentstable').DataTable().destroy();
            var table = $('#paymentstable').DataTable( {
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": base_url+"payment/payments/getpayments?fromdate="+fromdate+"&todate="+todate,
                "aLengthMenu": [[20, 50, 100], [20, 50, 100]],
                "columnDefs" : [
                ],
            });
        }
        
    </script>
