log_action_view.php 10.4 KB
Newer Older
Phạm Văn Đoan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?php if($this->session->flashdata('success')): ?>
    <div class="row">
        <div class="alert alert-block alert-success" style="margin-bottom: 5px">
            <button type="button" class="close" data-dismiss="alert">
                <i class="ace-icon fa fa-times"></i>
            </button>
            <i class="ace-icon fa fa-check green"></i>
            <?php echo $this->session->flashdata('success'); ?>
        </div>
    </div>
<?php endif; ?>
<?php if($this->session->flashdata('error')): ?>
    <div class="row">
        <div class="alert alert-block alert-danger" style="margin-bottom: 5px">
            <button type="button" class="close" data-dismiss="alert">
                <i class="ace-icon fa fa-times"></i>
            </button>
            <i class="ace-icon fa fa-times"></i>
            <?php echo $this->session->flashdata('error'); ?>
        </div>
    </div>
<?php endif; ?>
<div class="row">
    <?php echo form_open(base_url().'backend/cmsSetting/logAction'); ?>
    <div class="col-lg-3" style="margin-left: -12px">
        <div class="input-group">
            <input
                class="form-control" type="text"
                name="date-range-picker"
                id="input-date-range-log-action"
                readonly style="text-align: center"
                placeholder="Kích chọn ngày tạo"/>
                <span class="input-group-addon">
                    <i class="fa fa-calendar bigger-110" id="daterange-picker"></i>
                </span>
        </div>
    </div>
    <div class="col-lg-2">
        <input
            class="form-control" type="text"
            name="input-account"
            id="input-account"
            placeholder="username..."/>
    </div>
    <div class="col-lg-2">
        <select class="form-control" id="select-action-type" name="select-action-type">
            <option value="">-- Tất cả mã action --</option>
48 49
            <option value="RANKING">Xem BXH</option>
            <option value="SHOW_HISTORY">Xem lịch sử lượt nghe</option>
Phạm Văn Đoan committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
            <option value="ADDED">Thêm mới</option>
            <option value="UPDATED">Cập nhật</option>
            <option value="DELETED">Xóa</option>
            <option value="RESET_PASSWORD">Đổi mật khẩu</option>
            <option value="ASIGNED_PERMISSION_USER">Gán quyền</option>
            <option value="EXPORTED">Xuất excel</option>
            <option value="SHOW_USER_INFO">Thông tin tài khoản</option>
            <option value="CHANGED_ACTIVE">Đổi trạng thái</option>
        </select>
    </div>
    <div class="col-lg-2">
        <input
            class="form-control" type="text"
            name="input-ip"
            id="input-ip"
            style="text-align: right"
            placeholder="IP..."/>
    </div>
    <div class="col-lg-1">
        <button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
    </div>
    <?php echo form_close(); ?>
</div>
<!-- /.row -->
<div class="space-6"></div>
<div class="row" >
    <div style="text-align: center" id="data-loading">
        <i class="fa fa-refresh fa-spin bigger-200"></i> Đang tải dữ liệu...
    </div>
    <div id="div-mo-list">
        <table class="table table-striped table-bordered table-hover">
            <thead></thead>
            <tbody></tbody>
        </table>
    </div>
</div>

