<?php
$base_url = base_url();
$this->load->view('layout/admin/header', array('base_url' => $base_url));
$this->load->view('layout/admin/sidebar', array('base_url' => $base_url, 'method'=>$this->router->method, 'class'=>$this->router->class  ));
?>
<script type="text/javascript">
    function init_page()
    {
        $(".ajax_paging").click(function () {
            $.ajax({
                url: $(this).attr("href"),
                type: "POST",
                data: $("#cardlog").serialize(),
                success: function (data, textStatus, jqXHR)
                {
                    $("#content").html(data);
                    init_page();
                },
                error: function (jqXHR, textStatus, errorThrown)
                {
                    $(".ajaxloading").hide();
                }
            });
            return false;
        });
		$('#keyword').bind('input', function(){
			filter();
		});
		
		$( '.sorting, .sorting_desc, .sorting_asc' ).click(function( index ) {
            var current_class=$( this ).attr('class');
            $(".sorting_desc").attr("class","sorting");
            $(".sorting_asc").attr("class","sorting");
     
            if(current_class=='sorting')
            {
                $(this).attr("class","sorting_desc");
            }
            else
            {
                if(current_class=='sorting_desc')
                {
                    $(this).attr("class","sorting_asc");
                }
                else
                    {
                    if(current_class=='sorting_asc')
                    {
                        $(this).attr("class","sorting");
                    }
                }
            }
            $("#sorting_field").val($(this).attr("id"));
            $("#sorting_order").val($(this).attr("class"));
            filter();
        });
	}
	
	function filter()
	{
		$.ajax({
			url: 'http://viettel.violet.vn/admin/card_log/trang/1',
			type: "POST",
			data: $("#cardlog").serialize(),
			success: function (data, textStatus, jqXHR)
			{
				console.log(data);
				$("#content").html(data);
				init_page();
				$("#keyword").focus();
				$("#keyword").setCursorToTextEnd();
			},
			error: function (jqXHR, textStatus, errorThrown)
			{
				console.log("ERROR");
				$(".ajaxloading").hide();
			}
        });
	}
		
</script>

<div class="main-content" id="content">
    <?php echo $content; ?>
</div><!-- /.main-content -->
</div><!-- /.main-container-inner -->

<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
</div><!-- /.main-container -->

<?php
$this->load->view('layout/admin/footer', array('base_url' => $base_url, 'adminjs'=>array('assets/js/admin/smslog.js')));
?>