<?php
	require_once("config/connect.php");
	require_once("config/pageConfig.php");
	require_once("global_functions.php");
	check_login('', '', 'ENABLERKEY_ADMIN_WARENGRUPPEN');
	
	
?>
<head>
	<title>SITPOS Warengruppe</title>
	
	<?php echo META_DATA_ADMIN; ?>
	
		<script src="jquery/jscolor.min.js"></script>
	<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; }
	</style>
</head>
	
<body >
	<div id="wrapper_admin" class="wrapper_admin">

	
	<script>
	
	// Umrechnen von RGB Farbe auf Hex (#aabbcc)
	function componentToHex(c) {
		var hex = c.toString(16);
		return hex.length == 1 ? "0" + hex : hex;
	}


	function getContrastColor( colour, breakEven=0 ) {
		var r,g,b;			// ursprünglich zur umrechnung von hex farbe auf rgb gedacht, umgebaut auf kontrast, hintergrundfarbe gegeben, text farbe ausgerechnet 
		if ( colour.charAt(0) == "#" ) {	colour = colour.substr(1);	}
		else return false;
		r = colour.charAt(0)+''+colour.charAt(1);
		g = colour.charAt(2)+''+colour.charAt(3);
		b = colour.charAt(4)+''+colour.charAt(5);

		r = parseInt( r,16 );
		g = parseInt( g,16 );
		b = parseInt( b ,16);
		
		averageBrightness=((r*299)+(g*587)+(b*114))/1000;		// druchschnitt ausrechenen
		
		if(averageBrightness >= breakEven) cColor="#000";
		else if(averageBrightness < breakEven) cColor="#fff";
		else cColor="#115";
		
		return cColor;
				//	return "rgb(" + r + "," + g + "," + b + ")";		ist eigentlich die original funktion, sollte einen rgb string retournieren
	}
	
	
	
	function rgbToHex(string) {
		var a = string.split("(")[1].split(")")[0];
		a = a.split(",");
		var b = a.map(function(x){             //For each array element
			x = parseInt(x).toString(16);      //Convert to a base16 string
			return (x.length==1) ? "0"+x : x;  //Add zero if we get only one character
		});
		b = b.join("");
		//alert (b);
		return(b);
	}
	

	// Farbe aus Picker rauslesen und in die jeweiligen Felder setzen
	function setTextColor(picker) {

		text_farbe = document.getElementById('farb_auswahl').style.color;
		text_farbe=rgbToHex(text_farbe);

		$("input[name='PME_data_COLOR']").val('#' + picker.toString());
		$("input[name='PME_data_text_color']").val('#' + text_farbe);	
	}
	
	$(document).ready(function() {

			// Color Picker !!!!!
		var currentColor = 'fff';
		if($("input[name='PME_data_COLOR']").length){
			currentColor=$("input[name='PME_data_COLOR']").val().replace("#", "");
		}
		$("input[name='PME_data_COLOR']").after("<button id='farb_auswahl' style='margin:3px 5px;' class=\"button_none_float button_gross orange jscolor {valueElement:'chosen-value', onFineChange:'setTextColor(this)', value:'"+currentColor+"' }\">Farbe w&auml;hlen</button>");
		
			$('.sitPos_doColor').each(function () {
			  $(this).css({"background-color": $(this).text()});			  
				txtColor= getContrastColor($(this).text(), 128);	// breakeven of brightness as critieria wher to break between black an white.
				$(this).css({"color": txtColor});
			});
			
			$('.pme-header-').removeClass( "sitPos_doColor" ).css({ "color":"#006"});
					
	});
	

	</script>

	<?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();

