<title>Dashboard <?php echo $sdt['metadata_title']; ?></title>
<div id="bgdashboard" class="clearfix">
	
	<div id="pagetitle">DASHBOARD</div>
	
	<div id="sumdashboard" class="clearfix">
		<a href="?m=bus_index">
			<div id="sumdashbox1">
				<?php 
					$sdb = "SELECT count(*) AS jumlah FROM cmas_bus";
					$qdb = mysqli_query($koneksi, $sdb);
					$res = mysqli_fetch_array($qdb);
					echo "<div class='dashval'>$res[jumlah]</div>";
					echo "<div class='dashtit'>BUS</div>";
				?>
			</div>
		</a>
		<a href="?m=konten_index">
			<div id="sumdashbox2">
				<?php 
					$sdb = "SELECT count(*) AS jumlah FROM cmas_konten";
					$qdb = mysqli_query($koneksi, $sdb);
					$res = mysqli_fetch_array($qdb);
					echo "<div class='dashval'>$res[jumlah]</div>";
					echo "<div class='dashtit'>KONTEN</div>";
				?>
			</div>
		</a>
		<a href="?m=slideshow_index">
			<div id="sumdashbox3">
				<?php 
					$sdb = "SELECT count(*) AS jumlah FROM cmas_slideshow";
					$qdb = mysqli_query($koneksi, $sdb);
					$res = mysqli_fetch_array($qdb);
					echo "<div class='dashval'>$res[jumlah]</div>";
					echo "<div class='dashtit'>SLIDESHOW</div>";
				?>
			</div>
		</a>
		<a href="?m=tujuan_index">
			<div id="sumdashbox4">
				<?php 
					$sdb = "SELECT count(*) AS jumlah FROM cmas_tujuan WHERE tujuan_status='Aktif'";
					$qdb = mysqli_query($koneksi, $sdb);
					$res = mysqli_fetch_array($qdb);
					echo "<div class='dashval'>$res[jumlah]</div>";
					echo "<div class='dashtit'>TUJUAN</div>";
				?>
			</div>
		</a>
	</div>
	
	<!---------------------------------------------------------------------------------------------------------------------------->
	
	<div id="bgboxdashboard" class="clearfix">
		<div id="boxdashboard">
			<div id="titledashboard">BUS <span><a href="?m=bus_index">Lihat Selengkapnya</a></span></div>
			<table width="100%">
				<thead>
					<tr align="left">
						<th>NO</th>
						<th>TANGGAL</th>
						<th>DESKRIPSI</th>
					</tr>
				</thead>
				<tbody>
					<?php 
						$nomor = 1;
						$artdb = mysqli_query($koneksi, "SELECT * FROM cmas_bus ORDER BY bus_id DESC LIMIT 3");
						while($artdt = mysqli_fetch_array($artdb)) {
					?>
						<tr>
							<td align="center" width="1%">
								<?php echo $nomor; ?>
							</td>
							<td width="25%">
								<span><?php echo date_format(date_create($artdt["postdated"]), 'd/m/Y H:i:s'); ?></span>
							</td>
							<td>
								<?php echo $artdt['bus_nama']; ?>
							</td>
						</tr>
					<?php $nomor++; } ?>
				</tbody>
			</table>
		</div>
		<div id="boxdashboard">
			<div id="titledashboard">KONTEN <span><a href="?m=konten_index">Lihat Selengkapnya</a></span></div>
			<table width="100%">
				<thead>
					<tr align="left">
						<th>NO</th>
						<th>TANGGAL</th>
						<th>DESKRIPSI</th>
					</tr>
				</thead>
				<tbody>
					<?php 
						$nomor = 1;
						$artdb = mysqli_query($koneksi, "SELECT * FROM cmas_konten ORDER BY konten_id DESC LIMIT 3");
						while($artdt = mysqli_fetch_array($artdb)) {
					?>
						<tr>
							<td align="center" width="1%">
								<?php echo $nomor; ?>
							</td>
							<td width="25%">
								<span><?php echo date_format(date_create($artdt["postdated"]), 'd/m/Y H:i:s'); ?></span>
							</td>
							<td>
								<?php echo $artdt['konten_judul']; ?>
							</td>
						</tr>
					<?php $nomor++; } ?>
				</tbody>
			</table>
		</div>
	</div>
	
	<div id="bgboxdashboard" class="clearfix">
		<div id="boxdashboard">
			<div id="titledashboard">VISITOR <span><a href="?m=visitor_index">Lihat Selengkapnya</a></span></div>
			<table width="100%">
				<thead>
					<tr align="left">
						<th>NO</th>
						<th>TANGGAL</th>
						<th>IP ADDRESS</th>
						<th>HITS</th>
					</tr>
				</thead>
				<tbody>
					<?php 
						$nomor = 1;
						$artdb = mysqli_query($koneksi, "SELECT * FROM cmas_visitor ORDER BY visitor_date DESC LIMIT 3");
						while($artdt = mysqli_fetch_array($artdb)) {
					?>
						<tr>
							<td align="center" width="1%">
								<?php echo $nomor; ?>
							</td>
							<td width="25%">
								<span><?php echo date_format(date_create($artdt["visitor_date"]), 'd/m/Y H:i:s'); ?></span>
							</td>
							<td>
								<?php echo $artdt['visitor_ip']; ?>
							</td>
							<td>
								<?php echo $artdt['visitor_hits']; ?>
							</td>
						</tr>
					<?php $nomor++; } ?>
					<tr>
						<td></td>
						<td align="right"><b>TOTAL</b></td>
						<td>
							<?php
								$vdb = mysqli_query($koneksi, "SELECT COUNT(visitor_ip) AS TotalVisitor FROM cmas_visitor");
								$vdt = mysqli_fetch_array($vdb);
								echo "<b>".number_format($vdt['TotalVisitor'],0,",",".")." Visitor</b>";
							?>
						</td>
						<td>
							<?php
								$hdb = mysqli_query($koneksi, "SELECT SUM(visitor_hits) AS TotalHits FROM cmas_visitor");
								$hdt = mysqli_fetch_array($hdb);
								echo "<b>".number_format($hdt['TotalHits'],0,",",".")." Hits</b>";
							?>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div id="boxdashboard">
			<div id="titledashboard">LOGHITS <span><a href="?m=visitor_index">Lihat Selengkapnya</a></span></div>
			<table width="100%">
				<thead>
					<tr align="left">
						<th>NO</th>
						<th>TANGGAL</th>
						<th>CONTENT</th>
						<th>IP ADDRESS</th>
						<th>HITS</th>
					</tr>
				</thead>
				<tbody>
					<?php 
						$nomor = 1;
						$artdb = mysqli_query($koneksi, "SELECT * FROM cmas_loghits ORDER BY loghits_date DESC LIMIT 3");
						while($artdt = mysqli_fetch_array($artdb)) {
					?>
						<tr>
							<td align="center" width="1%">
								<?php echo $nomor; ?>
							</td>
							<td width="25%">
								<span><?php echo date_format(date_create($artdt["loghits_date"]), 'd/m/Y H:i:s'); ?></span>
							</td>
							<td>
								<?php echo $artdt['contenttitle']; ?>
							</td>
							<td>
								<?php echo $artdt['loghits_ip']; ?>
							</td>
							<td>
								<?php echo $artdt['loghits_hits']; ?>
							</td>
						</tr>
					<?php $nomor++; } ?>
					<tr>
						<td></td>
						<td></td>
						<td align="right"><b>TOTAL</b></td>
						<td>
							<?php
								$vdb = mysqli_query($koneksi, "SELECT COUNT(loghits_ip) AS TotalVisitor FROM cmas_loghits");
								$vdt = mysqli_fetch_array($vdb);
								echo "<b>".number_format($vdt['TotalVisitor'],0,",",".")." IP</b>";
							?>
						</td>
						<td>
							<?php
								$hdb = mysqli_query($koneksi, "SELECT SUM(loghits_hits) AS TotalHits FROM cmas_loghits");
								$hdt = mysqli_fetch_array($hdb);
								echo "<b>".number_format($hdt['TotalHits'],0,",",".")." Hits</b>";
							?>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>