
<?php $this->load->view('site/layout'); ?>
<link href="<?php echo base_url() ?>public/css/style.bundle_front.css"
      rel="stylesheet" type="text/css" />
      <?php $this->load->view('site/navbar'); ?>
<style>
    .alert.alert-elevate{
        margin-bottom: 0px !important;
    }
    .rtl .dataTables_filter{
        float: right
    }
    .float-left{
        float: left !important;
    }
    .rtl .float-left{
        float: right !important;
    }
</style>
<div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">
    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a></h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('main'); ?></span>
            </div>

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


<br/>
<div style="margin-left: 20px;margin-right: 20px">
    <button class="btn btn-primary mb-3 float-left" onclick="toggle_filter()"><?= $this->lang->line('show_hide_filter') ?></button>
</div>
<div class="kt-container  kt-container--fluid  kt-grid__item kt-grid__item--fluid" >
    <div class="kt-portlet kt-portlet--mobile">
        <div class="alert alert-elevate" role="alert" id="filter_container">
            <div class="alert-text">
                <?php if ($this->session->flashdata('msg')): ?>
                    <div class="alert alert-success alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <h4><i class="icon fa-warning"></i> Success!</h4>&nbsp;
                        <?= $this->lang->line('op_success'); ?>
                    </div>
                <?php endif; ?>  
                <form class="kt-form kt-form--label-right" method="post" action=""> 
                    <div class="kt-portlet__body">
                        <div class="form-group row">
                            <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('date') ?></label>
                            <div class="col-9">
                                <input type="text" name="start_expiry" id="start_expiry" class="form-control" value="<?= set_value('start_expiry') ?>"> 
                            </div>
                            <div class="col-1" style="padding-left: 0px">
                                <a onclick="clear_date()" class="btn btn-light btn-text-primary btn-hover-text-primary font-weight-bold"><?= $this->lang->line('clear') ?></a>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('status') ?></label>
                            <div class="col-9">
                                <select name="status" class="topnav form-control" >
                                    <option value="-1" <?= $this->input->post('status') == -1 ? 'selected' : '' ?>><?= $this->lang->line('all') ?></option>
                                    <option value="1" <?= $this->input->post('status') == 1 ? 'selected' : '' ?>><?= $this->lang->line('active') ?></option>
                                    <option value="0" <?= $this->input->post('status') == 0 ? 'selected' : '' ?>><?= $this->lang->line('de-active') ?></option>
                                </select> 
                            </div>
                        </div>
                        <div class="form-group row">

                            <button  class="btn btn-primary btn-brand btn-elevate btn-icon-sm mr-5">
                                <?php echo $this->lang->line('submit') ?>
                            </button>

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


