<?php
	require_once("config/connect.php");
	require_once("config/pageConfig.php");
	require_once("global_functions.php");
	check_login('', '', 'ENABLERKEY_ADMIN_KONFIGURATION');
?>
<head>
	<title>SITPOS Drucker anlegen</title>
	
	<?php echo META_DATA_ADMIN; ?>

		<style type="text/css">
		<?php include 'include/main.css'; ?>
		<?php include 'include/menue.css'; ?>
		
		a.pme-navigation-0, a.pme-navigation-1, a.pme-navigation-0:hover, a.pme-navigation-1:hover, td.pme-navigation-0, td.pme-navigation-1 {width:160px; }
		.pme-main {width:auto !important; }
		.a4callTestFunction { 		}
		</style>
		
		<script>
		
			// dient zum erstellen von A4 pdf template erstellen. template code -> a4_rechnung_erstellen.php
			// erstelltes template in table pdf_a4_rechung, column a4_template kopieren, von da einen export (add drop table in den einstellungen setzen)
			// den export mit dateinamen pdf_a4_rechnungs_template.sql in den ordner upgrade (zu den anderen *.sql datein) legen. 
			// beim upgrade auf version 1.4.1 wird ein sql restore von ausgeführt.
		
		$(function() {
			$("#menuDivRight").html("<input id='callA4TestBut' style='width:100%; height:30%; border:0; color:#eee;' type='text' oninput='getA4TestInput(this.value)' /><div id='A4TestButDiv' style='display:none;'>Bon Id:<input id='ip_bonId' style='width:55px;' type='text' value='' /><button onclick='ajaxA4PdfPrint()'>Call A4 Ajax</button><br />LS Nr:<input id='ip_lsId' style='width:55px;' type='text' value='' /><button onclick='ajaxA4PdfPrintLs()'>Call Ls A4 Ajax</button></div>").css({ "visibility":"visible"	});
		});
		
		function getA4TestInput(ipVal){
			if($("#callA4TestBut").val().toLowerCase() == 'test' || $("#callA4TestBut").val().toLowerCase() == 'kpkp'){
				$("#A4TestButDiv").css({ "display":"block"			});
				$("#callA4TestBut").val('');
				
			}
			else if($("#callA4TestBut").val().toLowerCase() == '?'){
				$("#callA4TestBut").val('');
				console.log( "test oder kpkp case insensitive -> displays the input field");
			}
			
			
		}
		

		
		// hilfsfunktion ende !!!!!
		function ajaxA4PdfPrint___(){	
			xBonid=$("#ip_bonId").val();
			
			seite_drucken('bonjournalInvoicePrint_A4', xBonid, '', '');
			
		}
		
		//nicht mehr verwendet
		
		function ajaxA4PdfPrint(){	
			xBonid=$("#ip_bonId").val();
				//	if( $("#printCallType").prop("checked") == true) printCallType = 'callFromDb';
				//	else printCallType = false;
			$.ajax({
				type: "POST",
				url: "a4_rechnung_erstellen.php",
				dataType : "html",
				data: {functionKey:'a4_rechnung_testAusdruck', printBonid: xBonid },
				async: false,
				success:function(result){
		
					if(checkJson(result) == true){
						resultArray=JSON.parse(result);
						if(resultArray[0].toLowerCase().indexOf('success') !== -1 && resultArray[1].toLowerCase() == 'browserprint' ){
							window.open(resultArray[2], '_blank');
						}
						else if(resultArray[0].toLowerCase().indexOf('success') !== -1 && resultArray[1].toLowerCase() != 'browserprint' ){							
							//	console.log(" ist printer print\n"+resultArray);							
						}
					}
					else  console.log("Fehler #####\n"+result);				
				}
			
			});
		
		}
		
		function ajaxA4PdfPrintLs(){
			xLsid=$("#ip_lsId").val();
			
			$.ajax({
				type: "POST",
				url: "a4_lieferschein_erstellen.php",
				dataType : "html",
				data: {functionKey:'a4_lieferschein_testAusdruck', printLsId: xLsid },
				async: false,
				success:function(result){
					if(checkJson(result) == true){
						resultArray=JSON.parse(result);
						if(resultArray[0].toLowerCase().indexOf('success') !== -1 && resultArray[1].toLowerCase() == 'browserprint' ){
							window.open(resultArray[2], '_blank');
						}
						else if(resultArray[0].toLowerCase().indexOf('success') !== -1 && resultArray[1].toLowerCase() != 'browserprint' ){							
							//	console.log(" ist printer print\n"+resultArray);							
						}
					}
					else  console.log("Fehler #####\n"+result);				
				
				}
			
			});
		}

		
		</script>
