<?php
	session_start();
	require_once("config/connect.php");
	
	global $con;
	$printer=mysql_fetch_array(mysql_query("SELECT distinct win_drucker_name FROM drucker WHERE LOWER(ist_rechnungsdrucker) = 'ja' "));
	echo "SELECT distinct win_drucker_name FROM drucker WHERE LOWER(ist_rechnungsdrucker) = 'ja' ";
	$drucker=$printer['win_drucker_name'];
	echo $drucker."\n";
	//file_put_contents('kpcheckit.txt', $printer);
	$printer=mysql_fetch_array(mysql_query("SELECT wert FROM konfiguration WHERE name = 'PRINTER_ANSTEUERUNG' "));
	echo $printer[0]."\n";
	if(isset($printer[0]) && $printer[0] == 'foxit'){
		$outputTarget = "C:\sitpos\FoxitReaderPortable\App\blank.pdf";
		//c:\xampp\php\php.exe "C:\xampp\htdocs\sITposLanger\initialize_printer.php"
		$command='"C:\sitpos\FoxitReaderPortable\App\Foxit Reader\foxitreader.exe" /t "C:\sitpos\FoxitReaderPortable\App\blank.pdf" "'.$drucker.'" ';
		//$command='"C:\sitpos\FoxitReaderPortable\App\Foxit Reader\foxitreader.exe" /t "'.$outputTarget.'" "'.$drucker.'" ';
		echo "Command: ". $command."\n";
		//file_put_contents('kpcheckit.txt', "\n".basename( __FILE__)." / ". __LINE__ ."   seiteDrucken ansteuerung Foxit: ".PRINTER_ANSTEUERUNG."\n".$command, FILE_APPEND);
		
		exec($command, $output, $error_code);
		var_dump($error_code);
		var_dump($output);
		//file_put_contents('kpcheckit.txt', "\n".basename( __FILE__)." / ". __LINE__ ."   seiteDrucken ansteuerung Foxit: ".PRINTER_ANSTEUERUNG."\n".$error_code, FILE_APPEND);
		
	}
	
	
	
	
?>