<?php /** Administration Bootstrap */

	//session_start();
	chdir('../');
	include($_SERVER['DOCUMENT_ROOT'] . '/includes/include_all.inc.php');
	/* **************** HEADER FROM MAIN (REQUIRED FOR MENU) **************/
	include($_SERVER['DOCUMENT_ROOT'] . '/menu.php');
	$userDetails = menuUserDetails($_SESSION['front_user_id']);
	/* ***************** END HEADER FROM MAIN *****************************/

	// current page variable
	$current_page = 'userdata';
	
	include ($_SERVER['DOCUMENT_ROOT'] . '/admin/inc/session_logic.inc.php');
	
	include ($_SERVER['DOCUMENT_ROOT'] . '/admin/header.php'); 
	
	$userId = $_SESSION['front_user_id'];
	$user = getUserDetails($userId);
                                        
?>

<div class="wrap about-wrap">

	<div class="tabs">
	   <div class="tab">
		   <a class="tabslinks" href="index.php">Users</a>
	   </div>

	   <div class="tab">
		   <span class="currentlink">Data</span>
		   
		   <div class="content">
			   <h2><?php if($user_info[0]['first_name']!='' or $user_info[0]['last_name']!='') { echo $user_info[0]['first_name']." ".$user_info[0]['last_name']."'s "; } ?><?php if($user_info[0]['first_name']=='' and $user_info[0]['last_name']==''){ echo "".$user_info[0]['user_email'].""; }elseif($user_info[0]['user_email']!='') { echo "(".$user_info[0]['user_email'].")";} ?> Data  <div style='float:right;'><a href='data.php'>< Back to data list</a></div></h2><br>
                              
				<div class="table-cont">
				<table class="home-table">
					<th>Date Saved</th>
					<th>User Data</th>
					
				   <?php 
                                        
                                        // Collects data from "wp_users" table 
				$stmt = $pdo->prepare("SELECT * FROM wp_groupusers_data WHERE user_id = :userid");
				$stmt->execute(['userid' => $userid]);
				$result = $stmt->fetchAll(PDO::FETCH_ASSOC);

				foreach ($result as $info) {
					echo "<tr><td>" . date('Y-m-d H:i:s', strtotime($info['datetime'])) . " &emsp;</td><td>";
					echo nl2br(urldecode($info['user_data'])) . " &emsp;</td></tr>";
				}
					  ?>
				</table>
				</div>
		   </div> 
	   </div>
	   
	   <div class="tab">
		   <a class="tabslinks" href="groups.php">Groups</a>
	   </div>
	   
		<div class="tab">
		   <a class="tabslinks" href="newuser.php">New User</a>
	   </div>
	   
		<div class="tab">
		   <a class="tabslinks" href="newgroup.php">New Group</a>
	   </div>
	   
	   <div class="tab">
		   <a class="tabslinks" href="statistics.php">Statistics</a>
	   </div>

	   <div class="tab">
		   <a class="tabslinks" href="operations.php">Operations</a>
	   </div>
	</div>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/admin/footer.php'); ?>
</body>
</html>