<?php include_once($_SERVER['DOCUMENT_ROOT'].'/_ps2020/_global/dir_root.php'); ?>
<?php include_once($_SERVER['DOCUMENT_ROOT'].'/_ps2020/config/cfg_loggedUser.php'); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php"); ?>

<!DOCTYPE HTML>
<!--
	Hielo by TEMPLATED
	templated.co @templatedco
	Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
-->
<html>
	<head>
		<title>Dashboard | GEESE</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />

		<?php include_once(dir_rootPHP.'_global/icon.php'); ?>


		<!-- libs -->
			<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
			<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
			<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>libs/fontAwesome/css/font-awesome.min.css" /> -->
			<!-- <link rel="stylesheet" type="text/css" href="<?php echo dir_root; ?>libs/Bootstrap-4-4.4.1/css/bootstrap.min.css"/> -->
			<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>libs/animate.css" /> -->

			<!-- animation -->
				<link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate.css" />
				<link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_bounce.css" />
				<link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_fade.css" />
				<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_flip.css" /> -->
				<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_other.css" /> -->
				<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_rotate.css" /> -->
				<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_slide.css" /> -->
				<link rel="stylesheet" href="<?php echo dir_root; ?>libs/Animate/animate_zoom.css" />

		<!-- css -->
			<link rel="stylesheet" href="<?php echo dir_root; ?>css/template-hielo/main.css" />

		<!-- css (custom) -->
			<link rel="stylesheet" href="<?php echo dir_root; ?>css/henry_style.css" />
			<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>css/tanuj_style.css" /> -->
			<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>css/karl_style.css" /> -->
			<!-- <link rel="stylesheet" href="<?php echo dir_root; ?>css/harsh_style.css" /> -->

	</head>
	<!-- <body class="subpage"> -->
	<body>

		<!-- Header | Nav -->
			<?php include_once(dir_rootPHP.'_global/navbar/navbar.php'); ?>
			<?php include_once(dir_rootPHP.'_global/navbar/navbar-mobile.php'); ?>

		<!-- Page-Title -->
			<section id="One" class="wrapper style3" style="padding-top: 9rem;">
				<div class="inner">
					<header class="align-center">
						<p>Greenscape Environmental Experience & Learning Survey Experiments</p>
						<h2>Dashboard</h2>
					</header>
				</div>
			</section>

		<!-- Content -->
			<!-- <iframe src="https://pa2004.scem.westernsydney.edu.au/redcap/surveys/?s=JJPXND4PCK" title="W3Schools Free Online Web Tutorials" width="100%" height="800px"></iframe> -->
			<?php
				// if (!isset($_SESSION['user'])){
				// 	include_once(dir_rootPHP.'_a_henry/test.php');
				// }
				if ($_SESSION['accountType'] == 0 || $_SESSION['accountType'] == 1){
					$secFuncClass_hide = 'ctm-hide';
				}
				else
					$secFuncClass_hide = '';
			?>

			<?php
			 //    echo "<h3> PHP List All Session Variables</h3>";
			 //    foreach ($_SESSION as $key=>$val)
			 //    echo $key." ".$val."<br/>";

				// $msg = isset($_SESSION['user']) ? 'SESSION_user "set": yes' : 'SESSION_user "set": no';
				// $msgEm = empty($_SESSION['user']) ? 'SESSION_user "empty": yes' : 'SESSION_user "empty": no';

				// echo $msg;
				// echo '<br>';
				// echo $msgEm;
			?>
			<!-- section-Function -->
			<section id="section_function" class="wrapper style2 <?php echo $secFuncClass_hide; ?>" style="padding-bottom: 0;">
				<div class="inner">

					<!-- section-Title -->
					<header class="align-left" style="margin-bottom: 25px;">
						<h2>Functions</h2>
					</header>

					<!-- section-Content -->
					<div class="grid-style">

						<?php
							$result = $conn->query("SELECT * FROM function ORDER BY function_id ASC");

								if($result) {
									while ( $row = $result->fetch_assoc() ){
										
										$val = explode(',', $row['accountType']);
										foreach ( $val as $v){

											if ( $_SESSION['accountType'] == $v[0] ){

												$id = $row['function_id'];
												$url = $row['function_url'];

												$title = $row['function_name'];
												$subTitle = $row['function_subTitle'];
												$img_src = $row['function_img'];
												$img_ic = $row['function_ic'];

												include(dir_rootPHP.'_global/html/get_clickBox_25.php');
											}
										}
									}
								}
						?>

					</div>
				</div>

				<div class="ctm-toCenter"><div style="height: 100px; width: 80%; border-bottom: 2px solid rgba(0, 0, 0, 0.125);"></div></div>
			</section>

			<!-- section-Survey -->
			<section id="one" class="wrapper style2" style="padding-bottom: 9rem;">
				<div class="inner">

					<!-- section-Title -->
					<header class="align-left" style="margin-bottom: 25px;">
						<h2>Surveys</h2>
					</header>

					<!-- section-Content -->
					<div class="grid-style">

						<?php
							// Check if 'Demographic' is completed
							$demographic_isFinished = 0;
							$disable_survey = '';

							$result_sNonDem = $conn->query("SELECT * FROM user_account WHERE user_id = ".$_SESSION['userID']);
								if($result_sNonDem) {
									while ( $row_nonDem = $result_sNonDem->fetch_assoc() ){
										$demographic_isFinished = $row_nonDem['completed_demographic'];
									}
								}


							$result = $conn->query("SELECT * FROM survey ORDER BY order_id ASC");
							if($result) {
								while ( $row = $result->fetch_assoc() ){
									
									if ($row['survey_id'] > 1){	// (Not) Demographic Survey
										
										if ( $demographic_isFinished == 0 && $row['survey_id'] != 1 && $row['survey_exempt'] != 1){
											$disable_survey = 'ctm-disable';
										}
										else
											$disable_survey = '';

										// echo "<h3>".$disable_survey."</h3>";
									}
						?>
									<div class="animated fadeInUp">
										<div class="box ctm-box ctm-box_toClick <?php echo $disable_survey; ?>">
											<div class="image fit">
												<!-- <img src="<?php echo dir_root; ?>images/pic02.jpg" alt="" /> -->
											</div>
											<div class="content">
												<a href="<?php echo dir_root; ?>account/survey.php?sid=<?php echo($row['survey_id']); ?>" style="text-decoration:none">
													<header class="align-center">
														<p>GEESE Survey</p>
														<h2><?php echo($row['survey_name']); ?></h2>
													</header>
													<!-- <p> Cras aliquet urna ut sapien tincidunt, quis malesuada elit facilisis. Vestibulum sit amet tortor velit. Nam elementum nibh a libero pharetra elementum. Maecenas feugiat ex purus, quis volutpat lacus placerat malesuada.</p> -->
													<footer class="align-center">
														<a href="<?php echo dir_root; ?>account/survey.php?sid=<?php echo($row['survey_id']); ?>" class="button alt">Start now</a>
													</footer>
												</a>
											</div>
										</div>
									</div>
						<?php
								}
							}
						?>

						<!-- <div class="animated fadeInUp">
							<div class="box ctm-box ctm-box_toClick">
								<div class="image fit">
									<img src="<?php echo dir_root; ?>images/pic03.jpg" alt="" />
								</div>
								<div class="content">
									<header class="align-center">
										<p>GEESE Survey</p>
										<h2>Experience-based</h2>
									</header>
									<p> Cras aliquet urna ut sapien tincidunt, quis malesuada elit facilisis. Vestibulum sit amet tortor velit. Nam elementum nibh a libero pharetra elementum. Maecenas feugiat ex purus, quis volutpat lacus placerat malesuada.</p>
									<footer class="align-center">
										<a href="#" class="button alt">Start now</a>
									</footer>
								</div>
							</div>
						</div> -->

					</div>
				</div>
			</section>


		<!-- Footer -->
			<?php include_once(dir_rootPHP.'_global/footer/footer.php'); ?>

		<!-- Scripts -->
			<script src="<?php echo dir_root; ?>js/template-hielo/jquery.min.js"></script>
			<script src="<?php echo dir_root; ?>js/template-hielo/jquery.scrollex.min.js"></script>
			<script src="<?php echo dir_root; ?>js/template-hielo/skel.min.js"></script>
			<script src="<?php echo dir_root; ?>js/template-hielo/util.js"></script>
			<script src="<?php echo dir_root; ?>js/template-hielo/main.js"></script>

		<?php include_once(dir_rootPHP.'_global/tools/popAlert.php'); ?>

		<!-- Scripts (custom) -->
			<script type="text/javascript">
				
				$('#complete_students').click(function(){
					popAlert_show();
				});

			</script>


	</body>
</html>