<?php
	require_once("config/connect.php");
	require_once("config/pageConfig.php");
	require_once("global_functions.php");
	check_login('', '', 'ENABLERKEY_ADMIN_AUSWERTUNGEN');
	
	$tOp="";
/*	$export_string="";
	
	$getData=mysql_query("SELECT abgeschlossener_bon.bon_id, gesamt_summe, bon_erstellt_datum FROM abgeschlossener_bon
							WHERE bon_erstellt_datum > '2016-04-15 00:00:00' AND bon_erstellt_datum < '2016-04-29 23:59:59' ");
	while($dataRow=mysql_fetch_array($getData)){
		$taxData=mysql_query("SELECT tax_rate, gesamt_betrag FROM abgeschlossener_bon_steuern WHERE bon_id = ".$dataRow['bon_id']." ");
	
		$taxN=number_format(0,2,".","");
		$tax1=number_format(0,2,".","");
		$tax2=number_format(0,2,".","");
		$taxNull=number_format(0,2,".","");
		$taxB=number_format(0,2,".","");		
		
		while($taxRow=mysql_fetch_array($taxData)){
			
			if($taxRow['tax_rate'] == number_format(0.2,4,".","")) $taxN=number_format((1+$taxRow['tax_rate'])*$taxRow['gesamt_betrag'],2,",",""); 		
			if($taxRow['tax_rate'] == number_format(0.13,4,".","")) $tax1=number_format((1+$taxRow['tax_rate'])*$taxRow['gesamt_betrag'],2,",","");			
			if($taxRow['tax_rate'] == number_format(0.10,4,".",""))$tax2=number_format((1+$taxRow['tax_rate'])*$taxRow['gesamt_betrag'],2,",",""); 
			if($taxRow['tax_rate'] == number_format(0,4,".",""))$taxNull=number_format((1+$taxRow['tax_rate'])*$taxRow['gesamt_betrag'],2,",","");		
			if($taxRow['tax_rate'] == number_format(0.12,4,".",""))$taxB=number_format((1+$taxRow['tax_rate'])*$taxRow['gesamt_betrag'],2,",",""); 
			
			
	
		}
		
		
		
		$tOp.=$dataRow['bon_id']." -- ".$dataRow['gesamt_summe']."--N:".$taxN."--1:".$tax1."2:".$tax2."Null:".$taxNull."B:".$taxB."-<br />";
		
		$dDatum=preg_split('/\s/', $dataRow['bon_erstellt_datum']);
		
		
		$export_string.=KASSA_ID."_Receipt-ID-".$dataRow['bon_id']."_".$dDatum[0]."T".$dDatum[1]."_".$taxN."_".$tax1."_".$tax2."_".$taxNull."_".$taxB."\n";
	
	}
	
	
	file_put_contents("fiscalExport.txt", $export_string,   FILE_APPEND)
	*/
?>
<head>
<meta charset="utf-8">
<title>SITPOS Fiscal Export</title>
	<?php echo META_DATA_ADMIN; ?>
	<script src="jquery/datepicker-de.js"></script>

	<link rel="stylesheet" type="text/css" href="include/menue.css">
	<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'; ?>
	
	#ui-datepicker-div { left:500px;}
	</style>
	
	<script>
	
		function depTestFunction(){
		
			xmlhttp=GetXmlHttpObject();
			xmlhttp.open("POST", "ajax_funktionen.php", false);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
			sendCont="funktion=write_data_export_protocol_table";
		
			xmlhttp.send(sendCont);
			resp=xmlhttp.responseText;
			
			
			alert("gfgfgfgffg"+resp);
		
		}
		
		function exportDepData(){
			dateFrom=$("#depDateFrom" ).val();
			dateTo=$("#depDateTo" ).val();
			
			if(dateFrom == "" || dateTo == "") return false;
			
			xmlhttp=GetXmlHttpObject();
			xmlhttp.open("POST", "ajax_funktionen_kp.php", false);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
			sendCont="functionKey=exportDepData&depDateFrom="+dateFrom+"&depDateTo="+dateTo;
		
			$.ajax({
			type: "POST",
			url: "ajax_funktionen_kp.php",
			dataType : "text",
			data: "",
			async: true,
			success:function(rResponse){
				alert(rResponse);
			}
		
		}
		
		$(function() {
			$("#depDateFrom" ).datepicker({	dateFormat: "yy-mm-dd"		});
			$("#depDateTo" ).datepicker({	dateFormat: "yy-mm-dd"		});
			
			$(".ui-datepicker").css({  "margin":"-22 0 0 200", "z-index": 1000	});
		});
		
		
		function checkMail(){
			alert("ggffgfgfgf");
		
		}
	
	
	
	</script>
	
	
	

</head>

<body>
	<button class="button_gross button_none_float organge" onclick="depTestFunction()" />Fire Write to DEP Table</button>
	<br /><br /><br />
	<hr />
	Datum Start: <input type="text" id="depDateFrom" value="" /><br /><br />
	Datum Ende: <input type="text" id="depDateTo" value="" /><br /><br />
	<button class="button_gross button_none_float organge" onclick="exportDepData()" />Export DEP Data</button>

	<?php 
		echo $tOp; 
	
	
	
	
	?>

	<hr />
	<hr />
	
	<button class="button_gross button_none_float organge" onclick="checkMail()" />Test Php Mailer</button>













</body>
</html>
