<?php
		# require_once("config/connect.php");
	require_once("config/pageConfig.php");
	require_once("global_functions.php");
	#check_login('', '', 'ENABLERKEY_ADMIN_AUSWERTUNGEN');			# das würde den Aufruf der Seite für den Finanz Kontroll Export verhindern

	if(strtolower(AUSWERTUNG_PRODUKTNAME_CODIERUNG_ENDE)=='ja')$reportMenuProdCode="<option value='report_on_product_name_end' >Produktname Ende</option>";
	else $reportMenuProdCode="";
	
	$germFinanzDataExport=false;
	$reportDep="";
	if(strtolower(AUSWERTUNG_DEP)=='ja' && defined('LAENDERKENNUNG_DE') && LAENDERKENNUNG_DE == 'A')$reportDep="<option value='report_dep' >Daten Erfassungs Protokoll</option>";
	else if(defined('LAENDERKENNUNG_DE') && LAENDERKENNUNG_DE == 'DE')$germFinanzDataExport="<option value='GDPdU_export' >GDPdU Export</option>";
	 
	if(strtolower(FUNKTION_BUTTON_LIEFERSCHEIN) == 'ja')$reportOffeneLieferscheine="<option value='report_offene_lieferscheine' >Offene Lieferscheine</option>";
	else $reportOffeneLieferscheine="";
	if(defined('GUTSCHEIN_LIZENZ') && strtolower(GUTSCHEIN_LIZENZ) == 'ja' && defined('GUTSCHEIN_KARTE_FUNKTION') && strtolower(GUTSCHEIN_KARTE_FUNKTION) == 'ja'){
		$reportGutscheinFunktion="<option value='report_gutschein_funktion' >Gutscheine Buchungen</option>
								<option value='report_gutschein_short_funktion' >Gutscheine Übersicht</option>";
	}
	else $reportGutscheinFunktion="";
	
	
	$wgList="<option value='' >Warengruppe</option>";
	$wgQl=mysql_query("SELECT ID, name FROM categories");
	while($wgRow=mysql_fetch_array($wgQl)){
		$wgList.="<option value='".$wgRow['ID']."' class=''>".$wgRow['name']."</option>";
		
	}

	$tableList="<option value='' >Tisch</option>";
	$tischQl=mysql_query("SELECT ID, tischName FROM tische");
	while($tableRow=mysql_fetch_array($tischQl)){
		$tableList.="<option value='".$tableRow['ID']."' class=''>".$tableRow['tischName']."</option>";
		
	}

	$kundenList="<option value='' >Kunde</option>";
	$kundenQl=mysql_query("SELECT ID, nachname FROM kunden");
	while($kundenRow=mysql_fetch_array($kundenQl)){
		$kundenList.="<option value='".$kundenRow['ID']."' class=''>".$kundenRow['nachname']."</option>";
		
	}

	$users="<option value='0' >Benutzer</option>";
	$userQ1=mysql_query("SELECT ID, name FROM benutzer where ausblenden=0 and arbeitszeit_schreiben = 1");
	while($userRow=mysql_fetch_array($userQ1)){
		$users.="<option value='".$userRow['ID']."' class=''>".$userRow['name']."</option>";
		
	}

	$usersales="<option value='0' >Bitte Auswählen</option>";
	$usersalesQ1=mysql_query("SELECT ID, name FROM benutzer where ausblenden=0");
	$usersales.="<option value='all' class=''>Alle Benutzer</option>";
	while($userRow=mysql_fetch_array($usersalesQ1)){
		$usersales.="<option value='".$userRow['ID']."' class=''>".$userRow['name']."</option>";
		
	}
	
		$reportMenuAll="<select id='adminReportSelect' class='adminReportSelect orange' >
							<optgroup class='adminReportSelectOptgroup'>
								<option value='' >Report auswählen</option>
								<option value='report_categorie' >Umsatz Warengruppen</option>
								<option value='report_products' >Umsatz Produkte</option>
								<option value='report_tables' >Umsatz Tische</option>
								<option value='report_customer' >Umsatz Kunden</option>
								<option value='report_seller_excl_storno' >Umsatz Verkäufer</option>
								<option value='report_seller' >Umsatz Verkäufer - Stornos unberücksichtigt</option>	
								<option value='report_seller_payment' >Umsatz Verkäufer - Zahlung</option>
								<option value='report_total_user_payment' >Umsatz Verkäufer - Produkte</option>
								<option value='report_total_user_payment_categories' >Umsatz Verkäufer - Warengruppe</option>
								<option value='report_total_revenue' >Gesamt Umsatz</option>
								<option value='report_total_revenue_payment' >Gesamt Umsatz inkl. Zahlung</option>
								<option value='report_free_revenue' >Freie Artikel</option>
								<option value='report_cashbook' >Kassabuch</option>							
								".$reportOffeneLieferscheine.
								 $reportGutscheinFunktion.
								 $reportMenuProdCode.
								 $reportDep."
								 <option value='report_kunden_daten' >Kunden Daten</option>
								<option value='report_auditing' >Auditing</option>
								<option value='report_working_hours' >Arbeitszeiten</option>	
								".$germFinanzDataExport."
							</optgroup>
						</select>";
		$reportMenuFinanzControl="<select id='adminReportSelect' class='adminReportSelect orange' >
							<option value='' >Report auswählen</option>
							<option value='report_categorie' >Umsatz Warengruppen</option>
							<option value='report_products' >Umsatz Produkte</option>						
							".$reportDep."							
						</select>";
		$reportKassenbuch="<select id='adminReportSelect' class='adminReportSelect orange' >
							<option value='' >Report auswählen</option>
							<option value='report_cashbook' >Kassabuch</option>
						</select>";
		$reportKassenbuch="<select id='adminReportSelect' class='adminReportSelect orange' >
						<option value='' >Benutzer auswählen</option>
						<option value='report_cashbook' >test</option>
					</select>";
						
		if($_SESSION['userLevel'] >= ENABLERKEY_ADMIN_AUSWERTUNGEN){
			check_login('', '', 'ENABLERKEY_ADMIN_AUSWERTUNGEN');
			$displayReports = $reportMenuAll;
		}
		else if($_SESSION['userLevel'] >= ENABLERKEY_BENUTZER_FINANZEXPORT){
			check_login('', '', 'ENABLERKEY_BENUTZER_FINANZEXPORT');
			$displayReports = $reportMenuFinanzControl;
		}
		else if($_SESSION['userLevel'] >= ENABLERKEY_BENUTZER_KASSENBUCH){
			$displayReports = $reportKassenbuch;
		}
		else $displayReports=false;
		
		$GDPdUBut=false;
		if(defined('LAENDERKENNUNG_DE') && LAENDERKENNUNG_DE == 'DE'){
			$GDPdUBut="<button id='adminReportGDPdUBut' class='button orange adminReportBut' style='display:none;' 
												onclick=\"displayReportDiv($('#adminReportSelect option:selected').prop('value'), 'downloadReport' )\">Download Report
					</button>";
		}
		$reportList = 	$displayReports.
						"<div id='adminReportSubDivA'>
							<select id='adminReportSubSelectWg' class='adminReportSubSelect orange'>
								".$wgList."
							
							</select>
						</div>
						<div id='adminReportTables'>
							<select id='adminReportSubTables' class='adminReportSubSelect orange'>
								".$tableList."
							
							</select>
						</div>
						<div id='adminReportKunden'>
							<select id='adminReportSubSelectKunden' class='adminReportSubSelect orange'>
								".$kundenList."
							
							</select>
						</div>
						<div id='adminReportSubDivWorkingHours'>
							<select id='adminReportSubSelectWorkingHours' class='adminReportSubSelect orange'>
								".$users."
							
							</select>
						</div>
						<div id='adminReportSubDivUserPayment'>
							<select id='adminReportSubSelectUserPayment' class='adminReportSubSelect orange'>
								".$usersales."
							
							</select>
						</div>
						<div id='adminReportSubDivUserPaymentCategories'>
							<select id='adminReportSubSelectUserPaymentCategories' class='adminReportSubSelect orange'>
								".$usersales."
							
							</select>
						</div>
						<div id='adminReportSubDivB'></div>
						
						<div class='adminReportDateDiv' >
							<button class='dateIpClearBut' onclick=\"cclearFieldVal('reportDateStartField', 'datepickertimeFrom')\">
									<img class='adminReportDelBut' src='images/kp-delete.png' /></button>
								<input id='reportDateStartField' type='text' class='datepicker adminPmeInputMed_2'  name='filter_date_from' size='' />
								<input type='text' id='datepickertimeFrom' class='adminPmeInputMed_3' value='00:00' />
								<p>Von: </p>
							<div class='cclear'></div>
							<button class='dateIpClearBut' onclick=\"cclearFieldVal('reportDateEndField', 'datepickertimeTo')\">
									<img class='adminReportDelBut' src='images/kp-delete.png' /></button>
								<input id='reportDateEndField' type='text' class='datepicker adminPmeInputMed_2' name='filter_date_to'  size='' />
								<input type='text' id='datepickertimeTo' class='adminPmeInputMed_3' value='23:59' />
								<p >Bis: </p>
						</div><div class='cclear'></div>
							<button class='button orange adminReportBut' onclick=\"displayReportDiv($('#adminReportSelect option:selected').prop('value'), 'screen' )\">Report anzeigen</button>
							<button id='adminReportPdfBut' class='button orange adminReportBut' 
												onclick=\"displayReportDiv($('#adminReportSelect option:selected').prop('value'), 'exportPDF' )\">Report Export PDF
							</button>
							".$GDPdUBut."
							<button id='adminReportExcelCsvBut' class='button orange adminReportButCsvL' 
												onclick=\"displayReportDiv($('#adminReportSelect option:selected').prop('value'), 'exportExcelCSV' )\"> Excel CSV&nbsp
							</button>
							<button id='adminReportDosCsvBut' class='button orange adminReportButCsvR' 
												onclick=\"displayReportDiv($('#adminReportSelect option:selected').prop('value'), 'exportDosCSV' )\"> Dos CSV
							</button>
							<button id='downloader' class='' style='visibility:hidden'  download ></button>";

	
	$reportContent="
		<div id='report_categorie' class='reportContentDiv' ></div>
		<div id='report_products' class='reportContentDiv' ></div>
		<div id='report_tables' class='reportContentDiv' ></div>
		<div id='report_customer' class='reportContentDiv'></div>
		<div id='report_seller' class='reportContentDiv'></div>
		<div id='report_seller_payment' class='reportContentDiv'></div>
		<div id='report_seller_excl_storno' class='reportContentDiv'></div>
		<div id='report_total_revenue' class='reportContentDiv'></div>
		<div id='report_total_revenue_payment' class='reportContentDiv'></div>
		<div id='report_total_revenue_payment_categories' class='reportContentDiv'></div>
		<div id='report_total_user_payment' class='reportContentDiv'></div>
		<div id='report_total_user_payment_categories' class='reportContentDiv'></div>
		<div id='report_free_revenue' class='reportContentDiv'></div>
		<div id='report_cashbook' class='schrift_auswertungen_cashbook reportContentDiv'></div>
		<div id='report_on_product_name_end' class='reportContentDiv'></div>
		<div id='report_dep' class='reportContentDiv'></div>
		<div id='report_offene_lieferscheine' class='reportContentDiv'></div>
		<div id='report_gutschein_funktion' class='reportContentDiv'></div>
		<div id='report_gutschein_short_funktion' class='reportContentDiv'></div>
		<div id='report_kunden_daten' class='reportContentDiv'></div>
		<div id='report_auditing' class='reportContentDiv'></div>
		<div id='report_message' class='reportContentDiv'></div>
		<div id='report_working_hours' class='reportContentDiv'></div>
		
		<div id='GDPdU_export' class='reportContentDiv'>GDPdU Report aufgerufen.</div>
	";
	$menH=16;
	 preg_match('/\d+px/', SCHRIFT_DEFAULT, $match);
	if($match[0]== true){
		$fontS=preg_replace('/\D+/', '', $match[0]);
		if($fontS > 16 && $fontS <= 20){	$menH=18;	}
		else if($fontS > 20 && $fontS <= 24){	$menH=22;	}				
	}
	 $contH=93-$menH;
	 
	 # Aufruf der Ajax Report Funktion -> function displayReportDiv()   in global_js_functions.js
	
