<script type="text/javascript">
    $(document).ready(function () {
<!-- page script -->
        $('.datatables').DataTable();
        $('.datetimepicker').datetimepicker({
            viewMode: 'months',
            format: 'DD-MM-YYYY'
        });

    });

    function conf_delete_user(me){
        confirmBox('delete_selected_user()', '<?php echo $this->lang->line('msgconfirm'); ?>');
    }

    function delete_selected_user(){
       $('#frm_submit_delete_user').submit();
    }

    function print_user_list(){
        var dateFrom = $("#dateFrom").val();
        var dateTo = $("#dateTo").val();
        window.location = "<?php echo base_url(); ?>admin/print_user/" + dateFrom + "/" + dateTo;
    }

    function select_or_unselect_all(me){
         var oTable = $("#datatable_userlist").dataTable();
        if($(me).is(":checked")){
            $(oTable.fnGetNodes()).find(':checkbox').prop('checked', true);
            $("#btn_delete_user").removeAttr("disabled");
        }else{
            $(oTable.fnGetNodes()).find(':checkbox').prop('checked', false);
            $("#btn_delete_user").attr("disabled","disabled");
        }
    }

    function enabled_or_disabled_delete_btn(me){
       if($(me).is(":checked")){
            $("#btn_delete_user").removeAttr("disabled");
        }else{
            var oTable = $("#datatable_userlist").dataTable();
            $(oTable.fnGetNodes()).find('input[type=checkbox] :checked');
            var notfind = true;
            $(oTable.fnGetNodes()).find(':checkbox:checked').each(function(){
                $("#btn_delete_user").removeAttr("disabled");
                notfind = false;
               return true;
            });
            if(notfind){
                 $("#btn_delete_user").attr("disabled","disabled");
            }

        }
    }

</script>
<style>

</style>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            <?php echo $this->lang->line('module'); ?>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-home"></i><?php echo $this->lang->line('home'); ?></a></li>
            <li><a href="#"> <?php echo $this->lang->line('module'); ?></a></li>
            <li class="active"><?php echo $this->lang->line('titlelist2'); ?></li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <!-- Horizontal Form -->

                <!-- general form elements disabled -->
                <div class="box box-primary">
                    <div class="box-header with-border ">
                        <h3  class="box-title">
                            <h3 class="pull-left"><?php echo $this->lang->line('titlelist2'); ?></h3>
                            <div style="margin-top:10px;" class="pull-right">
                            <a href="<?php echo base_url() ?>admin/addNewUser" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon glyphicon-plus"></span></a>
                            <button id="btn_delete_user" disabled="disabled" onclick="conf_delete_user(this)" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon glyphicon-minus"></span></button>
                            <!--<button onclick="print_user_list(this)" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon glyphicon-print"></span></button>-->
                            </div>
                        </h3>
                    </div><!-- /.box-header -->
                    <div class="box-body">
                        <form id="frm_submit_delete_user" method="post" action="<?php echo base_url(); ?>admin/delete_user">
                        <table id="datatable_userlist" class="table table-bordered table-striped datatables">
                            <thead>
                                <tr>
                                    <th class="text-left"><?php echo $this->lang->line('no'); ?></th>
                                    <th class="text-left"><?php echo $this->lang->line('userid'); ?></th>
                                    <th><?php echo $this->lang->line('username'); ?></th>
                                    <th class="text-left"><?php echo $this->lang->line('email'); ?></th>
                                    <th class="text-left"><?php echo $this->lang->line('paymentBy'); ?></th>
                                    <th class="text-left"><?php echo $this->lang->line('startDate'); ?></th>
                                    <th class="text-left"><?php echo $this->lang->line('endDate'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if($user_company){
                                    $i = 1;
                                    foreach ($user_company as $row){
                                ?>
                                <tr>
                                    <td class="text-center"><?php echo $i++; ?></td>
                                    <td class="text-left"><a href="<?php echo base_url().'admin/renewUserLicense/'.$row->fldid; ?>"><?php echo $row->userid; ?></a></td>
                                    <td class="text-left"><?php echo $row->username; ?></td>
                                    <td class="text-left"><?php echo $row->email; ?></td>
                                    <td class="text-center"><?php if($row->typeOfPackage == 1){echo $this->lang->line('monthly');}else if($row->typeOfPackage == 2){echo $this->lang->line('yearly');} ?></td>
                                    <td class="text-center"><?php echo date("d-m-Y", strtotime($row->startDate)) ?></td>
                                	<td class="text-center"><?php echo date("d-m-Y", strtotime($row->endDate)) ?></td>
                                    
                                </tr>
                                <?php
                                    }
                                }
                                ?>


                            </tbody>
                        </table>
                        </form>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div>
        </div>


    </section><!-- /.content -->
</div><!-- /.content-wrapper -->
