<?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));
?>
<script type="text/javascript">
    function init_page()
    {
        $(".ajax_paging").click(function () {
            $.ajax({
                url: $(this).attr("href"),
                type: "POST",
                data: $("#admin").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");
                    }
                }
            }
			console.log($( this ).attr('class'));
            $("#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);
			}
        );
	}
	
	function filter()
	{
		$.ajax({
			url: '<?php echo base_url();?>admin/quan_tri_vien/trang/1',
			type: "POST",
			data: $("#admin").serialize(),
			success: function (data, textStatus, jqXHR)
			{
				$("#content").html(data);
				init_page();
				$("#keyword").focus();
				$("#keyword").setCursorToTextEnd();

			},
			error: function (jqXHR, textStatus, errorThrown)
			{
				$(".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 -->

<!-- Add Admin -->
<div tabindex="-1" class="modal fade in" id="addAdmin">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">
						<span class="white">×</span>
					</button>
					Tạo quản trị viên
				</div>
			</div>

			<div class="modal-body">
				<form id="add_frm" onsubmit="return false;" class="form-horizontal" role="form">
						<div class="form-group">
						<label for="form-field-1" class="col-sm-3 control-label no-padding-right"> Họ tên </label>
						<div class="col-sm-9">
							<label class="block clearfix has-error">
								<span class="input-icon">
									<input type="text" name="full_name" placeholder="Họ tên" id="form-field-1">
									<i class="icon-user blue"></i>
								</span>
								<div class="help-block" id="full_name_err" > </div>
							</label>
						</div>
						<div class="help-block"> </div>
					</div>
					
					<div class="form-group">
						<label for="form-field-2" class="col-sm-3 control-label no-padding-right"> Tài khoản </label>
						
						<div class="col-sm-9">
							
							<label class="block clearfix has-error">
								<span class="input-icon">
									<input type="text" name="login_name" placeholder="Tài khoản" id="form-field-2">
									<i class="icon-user blue"></i>
								</span>
								<div class="help-block" id="login_name_err" > </div>
							</label>
							
						</div>
					</div>

					<div class="form-group">
						<label for="form-field-3" class="col-sm-3 control-label no-padding-right"> Mật khẩu </label>
						<div class="col-sm-9">
							<label class="block clearfix has-error">
								<span class="input-icon">
									<input type="password" name="passwd" placeholder="Mật khẩu" id="form-field-3">
									<i class="icon-lock blue"></i>
								</span>
								
								<div class="help-block" id="pwd1_err"> </div>
							</label>
						</div>			
					</div>
					<div class="space-4"></div>
					
					<div class="form-group">
						<label for="form-field-4" class="col-sm-3 control-label no-padding-right">Xác nhận mật khẩu </label>
						<div class="col-sm-9">
							<label class="block clearfix has-error">
								<span class="input-icon">
									<input type="password" name="pwd2" placeholder="Nhập lại mật khẩu" id="form-field-4">
									<i class="icon-lock blue"></i>
								</span>
								
								<div class="help-block" id="pwd2_err"> </div>
							</label>
						</div>			
					</div>
					<div class="space-4"></div>	
					
					<div class="form-group">
						<label for="form-field-5" class="col-sm-3 control-label no-padding-right"> Email </label>
						<div class="col-sm-9">
							<label class="block clearfix has-error">
								<span class="input-icon">
									<input type="text" name="email" placeholder="Email" id="form-field-5">
									<i class="icon-envelope blue"></i>
								</span>
								<div class="help-block" id="email_err"> </div>
							</label>
						</div>
						<div class="help-block"> </div>
					</div>

					<div class="space-4"></div>
					
					<div class="form-group">
						<label for="form-field-6" class="col-sm-3 control-label no-padding-right"> Phone </label>

						<div class="col-sm-9">
							<label class="block clearfix has-error">
								<span class="input-icon">
									<input type="text" name="phone" placeholder="Phone" id="form-field-6">
									<i class="icon-phone blue"></i>
								</span>
								<div class="help-block" id="phone_err"> </div>
							</label>
						</div>
						<div class="help-block"> </div>
					</div>
					<div class="space-4"></div>
					
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" id="add" type="button">
								<i class="icon-ok bigger-110"></i>
								Hoàn tất
							</button>

							&nbsp; &nbsp; &nbsp;
							<button type="reset" name="reset" class="btn">
								<i class="icon-undo bigger-110"></i>
								Xóa hết
							</button>
						</div>
					</div>

					</div>
				</form>
			</div>
		</div>
	</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
<!-- Delete Admin -->
<div tabindex="-1" class="modal fade in" id="deleteAdmin">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">
						<span class="white">×</span>
					</button>
					Xóa quản trị viên
				</div>
			</div>
			
			<div class="modal-body">
				<form id="delete_frm" onsubmit="return false;" class="form-horizontal" role="form">
					<div class="form-group">
						<center>
							<label>Tài khoản: <span class="blue" id="us"></span></label>
							<h4> Chắc chắn muốn xóa tài khoản này? </h4>
						</center>
					</div>
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button type="button" id="delete" class="btn btn-info">
								<i class="icon-ok bigger-110"></i>
								Xóa
							</button>

							&nbsp; &nbsp; &nbsp;
							<button type="reset" name="reset" class="btn" data-dismiss="modal">
								<i class="icon-undo bigger-110"></i>
								Hủy
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>					
<!-- End Delete User -->
<?php
$this->load->view('layout/admin/footer', array('base_url' => $base_url, 'adminjs' => array('assets/js/admin/admin.js')));
?>