<?php
  require_once("session_check.php");
  require_once("../classes/main_classes.php");

  if($sign_in_status=="out"){
    header("location:login.php");
  }

  //OBJECTS
  $retrieveObj=new RETRIEVE();
  $rowcountObj=new ROWCOUNT();
  $allrowcountObj=new ALLROWCOUNT();

  $get_profile_info=$retrieveObj->retriever("users","*","user_id",$user_id,"fetch");

  if($get_profile_info=="1020"){
    die("<p class='alert alert-warning'>Something went wrong</p>");
  }

?>

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<title>Administrators Panel - Provama</title>
	<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
	<link rel="stylesheet" href="assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
	<link rel="stylesheet" href="assets/css/ready.css">
	<link rel="stylesheet" href="assets/css/demo.css">
	<link rel="stylesheet" href="assets/css/main.css">
	<link href="../lib/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css">
	<link rel="stylesheet" type="text/css" href="../lib/simditor-2.3.28/site/assets/styles/simditor.css" />
	<link href="../lib/croppie/croppie.css" rel="stylesheet">
	<link href="../css/universal.css" rel="stylesheet">
	<link href="../img/provama_logo.png" rel="icon">
</head>
<body>
	<div class="wrapper">
		<div class="main-header">
			<div class="logo-header">
				<a href="index.php" class="logo">
					<img src="../img/provama_logo.png" alt="provama logo" title="Product Value Making" style="max-width: 160px;">
				</a>
				<button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse" data-target="collapse" aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
					<span class="navbar-toggler-icon"></span>
				</button>
				<button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
			</div>
			<nav class="navbar navbar-header navbar-expand-lg">
				<div class="container-fluid">
					
					<!--form class="navbar-left navbar-form nav-search mr-md-3" action="">
						<div class="input-group">
							<input type="text" placeholder="Search ..." class="form-control">
							<div class="input-group-append">
								<span class="input-group-text">
									<i class="la la-search search-icon"></i>
								</span>
							</div>
						</div>
					</form-->
					<ul class="navbar-nav topbar-nav ml-md-auto align-items-center">
						<!--li class="nav-item dropdown hidden-caret">
							<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="la la-envelope"></i>
							</a>
							<div class="dropdown-menu" aria-labelledby="navbarDropdown">
								<a class="dropdown-item" href="#">Action</a>
								<a class="dropdown-item" href="#">Another action</a>
								<div class="dropdown-divider"></div>
								<a class="dropdown-item" href="#">Something else here</a>
							</div>
						</li-->
						<li class="nav-item dropdown hidden-caret">
							<?php
	                            $get_notifications_count=$rowcountObj->rowcounter("admin_notifications JOIN admin_notification_targets ON admin_notifications.an_id=admin_notification_targets.an_id","*","admin_notification_targets.ant_seen_status",0);
	                            $get_notifications_count_view="";
	                            if($get_notifications_count==0){
	                                $notification_effect="";
	                            }else{
	                                $get_notifications_count_view=$get_notifications_count;
	                            }

	                            $get_notifications=$retrieveObj->retriever("admin_notifications JOIN admin_notification_targets ON admin_notifications.an_id=admin_notification_targets.an_id WHERE admin_notification_targets.user_id='$user_id' ORDER BY admin_notifications.an_id DESC LIMIT 5","*","fetchAll");
	                        ?>
							<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="la la-bell"></i>
								<span class="notification" id="notification_count_id1"><?php echo $get_notifications_count ?></span>
							</a>
							<ul class="dropdown-menu notif-box" aria-labelledby="navbarDropdown">
								<li>
									<div class="dropdown-title ">You have <span id="notification_count_id2"> <?php echo $get_notifications_count ?></span>  unseen notification/s</div>
								</li>
								<li>

									<!--div class="notif-center">
										<a href="#" onclick="blog_post_comments_view()">
											<div class="notif-icon notif-primary"> <i class="fas fa-blog"></i> </div>
											<div class="notif-content">
												<span class="block">
													New blog comment
												</span>
												<span class="time">20/12/2020 15:00:00</span> 
											</div>
										</a>
									</div-->


									<?php
		                                if($get_notifications!="1020"){
		                                    $notification_icon_properties="";
		                                    $onclick_event_function="";
		                                    foreach ($get_notifications as $notification_) {
		                                        $an_source_id=$notification_->an_source_id;
		                                        if($notification_->an_source=="blog_comment"){
		                                            $notification_icon_properties="fas fa-blog ";
		                                            $notification_icon_properties_bg=" notif-primary ";
		                                            $onclick_event_function=" blog_post_comment_reply_view($an_source_id) ";
		                                        }else if($notification_->an_source=="blog_reply"){
		                                            $notification_icon_properties="fas fa-blog ";
		                                            $notification_icon_properties_bg=" notif-primary ";
		                                            $onclick_event_function=" blog_post_comment_reply_view($an_source_id) ";
		                                        }else if($notification_->an_source=="contact_us_message"){
		                                            $notification_icon_properties="fas fa-envelope ";
		                                            $notification_icon_properties_bg=" notif-success ";
		                                            $onclick_event_function=" not_contact_us_details_view($an_source_id) ";
		                                        }
		                            ?>
		                            	<div class="notif-center <?php if($notification_->ant_seen_status=="0"){echo " bg-light ";} ?>" onclick="$(this).removeClass('bg-light')" onmousedown="refresh_notifications_count()">
											<a href="#" onclick="<?php echo $onclick_event_function ?>">
												<div class="notif-icon <?php echo $notification_icon_properties_bg; ?>"> <i class="<?php echo $notification_icon_properties; ?>"></i> </div>
												<div class="notif-content">
													<span class="block" style="text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">
														
														<?php echo $notification_->an_message ?>
													</span>
													<span class="time"><?php echo date("d-m-Y H:i:s", strtotime($notification_->an_date_time))  ?></span> 
												</div>
											</a>
										</div>
		                                
		                            
		                            <?php
		                                    }
		                                }else{
		                            ?>
		                                <p class="alert alert-info">You currently do not have notifications</lp>
		                            <?php
		                                }

		                                if($get_notifications!="1020"){
		                            ?>
		                            <?php
		                                }
		                            ?>
								</li>
								<li>
									<a class="see-all" href="javascript:void(0);" onclick="notifications_view()"> <strong>See all notifications</strong> <i class="la la-angle-right"></i> </a>
								</li>
							</ul>
						</li>
						<li class="nav-item dropdown">
							<a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false"> 
								<!--img src="../img/profile_pictures/mwenewezi.png" alt="user-img" width="36" class="img-circle"-->
								<span class="hand_cursor mx-auto px-0" data-toggle="collapse" data-target="#update_profile_container" id="profilePhotoSubContainer" onclick="profile_view()">
					              <?php 
					                if($get_profile_info!="1020"){
					                  if(!empty($get_profile_info->photo)){
					                    echo '<img id="sub_profile_picture" src="../img/profile_pictures/'.$get_profile_info->photo.'?'.date("Y-m-d").time().'" alt="Profile" width="30px" class="rounded-circle my-2 text-light font-weight-bold" > ';
					                  }else{
					                    echo "<span class='fas fa-user text-dark rounded' style='padding:8px 10px;'></span>";
					                  }
					                  
					                }else{
					                  echo "<span class='fas fa-user text-dark rounded' style='padding:8px 10px;'></span>";
					                }
					                  
					              ?>
					            </span>
								<span class="px-0">Mwenewezi</span></span> 
							</a>
							<ul class="dropdown-menu dropdown-user">
								<li>
									<div class="user-box">
										<div class="u-img">
											<!--img src="../img/profile_pictures/mwenewezi.png" alt="user"-->
											<span class="hand_cursor mx-auto" id="profilePhotoSubContainer2" onclick="profile_view()">
								              <?php 
								                if($get_profile_info!="1020"){
								                  if(!empty($get_profile_info->photo)){
								                    echo '<img id="sub_profile_picture2" src="../img/profile_pictures/'.$get_profile_info->photo.'?'.date("Y-m-d").time().'" alt="Profile" width="30px" class="rounded-circle my-2 text-light font-weight-bold" > ';
								                  }else{
								                    echo "<span class='fas fa-user fa-4x text-dark rounded' style='padding:8px 10px;'></span>";
								                  }
								                  
								                }else{
								                  echo "<span class='fas fa-user fa-4x text-dark rounded' style='padding:8px 10px;'></span>";
								                }
								                  
								              ?>
								            </span>
										</div>
										<div class="u-text">
											<h4>Mwenewezi</h4>
											<p class="text-muted">mwenewezi@gmail.com</p><a href="#!" class="btn btn-rounded btn-primary btn-sm" onclick="profile_view()">View Profile</a></div>
										</div>
									</li>
									<div class="dropdown-divider"></div>
									<!--a class="dropdown-item" href="#"><i class="fas fa-cog"></i> Settings</a>
									<div class="dropdown-divider"></div-->
									<a class="dropdown-item" href="#" onclick="logout()"><i class="fa fa-power-off"></i> Logout</a>
								</ul>
								<!-- /.dropdown-user -->
							</li>
						</ul>
					</div>
				</nav>
			</div>
			<div class="sidebar">
				<div class="scrollbar-inner sidebar-wrapper">
					<div class="user text-dark font-weight-bold">
						<span class="px-2">Administrators' Panel</span>
					</div>
					<ul class="nav">
						<li class="nav-item sidebar_menu_ active" id="sidebar_menu_dashboard">
							<a href="#!" onclick="dashboard_view()">
								<i class="la la-dashboard"></i>
								<p>Dashboard</p>
							</a>
						</li>
						<li class="nav-item sidebar_menu_" id="sidebar_menu_users">
							<a href="#!" onclick="users_view()">
								<i class="la la-users"></i>
								<p>Users</p>
								<span class="badge badge-count"><?php echo $allrowcountObj->allrowcounter("users","*"); ?></span>
							</a>
						</li>
						<li class="nav-item sidebar_menu_" id="sidebar_menu_products">
							<a href="#!" onclick="products_view()">
								<i class="la la-cubes"></i>
								<p>Products</p>
								<span class="badge badge-count"><?php echo $allrowcountObj->allrowcounter("products","*"); ?></span>
							</a>
						</li>
						<li class="nav-item sidebar_menu_" id="sidebar_menu_miscellaneous_goods">
							<a href="#!" onclick="miscellaneous_goods_view()">
								<i class="la la-cubes"></i>
								<p>Miscellaneous goods</p>
								<span class="badge badge-count"><?php echo $allrowcountObj->allrowcounter("miscellaneous_goods","*"); ?></span>
							</a>
						</li>
						<li class="nav-item sidebar_menu_" id="sidebar_menu_blog">
							<a href="#!" onclick="blog_view()">
								<i class="fas fa-blog"></i>
								<p>Blog</p>
								<span class="badge badge-count"><?php echo $allrowcountObj->allrowcounter("blog","*"); ?></span>
							</a>
						</li>
						<li class="nav-item sidebar_menu_" id="sidebar_menu_blog">
							<a href="#!" onclick="contact_us_view()">
								<i class="fas fa-envelope"></i>
								<p>Contact</p>
								<span class="badge badge-count"><?php echo $allrowcountObj->allrowcounter("contact_us","*"); ?></span>
							</a>
						</li>
						
					</ul>
				</div>
			</div>
			<div class="main-panel">
				<div class="content">
					<div class="container-fluid" id="main_section">
						
					</div>
				</div>
				<div id="page-bottom">
					
				</div>
				<!--footer class="footer">
					<div class="container-fluid">
						<nav class="pull-left">
							<ul class="nav">
								<li class="nav-item">
									<a class="nav-link" href="http://www.themekita.com">
										ThemeKita
									</a>
								</li>
								<li class="nav-item">
									<a class="nav-link" href="#">
										Help
									</a>
								</li>
								<li class="nav-item">
									<a class="nav-link" href="https://themewagon.com/license/#free-item">
										Licenses
									</a>
								</li>
							</ul>
						</nav>
						<div class="copyright ml-auto">
							2018, made with <i class="la la-heart heart text-danger"></i> by <a href="http://www.themekita.com">ThemeKita</a>
						</div>				
					</div>
				</footer-->
			</div>
		</div>
	</div>
	<!-- Modal -->
	<div class="modal fade" id="modalUpdate" tabindex="-1" role="dialog" aria-labelledby="modalUpdatePro" aria-hidden="true">
		<div class="modal-dialog modal-dialog-centered" role="document">
			<div class="modal-content">
				<div class="modal-header bg-primary">
					<h6 class="modal-title"><i class="la la-frown-o"></i> Under Development</h6>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body text-center">									
					<p>Currently the pro version of the <b>Ready Dashboard</b> Bootstrap is in progress development</p>
					<p>
						<b>We'll let you know when it's done</b></p>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="assets/js/core/jquery.3.2.1.min.js"></script>
