<div id="breadcrumbs" class="breadcrumbs">

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">Trang chủ</a>
        </li>

        <li>
            <a href="#">Quản lý tài khoản</a>
        </li>
        <li>
            <a href="#">Người dùng</a>
        </li>
        <li class="active">Danh sách</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">
        <h1>
            Người dùng
            <small>
                <i class="icon-double-angle-right"></i>
                Danh sách
            </small>
        </h1>
    </div><!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <div style="padding-bottom:4px" class="table-header">
                Danh sách
                <button href="#addUser" data-toggle="modal" class="btn btn-success pull-right">
                    <i class="icon-plus"></i>
                    Thêm người dùng
                </button>

            </div>

            <div class="table-responsive">
                <div role="grid" class="dataTables_wrapper" id="sample-table-2_wrapper">
                    <form onsubmit="return false;" id="user" >
                        <div class="row">
                            <div class="col-sm-6">
                                <div id="sample-table-2_length" class="dataTables_length"><label>Hiện thị 
                                        <select onchange="filter();" name="items" size="1" aria-controls="sample-table-2">
                                            <?php foreach ($itemsoptions as $option) { ?>
                                            <option <?php if($option == $perpage) echo "selected"; ?> value="<?php echo $option;?>"><?php echo $option;?></option>
                                            <?php } ?>
                                        </select> bản ghi</label>

                                </div>
                            </div>
								
                            <div class="col-sm-6">
                                <div class="dataTables_filter" id="sample-table-2_filter">
                                    <label>Tìm kiếm: 
                                        <input type="text" name="keyword" id="keyword" value='<?php echo $keyword;?>' aria-controls="sample-table-2"></label>
                                </div>
								<div class="dataTables_status" style="float: right;" id="sample-table-2_status"><label>Lọc:
									<select onchange="filter();" name="status" size="1" style="width: 139px; height: 28px;" aria-controls="sample-table-2" class="">                                      
										<?php foreach ($statusoptions as $key=>$option):?>
										<option <?php if ($key == $status) echo "selected"; ?> value="<?php echo $key; ?>"><?php echo $option; ?></option>
										<?php endforeach; ?>
									</select>
								</div>
                            </div>

                        </div>
							
						<input type="hidden" name="sorting_order" id="sorting_order" value="<?php echo $sorting_order;?>" />
						<input type="hidden" name="sorting_field" id="sorting_field" value="<?php echo $sorting_field;?>"/>
                    </form>
                    <table class="table table-striped table-bordered table-hover dataTable" id="sample-table-2" aria-describedby="sample-table-2_info">
                        <thead>
                            <tr role="row">
                                <th class="center sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 44px;" aria-label="">
                                    <label>
                                        <input type="checkbox" class="ace">
                                        <span class="lbl"></span>
                                    </label>
                                </th>
								<th class="<?php if ($sorting_field == 'cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Tài khoản: activate to sort column ascending">Tài khoản</th>
                                <th class="<?php if ($sorting_field == 'cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Số điện thoại: activate to sort column ascending">Số điện thoại</th>
                                <th class="<?php if ($sorting_field == 'acc_balanced') {echo $sorting_order;} else {echo "sorting";}?>" id="acc_balanced" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 122px;" aria-label="Tiền: activate to sort column ascending">Tiền</th>
                                <th class="<?php if ($sorting_field == 'created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="Ngày đăng ký: activate to sort column ascending">
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    Ngày đăng ký
                                </th>
								<th class="<?php if ($sorting_field == 'expire_date') {echo $sorting_order;} else {echo "sorting";}?>" id="expire_date" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="Ngày hết hạn: activate to sort column ascending">
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    Ngày hết hạn
                                </th>
								<th class="sorting_disabled" id="status" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;">Tình trạng</th>
                            </tr>
                        </thead>

                        <tbody role="alert" aria-live="polite" aria-relevant="all">
                            
                            <?php
                            foreach ($users as $user) {
                                ?>
                            <tr class="odd">
                                <td class="center  sorting_1">
                                    <label>
                                        <input type="checkbox" class="ace">
                                        <span class="lbl"></span>
                                    </label>
                                </td>
								<td class=" ">
                                    <a><?php echo @$user['username']; ?></a>
                                </td>
                                <td class=" ">
                                    <?php echo $user['cellphone']; ?>
                                </td>
                                <td class="hidden-480 "><?php echo $user['acc_balanced']. " VNĐ"; ?></td>
                                <td class=" "><?php echo $user['created_time']; ?></td>
								<td class=" "><?php echo isset($user['expire_date']) && strtotime($user['expire_date'])>0 ? date('d/m/Y', strtotime($user['expire_date'])) : '';?></td>
								<td class=" ">
								<?php  if(strtotime($user['expire_date'])>time()){ ?>
									<span class="label label-sm label-success">Đã đăng ký</span>
								<?php }else{ ?>
									<span class="label label-sm label-warning">Dùng thử</span>
								<?php } ?>
								</td>

                            </tr>
                            <?php } ?>

                        </tbody></table>
						<div class="row"><div class="col-sm-6">
							<div class="dataTables_info" id="sample-table-2_info">Hiển thị <?php echo ($start+1)?> đến <?php echo ($start+$perpage)?> của <?php echo $total?> bản ghi</div>
                                    
							</div>
							<div class="col-sm-6">
								<div class="dataTables_paginate paging_bootstrap">
									<ul class="pagination">
										<?php echo $paging; ?>
									</ul>
								</div>
							</div>
						</div>

                </div>
            </div>

            
        </div>

        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->
</div>
<script type="text/javascript">
    window.onload = function ()
    {
        init_page();
    }


</script>