<script type="text/javascript">
    $(document).ready(function() {
        drawtabledata();
        drawtabledata();
        $('#filter_begin').datepicker().on('changeDate', function (ev) { 
            drawtabledata();
        });
        $('#filter_end').datepicker().on('changeDate', function (ev) { 
            drawtabledata();
        });
    });
    function drawtabledata() {
        var filter_begin =  $("#filter_begin").val();
        var filter_end =  $("#filter_end").val();
        $('#recieptdatatable').DataTable().destroy();
        var table = $('#recieptdatatable').DataTable({
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "<?php echo base_url('sales/sales/getreceipts') ?>"+"?filter_begin="+filter_begin+"&filter_end="+filter_end,
            "lengthMenu": [[20, 50, 100], [20, 50, 100]],
            "language": {
                "lengthMenu": "<?php echo $this->lang->line("DISPLAY"); ?> _MENU_ <?php echo $this->lang->line("RECORDSPERPAGE"); ?>",
                "zeroRecords": "<?php echo $this->lang->line("NOTHINGFOUND"); ?>",
                "info": "<?php echo $this->lang->line("SHOWINGPAGE"); ?> _PAGE_ <?php echo $this->lang->line("OF"); ?> _PAGES_",
                "infoEmpty": "<?php echo $this->lang->line("NORECORDSAVAILABLE"); ?>",
                "infoFiltered": "(<?php echo $this->lang->line("FILTEREDFROM"); ?> _MAX_ <?php echo $this->lang->line("TOTALRECORDS"); ?>)",
                "search": "<?php echo $this->lang->line("SEARCH"); ?> : ",
                "paginate": {
                    "previous": "<?php echo $this->lang->line("PREVIOUS"); ?>",
                    "next":"<?php echo $this->lang->line("NEXT"); ?>"
                }
            },
            "columnDefs" : [
                {"targets": [ 7 ],"sortable" : false  ,"render": function ( data, type, row ) {
                    return '<a class="btn btn-yellow shiny btn-xs" href="'+base_url+'sales/sales/getreceiptlines/'+data+'/"><i class="fa fa-eye"></i></a>\n\
                        <a class="btn btn-danger shiny btn-xs" href="'+base_url+'sales/sales/printsr/'+data+'/" target="_blank">\n\
                            <i class="fa fa-file-pdf-o"></i></a>';
                }}
            ],
        });
    }
</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("RECIEPTS"); ?>
                        </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 id="myModal" class="modal fade" role="dialog">
                              <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
    <form action="<?php echo base_url();?>settings/users/addusers" method="post" id="userform">
      <div class="modal-body">
       <div class="row">
            <div class="col-md-12">
                <input type="hidden" id="id" name="id">
                <div class="form-group">
                    <input type="text" class="form-control" name="name" id="name" placeholder="<?php echo $this->lang->line("NAME"); ?>">
                </div>
                 <div class="form-group">
                    <input type="text" class="form-control" name="password" id="password" placeholder="<?php echo $this->lang->line("PASSWORD"); ?>">
                </div>
                 <div class="form-group">
                    <input type="text" class="form-control" name="c_password" id="c_password"
                           placeholder="<?php echo $this->lang->line("CONFIRM")." ".$this->lang->line("PASSWORD"); ?>">
                </div>
                   <div class="form-group">
                    <input type="text" class="form-control" name="card" id="card" placeholder="<?php echo $this->lang->line("CARD"); ?>">
                </div>
                 <div class="form-group">
                    <input type="text" class="form-control" name="role" id="role" placeholder="<?php echo $this->lang->line("ROLE"); ?>">
                </div>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="submit" class="btn btn-success"><?php echo $this->lang->line("SUBMIT"); ?></button>
        <button type="button" class="btn btn-danger" data-dismiss="modal"><?php echo $this->lang->line("CLOSE"); ?></button>
      </div>
  </form>
    </div>
</div>
</div>
                            
            <div style="margin-bottom: 15px;">
                <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="recieptdatatable">
                                        <thead>
                                            <tr role="row">
                                                <th style="width: 80px;">
                                                    <?php echo $this->lang->line("ID"); ?>
                                                </th>
                                                <th style="width: 110px;">
                                                    <?php echo $this->lang->line("DATE"); ?>
                                                </th>
                                                <th style="width: 100px;">
                                                    <?php echo $this->lang->line("RECEIPT"); ?>
                                                </th>
                                                <th style="width: 190px;">
                                                    <?php echo $this->lang->line("CUSTOMER"); ?>
                                                </th>
                                                <th style="width: 90px;">
                                                    <?php echo $this->lang->line("TOTAL"); ?>
                                                </th>
                                                <th style="width: 90px;">
                                                    <?php echo $this->lang->line("TAX"); ?>
                                                </th>
                                                <th style="width: 160px;">
                                                    <?php echo $this->lang->line("USER"); ?>
                                                </th>
                                                <th style="width: 90px;">
                                                    <?php echo $this->lang->line("ACTION"); ?>
                                                </th>
                                            </tr>
                                        </thead>
                                    </table>
                                 </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
        </div>
        <!-- /Page Container -->
        <!-- Main Container -->
    </div>