| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
//$Id: zusammenfassung_von_bestellungen.php 3361 2011-02-24 15:34:41Z tiefland $
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* @author Patirck Lautsch <lautsch@weban.de>
|
|
|
7 |
* @copyright 2009 Webagentur Niewerth
|
|
|
8 |
* @package Content-management
|
|
|
9 |
* @version $Rev: 3361 $
|
|
|
10 |
* @license propietary
|
|
|
11 |
* @filesource
|
|
|
12 |
*
|
|
|
13 |
*/
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
*
|
|
|
17 |
* @author Patirck Lautsch <lautsch@weban.de>
|
|
|
18 |
* @copyright 2009 Webagentur Niewerth
|
|
|
19 |
* @package Content-management
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
// Wenn $_GET['shops_id'] nicht gesetzt ist oder leer ist -> Fehlermeldung und die
|
|
|
23 |
if ( empty( $_GET['shops_id'] ) )
|
|
|
24 |
{
|
|
|
25 |
die( "Es wurde vergessen die Shop ID anzugeben!<br />
|
|
|
26 |
Bitte geben Sie die Datenbank über die Get-Variable \"shops_id\" an." );
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
// Wenn $_GET['bestellart_id'] nicht gesetzt ist oder leer ist -> Fehlermeldung und die
|
|
|
30 |
if ( empty( $_GET['bestellart_id'] ) )
|
|
|
31 |
{
|
|
|
32 |
die( "Es wurde vergessen die Bestellart ID anzugeben!<br />
|
|
|
33 |
Bitte geben Sie die Datenbank über die Get-Variable \"bestellart_id\" an." );
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
// connect-Datei einbinden
|
|
|
37 |
//require_once "../../Online-Shop/connect2.php";
|
|
|
38 |
mysql_connect('shop1.weban.de', 'teile_freak_de', '1-h4-a');
|
|
|
39 |
mysql_select_db('teile_freak_de');
|
|
|
40 |
|
|
|
41 |
// Binde Funktionen ein
|
|
|
42 |
require_once "includes/funktionen.inc.php";
|
|
|
43 |
|
|
|
44 |
// hole den Ort der Config-Datei aus 'eBay_settings'
|
|
|
45 |
$sql = "
|
|
|
46 |
SELECT
|
|
|
47 |
Inhalt
|
|
|
48 |
FROM
|
|
|
49 |
eBay_settings
|
|
|
50 |
WHERE
|
|
|
51 |
Typ = 'confDatei'
|
|
|
52 |
AND shops_id = '" . $_GET['shops_id'] . "'
|
|
|
53 |
";
|
|
|
54 |
$result = mysql_query( $sql ) or die( mail("admin@weban.de",
|
|
|
55 |
"eBay-Cronjob Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
56 |
|
|
|
57 |
// Debug
|
|
|
58 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
59 |
echo 'eBay_settings: <br>' . $sql;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
$row = mysql_fetch_assoc( $result );
|
|
|
63 |
|
|
|
64 |
$confDatei = $row[Inhalt];
|
|
|
65 |
|
|
|
66 |
$_GET["confDatei"] = $confDatei;
|
|
|
67 |
|
|
|
68 |
// hole die XML-Datei in der die Transactions sind
|
|
|
69 |
ob_start();
|
|
|
70 |
require_once "/web/apache/content-management/cronjobs/ebay/holeXML.php";
|
|
|
71 |
$file = ob_get_contents();
|
|
|
72 |
ob_end_clean();
|
|
|
73 |
|
|
|
74 |
// Definition welcher Teil der XML-Datei gelesen werden soll
|
|
|
75 |
$start = "<TransactionArray>";
|
|
|
76 |
$ende = "</TransactionArray>";
|
|
|
77 |
|
|
|
78 |
// speichere den XML-Ausschnitt in Treffer
|
|
|
79 |
$treffer = get_string_between( $file, $start, $ende );
|
|
|
80 |
|
|
|
81 |
// Sonderzeichen wie spitze Klammern werden in Entities geschrieben,
|
|
|
82 |
// deshalb müssen diese mit html_entity_decode() zurückverwandelt werden
|
|
|
83 |
$treffer = html_entity_decode( $treffer );
|
|
|
84 |
|
|
|
85 |
// packe ein Root-Tag um den ausgeschnitten XML-Teil
|
|
|
86 |
$treffer = "<ebay>" . $treffer . "</ebay>";
|
|
|
87 |
|
|
|
88 |
// erzeuge ein Objekt aus dem ausgeschnitten XML-Teil
|
|
|
89 |
$xml = simplexml_load_string( $treffer );
|
|
|
90 |
|
|
|
91 |
if ( $_GET['debug'] == 1 ) {
|
|
|
92 |
print_r($xml);
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
// Gehe alle Transactions durch
|
|
|
96 |
foreach ( $xml->Transaction as $ta )
|
|
|
97 |
{
|
|
|
98 |
/**
|
|
|
99 |
* Notiz:
|
|
|
100 |
* When an item is listed as a Chinese auction type ( the default value of the AddItem.Item.ListingType property), the TransactionID
|
|
|
101 |
* always returns a value of '0' as described in the online document :
|
|
|
102 |
* http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetItemTransactions.html
|
|
|
103 |
**/
|
|
|
104 |
// Wenn das ListingType = "chinese" ist, nehme die ItemID als TransactionID
|
|
|
105 |
if ( "Chinese" == $ta->Item->ListingType )
|
|
|
106 |
{
|
|
|
107 |
$ta->TransactionID = $ta->Item->ItemID;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
// Überprüfe ob die Transaction schon in der Datenbank ist
|
|
|
111 |
$sql = "
|
|
|
112 |
SELECT
|
|
|
113 |
TransactionId
|
|
|
114 |
FROM
|
|
|
115 |
eBay_Bestellung
|
|
|
116 |
WHERE
|
|
|
117 |
TransactionId = '" . $ta->TransactionID . "'
|
|
|
118 |
";
|
|
|
119 |
$result = mysql_query( $sql ) or die( mail("admin@weban.de",
|
|
|
120 |
"eBay-Cronjob Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
121 |
$row = mysql_fetch_assoc( $result );
|
|
|
122 |
|
|
|
123 |
// Debug
|
|
|
124 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
125 |
echo 'eBay_Bestellung: <br>' . $sql;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
// Transaction vorhanden?
|
|
|
129 |
if ( NULL == $row[TransactionId] )
|
|
|
130 |
{
|
|
|
131 |
// Transaction nicht vorhanden:
|
|
|
132 |
// Trage Transaction und dazugehörige Daten in die Datenbank
|
|
|
133 |
|
|
|
134 |
// Attribut-Inhalt löschen wenn Inhalt gleich "Invalid Request"
|
|
|
135 |
if ( $ta->Buyer->Email == "Invalid Request" )
|
|
|
136 |
{
|
|
|
137 |
$ta->Buyer->Email = "";
|
|
|
138 |
}
|
|
|
139 |
if ( $ta->Buyer->RegistrationAddress->Phone == "Invalid Request" )
|
|
|
140 |
{
|
|
|
141 |
$ta->Buyer->RegistrationAddress->Phone = "";
|
|
|
142 |
}
|
|
|
143 |
if ( $ta->Buyer->BuyerInfo->ShippingAddress->Phone == "Invalid Request" )
|
|
|
144 |
{
|
|
|
145 |
$ta->Buyer->BuyerInfo->ShippingAddress->Phone = "";
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
// ME: bei Usern aus dem Ausland wird die Rechnungsadresse nicht korrekt gefüllt
|
|
|
149 |
// das muss hier behoben werden:
|
|
|
150 |
// wenn keine Rechnungsadresse eingetragen ist, wird die Rechnungsadresse mit den Daten der
|
|
|
151 |
// Lieferadresse gefüllt
|
|
|
152 |
unset($RegistrationAddress_Name);
|
|
|
153 |
if ( strlen($ta->Buyer->RegistrationAddress->Name) == 0 )
|
|
|
154 |
{
|
|
|
155 |
$RegistrationAddress_Name = $ta->Buyer->BuyerInfo->ShippingAddress->Name;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
unset($RegistrationAddress_Street);
|
|
|
159 |
if ( strlen($ta->Buyer->RegistrationAddress->Street) == 0 )
|
|
|
160 |
{
|
|
|
161 |
$RegistrationAddress_Street = $ta->Buyer->BuyerInfo->ShippingAddress->
|
|
|
162 |
Street1;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
unset($RegistrationAddress_PostalCode);
|
|
|
166 |
if ( strlen($ta->Buyer->RegistrationAddress->PostalCode) == 0 )
|
|
|
167 |
{
|
|
|
168 |
$RegistrationAddress_PostalCode = $ta->Buyer->BuyerInfo->ShippingAddress->
|
|
|
169 |
PostalCode;
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
unset($RegistrationAddress_CityName);
|
|
|
173 |
if ( strlen($ta->Buyer->RegistrationAddress->CityName) == 0 )
|
|
|
174 |
{
|
|
|
175 |
$RegistrationAddress_CityName = $ta->Buyer->BuyerInfo->ShippingAddress->
|
|
|
176 |
CityName;
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
unset($RegistrationAddress_CountryName);
|
|
|
180 |
if ( strlen($ta->Buyer->RegistrationAddress->CountryName) == 0 )
|
|
|
181 |
{
|
|
|
182 |
$RegistrationAddress_CountryName = $ta->Buyer->BuyerInfo->ShippingAddress->
|
|
|
183 |
CountryName;
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
// Ist der eBay-Benutzer schon vorhanden in der Datenbank?
|
|
|
187 |
$sql = "
|
|
|
188 |
SELECT
|
|
|
189 |
ID,
|
|
|
190 |
ebay_UserID
|
|
|
191 |
FROM
|
|
|
192 |
Logins
|
|
|
193 |
WHERE
|
|
|
194 |
ebay_UserID = '" . mysql_real_escape_string( deutsche_umlaute
|
|
|
195 |
($ta->Buyer->UserID) ) . "'
|
|
|
196 |
";
|
|
|
197 |
$result = mysql_query( $sql ) or die( mysql_errno() . ': ' . mysql_error() .
|
|
|
198 |
'<hr />' . $sql );
|
|
|
199 |
$row = mysql_fetch_assoc( $result );
|
|
|
200 |
|
|
|
201 |
// Debug
|
|
|
202 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
203 |
echo 'Logins: <br>' . $sql;
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
if ( $row['ebay_UserID'] == mysql_real_escape_string(deutsche_umlaute($ta->
|
|
|
207 |
Buyer->UserID)) )
|
|
|
208 |
{
|
|
|
209 |
// eBay-Benutzer ist schon vorhanden
|
|
|
210 |
$user_id = $row['ID'];
|
|
|
211 |
|
|
|
212 |
// UPDATE der Logins-Tabelle
|
|
|
213 |
$sql = "
|
|
|
214 |
UPDATE
|
|
|
215 |
Logins
|
|
|
216 |
SET
|
|
|
217 |
Name1 = '" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_Name) ?
|
|
|
218 |
$RegistrationAddress_Name : $ta->Buyer->RegistrationAddress->Name) ) . "',
|
|
|
219 |
Strasse = '" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_Street) ?
|
|
|
220 |
$RegistrationAddress_Street : $ta->Buyer->RegistrationAddress->Street) ) .
|
|
|
221 |
"',
|
|
|
222 |
PLZ = '" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_PostalCode) ?
|
|
|
223 |
$RegistrationAddress_PostalCode : $ta->Buyer->RegistrationAddress->
|
|
|
224 |
PostalCode) ) . "',
|
|
|
225 |
ORT = '" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_CityName) ?
|
|
|
226 |
$RegistrationAddress_CityName : $ta->Buyer->RegistrationAddress->CityName) ) .
|
|
|
227 |
"',
|
|
|
228 |
Land = '" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_CountryName) ?
|
|
|
229 |
$RegistrationAddress_CountryName : $ta->Buyer->RegistrationAddress->
|
|
|
230 |
CountryName) ) . "',
|
|
|
231 |
E_Mail = '" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
232 |
Buyer->Email) ) . "',
|
|
|
233 |
Telefon = '" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
234 |
Buyer->BuyerInfo->ShippingAddress->Phone) ) . "',
|
|
|
235 |
liefer_Name = '" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
236 |
Buyer->BuyerInfo->ShippingAddress->Name) ) . "',
|
|
|
237 |
liefer_Strasse = '" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
238 |
Buyer->BuyerInfo->ShippingAddress->Street1) ) . "',
|
|
|
239 |
liefer_PLZ = '" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
240 |
Buyer->BuyerInfo->ShippingAddress->PostalCode) ) . "',
|
|
|
241 |
liefer_Ort = '" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
242 |
Buyer->BuyerInfo->ShippingAddress->CityName) ) . "',
|
|
|
243 |
letzte_Aenderung_am = NOW(),
|
|
|
244 |
ebay_FeedbackScore = '" . $ta->Buyer->FeedbackScore . "',
|
|
|
245 |
ebay_PositiveFeedbackPercent = '" . $ta->Buyer->PositiveFeedbackPercent . "'
|
|
|
246 |
WHERE
|
|
|
247 |
ID = $user_id;
|
|
|
248 |
";
|
|
|
249 |
mysql_query( $sql ) or die( mysql_errno() . ': ' . mysql_error() .
|
|
|
250 |
'<hr />' . $sql );
|
|
|
251 |
|
|
|
252 |
// Debug
|
|
|
253 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
254 |
echo 'Logins(UPDATE): <br>' . $sql;
|
|
|
255 |
}
|
|
|
256 |
}
|
|
|
257 |
else
|
|
|
258 |
{
|
|
|
259 |
// eBay-Benutzer ist noch nicht vorhanden
|
|
|
260 |
// SQL: Benutzer anlegen
|
|
|
261 |
$sql = "
|
|
|
262 |
INSERT INTO Logins
|
|
|
263 |
(
|
|
|
264 |
Name1,
|
|
|
265 |
Strasse,
|
|
|
266 |
PLZ,
|
|
|
267 |
ORT,
|
|
|
268 |
Land,
|
|
|
269 |
E_Mail,
|
|
|
270 |
Telefon,
|
|
|
271 |
liefer_Name,
|
|
|
272 |
liefer_Strasse,
|
|
|
273 |
liefer_PLZ,
|
|
|
274 |
liefer_Ort,
|
|
|
275 |
erstellt_am,
|
|
|
276 |
erstellt_von,
|
|
|
277 |
letzte_Aenderung_am,
|
|
|
278 |
letzte_Aenderung_von,
|
|
|
279 |
ebay_UserID,
|
|
|
280 |
ebay_FeedbackScore,
|
|
|
281 |
ebay_PositiveFeedbackPercent
|
|
|
282 |
)
|
|
|
283 |
VALUES
|
|
|
284 |
(
|
|
|
285 |
'" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_Name) ?
|
|
|
286 |
$RegistrationAddress_Name : $ta->Buyer->RegistrationAddress->Name) ) . "',
|
|
|
287 |
'" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_Street) ?
|
|
|
288 |
$RegistrationAddress_Street : $ta->Buyer->RegistrationAddress->Street) ) .
|
|
|
289 |
"',
|
|
|
290 |
'" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_PostalCode) ?
|
|
|
291 |
$RegistrationAddress_PostalCode : $ta->Buyer->RegistrationAddress->
|
|
|
292 |
PostalCode) ) . "',
|
|
|
293 |
'" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_CityName) ?
|
|
|
294 |
$RegistrationAddress_CityName : $ta->Buyer->RegistrationAddress->CityName) ) .
|
|
|
295 |
"',
|
|
|
296 |
'" . mysql_real_escape_string( deutsche_umlaute(($RegistrationAddress_CountryName) ?
|
|
|
297 |
$RegistrationAddress_CountryName : $ta->Buyer->RegistrationAddress->
|
|
|
298 |
CountryName) ) . "',
|
|
|
299 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
300 |
Buyer->Email) ) . "',
|
|
|
301 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
302 |
Buyer->BuyerInfo->ShippingAddress->Phone) ) . "',
|
|
|
303 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
304 |
Buyer->BuyerInfo->ShippingAddress->Name) ) . "',
|
|
|
305 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
306 |
Buyer->BuyerInfo->ShippingAddress->Street1) ) . "',
|
|
|
307 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
308 |
Buyer->BuyerInfo->ShippingAddress->PostalCode) ) . "',
|
|
|
309 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
310 |
Buyer->BuyerInfo->ShippingAddress->CityName) ) . "',
|
|
|
311 |
NOW(),
|
|
|
312 |
'ebay-cronjob',
|
|
|
313 |
NOW(),
|
|
|
314 |
'ebay-cronjob',
|
|
|
315 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
316 |
Buyer->UserID) ) . "',
|
|
|
317 |
'" . $ta->Buyer->FeedbackScore . "',
|
|
|
318 |
'" . $ta->Buyer->PositiveFeedbackPercent . "'
|
|
|
319 |
);
|
|
|
320 |
";
|
|
|
321 |
|
|
|
322 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
323 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
324 |
|
|
|
325 |
// Speichere die gerade eingefügte UserID
|
|
|
326 |
$user_id = mysql_insert_id();
|
|
|
327 |
|
|
|
328 |
// Debug
|
|
|
329 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
330 |
echo 'Logins(INSERT): <br>' . $sql;
|
|
|
331 |
}
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
// eBay-Shops sind unter "shops.ebay = 1" markiert
|
|
|
335 |
$shops_id = $_GET['shops_id'];
|
|
|
336 |
|
|
|
337 |
// SQL: Bestellung
|
|
|
338 |
$jetztBezahlen = ( $ta->Status->CheckoutStatus == "CheckoutComplete" ) ?
|
|
|
339 |
"Der Käufer hat die Kaufabwicklung nach dem Kauf abgeschlossen\nZahlungsart: " .
|
|
|
340 |
$ta->Status->PaymentMethodUsed :
|
|
|
341 |
"Der Käufer hat die Kaufabwicklung nach dem Kauf noch nicht abgeschlossen";
|
|
|
342 |
|
|
|
343 |
$erstellt_am = $ta->CreatedDate;
|
|
|
344 |
|
|
|
345 |
// Wenn $erstellt_am nicht gesetzt, dann nehme das aktuelle Datum
|
|
|
346 |
$ts = ( $erstellt_am ) ? strtotime( $erstellt_am ) : time();
|
|
|
347 |
$ts = date( "Y-m-d H:i:s", $ts );
|
|
|
348 |
|
|
|
349 |
// Gibt es bereits eine offene Bestellung des eBay-Nutzers
|
|
|
350 |
$sql = '
|
|
|
351 |
SELECT
|
|
|
352 |
MAX(b.ID) AS id
|
|
|
353 |
FROM
|
|
|
354 |
Bestellung AS b JOIN artikel_to_Bestellung AS a2b
|
|
|
355 |
ON b.ID = a2b.Bestellung
|
|
|
356 |
RIGHT JOIN eBay_Bestellung AS eb
|
|
|
357 |
ON a2b.ID = eb.a2b_ID
|
|
|
358 |
LEFT JOIN Logins AS l
|
|
|
359 |
ON l.ID = b.Login
|
|
|
360 |
WHERE
|
|
|
361 |
b.Status = \'offen\'
|
|
|
362 |
AND b.Login = ' . $user_id . '
|
|
|
363 |
AND b.erstellt_am > NOW() - INTERVAL 6 HOUR
|
|
|
364 |
;';
|
|
|
365 |
|
|
|
366 |
$result = mysql_query( $sql ) or die( mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql );
|
|
|
367 |
$row = mysql_fetch_assoc($result);
|
|
|
368 |
|
|
|
369 |
// Debug
|
|
|
370 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
371 |
echo 'Bestellung: <br>' . $sql;
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
// Offene BestellId-Variable löschen
|
|
|
375 |
unset($offeneBestellId);
|
|
|
376 |
|
|
|
377 |
// Offene BestellId-Variable
|
|
|
378 |
$offeneBestellId = $row['id'];
|
|
|
379 |
|
|
|
380 |
if ( $offeneBestellId > 0 )
|
|
|
381 |
{
|
|
|
382 |
// Es gibt eine offene Bestellung, die nicht älter als 6 Stunden ist
|
|
|
383 |
// Füge die Artikel dieser Auktion, in die mit der BestellId = $offeneBestellId ein
|
|
|
384 |
$sql = "
|
|
|
385 |
INSERT INTO artikel_to_Bestellung
|
|
|
386 |
(
|
|
|
387 |
artikel,
|
|
|
388 |
Bestellung,
|
|
|
389 |
Menge,
|
|
|
390 |
Preis_pro_Stueck,
|
|
|
391 |
status,
|
|
|
392 |
Bezeichnung
|
|
|
393 |
)
|
|
|
394 |
VALUES
|
|
|
395 |
(
|
|
|
396 |
'999999',
|
|
|
397 |
" . $offeneBestellId . ",
|
|
|
398 |
" . $ta->QuantityPurchased . ",
|
|
|
399 |
" . $ta->TransactionPrice . ",
|
|
|
400 |
'offen',
|
|
|
401 |
'" . deutsche_umlaute( $ta->Item->Title ) . "'
|
|
|
402 |
);
|
|
|
403 |
";
|
|
|
404 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
405 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
406 |
|
|
|
407 |
$a2bId = mysql_insert_id();
|
|
|
408 |
|
|
|
409 |
// Debug
|
|
|
410 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
411 |
echo 'artikel_to_Bestellung(INSERT): <br>' . $sql;
|
|
|
412 |
}
|
|
|
413 |
|
|
|
414 |
// SQL: ebay_Bestellung
|
|
|
415 |
$sql = "
|
|
|
416 |
INSERT INTO eBay_Bestellung
|
|
|
417 |
(
|
|
|
418 |
a2b_ID,
|
|
|
419 |
PaymentMethodUsed,
|
|
|
420 |
TransactionId,
|
|
|
421 |
eBay_Auktionen_ID,
|
|
|
422 |
CheckoutAfterSales
|
|
|
423 |
)
|
|
|
424 |
VALUES
|
|
|
425 |
(
|
|
|
426 |
'" . $a2bId . "',
|
|
|
427 |
'" . $ta->Status->PaymentMethodUsed . "',
|
|
|
428 |
'" . $ta->TransactionID . "',
|
|
|
429 |
'" . $ta->Item->ItemID . "',
|
|
|
430 |
'" . $checkoutStatus . "'
|
|
|
431 |
);
|
|
|
432 |
";
|
|
|
433 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
434 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
435 |
|
|
|
436 |
// Debug
|
|
|
437 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
438 |
echo 'eBay_Bestellung(INSERT): <br>' . $sql;
|
|
|
439 |
}
|
|
|
440 |
}
|
|
|
441 |
else
|
|
|
442 |
{
|
|
|
443 |
$sql = "
|
|
|
444 |
INSERT INTO Bestellung
|
|
|
445 |
(
|
|
|
446 |
Bemerkung,
|
|
|
447 |
Login,
|
|
|
448 |
shops_ID,
|
|
|
449 |
bestellart_id,
|
|
|
450 |
erstellt_am,
|
|
|
451 |
erstellt_von,
|
|
|
452 |
liefer_Name,
|
|
|
453 |
liefer_Strasse,
|
|
|
454 |
liefer_PLZ,
|
|
|
455 |
liefer_Ort,
|
|
|
456 |
liefer_Land
|
|
|
457 |
)
|
|
|
458 |
VALUES
|
|
|
459 |
(
|
|
|
460 |
'eBay-Benutzername: " . deutsche_umlaute( $ta->Buyer->
|
|
|
461 |
UserID ) . "\n" . $jetztBezahlen . "',
|
|
|
462 |
'" . $user_id . "',
|
|
|
463 |
'" . $shops_id . "',
|
|
|
464 |
'" . $_GET['bestellart_id'] . "',
|
|
|
465 |
'$ts',
|
|
|
466 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
467 |
Buyer->UserID) ) . " (" . $ta->Buyer->FeedbackScore . " - " . $ta->Buyer->
|
|
|
468 |
PositiveFeedbackPercent . "%)',
|
|
|
469 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
470 |
Buyer->BuyerInfo->ShippingAddress->Name) ) . "',
|
|
|
471 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
472 |
Buyer->BuyerInfo->ShippingAddress->Street1) ) . "',
|
|
|
473 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
474 |
Buyer->BuyerInfo->ShippingAddress->PostalCode) ) . "',
|
|
|
475 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
476 |
Buyer->BuyerInfo->ShippingAddress->CityName) ) . "',
|
|
|
477 |
'" . mysql_real_escape_string( deutsche_umlaute($ta->
|
|
|
478 |
Buyer->BuyerInfo->ShippingAddress->CountryName) ) . "'
|
|
|
479 |
);
|
|
|
480 |
";
|
|
|
481 |
|
|
|
482 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
483 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
484 |
|
|
|
485 |
// Debug
|
|
|
486 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
487 |
echo 'Bestellung(INSERT): <br>' . $sql;
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
// Speichere die gerade eingefügte BestellID
|
|
|
491 |
$bestell_id = mysql_insert_id();
|
|
|
492 |
|
|
|
493 |
// Wenn der CheckoutStatus auf "CheckoutComplete" steht, setzte $checkoutStatus = 1
|
|
|
494 |
$checkoutStatus = $ta->Status->CheckoutStatus == "CheckoutComplete" ? 1 : 0;
|
|
|
495 |
|
|
|
496 |
// SQL: artikel_to_Bestellung
|
|
|
497 |
$sql = "
|
|
|
498 |
INSERT INTO artikel_to_Bestellung
|
|
|
499 |
(
|
|
|
500 |
artikel,
|
|
|
501 |
Bestellung,
|
|
|
502 |
Menge,
|
|
|
503 |
Preis_pro_Stueck,
|
|
|
504 |
status,
|
|
|
505 |
Bezeichnung
|
|
|
506 |
)
|
|
|
507 |
VALUES
|
|
|
508 |
(
|
|
|
509 |
'999999',
|
|
|
510 |
" . $bestell_id . ",
|
|
|
511 |
" . $ta->QuantityPurchased . ",
|
|
|
512 |
" . $ta->TransactionPrice . ",
|
|
|
513 |
'offen',
|
|
|
514 |
'" . deutsche_umlaute( $ta->Item->Title ) . "'
|
|
|
515 |
);
|
|
|
516 |
";
|
|
|
517 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
518 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
519 |
|
|
|
520 |
$a2bId = mysql_insert_id();
|
|
|
521 |
|
|
|
522 |
// Debug
|
|
|
523 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
524 |
echo 'artikel_to_Bestellung(INSERT): <br>' . $sql;
|
|
|
525 |
}
|
|
|
526 |
|
|
|
527 |
// SQL: ebay_Bestellung
|
|
|
528 |
$sql = "
|
|
|
529 |
INSERT INTO eBay_Bestellung
|
|
|
530 |
(
|
|
|
531 |
a2b_ID,
|
|
|
532 |
PaymentMethodUsed,
|
|
|
533 |
TransactionId,
|
|
|
534 |
eBay_Auktionen_ID,
|
|
|
535 |
CheckoutAfterSales
|
|
|
536 |
)
|
|
|
537 |
VALUES
|
|
|
538 |
(
|
|
|
539 |
'" . $a2bId . "',
|
|
|
540 |
'" . $ta->Status->PaymentMethodUsed . "',
|
|
|
541 |
'" . $ta->TransactionID . "',
|
|
|
542 |
'" . $ta->Item->ItemID . "',
|
|
|
543 |
'" . $checkoutStatus . "'
|
|
|
544 |
);
|
|
|
545 |
";
|
|
|
546 |
|
|
|
547 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
548 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
549 |
|
|
|
550 |
// Debug
|
|
|
551 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
552 |
echo 'eBay_Bestellung(INSERT): <br>' . $sql;
|
|
|
553 |
}
|
|
|
554 |
|
|
|
555 |
|
|
|
556 |
|
|
|
557 |
// Versand angegeben?
|
|
|
558 |
if ( isset($ta->ShippingServiceSelected->ShippingService) )
|
|
|
559 |
{
|
|
|
560 |
// SQL: Hole die ID des eBay-Versandartikels
|
|
|
561 |
$sql = "
|
|
|
562 |
SELECT
|
|
|
563 |
Inhalt
|
|
|
564 |
FROM
|
|
|
565 |
eBay_settings
|
|
|
566 |
WHERE
|
|
|
567 |
Typ = 'static'
|
|
|
568 |
AND shops_ID = $shops_id
|
|
|
569 |
";
|
|
|
570 |
$result = mysql_query( $sql ) or die( mail("admin@weban.de",
|
|
|
571 |
"eBay-Cronjob Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
572 |
$row = mysql_fetch_assoc( $result );
|
|
|
573 |
|
|
|
574 |
// Debug
|
|
|
575 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
576 |
echo 'Inhalt(INSERT): <br>' . $sql;
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
// eBay Versandartikel
|
|
|
580 |
$ebay_versandartikel_id = $row['Inhalt'];
|
|
|
581 |
|
|
|
582 |
// Falls der Bezeichnung "DE_Paket" für den Versandartikel in der XML ist,
|
|
|
583 |
// dann nenne ihn "Vorkasse / Versandkosten"
|
|
|
584 |
$va_bez = ( deutsche_umlaute($ta->ShippingServiceSelected->ShippingService) ==
|
|
|
585 |
"DE_Paket" ) ? "Vorkasse / Versandkosten" : deutsche_umlaute( $ta->
|
|
|
586 |
ShippingServiceSelected->ShippingService );
|
|
|
587 |
|
|
|
588 |
// SQL: Versandartikel in die Bestellung übernehmen
|
|
|
589 |
$sql = "
|
|
|
590 |
INSERT INTO artikel_to_Bestellung
|
|
|
591 |
(
|
|
|
592 |
artikel,
|
|
|
593 |
Bestellung,
|
|
|
594 |
Menge,
|
|
|
595 |
Preis_pro_Stueck,
|
|
|
596 |
Bezeichnung,
|
|
|
597 |
status
|
|
|
598 |
)
|
|
|
599 |
VALUES
|
|
|
600 |
(
|
|
|
601 |
'" . $ebay_versandartikel_id . "',
|
|
|
602 |
" . $bestell_id . ",
|
|
|
603 |
" . 1 . ",
|
|
|
604 |
" . $ta->ShippingServiceSelected->ShippingServiceCost .
|
|
|
605 |
",
|
|
|
606 |
'" . $va_bez . "',
|
|
|
607 |
''
|
|
|
608 |
);";
|
|
|
609 |
|
|
|
610 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
611 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
612 |
|
|
|
613 |
// Debug
|
|
|
614 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
615 |
echo 'artikel_to_Bestellung(INSERT): <br>' . $sql;
|
|
|
616 |
}
|
|
|
617 |
}
|
|
|
618 |
}
|
|
|
619 |
}
|
|
|
620 |
else
|
|
|
621 |
{
|
|
|
622 |
// Transaction ist vorhanden:
|
|
|
623 |
|
|
|
624 |
// CheckoutAfterSales in der Tabelle 'eBay_Bestellung' = 0 und $ta->Status->CheckoutStatus = "CheckoutComplete", dann update die Tabelle 'eBay_Bestellung' und 'Bestellung'
|
|
|
625 |
$sql = "
|
|
|
626 |
SELECT
|
|
|
627 |
CheckoutAfterSales,
|
|
|
628 |
a2b_ID
|
|
|
629 |
FROM
|
|
|
630 |
eBay_Bestellung
|
|
|
631 |
WHERE
|
|
|
632 |
TransactionId = '" . $ta->TransactionID . "'
|
|
|
633 |
";
|
|
|
634 |
$result = mysql_query( $sql ) or die( mail("admin@weban.de",
|
|
|
635 |
"eBay-Cronjob Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
636 |
$row = mysql_fetch_assoc( $result );
|
|
|
637 |
|
|
|
638 |
// Debug
|
|
|
639 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
640 |
echo 'eBay_Bestellung: <br>' . $sql;
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
$CheckoutAfterSales = $row[CheckoutAfterSales];
|
|
|
644 |
$Bestellung_ID = $row['a2b_ID'];
|
|
|
645 |
|
|
|
646 |
// Wenn '$Bestellung_ID' nicht vorhanden ist, heißt das der Transaktion nicht vorhanden ist,
|
|
|
647 |
// in diesem Fall soll auch kein Update gefahren werden.
|
|
|
648 |
if ( $Bestellung_ID )
|
|
|
649 |
{
|
|
|
650 |
// Wenn der CheckoutStatus verändert wurde
|
|
|
651 |
if ( 0 == $CheckoutAfterSales && "CheckoutComplete" == $ta->Status->
|
|
|
652 |
CheckoutStatus )
|
|
|
653 |
{
|
|
|
654 |
$sql = "
|
|
|
655 |
UPDATE
|
|
|
656 |
eBay_Bestellung
|
|
|
657 |
SET
|
|
|
658 |
CheckoutAfterSales = 1,
|
|
|
659 |
PaymentMethodUsed = '" . $ta->Status->
|
|
|
660 |
PaymentMethodUsed . "'
|
|
|
661 |
WHERE
|
|
|
662 |
TransactionId = '" . $ta->TransactionID . "'
|
|
|
663 |
";
|
|
|
664 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
665 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
666 |
|
|
|
667 |
// Debug
|
|
|
668 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
669 |
echo 'eBay_Bestellung(UPDATE): <br>' . $sql;
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
$jetztBezahlen = ( $ta->Status->CheckoutStatus == "CheckoutComplete" ) ?
|
|
|
673 |
"Der Käufer hat die Kaufabwicklung nach dem Kauf abgeschlossen\nZahlungsart: " .
|
|
|
674 |
$ta->Status->PaymentMethodUsed : "";
|
|
|
675 |
|
|
|
676 |
|
|
|
677 |
$sql = "
|
|
|
678 |
UPDATE
|
|
|
679 |
Bestellung
|
|
|
680 |
SET
|
|
|
681 |
Bemerkung = 'eBay-Benutzername: " .
|
|
|
682 |
deutsche_umlaute( $ta->Buyer->UserID ) . "\n" . $jetztBezahlen . "',
|
|
|
683 |
liefer_Name = '" . deutsche_umlaute( $ta->Buyer->
|
|
|
684 |
BuyerInfo->ShippingAddress->Name ) . "',
|
|
|
685 |
liefer_Strasse = '" . deutsche_umlaute( $ta->Buyer->
|
|
|
686 |
BuyerInfo->ShippingAddress->Street1 ) . "',
|
|
|
687 |
liefer_PLZ = '" . deutsche_umlaute( $ta->Buyer->
|
|
|
688 |
BuyerInfo->ShippingAddress->PostalCode ) . "',
|
|
|
689 |
liefer_Ort = '" . deutsche_umlaute( $ta->Buyer->
|
|
|
690 |
BuyerInfo->ShippingAddress->CityName ) . "',
|
|
|
691 |
liefer_Land = '" . deutsche_umlaute( $ta->Buyer->
|
|
|
692 |
BuyerInfo->ShippingAddress->CountryName ) . "'
|
|
|
693 |
WHERE
|
|
|
694 |
ID = '" . $Bestellung_ID . "'
|
|
|
695 |
";
|
|
|
696 |
|
|
|
697 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
698 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
699 |
|
|
|
700 |
// Debug
|
|
|
701 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
702 |
echo 'Bestellung(UPDATE): <br>' . $sql;
|
|
|
703 |
}
|
|
|
704 |
|
|
|
705 |
// Versand angegeben?
|
|
|
706 |
if ( isset($ta->ShippingServiceSelected->ShippingService) )
|
|
|
707 |
{
|
|
|
708 |
// SQL: Hole die ID des eBay-Versandartikels
|
|
|
709 |
$sql = "
|
|
|
710 |
SELECT
|
|
|
711 |
ID
|
|
|
712 |
FROM
|
|
|
713 |
artikel
|
|
|
714 |
WHERE
|
|
|
715 |
kurzbezeichnung = 'eBay-Versand'
|
|
|
716 |
AND
|
|
|
717 |
Father = -3
|
|
|
718 |
";
|
|
|
719 |
$result = mysql_query( $sql ) or die( mail("admin@weban.de",
|
|
|
720 |
"eBay-Cronjob Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
721 |
$row = mysql_fetch_assoc( $result );
|
|
|
722 |
|
|
|
723 |
// Debug
|
|
|
724 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
725 |
echo 'artikel: <br>' . $sql;
|
|
|
726 |
}
|
|
|
727 |
|
|
|
728 |
// eBay Versandartikel
|
|
|
729 |
$ebay_versandartikel_id = $row[ID];
|
|
|
730 |
|
|
|
731 |
// Falls der Bezeichnung "DE_Paket" für den Versandartikel in der XML ist,
|
|
|
732 |
// dann nenne ihn "Vorkasse / Versandkosten"
|
|
|
733 |
$va_bez = ( deutsche_umlaute($ta->ShippingServiceSelected->ShippingService) ==
|
|
|
734 |
"DE_Paket" ) ? "Vorkasse / Versandkosten" : deutsche_umlaute( $ta->
|
|
|
735 |
ShippingServiceSelected->ShippingService );
|
|
|
736 |
// SQL: Versandartikel in die Bestellung übernehmen
|
|
|
737 |
$sql = "
|
|
|
738 |
INSERT INTO artikel_to_Bestellung
|
|
|
739 |
(
|
|
|
740 |
artikel,
|
|
|
741 |
Bestellung,
|
|
|
742 |
Menge,
|
|
|
743 |
Preis_pro_Stueck,
|
|
|
744 |
Bezeichnung,
|
|
|
745 |
status
|
|
|
746 |
)
|
|
|
747 |
VALUES
|
|
|
748 |
(
|
|
|
749 |
'" . $ebay_versandartikel_id . "',
|
|
|
750 |
" . $Bestellung_ID . ",
|
|
|
751 |
" . 1 . ",
|
|
|
752 |
" . $ta->ShippingServiceSelected->
|
|
|
753 |
ShippingServiceCost . ",
|
|
|
754 |
'" . $va_bez . "',
|
|
|
755 |
''
|
|
|
756 |
);";
|
|
|
757 |
|
|
|
758 |
mysql_query( $sql ) or die( mail("admin@weban.de", "eBay-Cronjob Fehler",
|
|
|
759 |
mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
760 |
|
|
|
761 |
// Debug
|
|
|
762 |
if ( $_GET['sqlDebug'] == 1 ) {
|
|
|
763 |
echo 'artikel_to_Bestellung(INSERT): <br>' . $sql;
|
|
|
764 |
}
|
|
|
765 |
}
|
|
|
766 |
}
|
|
|
767 |
}
|
|
|
768 |
}
|
|
|
769 |
}
|
|
|
770 |
?>
|