<div class="kt-portlet kt-portlet--mobile">

    <div class="kt-portlet__head kt-portlet__head--lg">
        <div class="kt-portlet__head-label">
            <span class="kt-portlet__head-icon">
                <i class="kt-font-brand flaticon2-line-chart"></i>
            </span>
            <h3 class="kt-portlet__head-title">
                <?php echo $this->lang->line('users'); ?>
            </h3>
        </div>
    </div>
    <div class="kt-portlet__body">
        <?php if ($this->session->flashdata('success')): ?>
            <div class="alert alert-success alert-dismissible">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon fa-warning"></i> Success!</h4>&nbsp;
                <?= $this->lang->line('op_success'); ?>
            </div>
        <?php endif; ?>  
        <?php if (get_ap('student_approve', $this->operator_id)) { ?>
            <div style="dispaly: block">
                <div class="col-3" style="float:right;padding: 0px">
                    <button id="btnGroupVerticalDrop1" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="float: right;">
                        <?php echo $this->lang->line('active') . '/' . $this->lang->line('de-active') ?>
                    </button>
                    <div class="dropdown-menu" aria-labelledby="btnGroupVerticalDrop1">
                        <a class="dropdown-item" href="" onclick="form_submit(1)"><?php echo $this->lang->line('active') ?></a>
                        <a class="dropdown-item" href="" onclick="form_submit(0)"><?php echo $this->lang->line('de-active') ?></a>
                    </div>
                </div>
            </div>
        <?php } ?>

        <form action="<?= base_url() ?>Users/inbox_multi_action" method="post" id="approve_form" >
            <input type="hidden" name="status" id="status" />
            <!--begin: Datatable -->
            <table class="table table-striped- table-bordered table-checkable" id="summary_table">
                <thead>
                    <tr>
                        <th><input type="checkbox" id="approve_check_all" title="Select/Deselect All" /></th>
                        <th><?php echo $this->lang->line('sno') ?></th>
                        <th><?php echo $this->lang->line('name') ?></th>
                        <th><?php echo $this->lang->line('email') ?></th>
                        <th><?php echo $this->lang->line('register_date') ?></th>
                        <?php if (get_ap('student_approve', $this->operator_id)) { ?>
                            <th class="text-center"><?php echo $this->lang->line('approve') ?></th>
                        <?php } ?>

                        <?php if (get_ap('inbox_delete_user', $this->operator_id)) { ?>
                            <th class="text-center"><?php echo $this->lang->line('delete') ?></th>
                        <?php } ?>
                    </tr>
                </thead>
                <tbody><?php
                    $i = 0;
                    $count = 0;
                    foreach ($all_groups as $row):
                        ?>
                        <tr>
                            <td><input type="checkbox" name="multi_action[<?= $row['id'] ?>]" class="approve_check_one" /></td>
                            <td><?= ++$i; ?></td>
                            <td><?= $row['username']; ?></td>
                            <td><?= $row['email']; ?></td>
                            <td><?= $row['create_on'] ?></td>
                            <?php if (get_ap('student_approve', $this->operator_id)) { ?>
                                <td class="text-center">

                                    <span class="switch switch-outline switch-success">
                                        <label>
                                            <input type="checkbox" <?= $row['approve_status'] == 1 ? 'checked="checked"' : '' ?> name="select" class="approve_switch" data-url="<?= $row['id']; ?>/<?= $row['approve_status']; ?>" />
                                            <span></span>
                                        </label>
                                    </span>

                                </td>
                            <?php } ?>
                            <?php if (get_ap('inbox_delete_user', $this->operator_id)) { ?>
                                <td class="text-center">
                                    <a href=""  onclick="alert_box(<?php echo $row['id'] ?>)" class="btn btn-icon btn-danger btn-sm" title="Delete">
                                        <i class="la la-trash"></i>
                                    </a>
                                </td> 
                            <?php } ?>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </form>

        <!--end: Datatable -->
    </div>
</div>
<?php $this->load->view('site/footer_2'); ?>  

<!--    <script src="<?php //echo base_url()         ?>public/plugins/global/plugins.bundle.js" type="text/javascript"></script>
    <script src="<?php //echo base_url()         ?>public/js/scripts.bundle.js" type="text/javascript"></script>-->

<!--end::Global Theme Bundle -->

<!--begin::Page Vendors(used by this page) -->
<!-- <script src="<?php echo base_url() ?>public/plugins/custom/datatables/datatables.bundle.js" type="text/javascript"></script> -->

<!--end::Page Vendors -->

<!--begin::Page Scripts(used by this page) -->
<!--<script src="<?php //echo base_url()         ?>public/js/pages/crud/datatables/basic/basic.js" type="text/javascript"></script>-->

<script>function alert_box(id) {
        var result = confirm("Are You Confirm!")
        if (result) {
            window.location.href = "<?= base_url('' . $this->thispage . '/del_user/') ?>" + id;

        }
    }
    function clear_date() {
        $("#start_expiry").val('');
    }

    function form_submit(status) {
        event.preventDefault();
        $("#status").val(status);
        $("#approve_form").submit();
    }
    function toggle_filter() {
        $("#filter_container").toggle();
        $(".select2_plug").select2();
    }

    $(function () {
        $("#filter_container").hide();
        $(".approve_switch").change(function () {
            location.href = "<?= base_url() ?>users/approve_status_student/" + $(this).data('url');
        });
        $("#approve_check_all").change(function () {
            if ($(this).prop('checked')) {
                $(".approve_check_one").prop('checked', 'checked');
            } else {
                $(".approve_check_one").prop('checked', false);
            }
        });
        $("#summary_table").DataTable({dom: 'Blfrtip',
            destroy: true,
            lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
            buttons: [
                {
                    extend: 'excelHtml5',
                    charset: 'UTF-16LE',
                    fieldSeparator: '\t',
                    bom: true
                },
                {
                    extend: 'csvHtml5',
                    charset: 'UTF-16LE',
                    fieldSeparator: '\t',
                    bom: true
                },
                {
                    extend: 'pdfHtml5',
                    charset: 'UTF-16LE',
                    fieldSeparator: '\t',
                    bom: true
                },
                {
                    extend: 'print',
                    autoPrint: false,
                    footer: true
                }

            ]
        });
//            buttons: [
//                'copyHtml5',
//                'excelHtml5',
//                'csvHtml5',
//                'pdfHtml5'
//            ]
    });
</script>