?>





<!DOCTYPE HTML>
<html>
	<head>
		<title>SITPOS Auswertungen</title>
		<?php 	echo META_DATA_ADMIN;  ?>
		<script src="jquery/datepicker-de.js"></script>
		<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" >
		<style type="text/css">
			<?php include 'include/main.css'; ?>
			<?php include 'include/menue.css'; 
			
			echo "#menu {height:".$menH."%; }";
			echo "#adminReportContent {height:".$contH."%; }";
			echo ".menuDivLeft{ border:none;	} ";
							#	#datepickertimeFrom, #datepickertimeTo
			?>
		
		</style>
		<script>
			$(function() {	
					cashbookLizenz="<?php if(defined('KASSABUCH_LIZENZ')) echo strtolower(KASSABUCH_LIZENZ); else echo 'nein' ?>";
					$("#adminReportSelect").change(function() {		
						$("#adminReportSubDivA").css({ "display":"none"			});
						$("#adminReportTables").css({ "display":"none"			});
						$("#adminReportKunden").css({ "display":"none"			});
						$("#adminReportSubDivWorkingHours").css({ "display":"none"			});
						$("#adminReportSubDivUserPayment").css({ "display":"none"			});
						$("#adminReportSubDivUserPaymentCategories").css({ "display":"none"			});
						$("#adminReportPdfBut, #adminReportExcelCsvBut, #adminReportDosCsvBut, #reportDateStartField, #reportDateEndField, .adminReportDateDiv, #datepickertimeFrom, #datepickertimeTo ").prop( "disabled", false ).removeAttr('style');
						$("#adminReportGDPdUBut").css({"display":"none"});
						
						if($("#adminReportSelect option:selected").val() == 'report_seller_payment'){
							$(".adminReportDateDiv").css({ "display":"none"			});
							$("#adminReportExcelCsvBut, #adminReportDosCsvBut").prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});
						//	$("#menuDivLeft" ).add( "<input type='text' class='' value='X' />" );
																			
							xmlhttp=GetXmlHttpObject();
							xmlhttp.open("POST", "ajax_funktionen_kp.php", false);
							xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
							sendCont="functionKey=getLastAbschlId";
							xmlhttp.send(sendCont);
							resp=xmlhttp.responseText;
							
						//	$( "<div id='reportSellIpFieldDiv'>Kassenab-<br />schluss Id:<br /><input type='text' selected id='reportSellIpField' onclick='this.select()' value="+resp+" /></div>" ).appendTo("#adminOperatorDiv");
							$("#adminReportSubDivB").html("Kassenabschluss Id:<input type='text' selected id='reportSellIpField' onclick='this.select()' value="+resp+" />").css({"display":"block"});
			
						}
						else { 
							$("#reportSellIpFieldDiv").remove();
							$("#adminReportSubDivB").html("").css({"display":"none"});
							$(".adminReportDateDiv").css({ "display":"block"			});	
							if($("#adminReportExcelCsvBut").prop("disabled") == true){
								$("#adminReportExcelCsvBut, #adminReportDosCsvBut").prop( "disabled", false ).removeAttr('style');
							}
						}
						if($("#adminReportSelect option:selected").val() == 'report_dep'){
							$("#adminReportPdfBut, #adminReportExcelCsvBut, #adminReportDosCsvBut").prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});					
						}
						else if(($("#adminReportSelect option:selected").val() == 'report_total_revenue') || ($("#adminReportSelect option:selected").val() == 'report_total_revenue_payment')){				
							$("#adminReportKunden").css({ "display":"block"			});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_products'){				
							$("#adminReportSubDivA").css({ "display":"block"			});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_tables'){				
							$("#adminReportTables").css({ "display":"block"			});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_offene_lieferscheine'){				
							$("#adminReportExcelCsvBut, #adminReportDosCsvBut").prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_kunden_daten'){	
							$("#adminReportPdfBut, #reportDateStartField, #reportDateEndField, #datepickertimeFrom, #datepickertimeTo").prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_cashbook'){	
							if(cashbookLizenz && cashbookLizenz == 'ja'){
								$("#reportDateStartField, #reportDateEndField").val('').prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});
								$("#datepickertimeFrom").val('00:00').prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});
								$("#datepickertimeTo").val('23:59').prop( "disabled", true ).css({"background":"#aaa", "cursor":"default", "border":"none"	});
							}							
						}
						else if($("#adminReportSelect option:selected").val() == 'GDPdU_export'){
							$("#adminReportExcelCsvBut, #adminReportDosCsvBut, #adminReportPdfBut").css({"display":"none"	});
							$("#adminReportGDPdUBut").css({"display":"block"	});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_working_hours'){				
							$("#adminReportSubDivWorkingHours").css({ "display":"block"			});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_total_user_payment'){				
							$("#adminReportSubDivUserPayment").css({ "display":"block"			});
						}
						else if($("#adminReportSelect option:selected").val() == 'report_total_user_payment_categories'){				
							$("#adminReportSubDivUserPaymentCategories").css({ "display":"block"			});
						}
						
					})
			});
			
			
			function checkSigExe(testParm){
				xmlhttp=GetXmlHttpObject();
				xmlhttp.open("POST", "include/rk_exe_test.php", false);
				xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
				sendCont="functionKey=exeTest&testParm="+testParm;
				xmlhttp.send(sendCont);
				resp=xmlhttp.responseText;
				alert(resp);
			}
			
			function displayGsInfo(bookingId){
				//$("#gsReportInfoDiv").html(" des is die ID ->>>>>>>>>> "+bookingId);
			
			}
			
			
			
			gdpduCompany=0;
			gdpduStandort=0;
			gdpduComment=0;
			
		<?php 

			if(defined('LAENDERKENNUNG_DE') && LAENDERKENNUNG_DE == 'DE'){
		?>
				gdpduCompany="<?php echo strlen(GDPdU_EXPORT_FIRMA); ?>";
				gdpduStandort="<?php echo strlen(GDPdU_EXPORT_STANDORT); ?>";
				gdpduComment="<?php echo strlen(GDPdU_EXPORT_COMMENT); ?>";
		<?php
			}
			
		?>
				
		</script>
		
	</head>
	<body >

		<div id="wrapper_admin" class="wrapper_admin">
			<div id="kassabuch_modal" class="modal">
				<div class='modal-content'>
					<span class="closeModal" onclick="kassabuch_modal_close()">×</span>
					<div class="modal-body">
						<div id="cashbookModalContent">
					
						</div>
					</div>
				</div>
			
			</div>
			<div id="adminOperatorDiv" class="schrift" ><?php  echo  $reportList ?></div>
			<?php 	menue_anzeigen();?>
			<div id="adminReportContent">
				<?php echo $reportContent; ?>
			</div>
			
		</div>
	</body>
</html>






















