<?php
// V4.09 RFR	Filiasystem geändert, dass css angezeigt wird (URL ohne / angeben, weil zwei // das Problem machen)
	require_once("config/connect.php");
	require_once("config/pageConfig.php");
	require_once("global_functions.php");
	require_once("sITeditor/sITeditor.php");
	require_once("api/telefon/telefon_funktionen.php");
	
	check_login('', '', 'BENUTZERRECHT_KUNDEN_ANLEGEN');
	
?>
<link rel="stylesheet" type="text/css" href="sITeditor/sITeditor.css">
	<script src="include/global_js_functions.js"></script>
	<style type="text/css">
		<?php include 'include/main.css'; ?>
		<?php include 'include/menue.css'; ?>
		.tablesorter-header-inner button{height:40px;width:120px;}
		table, th, td img{width:40px;height:40px;}
	</style>

	
	
</head>
<body>

<?php

if (FILIALSYSTEM_IST_FILIALSYSTEM == "ja" && FILIALSYSTEM_SYNCHRONISATION_KUNDEN_BON == "ja") 
{
	menue_anzeigen();
	echo '<iframe src="'.FILIALSYSTEM_URL_ZENTRALSYSTEM.'kunden.php?token='.FILIALSYSTEM_TOKEN.'" height="100%" width="100%"></iframe>'; 
}
else
{
	
$kunden_id=0;
$autoedit=false;

if (isset($_REQUEST['kunden_id']))
{
	$kunden_id=$_REQUEST['kunden_id'];
	echo "Kunden ID: $kunden_id";
}
$telefon="";
if (isset($_REQUEST['telefon1']))
{
	$telefon=$_REQUEST['telefon1'];
}

if (isset($_REQUEST['autoedit']))
{
	$kunden_id=$_REQUEST['autoedit'];
	$autoedit=true;
	echo "<div id='autologoffChecker'></div>";
}
else 
{
	menue_anzeigen();
	echo '<div id="wrapper_bon" class="wrapper_bon">';
	
?>
	<div id="tische_messageDiv">
	<div id="tische_loginInfoDiv" class="loginInfoDiv" >
	<?php 
		if (defined('TELEFON_ANRUFE_ANZEIGEN') && strtolower(TELEFON_ANRUFE_ANZEIGEN)==='ja')
		{
			echo "	<script>
					setInterval(function () 
					{
						zeige_letzte_telefonanrufe_an(false);
					}, 3000);
					</script>";
			zeige_letzte_telefonanrufe_an(false);
		}
		
	?>
	
	</div>
	
	<div id="tische_error_message" >
		<div id="tische_error_message_innen">
		<?php
			if (defined('TELEFON_ANRUFE_ANZEIGEN') && strtolower(TELEFON_ANRUFE_ANZEIGEN)==='ja')
			{
				echo '<a href="telefonanrufe_sITeditor.php"><button style="width:70px;" class="button button_gross_anrufe_menue orange">Telefon Anrufe</button></a>';
			}
		?>
		</div>
	</div>
</div>



	<?php
	if (!empty($telefon))
	{
		//echo "<br><br><h1>Telefonanruf mit Nummer: $telefon </h1>";
		echo "<center><br><br><br><br><br>";
		//echo '<input type="button" class="button button_gross orange" value="Kunden anlegen mit Telefon Nr. '.$telefon.'" onClick="open_iframe(\'anlegen_kunden_sITeditor.php?autoedit=true&telefon1='.$telefon.'\', true, false)" />';
		echo '<button type="submit" class="button button_gross orange" onClick="open_iframe(\'anlegen_kunden_sITeditor.php?autoedit=true&telefon1='.$telefon.'\', true, false)" >Kunden anlegen mit Telefon Nr. '.$telefon.'</button>';
		echo "<br><br><br><br><br></center>";
		

	}
}



	$konfiguration= array (
		'table'		=> 'kunden',
		'key'		=> 'id',
		'functions' => array (	'add' => true,
								'delete' => true,
								'edit' => true,
								'autoedit' => $autoedit,
								'view' => true,
								'copy' => true,
								'download_csv' => true,
								'download_pdf' => true,
								'css' => 'width:100px; min-width:100px; ',
								'style' => 'image'
							),
		'filter'	=> array (
								'field' 	=> 'geloescht',
								'operator'	=> '=',
								'filter_value'		=> 0
						),
		'user_search_filter'	=> array (
								'fields' 	=> array ('kundennummer','Firma','vorname','nachname','plz','Ort','telefon1','telefon2', 'mobil'),
								'default_filter_value'		=> '',
								'anzahl_ergebnisse' => KUNDENANZEIGE_TABELLE_MAX
						),
		'functions_delete_sql' => 'UPDATE kunden SET geloescht="1" WHERE id="§§id§§"',
		'fields'	=> array(
			array (
				'feldname' 	=> 'id',
				'type' 		=> 'text',
				'header'	=> 'ID',
				'view_options'	=> array ('view', 'edit'),
				'edit_input_option' => array('size' => '10', 'maxlength'=>'10'),
				'readonly' 	=> true
			),
			array (
				'feldname' 	=> 'dummy1',
				'type' 		=> 'ajax_function',
				'button_text'=> 'Tisch anlegen',
				'header'	=> 'Tisch anlegen',
				'php_file'	=>	'ajax_funktionen.php?funktion=telefon_create_table_weiterleiten&kunden_id=§§id§§',
				'css_option' => array('css_table_list' => 'width:90px;'),
				'view_options'	=> array ('table_list'),
				'readonly' 	=> true
			),
			array (
				'feldname' 	=> 'dummy1',
				'type' 		=> 'iframe_dialog',
				'button_text'=> 'Eink&auml;ufe',
				'header'	=> 'Eink&auml;ufe',
				'php_file'	=>	'ajax_funktionen.php?funktion=kunden_einkaeufe_anzeigen&kunden_id=§§id§§',
				'css_option' => array('css_table_list' => 'width:90px;'),
				'view_options'	=> array ('table_list'),
				'readonly' 	=> true
			),
			array (
				'feldname' 	=> 'kundennummer',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'css_option' => array('css_table_list' => 'width:50px;'),
				'edit_input_option' => array('size' => '10', 'maxlength'=>'10'),
				'header'	=> 'Kd. Nr'
			),
			array (
				'feldname' 	=> 'anrede',
				'type' 		=> 'text',
				'view_options'	=> array ('view', 'edit'),
				'header'	=> 'Anrede'
			),
			array (
				'feldname' 	=> 'titel',
				'type' 		=> 'text',
				'view_options'	=> array ('view', 'edit'),
				'header'	=> 'Titel'
			),
			array (
				'feldname' 	=> 'vorname',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'header'	=> 'Vorname'
			),
			array (
				'feldname' 	=> 'nachname',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'header'	=> 'Nachname'
			),
			array (
				'feldname' 	=> 'loyality_card',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'header'	=> 'Cashback Card Nr.'
			),
			array (
				'feldname' 	=> 'Firma',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'css_option' => array('css_table_list' => 'width:150px;'),
				'header'	=> 'Firma',
				'edit_input_option' => array('size' => '100', 'maxlength'=>'255')
			),
			array (
				'feldname' 	=> 'strasse1',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'edit_input_option' => array('size' => '100', 'maxlength'=>'255'),
				'header'	=> 'Strasse 1'
			),
			array (
				'feldname' 	=> 'strasse2',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'edit_input_option' => array('size' => '100', 'maxlength'=>'255'),
				'header'	=> 'Strasse 2'
			),
			array (
				'feldname' 	=> 'plz',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'edit_input_option' => array('size' => '10', 'maxlength'=>'10'),
				'header'	=> 'Plz'
			),
			array (
				'feldname' 	=> 'zone',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'edit_input_option' => array('size' => '10', 'maxlength'=>'10'),
				'header'	=> 'Zustell Zone'
			),
			array (
				'feldname' 	=> 'Ort',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'edit_input_option' => array('size' => '100', 'maxlength'=>'255'),
				'header'	=> 'Ort'
			),
			array (
				'feldname' 	=> 'Land',
				'type' 		=> 'text',
				'view_options'	=> array ('view', 'edit'),
				'edit_input_option' => array('size' => '100', 'maxlength'=>'255'),
				'header'	=> 'Land'
			),
			array (
				'feldname' 	=> 'telefon1',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'default_value' => $telefon,
				'header'	=> 'Telefon 1',
				'validation'=> 'nur_ziffern_zulassen'
			),
			array (
				'feldname' 	=> 'telefon2',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'header'	=> 'Telefon 2',
				'validation'=> 'nur_ziffern_zulassen'
			),
			array (
				'feldname' 	=> 'mobil',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'header'	=> 'Mobil',
				'validation'=> 'nur_ziffern_zulassen'
			),
			array (
				'feldname' 	=> 'fax',
				'type' 		=> 'text',
				'view_options'	=> array ('view', 'edit'),
				'header'	=> 'Fax'
			),
			array (
				'feldname' 	=> 'email',
				'type' 		=> 'text',
				'view_options'	=> array ('table_list', 'view', 'edit'),
				'header'	=> 'E-Mail'
			),
			array (
				'feldname' 	=> 'anmerkung',
				'type' 		=> 'textarea',
				'view_options'	=> array ('view', 'edit'),
				'edit_input_option' => array('rows' => '4', 'cols'=>'100'),
				'header'	=> 'Anmerkung'
			)
		)
	
	);
	
	if (!empty($telefon))
	{
		$konfiguration['fields'][]=array (
			'feldname' 	=> 'dummy1',
			'type' 		=> 'ajax_function',
			'button_text'=> 'Tel. Nr. hinzufügen',
			'header'	=> 'Tel. Nr. hinzufügen',
			'php_file'	=>	'ajax_funktionen.php?funktion=telefon_nummer_zu_kunden_hinzufuegen&telefon_nr='.$telefon.'&kunden_id=§§id§§',
			'css_option' => array('css_table_list' => 'width:90px;'),
			'view_options'	=> array ('table_list'),
			'readonly' 	=> true
		);
	}
	//$konfiguration=sIT_editor_view_user_search_filter($konfiguration);
	sIT_editor_tabelle($konfiguration, $kunden_id);
}
?>


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

</body>