<script src="assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="assets/js/core/popper.min.js"></script>
<script src="assets/js/core/bootstrap.min.js"></script>
<script src="assets/js/plugin/chartist/chartist.min.js"></script>
<script src="assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>
<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>
<script src="assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>
<script src="assets/js/plugin/chart-circle/circles.min.js"></script>
<script src="assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="assets/js/ready.min.js"></script>
<script src="../lib/datatables/jquery.dataTables.min.js"></script>
<script src="../lib/datatables/dataTables.bootstrap4.min.js"></script>

<script type="text/javascript" src="../lib/simditor-2.3.28/site/assets/scripts/module.js"></script>
<script type="text/javascript" src="../lib/simditor-2.3.28/site/assets/scripts/hotkeys.js"></script>
<script type="text/javascript" src="../lib/simditor-2.3.28/site/assets/scripts/uploader.js"></script>
<script type="text/javascript" src="../lib/simditor-2.3.28/site/assets/scripts/simditor.js"></script>

<script type="text/javascript" src="../lib/croppie/croppie.js"></script>

<script src="https://cdn.jsdelivr.net/npm/gasparesganga-jquery-loading-overlay@2.1.7/dist/loadingoverlay.min.js"></script>

<!--script src="assets/js/demo.js"></script-->
<script src="../js/universal.js?<?php echo date("Y-m-d").time() ?>"></script> 
<script src="js/js.js?<?php echo date("Y-m-d").time() ?>"></script> 
<script type="text/javascript">
	$(document).ready(function(){
		dashboard_view()
	})
</script>
</html>