<?php


require_once("syncinclude.php");

$return=3;
if (auth())
{
	if (intval($_POST['KeyAdresse']))
	{
		//hole order
		$cur_query = eS_execute_query("select orders_id, attendees_id, delivery_name, delivery_company, delivery_street_address, delivery_postcode, delivery_city, delivery_land, attendees_telephone, attendees_email_address from orders where orders_id=".intval($_POST['KeyAdresse']));
		$Order = go_db_fetch_object($cur_query);

		//falls kein kunde existiert, key muss irgendwo her!
		if (!$Order->attendees_id)
			$Order->attendees_id = 10000000-$Order->orders_id;
		
		echo(CSVkonform($Order->orders_id).';');
		echo(CSVkonform($Order->attendees_id).';');
		echo(CSVkonform(substr($Order->delivery_name,0,strpos($Order->delivery_name," "))).';');
		echo(CSVkonform(substr($Order->delivery_name,strpos($Order->delivery_name," ")+1)).';');
		echo(CSVkonform($Order->delivery_company).';');
		echo(CSVkonform($Order->delivery_street_address).';');
		echo(CSVkonform($Order->delivery_postcode).';');
		echo(CSVkonform($Order->delivery_city).';');
		echo(CSVkonform($Order->delivery_land).';');
		echo(CSVkonform($Order->attendees_telephone).';');
		echo(';'); //keine Faxangaben
		echo(CSVkonform($Order->attendees_email_address).';');
		echo(';'); //Type
		echo(';'); //anrede
		echo(CSVkonform($Order->delivery_suburb).';'); //adresszusatz
		echo("\n");
		
		$return=0;
 	}
	else
		$return=5;
}

echo($return);
logge($return);
?>