<?php
	require_once("../config/connect.php");
	require_once("../config/pageConfig.php");
	require_once("../global_functions.php");
	//require_once("../ajax_funktionen.php");
	
	$page = $_SERVER['PHP_SELF'];
	$sec = "2";
	
?>
<html> 
<head> 

    <meta charset="UTF-8"> 
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	<style type="text/css">
	<?php include '../include/main.css'; ?>
	
	#slideshow { 
		margin: 2px auto; 
		position: absolute; 
		width: 38%; 
		height: 80%; 
		padding: 2px; 
		box-shadow: 0 0 0px rgba(0,0,0,0.4); 
	}

	#slideshow > div { 
		position: absolute; 
		top: 0px; 
		left: 5px; 
		right: 5px; 
		bottom: 5px; 
	}
	.div_left {
		float:left;
		width:30%;
	}
	.div_right {
		float:right;
		width:60%;
	}
	
	.div_leftNull { position:relative; float:left; width:0%;					}
	.div_rightFull { position:relative; float:left; width:100%;			}
	
	</style>
</head>
<?php
	$kpTestOp="";
	$run_slideshow=false;
	$cssLeft="";
		
		# KPE Dez 2020 -> Abdrehen von "Werbe"Bilder im Kundenmonitor
		#   !!!!!   der images Folder ist NICHT root/images sondern -> sitpos/display/images

	function show_slideshow()
	{
		global $run_slideshow;
		global $cssLeft;
		global $cssRight;

		$imagedir="images/";
		echo '<div id="slideshow">';
		$files=glob($imagedir.'*');
		
		if (count($files)>1)
		{
			$run_slideshow=true;
			$cssLeft="div_left";
			$cssRight="div_right";
			
			foreach($files as $filename){
			//echo basename($filename) . "\n";
				echo '<div>';
				echo '<img src="'.$filename.'" style="width:100%;">';
				echo '</div>';
			}
		}
		else{
			$cssLeft="div_leftNull";
			$cssRight="div_rightFull";
		}
		
		
		echo '</div>';
		
		if($run_slideshow == true){
			
		}
		else{
			
		}
		
		
	}
	
	$tisch_id=1;
	if (isset($_REQUEST['tisch_id']))
	{
		$tisch_id=$_REQUEST['tisch_id'];
	}
	else
	{
		if (file_exists('tisch_id_anzeigen.txt'))
		{
			if ($tisch_id=file_get_contents('tisch_id_anzeigen.txt'))
			{
				//echo $tisch_id;
			}
		}
	}
	
	
	
	echo '<div class="'.$cssLeft.'">';
		show_slideshow();
	echo '</div>';
	echo '<div class="'.$cssRight.'">';
	echo '<iframe marginwidth="0" marginheight="0" width="100%" height="80%" scrolling="no" frameborder=0 src="kundenmonitor_rechts.php?tisch_id='.$tisch_id.'">
</iframe>';
	echo '</div>';

?>
<script src="../jquery/jquery-2.1.1.min.js"></script>
<script>
<?php
if ($run_slideshow)
{
	echo '
	$("#slideshow > div:gt(0)").hide();

	setInterval(function() { 
	  $("#slideshow > div:first")
		.fadeOut(1000)
		.next()
		.fadeIn(1000)
		.end()
		.appendTo("#slideshow");
	},  5000);
	';
}
?>
</script>
<?php



?>
</html>
