<?= $this->extend('layouts/main.php') ?>

<?= $this->section('content') ?>
<?php
//act_count
$nuser = intval($nuser[0]['nuser']);

?>
<div class="page-wrapper">
	<div class="container-fluid">
		
		<div class="row page-titles">
			<div class="col-md-5 align-self-center">
				<h4 class="text-themecolor">Dashboard</h4>
			</div>					
		</div>
		
		<?php
		if($_SESSION['level']==0) {
		?>
		<div class='row mb-3'>
			<div class='col'>
				<select class='form-select form-select-sm' name="action" onchange="action(this)">
					<option value=""> - </option>
					<?php
					foreach($users as $data) {
						$quserid = $data['userid'];
						$qusername = $data['firstname'].' '.$data['lastname'];
						if($userid == $quserid) { echo "<option value='/Dashboard/user/$quserid' selected>$qusername</option>"; }
						else { echo "<option value='/Dashboard/user/$quserid'>$qusername</option>"; }
					}
					?>
				</select>
			</div>
		</div>
		<?php
		}
		?>
		
		<?php 
		echo view('dashboard_act_counter');
		
		if ( $user_position == 1 ) {
			echo view('dashboard_tsm_and_tss');
			echo view('dashboard_tsm');
		} else if ( $userid == 3) {
			echo view('dashboard_tsm_and_tss');
			echo view('dashboard_tss_ivd_barat');
		} else if ( $userid == 10) {
			echo view('dashboard_tsm_and_tss');
			echo view('dashboard_tss_ivd_tengah');
		} else if ( $userid == 2) {
			echo view('dashboard_tsm_and_tss');
			echo view('dashboard_tss_ivd_timur');
		} else if ( $userid == 5) {
			echo view('dashboard_tsm_and_tss');
			echo view('dashboard_tss_it');
		}
		
		echo view('dashboard_recent_act');
		?>
	</div>
</div>
<?= $this->endSection() ?>

<?= $this->section('script') ?>
<script>
<!-- SCRIPT DATATABLES -->
$(function () {
	$('#ActivityTable').DataTable({
		"order" : [],
		"pageLength" : 25,
		"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ]
	});
});
$(function () {
	$('#ivdActivityTable').DataTable({
		"order" : [],
		"pageLength" : 25,
		"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ]
	});
});
$(function () {
	$('#itActivityTable').DataTable({
		"order" : [],
		"pageLength" : 25,
		"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ]
	});
});
$(function () {
	$('#psActivityTable').DataTable({
		"order" : [],
		"pageLength" : 25,
		"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ]
	});
});
function action(e){
	//console.log(e.value);
	window.open(e.value);
}
</script>
<?= $this->endSection() ?>
