<?php include "../koneksi.php"; ?>
<div class="row">
<div class="col-md-6">
<p>
	<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-tambah">
	<i class="bi bi-plus-square"></i>&ensp;Tambah Data</button>
</p>	
</div>
<div class="col-md-6">
	 <nav>
    <ol class="breadcrumb">
		<li class="breadcrumb-item">Pengiriman</li>
        <li class="breadcrumb-item">Table Sopir Logistik</li>
    </ol>
</nav>
</div>
</div>

<div style="width:100%;height500px;overflow:scroll;" >
<table id="example" class="display nowrap" style="width:100%">
        <thead>
		<tr>
			<th width="10%">
				No ID
			</th>
			<th width="15%">
				NIK
			</th>
			<th width="20%">
				Username 
			</th>
			<th width="15%">
				Level
			</th>
			<th width="20%">
				Status
			</th>
			<th width="20%">
				Opsi
			</th>
		</tr>
		<thead>
		<tbody>
			<?php 
				$data = mysqli_query ($koneksi, " select * from user Where Dept='1' ORDER BY Kasta DESC");
				
				while($row = mysqli_fetch_array ($data)):
			?>
		
		<tr>
			<td width="10%">
				<?php echo $row['User_ID']; ?>
			</td>
			<td width="15%">
				<?php echo $row['Nik']; ?>
			</td>
			<td width="15%">
				<?php echo $row['User_Name']; ?>
			</td>
			<td width="20%">
				<?php if($row['Kasta']=='1') { ?>
					PPIC
				<?php } else if($row['Kasta']=='2') { ?>
					MANAGER PRODUKSI
				<?php } else if($row['Kasta']=='3') { ?>
					OPERATOR PRODUKSI
				<?php } else if($row['Kasta']=='4') { ?>
					MANAGER QA
				<?php } else if($row['Kasta']=='5') { ?>
					OPERATOR QC
				<?php } else { ?>
					ADMIN WAREHOUSE
				<?php } ?>
			</td>
			<td width="20%" valign="center">
				<?php if($row['Start_Activity']>$row['End_Activity']) { ?>
					<text style="color: green;"><i class='bi bi-circle-fill' ></i> Online</text>
				<?php } else { ?>
					<text style="color: grey;"><i class='bi bi-x-circle-fill' ></i> Offline</text>
				<?php } ?>
			</td>
			<td width="20%">
				<a href="user/profile.php?id=<?php echo $row['User_ID']; ?>" style="color: #00008B" ><i class="bi bi-clipboard-check"></i>Detail</a>&ensp;|&ensp; 
				<a href="#" style="color: #DC143C" data-href="user/hapus.php?id=<?php echo $row['User_ID']; ?>" data-toggle="modal" data-target="#confirm-delete"><i class="bi bi-trash-fill"></i> Hapus</a> 
			</td>
		</tr>
		<?php endwhile; ?>
	</tbody>
	</table>
	</div>
		<!-- Modal -->
		<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Kofirmasi Hapus</h4>
                </div>
            
                <div class="modal-body">
                    <p>Apakah anda mau melanjutkan menghapus data?</p>
                    <p class="debug-url"></p>
                </div>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-danger btn-ok">Delete</a>
                </div>
            </div>
        </div>
    </div>
	
	<script>
        $('#confirm-delete').on('show.bs.modal', function(e) {
            $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
            
        });

		$(document).ready(function () {
		$('#example').DataTable({
			scrollX: true,
		});
	});
    </script>