</head>
<body>
	<div id="wrapper_admin" class="wrapper_admin">
	<div id="testkpResultDiv"></div>
<?php

/*
 * IMPORTANT NOTE: This generated file contains only a subset of huge amount
 * of options that can be used with phpMyEdit. To get information about all
 * features offered by phpMyEdit, check official documentation. It is available
 * online and also for download on phpMyEdit project management page:
 *
 * http://platon.sk/projects/main_page.php?project_id=5
 *
 * This file was generated by:
 *
 *                    phpMyEdit version: 5.7.1
 *       phpMyEdit.class.php core class: 1.204
 *            phpMyEditSetup.php script: 1.50
 *              generating setup script: 1.50
 */

// MySQL host name, user name, password, database, and table
menue_anzeigen();

$opts['hn'] = SQL_HOST;
$opts['un'] = SQL_USER;
$opts['pw'] = SQL_PW;
$opts['db'] = SQL_DB;
$opts['tb'] = 'drucker';

// Name of field which is the unique key
$opts['key'] = 'drucker_id';

// Type of key field (int/real/string/date etc.)
$opts['key_type'] = 'int';

// Sorting field(s)
$opts['sort_field'] = array('id');

// Number of records to display on the screen
// Value of -1 lists all records in a table
$opts['inc'] = 15;

// Options you wish to give the users
// A - add,  C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
// $opts['options'] = 'ACPVDF';
$opts['options'] = 'ACPVD';

// Number of lines to display on multiple selection filters
$opts['multiple'] = '4';

// Navigation style: B - buttons (default), T - text links, G - graphic links
// Buttons position: U - up, D - down (default)
$opts['navigation'] = 'UDG';

$opts['buttons']['L']['up'] = array('<<','<','add','>','>>','goto_combo');
$opts['buttons']['F']['up'] = $opts['buttons']['L']['up'];

// Display special page elements
$opts['display'] = array(
	'form'  => true,
	'query' => true,
	'sort'  => true,
	'time'  => true,
	'tabs'  => true
);

// Set default prefixes for variables
$opts['js']['prefix']               = 'PME_js_';
$opts['dhtml']['prefix']            = 'PME_dhtml_';
$opts['cgi']['prefix']['operation'] = 'PME_op_';
$opts['cgi']['prefix']['sys']       = 'PME_sys_';
$opts['cgi']['prefix']['data']      = 'PME_data_';

/* Get the user's default language and use it if possible or you can
   specify particular one you want to use. Refer to official documentation
   for list of available languages. */
$opts['language'] = 'DE-UTF8';

/* Table-level filter capability. If set, it is included in the WHERE clause
   of any generated SELECT statement in SQL query. This gives you ability to
   work only with subset of data from table.

$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200";
*/