if (FILIALSYSTEM_IST_FILIALSYSTEM == "ja" && FILIALSYSTEM_UEBERNEHMEN_ZENTRALSYSTEM == "ja" && FILIALSYSTEM_WARENGRUPPEN_ANLEGEN_ANZEIGEN == "ja") 
{
	
	echo '<iframe src="'.FILIALSYSTEM_URL_ZENTRALSYSTEM.'/anlegen_categories.php?token='.FILIALSYSTEM_TOKEN.'" height="100%" width="100%"></iframe>'; 
}
else
{
// Covid-19 neuer Steuersatz 5%	
echo "<br>";
echo '<a href="anlegen_produkte_bulk.php"><button class="button orange">COVID-19 &Auml;nderung 5% Steuersatz</button></a>';
echo "<br><br><br>";
// Covid-19 Ende

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

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

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

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

// 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'] = 'ACPVD';

if (defined('FILIALSYSTEM_IST_FILIALSYSTEM') && FILIALSYSTEM_IST_FILIALSYSTEM == "ja" && defined('FILIALSYSTEM_UEBERNEHMEN_ZENTRALSYSTEM') && FILIALSYSTEM_UEBERNEHMEN_ZENTRALSYSTEM == "ja") {
	$opts['options'] = 'PVF';
}

$opts['triggers']['delete']['before'] = 'anlegen_mark_as_deleted.TR.php';

// 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'];

	$opts['buttons']['L']['down'] = $opts['buttons']['L']['up']; 
	$opts['buttons']['V']['down'] = false;
	$opts['buttons']['C']['down'] = false;

// 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'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';
$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";
*/

$opts['filters'] = "PMEtable0.geloescht = 0";

/* 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.
  
  Required Field ->   #	$opts['fdd']['NAME']['js']['required'] = true;    od = false;
  gibt es auf der ganzen seite kein field mit einer js option gesetzt, kommt ein PME_js_form_control_error
  auf der seite stornogründe wurde das extra dafür eingefügt
*/

	$opts['fdd']['ID'] = array(
	  'name'     => 'ID',
	  'select'   => 'T',
	  'options'  => '', // auto increment
	  'maxlen'   => 11,
	  'default'  => '0',
	  'sort'     => true
	);
	$opts['fdd']['NAME'] = array(
	  'name'     => 'Warengruppe',
	  'select'   => 'T',
	  'js'   	 => array('required' => 'true'),
	  'css'		 =>	array('postfix' => ' sitPos_tableCol_left_150'),
	  'sort'     => true
	);

	$opts['fdd']['PARENTID'] = array(
	  'name'     => 'Übergruppe',
	  'select'   => 'D',
	  'maxlen'   => 11,
	  'default'    => '',
	  'values2'  => array("" => "--- keine ---"), 
		'values'	 => array(
						'table' => 'categories',
						'column' => 'id',
						'description' => 'name',
						'filters' => 'geloescht = 0'
					),
	 'css'		 =>	array('postfix' => ' sitPos_tableCol_left_150'),				
	  'sort'     => true
	);
				/*
				$opts['fdd']['PARENTID'] = array(
				  'name'     => 'PARENTID',
				  'select'   => 'T',
				  'maxlen'   => 11,
				  'default'  => '',
				  'sort'     => false
				);
				*/
							/*	$opts['fdd']['IMAGE'] = array(
								  'name'     => 'Bild',
								  'select'   => 'T',
								  'maxlen'   => 16777215,
								  'textarea' => array(
									'rows' => 5,
									'cols' => 50),
									 'css'		 =>	array('postfix' => ' cellWidth200'),
								  'sort'     => true
								);
							*/
	$opts['fdd']['COLOR']['colattrs'] = 'align="center"';
	$opts['fdd']['COLOR'] = array(
	  'name'     => 'Farben Definition',
	  'select'   => 'T',
	  'maxlen'   => 11, 
	  'sort'     => true
	);
				//  			'css'		 =>	array('postfix' => ' width300'),				scheint hir nicht zu funktionieren, weil es schon einen postfix für diese Spalte gibt ?

	$opts['fdd']['text_color'] = array(
				  'name'     => 'Text Farbe',
				  'select'   => 'T',
				  'maxlen'   => 11,
				  'sort'     => true
				);	
	
	$opts['fdd']['anzeige_reihenfolge'] = array(
	  'name'     => 'Sortierung',
	  'select'   => 'T',
	  'maxlen'   => 11,
	  'default'  => '99',
	  'css'		=>	array('postfix' => ' cellWidth150'),
	  'sort'     => true
	);
	$opts['fdd']['anzeigen'] = array(
	  'name'     => 'Im Katalog anzeigen',
	  'select'   => 'D',
	  'maxlen'   => 1,
	  'values2'   => array(0=>'Nein',1=>'Ja'),
	  'default'  => '1',
	  'sort'     => true
	);
	if(defined('GASTRO_VERSION') && strtolower(GASTRO_VERSION) == 'ja' && defined('BASIS_LIZENZ_VORHANDEN') && strtolower(BASIS_LIZENZ_VORHANDEN) == 'ja'){
		$opts['fdd']['ist_beilage'] = array(
		  'name'     => 'Ist Beilage',
		  'select'   => 'D',
		  'maxlen'   => 1,
		  'values2'   => array('0'=>'Nein','1'=>'Ja'),
		  'default'  => '',
		  'sort'     => true
		);
		
		$opts['fdd']['beilage_basispreis_aendern'] = array(
		  'name'     => 'Beilage Basispreis ändern',
		  'select'   => 'D',
		  'maxlen'   => 1,
		  'values2'   => array('0'=>'Nein','1'=>'Ja'),
		  'default'  => '',
		  'sort'     => true
		);

		$opts['fdd']['artikel_art'] = array(
		  'name'     => 'Speisen Art',
		  'select'   => 'D',
		  'maxlen'   => 32,
		  'values2'  => array("" => "- keine -"),
		  'values'	 => array(
					'table' => 'artikel_art',
					'column' => 'id',
					'description' => 'bezeichnung',
				),
		  
		);
	}
	
	$opts['fdd']['supplyprint'] = array(
	  'name'     => 'Drucker Bestellung',
	  'select'   => 'D',
	  'maxlen'   => 11,
	  'default'    => '',
	  'values2'  => array("" => "--- keiner ---"), 
		'values'	 => array(
						'table' => 'drucker',
						'column' => 'drucker_id',
						'description' => 'funktion'
					),
	 'css'		 =>	array('postfix' => ' sitPos_tableCol_left_150'),				
	  'sort'     => true
	);
		/*	$opts['fdd']['zeitpreis_netto'] = array(
			  'name'     => 'Zeitabh&auml;ngiger Preis netto',
			  'select'   => 'TF',
			  'maxlen'   => 14,
			  'sort'     => true
			);
		die warengruppe hat keinen Steuersatz direkt zugewiesen, zwar unwahrsch das es innerhalb einer Warengruppe unterschiedl Sätze gibt aber möglich
		eingabe weil benutzerfreundlicher in brutto. Wenn aus der Warengruppe der Zeitpreis eingefügt wird vor dem einfügen in den offenen Bon netto errechnet
		*/
	if(defined('BASIS_LIZENZ_VORHANDEN') && strtolower(BASIS_LIZENZ_VORHANDEN) == 'ja'){
		$opts['fdd']['zeitpreis_brutto'] = array(
		  'name'     => 'Zeitabh&auml;ngiger Preis brutto',
		  'select'   => 'TF',
		  'maxlen'   => 14,
		  'sort'     => true
		);
	}
	
	$opts['fdd']['auftragsschein_print'] = array(
	  'name'     => 'Auf Auftragsschein drucken',
	  'select'   => 'D',
	  'values2'   => array('nein'=>'Nein','ja'=>'Ja'),
	  'default'  => ''
	);
	$opts['fdd']['anz_refbons'] = array(
	  'name'     => 'Anz. Referenzbons',
	  'select'   => 'T',
	  'maxlen'   => 5,
	  'default'  => ''
	);
	
	
		// add class by adding a postfix. phpMyEdit does not have a add class function. we do this by adding a postfix with leading " " (space), this will !!!'
			//	 $opts['fdd']['css'] example to manipulate all classes of this page, css options are, prefix, postfix, seperator, ...   see doc's
		$opts['fdd']['COLOR']['css'] = array( 'postfix' => ' sitPos_doColor' );
	//	$opts['fdd']['text_color']['css'] = array( 'postfix' => ' sitPos_doColor' );	// this column not used any more !!!

// Now important call to phpMyEdit
require_once 'phpmyedit/phpMyEdit.class.php';
new phpMyEdit($opts);
}
?>
	</div>  <!-- end of wrapper div -->
	</body>