<?php
/**
* jtlwawi_Connector/dbeS/GetKundeZuBestellung.php
* Synchronisationsscript
*
* Es gelten die Nutzungs- und Lizenzhinweise unter [url]http://www.jtl-software.de/jtlwawi.php[/url]
*
* @author JTL-Software <thomas@jtl-software.de>
* @copyright 2006, JTL-Software
* @link [url]http://jtl-software.de/jtlwawi.php[/url]
* @version v1.04 / 22.03.07
*/
require_once("syncinclude.php");
$return=3;
if (auth())
{
if (intval($_POST['KeyBestellung']))
{
$return=0;
//hole order
$cur_query = eS_execute_query("select * from orders where orders_id=".intval($_POST['KeyBestellung']));
$Kunde = mysql_fetch_object($cur_query);
//zusatzinfos vom kunden holen
$cur_query = eS_execute_query("select customers.customers_gender, customers.customers_newsletter, customers.customers_fax, date_format(customers.customers_dob, \"%d.%m.%Y\") as geburtsdatum from orders, customers where orders.customers_id=customers.customers_id and customers.customers_id=".$Kunde->customers_id);
$cust = mysql_fetch_object($cur_query);
//UstID aus adress book holen
$cur_query = eS_execute_query("select * from address_book where customers_id=",$Kunde->customers_id);
$ab = mysql_fetch_object($cur_query);
$Kunde->customers_gender = $cust->customers_gender;
$Kunde->customers_newsletter = $cust->customers_newsletter;
$Kunde->customers_fax = $cust->customers_fax;
$Kunde->customers_vat_id = $cust->customers_vat_id;
$Kunde->geburtsdatum = $cust->geburtsdatum;
$Kunde->cAnrede="Frau";
if ($Kunde->customers_gender=="m")
$Kunde->cAnrede="Herr";
$Kunde->cHaendler="N";
$Kunde->cNewsletter="N";
if ($Kunde->customers_newsletter)
$Kunde->cNewsletter="Y";
//falls kein kunde existiert, key muss irgendwo her!
if (!$Kunde->customers_id)
$Kunde->customers_id = 10000000-$Kunde->orders_id;
echo(CSVkonform($Kunde->customers_id).';');
echo(CSVkonform($Kunde->customers_id).';');
echo(';');
echo('"*****";');
echo(CSVkonform($Kunde->cAnrede).';');
echo(';'); //Titel
echo(CSVkonform(substr($Kunde->billing_name,0,strpos($Kunde->billing_name," "))).';');
echo(CSVkonform(substr($Kunde->billing_name,strpos($Kunde->billing_name," ")+1)).';');
echo(CSVkonform($Kunde->billing_company).';');
echo(CSVkonform($Kunde->billing_street_address).';');
echo(CSVkonform($Kunde->billing_postcode).';');
echo(CSVkonform($Kunde->billing_city).';');
echo(CSVkonform($Kunde->billing_country).';');
echo(CSVkonform($Kunde->customers_telephone).';');
echo(CSVkonform($Kunde->customers_fax).';');
echo(CSVkonform($Kunde->customers_email_address).';');
echo(CSVkonform($Kunde->cHaendler).';');
echo(';'); //Rabatt
echo(CSVkonform($ab->entry_company_tax_id).';'); // ustid
echo(CSVkonform($Kunde->cNewsletter).';');
echo(CSVkonform($Kunde->geburtsdatum).';'); //Geburtstag
echo(CSVkonform($Kunde->customers_suburb).';'); //adresszusatz
echo(';'); //www
echo("\n");
}
else
$return=5;
}
mysql_close();
echo($return);
logge($return);
?>