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

    <meta charset="UTF-8"> 
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
	
	<style type="text/css">
	<?php include '../include/main.css'; ?>
	.bon_anzeige {text-align:left; position:relative; float:right;  height:98%; width:98%; margin:0; margin:0; padding:1px 0; 
			border:1px solid gray; border-bottom:1px solid gray; border-left:none; }
	#bon_content_sum_div {height:40px;}
	#bon_content_sum_div div {font-size:2em;height:40px;}
	#bonContent {bottom:42px;}
	</style>
</head>
<?php

	function zeige_kundenmonitor($tisch_id)
	{
	
		$sql=mysql_query("SELECT * FROM offener_bon WHERE bon_id=$tisch_id ORDER by ID ASC");
		echo '<div class="bon_anzeige">
				<div id="bon_content_header_div" >
					<div id="bon_summe" class="bon_summe" >Summe&nbsp;</div><div id="bon_steuer" class="bon_steuer" >Steuer</div>
						<div id="bon_stk" class="bon_stk" >Stk</div><div id="bon_einzelpreis" class="bon_einzelpreis" >Einzel</div>
						<div id="bon_name"  class="bon_name" >&nbsp;Name</div><div class="cclear"></div>
				</div>';
		echo '<div id="bonContent">';
			
		$summe=0;
		if (!$sql) echo mysql_error();
		while ($row=mysql_fetch_assoc($sql))
		{
			$stueck=$row['stueck'];
			$netto=$row['PRICESELL'];
			$steuersatz=$row['tax_rate'];
			$brutto=$netto*(1+$steuersatz);
			$brutto_gesamt=$brutto*$stueck;
			$brutto_anz=number_format($brutto,2,",",".");
			$brutto_gesamt_anz=number_format($brutto_gesamt,2,",",".");
			$stueck_anz=number_format($stueck,1,",",".");
			$summe+=$brutto_gesamt;
			echo "<div class='line_unselected'>";
			echo "	<div id='bon_summe' class='bon_summe'>".$brutto_gesamt_anz."</div>
					<div id='bon_stk' class='bon_stk'>".$stueck_anz."</div>
					<div id='bon_einzelpreis' class='bon_einzelpreis'>".$brutto_anz."</div>
					<div id='bon_name' class='bon_name'>". $row['printname']."</div>";
			echo "</div>";
		}
		echo '</div>';
		$summe_anz=number_format($summe,2,",",".");
		
		echo '<div class="cclear"></div>
		<div id="bon_content_sum_div" >		 
			<div id="bon_sum_field" class="bon_summe_gesamtsumme">'.$summe_anz.'</div>
				<!--<div id="bon_steuer" class="bon_steuer schrift"></div>	-->
				<div id="bon_name" class="bon_name_gesamtsumme">Gesamtsumme:</div>
				<div id="bon_sum_div_customer_name" class="" ></div>
				
				<div class="cclear"></div>
		</div>
	</div>';
		
		echo "</div>";
	}
	

	
	zeige_kundenmonitor($tisch_id);
?>
<script>
var objDiv = document.getElementById("bonContent");
objDiv.scrollTop = objDiv.scrollHeight;
</script>