<script type="text/javascript">
    //Thuc hien viec ve bieu do
    $(document).ready(function() {
        $('#daterange-picker').click(function(){
            $('#input-date-range-log-action').click();
        });

        var url = '<?php echo base_url()."backend/cmsSetting/logActionAjax"; ?>';
        // Tìm kiếm theo ngày tháng
        $('#input-date-range-log-action').on('apply.daterangepicker', function(ev, picker) {
            loadDataByAjaxDateRange(picker.startDate.format('DD-MM-YYYY'), picker.endDate.format('DD-MM-YYYY'), url);
        });
        // Tìm kiếm theo SĐT
        var oldTimeout = '';
        $('#input-ip').keyup(function(){
            clearTimeout(oldTimeout);
            oldTimeout = setTimeout(function(){
                loadDataByAjaxFromInput(url);
105
            }, 250);
Phạm Văn Đoan committed
106 107 108 109 110 111 112
        });
        // Tìm kiếm theo cú pháp
        var oldTimeout2 = '';
        $('#input-account').keyup(function(){
            clearTimeout(oldTimeout2);
            oldTimeout2 = setTimeout(function(){
                loadDataByAjaxFromInput(url);
113
            }, 250);
Phạm Văn Đoan committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
        });
        // Tìm kiếm theo kênh
        loadDataByAjaxFromSelectBox("select-action-type", url);
        // Xóa bộ lọc
        $('#delete-filter').click(function(){
            $("#input-date-range-log-action").val('');
            $("#input-ip").val('');
            $("#input-account").val('');
            $("#select-action-type").val('');
            changePagination('0');
            return false;

        });
        changePagination('0');

    });
    //Ham chung cho cac input
    function loadDataByAjaxFromInput(url){
        var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
        var filterByDateRange = $("#input-date-range-log-action").val();
        var filterByIP = $('#input-ip').val();
        var filterByAccount = $("#input-account").val();
        var filterByActionType = $("#select-action-type").val();
        var dtFrom = "";
        var dtTo = "";
        //
        if(filterByDateRange.length > 0){
            var arr_filter_by_date = filterByDateRange.split("-");
            var date_from = arr_filter_by_date[0];
            var date_to = arr_filter_by_date[1];
            var arr_from = date_from.split("/");
            var arr_to = date_to.split("/");
            dtFrom = arr_from[0].trim()+"-"+arr_from[1].trim()+"-"+arr_from[2].trim();
            dtTo = arr_to[0].trim()+"-"+arr_to[1].trim()+"-"+arr_to[2].trim();
        }
        //Ajax ve bieu do
        $.ajax({
            type: "POST",
            url: url,
            data: {
                csrf_name: csrf_value,
                filterByIP: filterByIP,
                filterByAccount: filterByAccount,
                filterByActionType: filterByActionType,
                dtFrom: dtFrom,
                dtTo: dtTo
            },
            dataType: "text",
            cache: false,
            success: function(data){
                $('#div-mo-list').html(data);
                $('#data-loading').hide();
            }
        });
    }
    //Ham chung cho cac SelectBox
    function loadDataByAjaxFromSelectBox(id, url){
        $('#'+id).change(function(){
            var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
            var filterByDateRange = $("#input-date-range-log-action").val();
            var filterByIP = $("#input-ip").val();
            var filterByAccount = $("#input-account").val();
            var filterByActionType = $("#select-action-type").val();
            var dtFrom = "";
            var dtTo = "";
            //
            if(filterByDateRange.length > 0){
                var arr_filter_by_date = filterByDateRange.split("-");
                var date_from = arr_filter_by_date[0];
                var date_to = arr_filter_by_date[1];
                var arr_from = date_from.split("/");
                var arr_to = date_to.split("/");
                dtFrom = arr_from[0].trim()+"-"+arr_from[1].trim()+"-"+arr_from[2].trim();
                dtTo = arr_to[0].trim()+"-"+arr_to[1].trim()+"-"+arr_to[2].trim();
            }
            //Ajax ve bieu do
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    csrf_name: csrf_value,
                    filterByIP: filterByIP,
                    filterByAccount: filterByAccount,
                    filterByActionType: filterByActionType,
                    dtFrom: dtFrom,
                    dtTo: dtTo
                },
                dataType: "text",
                cache: false,
                success: function(data){
                    $('#div-mo-list').html(data);
                    $('#data-loading').hide();
                }
            });
        });
    }

    function loadDataByAjaxDateRange(dtFrom, dtTo, url){
        var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
        var filterByIP = $("#input-ip").val();
        var filterByAccount = $("#input-account").val();
        var filterByActionType = $("#select-action-type").val();
        // ajax
        $.ajax({
            type: "POST",
            url: url,
            data: {
                csrf_name: csrf_value,
                filterByIP: filterByIP,
                filterByAccount: filterByAccount,
                filterByActionType: filterByActionType,
                dtFrom: dtFrom,
                dtTo: dtTo
            },
            dataType: "text",
            cache: false,
            success: function(data){
                $('#div-mo-list').html(data);
                $('#data-loading').hide();
            }
        });
    }

    function changePagination(pageId) {
        var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
        var url = '<?php echo base_url()."backend/cmsSetting/logActionAjax"; ?>';
        var filterByDateRange = $("#input-date-range-log-action").val();
        var filterByIP = $("#input-ip").val();
        var filterByAccount = $("#input-account").val();
        var filterByActionType = $("#select-action-type").val();
        var dtFrom = "";
        var dtTo = "";
        //
        if(filterByDateRange.length > 0){
            var arr_filter_by_date = filterByDateRange.split("-");
            var date_from = arr_filter_by_date[0];
            var date_to = arr_filter_by_date[1];
            var arr_from = date_from.split("/");
            var arr_to = date_to.split("/");
            dtFrom = arr_from[0].trim()+"-"+arr_from[1].trim()+"-"+arr_from[2].trim();
            dtTo = arr_to[0].trim()+"-"+arr_to[1].trim()+"-"+arr_to[2].trim();
        }
        //Ajax ve bieu do
        $.ajax({
            type: "POST",
            url: url,
            data: {
                csrf_name: csrf_value,
                filterByIP: filterByIP,
                filterByAccount: filterByAccount,
                filterByActionType: filterByActionType,
                dtFrom: dtFrom,
                dtTo: dtTo,
                pageId: pageId
            },
            dataType: "text",
            cache: false,
            success: function(data){
                $('#div-mo-list').html(data);
                $('#data-loading').hide();
            }
        });
    }

</script>