<?php
require("dbconnect_mysqli.php");
require("functions.php");

$php_script = 'admin_day_planning.php';

$MT[0]='';
$chat_group_ids=$MT;

if (isset($_GET["user"]))							{$user=$_GET["user"];}
	elseif (isset($_POST["user"]))					{$user=$_POST["user"];}

if (isset($_GET["pass"]))							{$pass=$_GET["pass"];}
	elseif (isset($_POST["pass"]))					{$pass=$_POST["pass"];}

if (isset($_GET["query_date"]))							{$query_date=$_GET["query_date"];}
	elseif (isset($_POST["query_date"]))					{$query_date=$_POST["query_date"];}

if (isset($_GET["submit"]))							{$submit=$_GET["submit"];}
	elseif (isset($_POST["submit"]))					{$submit=$_POST["submit"];}



$PHP_SELF=$_SERVER['PHP_SELF'];
$PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF);

$DB=preg_replace("/[^0-9a-zA-Z]/","",$DB);
$user=preg_replace("/\'|\"|\\\\|;| /","",$user);
$pass=preg_replace("/\'|\"|\\\\|;| /","",$pass);

#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$VUselected_language = '';
$stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats,allow_web_debug FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
        if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
#if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
	{
	$row=mysqli_fetch_row($rslt);
	$non_latin =			$row[0];
	$SSenable_languages =	$row[1];
	$SSlanguage_method =	$row[2];
	$SSdefault_language =	$row[3];
	$SSallow_chats =		$row[4];
	$SSallow_web_debug =	$row[5];
	}
$VUselected_language = $SSdefault_language;
if ($SSallow_web_debug < 1) {$DB=0;}
##### END SETTINGS LOOKUP #####
###########################################

# if options file exists, use the override values for the above variables
#   see the options-example.php file for more information
if (file_exists('options.php'))
	{
	require_once('options.php');
	}

header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");                          // HTTP/1.0

if ($clickmute!="1") {$clickmute="0";} // Prevents annoying quirk of playing the audio cue every time you click the tab to view this 

$user = preg_replace("/[^0-9]/","",$user);


if ($non_latin < 1)
	{
	$user = preg_replace('/[^-\_0-9a-zA-Z]/','',$user);
	$pass=preg_replace("/[^-\.\+\/\=_0-9a-zA-Z]/","",$pass);
	}
else
	{
	$user = preg_replace('/[^-_0-9\p{L}]/u','',$user);
	$pass = preg_replace('/[^-\.\+\/\=_0-9\p{L}]/u','',$pass);
	}

$auth=0;
$auth_message = user_authorization($user,$pass,'',0,0,0,0,'agent_day_planning');
if ($auth_message == 'GOOD')
	{$auth=1;}

if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
	{
	echo _QXZ("Invalid Username/Password:")." |$user|$pass|$auth_message|vdc_chat_display|\n";
	exit;
	}

$stmt = "SELECT * FROM admin_day_planner WHERE user=$user AND event_date = '$query_date' ";
$rslt = mysql_to_mysqli($stmt, $link);
$activity_ct = mysqli_num_rows($rslt);
$o = 0;

while($activity_ct > $o)
{
	$activity_data[] = mysqli_fetch_assoc($rslt);
	$o++;
}

header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");                          // HTTP/1.0
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
';
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="css/style.css" />
	<link rel="stylesheet" type="text/css" href="inc/css/style.css" />
	<link rel="stylesheet" type="text/css" href="inc/libs/semantic/dist/semantic.css" />
	<link rel="stylesheet" type="text/css" href="inc/libs/semantic/dist/semantic.min.css" />

	<link rel="stylesheet" type="text/css" href="css/custom.css" />

	<link rel="stylesheet" type="text/css" href="./inc/css/vsidebar.css" />

	<script language="JavaScript" src="calendar_db.js"></script>
	<script src="inc/libs/jquery/jquery.js"></script>
	<script src="inc/libs/semantic/dist/semantic.js"></script>
	<script src="inc/libs/semantic/dist/semantic.min.js"></script>
	<script src="inc/libs/lordicons/lordiIcon.js"></script>
	<title></title>
</head>
<body>
		<div class="ui container">
			<div class="ui segment">
				<form class="ui form" method="GET">
					<input type="hidden" name="user" value="<?php echo $user;?>">
					<input type="hidden" name="pass" value="<?php echo $pass;?>">
					<div class="two fields">
						<div class="field">
							<label>Date:</label>
							<input type="date" name="query_date" value="<?php echo $query_date;?>">
						</div>
						<div class="field">
							<label>&nbsp;</label>
							<input type="submit" name="submit" value="SUBMIT" class="ui teal button">
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="ui container fluid">
			<?php if($activity_data){
				$i = 1;
				foreach($activity_data as $value)
				{ ?>
					<div class="ui red segment centered">
						<table class="ui table">
							<tr style="background-color: #444; color: white;">
								<th colspan="2" align="center">
									<h3>ACTIVITY <?php echo $i; ?></h3>
								</th>
							</tr>
							<tr style="background-color: #f3f3f3;">
								<td>
									<table class="">
										<tr>
											<th>USER</th>
											<td> : <?php echo $value['user'];?></td>
										</tr>
									</table>
								</td>
								<td>
									<table class="">
										<tr>
											<th>Event Date</th>
											<td> : <?php echo $value['event_date'];?></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2">
									<table class="ui table borderless structured">
										<tr style="background-color: #4d4d4d; color: white;">
											<th align="center">Activity Description</th>
										</tr>
										<tr>
											<td><?php echo $value['description'];?></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</div>
			<?php $i++;	}

			} else { ?>
				<div class="ui red segment centered">
					<div class="ui negative message">
						<div class="header">
							No Activity Found For : <?php echo $query_date; ?>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
</body>
</html>