/* Field definitions
   
Fields will be displayed left to right on the screen in the order in which they
appear in generated list. Here are some most used field options documented.

['name'] is the title used for column headings, etc.;
['maxlen'] maximum length to display add/edit/search input boxes
['trimlen'] maximum length of string content to display in row listing
['width'] is an optional display width specification for the column
          e.g.  ['width'] = '100px';
['mask'] a string that is used by sprintf() to format field output
['sort'] true or false; means the users may sort the display on this column
['strip_tags'] true or false; whether to strip tags from content
['nowrap'] true or false; whether this field should get a NOWRAP
['select'] T - text, N - numeric, D - drop-down, M - multiple selection
['options'] optional parameter to control whether a field is displayed
  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
            Another flags are:
            R - indicates that a field is read only
            W - indicates that a field is a password field
            H - indicates that a field is to be hidden and marked as hidden
['URL'] is used to make a field 'clickable' in the display
        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
['URLtarget']  HTML target link specification (for example: _blank)
['textarea']['rows'] and/or ['textarea']['cols']
  specifies a textarea is to be used to give multi-line input
  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
['values'] restricts user input to the specified constants,
           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
['values']['table'] and ['values']['column'] restricts user input
  to the values found in the specified column of another table
['values']['description'] = 'desc_column'
  The optional ['values']['description'] field allows the value(s) displayed
  to the user to be different to those in the ['values']['column'] field.
  This is useful for giving more meaning to column values. Multiple
  descriptions fields are also possible. Check documentation for this.
  
  $opts['css']['separator']="-";  -> is eh default kp
*/


	// Funktion listet vom Betriebssystem die Drucker auf und gibt die Namen dann im Array zurück
	// C:\>wmic printer list status
	// Name                                             Status
	// Send To OneNote 2016                             Unknown
	// EPSON SC-T5200 Series                            Degraded
	// SII RP-D10                                       Unknown
	// PDFCreator                                       Unknown
	// Microsoft XPS Document Writer                    Unknown
	// Microsoft Print to PDF                           Unknown
	// Fax                                              Unknown
	// \\sdc01.serviceit.at\RICOH_MPC305_PS_verteilt    Unknown
	// \\sdc01.serviceit.at\EpsonBackOfficeA3_verteilt  Unknown
	function list_printers()
	{
		$printers=array();
		$output="";
		$error_code="";
		exec('wmic printer list status ', $output, $error_code);
		//print_r($output);
		
		$position=strpos($output[0], "Status");
		for($i=1;$i<count($output);$i++)
		{
			$drucker=substr($output[$i],0,$position);
			$drucker=trim($drucker);
			if (!empty($drucker)) array_push($printers, $drucker);
		}
		return($printers);
	}
	
	$drucker=list_printers();
	//print_r($drucker);
	
	$opts['fdd']['drucker_id'] = array(
	  'name'     => 'ID',
	  'select'   => 'T',
	  'options'  => '', // auto increment
	  'maxlen'   => 4,
	  'default'  => '0',
	  'sort'     => true
	);
	$opts['fdd']['funktion'] = array(
	  'name'     => 'Funktion Name',
	  'select'   => 'T',
	  'maxlen'   => 255,
	  'sort'     => true
	);
	$opts['fdd']['win_drucker_name'] = array(
	  'name'     => 'Windows Druckername',
	  'select'   => 'T',
	  'values'	 => $drucker,
	  'maxlen'   => 12,								// postfix already done by " sitPos_replaceComma"
	  'js'   	 => array('required' => 'false'),	// das steht hier damit die funktion PME_js_form_control in der myedit class geladen wird, ansonsten haben wir error beim speichern
	  'sort'     => true
	);
	$opts['fdd']['ist_rechnungsdrucker'] = array(
	  'name'     => 'Ist Rechnungsdrucker',
	  'select'   => 'D',
	  'maxlen'   => 1,
	  'default'  => '0',
	  'values2'   => array('nein'=>'Nein','ja'=>'Ja'),
	  'sort'     => true
	);
	$opts['fdd']['ist_lieferscheindrucker'] = array(
	  'name'     => 'Ist Lieferscheindrucker',
	  'select'   => 'D',
	  'maxlen'   => 1,
	  'default'  => '0',
	  'values2'   => array('nein'=>'Nein','ja'=>'Ja'),
	  'sort'     => true
	);
	$opts['fdd']['ist_a4'] = array(
	  'name'     => 'Ist A4 Drucker',
	  'select'   => 'D',
	  'maxlen'   => 1,
	  'default'  => '0',
	  'values2'   => array('nein'=>'Nein','ja'=>'Ja'),
	  'sort'     => true
	);
	$opts['fdd']['drucker_margin_pdf'] = array(
	  'name'     => 'Pdf Ausdruck Seitenrand O,U,L',
	  'select'   => 'T',
	  'maxlen'   => 255,
	  'sort'     => true
	);
	$opts['fdd']['druckbreite'] = array(
	  'name'     => 'Ausdruck Breite',
	  'select'   => 'T',
	  'maxlen'   => 12
	);
	$opts['fdd']['zoom_factor'] = array(
	  'name'     => 'Zoom Faktor (0.9) "." als Komma',
	  'select'   => 'T',
	  'maxlen'   => 5,
	  'sort'     => false
	);
	$opts['fdd']['ip_adressen'] = array(
	  'name'     => 'Drucker (ip Adr) zuordnen. Mit ; getrennt',
	  'select'   => 'T',
	  'maxlen'   => 255,
	  'sort'     => true
	);
	$opts['fdd']['bildschirm_kueche'] = array(
	  'name'     => 'Name für Bildschirm in Küche',
	  'select'   => 'T',
	  'maxlen'   => 100,
	  'sort'     => true
	);
/*	$opts['fdd']['drucker_margin_html'] = array(
	  'name'     => 'Html Ausdruc Seitenrand T,B,L',
	  'select'   => 'T',
	  'maxlen'   => 255,
	  'sort'     => true
	);
*/
	// Now important call to phpMyEdit
	require_once 'phpmyedit/phpMyEdit.class.php';
	new phpMyEdit($opts);

?>
</div>  <!-- end of wrapper div -->
</body>












