<?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: $("#collaborator").serialize(),
                success: function (data, textStatus, jqXHR)
                {
                    // $result = jQuery.parseJSON(data);
                    $("#content").html(data);
                    init_page();

                },
                error: function (jqXHR, textStatus, errorThrown)
                {
                    $(".ajaxloading").hide();
                }
            });
            return false;
        })
        $('#keyword').keyup(function (event) {
            if (event.keyCode == '13') {
                filter();
            }
            return false;
        });
        
        
        $( '.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();
        });
        $('[data-toggle="ajaxModal"]').on('click',
              function(e) {
                $('#ajaxModal').remove();
                e.preventDefault();
                var $this = $(this)
                  , $remote = $this.data('remote') || $this.attr('href')
                  , $modal = $('<div class="modal" id="ajaxModal"><div class="modal-body"></div></div>');
                $('body').append($modal);
                $modal.modal({backdrop: 'static', keyboard: false});
                $modal.load($remote);
              }
            );


 
				$('#sales-charts').css({'width':'100%' , 'height':'200px'});
				$.plot("#sales-charts", <?php echo json_encode($chard) ?>, {
					hoverable: true,
					shadowSize: 0,
					series: {
						lines: { show: true },
						points: { show: true }
					},
					xaxis: {
						tickLength: 0
					},
					yaxis: {
						ticks: 10,
						min: 0,
						max:<?php echo $max;?>,
						tickDecimals: 0
					},
					grid: {
						backgroundColor: { colors: [ "#fff", "#fff" ] },
						borderWidth: 1,
						borderColor:'#555'
					}
				});
    }


    function filter()
    {
        $.ajax({
            url: '<?php echo base_url();?>admin/doanh_thu_tong_hop/trang/1',
            type: "POST",
            data: $("#collaborator").serialize(),
            success: function (data, textStatus, jqXHR)
            {
                // $result = jQuery.parseJSON(data);
                $("#content").html(data);
                init_page();
                $("#keyword").focus();
                $("#keyword").setCursorToTextEnd();

            },
            error: function (jqXHR, textStatus, errorThrown)
            {
                $(".ajaxloading").hide();
            }
        });
    }


</script>
<style type="text/css" media="screen">
			.widget-header-flat {
				background: #307ecc;
				color: #fff
			}
			.widget-toolbar>[data-action="collapse"], .header-color-dark>.widget-toolbar>[data-action="collapse"] {
				color: #fff
			}
			.widget-header, .widget-content {
				width: auto
			}
			.widget-body .table thead:first-child tr {
				background: #EDECEC;
			    color: #707070;
			    font-weight: normal;
			}
		</style>
             
<div class="main-content" >
    <div id="breadcrumbs" class="breadcrumbs">

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="<?php echo $base_url;?>/admin/home">Trang chủ</a>
        </li>

        <li>
            <a href="<?php echo $base_url;?>/admin/home"">Bảng điều khiển</a>
        </li>
        
    </ul><!-- .breadcrumb -->

    <div id="nav-search" class="nav-search">
        <form class="form-search">
            <span class="input-icon">
                <input type="text" autocomplete="off" id="nav-search-input" class="nav-search-input" placeholder="Tìm kiếm ...">
                <i class="icon-search nav-search-icon"></i>
            </span>
        </form>
    </div><!-- #nav-search -->
</div>
    
    
    
    
<div class="page-content">
    
    <div class="page-header">
       
    </div><!-- /.page-header -->
    
     <div class="row">  
    <?php echo $statistics; ?>   
     </div>
     <div class="row" id="content">    
    <?php echo $content; ?>
     </div>
    </div>
</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 -->



</div><!-- /.modal-dialog -->
<?php
$this->load->view('layout/admin/footer', array('base_url' => $base_url));
?>