<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<?php include "head.php"; ?>
	</head>
	<Body id="bg">
		<div id="tops">
			<div id="bgpanel" class="clearfix">
				<div id="panelleft">
					<div class="panellogo">
						<?php
							$ldb = mysqli_query($koneksi, "SELECT * FROM cmas_logo");
							$ldt = mysqli_fetch_array($ldb);
						?>
						<a href="?m=dashboard"><span><?php echo $ldt['logo_nama']; ?></span></a>
					</div>
				</div>
				<div id="panelrite">
					<div class="panelname">
						<div class="dropdown">
							<?php
								$indb = mysqli_query($koneksi, "SELECT COUNT(pesan_id) AS NewMail FROM cmas_pesan WHERE pesan_status='1' LIMIT 5");
								$indt = mysqli_fetch_array($indb);
								
								if ($indt['NewMail'] == 0) {
									$mail = 0;
								} else {
									$mail = $indt['NewMail'];
								}
							?>
							<button class="dropbtn">Inbox <span class="notify"><?php echo $mail; ?></span></button>
							<div class="dropdown-content">
								<?php
									$mdb = mysqli_query($koneksi, "SELECT * FROM cmas_pesan WHERE pesan_status='1' ORDER BY postdated DESC LIMIT 5");
									while($mdt = mysqli_fetch_array($mdb)) {
								?>
									<div class="dropdown-contentrow">
										<font color="grey"><?php echo date_format(date_create($mdt['postdated']), 'd/m/Y H:i:s'); ?></font><br>
										<?php echo $mdt['pesan_name']; ?> > <?php echo $mdt['pesan_subject']; ?>
									</div>
								<?php } ?>
								<center><a href="?m=pesan_index">Selengkapnya</a></center>
							</div>
						</div> &bull; 
						
						<div class="dropdown">
							<?php
								$nodb = mysqli_query($koneksi, "SELECT SUM(notification_read) as JumlahNotif FROM cmas_notification WHERE notification_read='1' LIMIT 5");
								$nodt = mysqli_fetch_array($nodb);
								
								if ($nodt['JumlahNotif'] == 0) {
									$totn = 0;
								} else {
									$totn = $nodt['JumlahNotif'];
								}
							?>
							<button class="dropbtn">Notifications <span class="notify"><?php echo $totn; ?></span></button>
							<div class="dropdown-content">
								<?php
									$nodb = mysqli_query($koneksi, "SELECT * FROM cmas_notification WHERE notification_read='1' ORDER BY postdated DESC LIMIT 5");
									while($nodt = mysqli_fetch_array($nodb)) {
								?>
									<div class="dropdown-contentrow">
										<font color="grey"><?php echo date_format(date_create($nodt['postdated']), 'd/m/Y H:i:s'); ?></font><br>
										<?php echo $nodt['posted_nama']; ?> > <?php echo $nodt['notification_status']; ?> > <?php echo $nodt['notification_description']; ?>
									</div>
								<?php } ?>
								<center><a href="?m=notification_index">Selengkapnya</a></center>
							</div>
						</div> &bull; 
						<a href="?m=admin_index"><?php echo $udt['admin_nama'];?></a> &bull; <a href="./" target="_blank">Website</a> &bull; <a href="?m=logout">Logout</a>
					</div>
				</div>
			</div>
		</div>
		
		<div id="mids" class="clearfix">
			<div id="midsleft">
				<?php include "menu.php"; ?>
			</div>
			<div id="midsrite">
				<div id="bgbody">
					<div id="bgcontent">
						<div id="bocontent">
							<?php include "libs/functionalert.php"; ?>
							<?php include "cmas/module/mod_core/core.php"; ?>
						</div>
					</div>
				</div>
				
				<div id="bots">
					<div id="bgfooter">
						<div id="bofooter" class="clearfix">
							<div id="copyright">
								<?php echo $sdt['metadata_copyright']; ?>
							</div>
							<div id="developed">
								<a href="https://www.maliniart.com/" target="_blank" title="Visit Us!">
									<?php echo $sdt['metadata_powered']; ?>
								</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</Body>
