	<?php

	include('../class/Appointment.php');

	$object = new Appointment;

	if (!$object->is_login()) {
		header("location:" . $object->base_url . "admin");
	}

	/*if($_SESSION['arsiparis_type'] != 'Admin')
	{
		header("location:".$object->base_url."");
	}*/

	include('header.php');

	?>

	<!-- Page Heading -->
	<h1 class="h3 mb-4 text-gray-800">Dashboard</h1>

	<!--div class="col mb-4">
		<div class="card border-left-primary shadow h-100 py-2">
			<div class="card-body">
				<div class="row no-gutters align-items-center">
					<img src="../vendors/images/banner-img.png" alt="">
					<div class="col-md-9">
						<h4 class="font-20 weight-500 mb-10 text-capitalize">
							Welcome back <div class="weight-600 font-30 text-blue">,</div>
						</h4>
						<p class="font-18 max-width-600">........</p>
					</div>
				</div>
			</div>
		</div>
	</div-->
	<!-- Content Row -->
	<div class="row row-cols-5">

		<?php if ($_SESSION['arsiparis_type'] == 'Admin') { ?>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="arsiparis.php">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Data Arsiparis</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_arsiparis(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
		<?php }
		if ($_SESSION['arsiparis_type'] == 'Admin' || $_SESSION['arsiparis_type'] == 'User') {
		?>
			<!-- Earnings (Monthly) Card Example -->

			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif_old.php?unit=TU">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Tata Usaha</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data_inaktif_TU(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif_old.php?unit=Logistik">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Logistik</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data_inaktif_Log(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif_old.php?unit=Pencegahan">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Cegah</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data_inaktif_Cegah(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif_old.php?unit=Humas">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Humas</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data_inaktif_Humas(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif_old.php?unit=Rehabilitasi">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Rehab</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data_inaktif_Rehab(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif_old.php?unit=Roum">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Biro Umum</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data_inaktif_Roum(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<a class="nav-link" href="inaktif.php">
									<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
										Total Arsip Inaktif Olah</div>
									<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_data(); ?></div>
								</a>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
		<?php
		}
		/*
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
									Last 7 Days Total Appointment</div>
								<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_seven_day_appointment(); ?></div>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
									Total Appointment till date</div>
								<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_appointment(); ?></div>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col mb-4">
				<div class="card border-left-primary shadow h-100 py-2">
					<div class="card-body">
						<div class="row no-gutters align-items-center">
							<div class="col mr-2">
								<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
									Total Registered Patient</div>
								<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $object->get_total_patient(); ?></div>
							</div>
							<div class="col-auto">
								<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
							</div>
						</div>
					</div>
				</div>
			</div>
			<*/ ?>
	</div>
	<div class="col-md-12">
		<div class="card mt-4 mb-4">

			<div class="card-body">
				<div class="chart-container pie-chart">
					<canvas id="bar_chart"></canvas>
				</div>
			</div>
		</div>
	</div>
	<?php
	include('footer.php');
	?>
	<script>
		$(document).ready(function() {
			makechart();

			function makechart() {
				$.ajax({
					url: "dashboard_action.php",
					method: "POST",
					data: {
						action: 'fetch'
					},
					dataType: "JSON",
					success: function(data) {
						var unit_kerja = [];
						var total = [];
						var color = [];

						for (var count = 0; count < data.length; count++) {
							unit_kerja.push(data[count].unit_kerja);
							total.push(data[count].total);
							color.push(data[count].color);
						}

						var chart_data = {
							labels: unit_kerja,
							datasets: [{
								label: 'unit kerja',
								backgroundColor: color,
								color: '#fff',
								data: total
							}]
						};

						var options = {
							responsive: true,
							scales: {
								yAxes: [{
									ticks: {
										min: 0
									}
								}]
							}
						};

						var group_chart = $('#bar_chart');

						var graph = new Chart(group_chart, {
							type: 'bar',
							data: chart_data,
							options: options
						});
					}
				})
			}
		});
	</script>