<?php
	
	if(!isset($_SESSION['login_user'])){
		header('location: ../../../login.php');
	}

	if(isset($_SESSION['user']) AND $_SESSION['user'] <> 'TRUE')
	{
		?>
		  <div class="alert alert-danger alert-dismissible" id="succsess-alert">
	        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
	        <h4><i class="icon fa fa-ban"></i> Alert!</h4>
	        Dilarang mengakses file ini.
	      </div>
		<?php
	}
	else{
	$linkaksi = 'med.php?mod=laporan_user';

	if(isset($_GET['act']))
	{
		$act = $_GET['act'];
		$linkaksi .= '&act='.$act;
	}
	else
	{
		$act = '';
	}

	$aksi = 'mod/sistem/act_laporan_user.php';
	$tgl = date('d-m-Y');

	?>
	<?php
	switch ($act) {
		default :
		flash('example_message');
		?>
		<!--breadcrumb-->
		<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
			<div class="breadcrumb-title pe-3">Sistem</div>
			<div class="ps-3">
				<nav aria-label="breadcrumb">
					<ol class="breadcrumb mb-0 p-0">
						<li class="breadcrumb-item"><a href="javascript:;"><i class="bx bx-home-alt"></i></a></li>
						<li class="breadcrumb-item active" aria-current="page">Laporan User</li>
					</ol>
				</nav>
			</div>
		</div>
		<!--end breadcrumb-->
		<?php flash('example_message'); ?>

		<div class="row">
			<div class="col-lg-12">
				<div class="card">
					<div class="card-header bg-primary text-center">
						<h4 class="m-b-0 text-white">Filter Periode</h4>
					</div>
					<div class="card-body">
						<div class="row mb-3">
							<label class="col-lg-2 col-sm-2 col-form-label">Periode</label>
							<div class="col-lg-10">
								<div class="input-group">
									<input type="text" value="<?php echo $tgl ?>" class="form-control" id="from" name="from">
									<div class="input-group-prepend">
										<span class="input-group-text">To</span>
									</div>
									<input type="text" value="<?php echo $tgl ?>" class="form-control" id="to" name="to">
									<span class="input-group-append">
										<button type="button" class="btn btn-success waves-effect waves-light" onclick="load()"><i class="bi bi-search me-2"></i>Cari</button>
									</span>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-lg-12">
				<div class="card mt-4">
					<div class="card-header bg-primary text-center">
						<h4 class="m-b-0 text-white">Data Log User</h4>
					</div>
					<div class="card-body">
						<div class="table-responsive">
							<table class="table table-striped table-hover align-middle" id="example23" cellspacing="0" width="100%">
								<thead>
									<tr>
										<th class="text-center">No</th>
										<th class="text-center">Petugas</th>
										<th class="text-center">Keterangan</th>
										<th class="text-center">Tanggal</th>
										<th class="text-center">Info Device</th>
									</tr>
								</thead>
								<tbody id="load">
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>

        <script type="text/javascript">
            $(window).on('load', function(){
                load();
            });
            
            function load(){	
                    var from = $("#from").val();
                    var to = $("#to").val();
                $.ajax({
                    type: 'POST',
                    url: "mod/sistem/load.php",
                    data: {from:from,to:to},
                    cache: false,
                    success: function(msg){	
                      $("#load").html(msg);
                    }
                });
            }
        </script>
		<?php
		break;
	}

	}
?>
<script>												
function myFunction() {
  var msg;
	msg= "Apakah Anda Yakin Akan Menghapus Data ? " ;
	var agree=confirm(msg);
	if (agree)
	return true ;
	else
	return false ;
}
</script>

