4963b3db3066e945b1c36747a5d20015df7a119e
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

1) <?php
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 4 years ago

2) require_once "lib/api.php";
3) require_once "lib/auftrag.php";
Bernd Wurst Session zerstören wenn der...

Bernd Wurst authored 2 months ago

4) if (!file_exists("../data/".date("Y"))) {
5)     mkdir("../data/".date("Y"));
6) }
7) 
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

8) session_start();
Bernd Wurst kill idle sessions

Bernd Wurst authored 1 year ago

9) if (isset($_SESSION['last_activity']) && $_SESSION['last_activity'] < time()-(20*60)) {
10)     // Session seit 20 Minuten nicht benutzt
11)     if (isset($_SESSION['kundennr']) || isset($_SESSION['orderid'])) {
12)         // Session hat Inhalt
13)         // Auftrag lokal speichern
Bernd Wurst time() am Beginn der Datein...

Bernd Wurst authored 1 year ago

14)         $filename = "../data/".date('Y').'/'.time().'-canceledsession.json';
Bernd Wurst kill idle sessions

Bernd Wurst authored 1 year ago

15)         if (isset($_SESSION['orderid'])) {
Bernd Wurst time() am Beginn der Datein...

Bernd Wurst authored 1 year ago

16)             $filename = "../data/".date('Y').'/'.time().'-canceledsession-'.$_SESSION['orderid'].'.json';
Bernd Wurst kill idle sessions

Bernd Wurst authored 1 year ago

17)         }
18)         @file_put_contents($filename, json_encode($_SESSION));
Bernd Wurst Noch ein Versuch, den Mode...

Bernd Wurst authored 1 month ago

19)         header('Location: clear.php');
20)         die();
Bernd Wurst kill idle sessions

Bernd Wurst authored 1 year ago

21)     }
22) }
23) $_SESSION['last_activity'] = time();
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

24) $_SESSION['warnings'] = [];
25) 
26) $_SESSION['angeliefert'] = true;
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

27) 
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 4 years ago

28) $handle_length = 8;
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

29) if (! isset($_SESSION['handle']) || !$_SESSION['handle']) {
30)     $random = base64_encode(md5(microtime()));
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 4 years ago

31)     $_SESSION['handle'] = substr(str_replace(array('+', '=', '/'), '', $random), 0, $handle_length);
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 4 years ago

32)     $_SESSION['date'] = date('Y-m-d H:i:s.v');
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

33)     $_SESSION['complete'] = false;
34) }
35) 
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 4 years ago

36) 
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

37) function showError()
38) {
39)     switch ($_REQUEST['form']) {
40)         case 'start':
41)                 $redirect = 'index.php?error&num='.urlencode($number).'&name='.urlencode($name);
42)                 break;
43)         case 'address':
44)                 $redirect = 'address.php?error';
45)                 break;
46)         case 'anlieferung':
47)                 $redirect = 'anlieferung.php?error';
48)                 break;
49)         case 'gitterbox':
50)             $redirect = 'gitterbox.php?error';
51)             break;
52)         case 'obstart':
53)             $redirect = 'obstart.php?error';
54)             break;
55)         case 'gebrauchte':
56)             $redirect = 'gebrauchte.php?error';
57)             break;
58)         case 'auftrag':
59)             $redirect = 'auftrag.php?error';
60)             break;
61)          case 'frischsaft':
62)             $redirect = 'frischsaft.php?error';
63)             break;
64)         case 'summary':
65)             $redirect = 'summary.php?error';
66)             break;
67)     }
68)     header('Location: '.$redirect);
69)     die();
70) }
71) 
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

72) $redirect = NULL;
73) if (isset($_REQUEST['form'])) {
74)     switch ($_REQUEST['form']) {
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

75)         case 'start':
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

76)             $number = '';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

77)             if (isset($_REQUEST['phone']) && trim($_REQUEST['phone']) != '') {
Bernd Wurst Ergänze lokale Vorwahl bei...

Bernd Wurst authored 6 years ago

78)                 $number = trim($_REQUEST['phone']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

79)             }
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

80)             $name = '';
81)             if (isset($_REQUEST['name']) && trim($_REQUEST['name']) != '') {
82)                 $name = trim($_REQUEST['name']);
83)             }
84) 
Bernd Wurst Änderungen Stand 2019

Bernd Wurst authored 4 years ago

85)             if (substr($number, 0, 1) != 0 && substr($number, 0, 3) != '+49') {
Bernd Wurst Ergänze lokale Vorwahl bei...

Bernd Wurst authored 6 years ago

86)                 $number = '07192'.$number;
87)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

88) 
Bernd Wurst Fange ungültige Telefonnumm...

Bernd Wurst authored 1 year ago

89)             $number = format_number_national($number);
90) 
91)             if (! $number || !$name || !format_number_api($number)) {
92)                 $redirect = 'index.php?error&num='.urlencode($number).'&name='.urlencode($name);
93)                 break;
94)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

95) 
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 4 years ago

96)             $_SESSION['name'] = htmlspecialchars($name);
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

97)             $_SESSION['phone'] = htmlspecialchars($number);
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

98)             if (isset($_REQUEST['save']) && $_REQUEST['save'] == 'yes' && $_SESSION['mode'] != 'local') {
Bernd Wurst bestehende Kunden über die...

Bernd Wurst authored 4 years ago

99)                 setcookie('NAME', $name, time() + 24*3600*500, "");
Bernd Wurst Cookie löschbar, Datenschut...

Bernd Wurst authored 6 years ago

100)                 setcookie('NUMBER', $number, time() + 24*3600*500, "");
101)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

102) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

103)             $redirect = 'address.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

104)             break;
105) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

106)         case 'address':
Bernd Wurst frage E-Mail-Adresse ab

Bernd Wurst authored 1 year ago

107)             $fields = array("firma", "fname", "lname", "address", "zip", "city", "email");
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

108)             foreach ($fields as $f) {
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

109)                 if (isset($_REQUEST[$f]) && trim($_REQUEST[$f]) != '') {
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

110)                     $_SESSION[$f] = trim(htmlspecialchars($_REQUEST[$f]));
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

111)                 } else {
112)                     if (! isset($_SESSION[$f])) {
113)                         $_SESSION[$f] = '';
114)                     }
115)                 }
116)             }
Bernd Wurst Fehlermeldungen auf BS4 por...

Bernd Wurst authored 6 years ago

117)             if ($_SESSION['lname'] == '') {
118)                 $redirect = 'address.php?error';
119)                 break;
120)             }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

121)             if (!isset($_SESSION['kundennr']) || !$_SESSION['kundennr']) {
122)                 $_SESSION['kundennr'] = erstelle_kunde($_SESSION);
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

123)                 if (!$_SESSION['kundennr']) {
124)                     showError();
125)                     }
Bernd Wurst frage E-Mail-Adresse ab

Bernd Wurst authored 1 year ago

126)             } else {
127)                 if (isset($_SESSION['email']) && $_SESSION['email']) {
128)                     update_kunde($_SESSION['kundennr'], ['email' => $_SESSION['email']]);
129)                 }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

130)             }
131) 
Bernd Wurst Auswahl, ob per E-Mail oder...

Bernd Wurst authored 1 month ago

132)             $redirect = 'notification.php';
133)             break;
134) 
135)         case 'notification':
136)             if (isset($_REQUEST['notification'])) {
137)                 if ($_REQUEST['notification'] == 'sms') {
138)                     $_SESSION['notificationPreference'] = 'sms';
139)                 } elseif ($_REQUEST['notification'] == 'whatsapp') {
140)                     $_SESSION['notificationPreference'] = 'whatsapp';
141)                 } elseif ($_REQUEST['notification'] == 'email') {
142)                     $_SESSION['notificationPreference'] = 'email';
143)                 } else {
144)                     $_SESSION['notificationPreference'] = '';
145)                 }
146)             }
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

147)             if ($_SESSION['mode'] == 'local') {
148)                 $_SESSION['angeliefert'] = true;
149)                 $redirect = 'gitterbox.php';
150)             } elseif (isset($_SESSION['angeliefert'])) {
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

151)                 if ($_SESSION['angeliefert']) {
152)                     $redirect = 'gitterbox.php';
153)                 } else {
154)                     $redirect = 'gitterbox_spaeter.php';
155)                 }
156)             } else {
157)                 $redirect = 'anlieferung.php';
158)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

159)             break;
160) 
Bernd Wurst Auswahl, ob per E-Mail oder...

Bernd Wurst authored 1 month ago

161) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

162)         case 'anlieferung':
163)             if (isset($_REQUEST['schonda'])) {
164)                 $_SESSION['angeliefert'] = true;
165)                 $redirect = 'gitterbox.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

166)             }
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

167)             if (isset($_REQUEST['kommtnoch'])) {
168)                 $_SESSION['angeliefert'] = false;
169)                 $redirect = 'gitterbox_spaeter.php';
170)             }
171)             break;
172)         case 'gitterbox':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

173)             if (isset($_REQUEST['lieferart'])) {
174)                 if ($_REQUEST['lieferart'] == 'gitterbox') {
175)                     $_SESSION['lieferart'] = 'gitterbox';
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

176)                     $_SESSION['gbcount'] = htmlspecialchars($_REQUEST['gbcount']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

177)                 }
178)                 if ($_REQUEST['lieferart'] == 'anhaenger') {
179)                     $_SESSION['lieferart'] = 'anhaenger';
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

180)                     $_SESSION['kennz'] = htmlspecialchars($_REQUEST['kennz']);
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

181)                     if ($_SESSION['angeliefert'] === false && ! $_SESSION['kennz']) {
182)                         $redirect = 'gitterbox_spaeter.php?error';
183)                         break;
184)                     }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

185)                 }
186)             }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

187)             $redirect = 'obstart.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

188)             break;
189) 
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

190)          case 'obstart':
191)             $_SESSION['obstart'] = $_REQUEST['obstart'];
192)             $redirect = 'gebrauchte.php';
193) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

194)          case 'gebrauchte':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

195)             if (isset($_REQUEST['kartonsja'])) {
196)                 $_SESSION['kartons'] = true;
197)             } 
198)             if (isset($_REQUEST['kartonsnein'])) {
199)                 $_SESSION['kartons'] = false;
200)             }
201) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

202)             $redirect = 'auftrag.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

203)             break;
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

204)          case 'auftrag':
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

205)             if (isset($_REQUEST['3er'])) {
206)                 $_SESSION['neue'] = '3er';
207)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

208)             if (isset($_REQUEST['5er'])) {
209)                 $_SESSION['neue'] = '5er';
210)             }
211)             if (isset($_REQUEST['10er'])) {
212)                 $_SESSION['neue'] = '10er';
213)             }
214)             if (isset($_REQUEST['submit']) && isset($_REQUEST['sonstiges']) && $_REQUEST['sonstiges'] != '') {
215)                 $_SESSION['neue'] = 'sonstiges';
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

216)                 $_SESSION['sonstiges'] = htmlspecialchars($_REQUEST['sonstiges']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

217)             }
218) 
219) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

220)             $redirect = 'frischsaft.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

221)             break;
222) 
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

223)          case 'frischsaft':
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

224)             if (isset($_REQUEST['frischsaftnein'])) {
225)                 $_SESSION['frischsaft'] = 0;
226)             } elseif (isset($_REQUEST['frischsaft'])) {
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

227)                 $_SESSION['frischsaft'] = htmlspecialchars($_REQUEST['frischsaft']);
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

228)             }
229) 
Bernd Wurst Dateinamen geändert

Bernd Wurst authored 6 years ago

230)             $redirect = 'summary.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

231)             break;
Bernd Wurst Spätere Anlieferung eingebaut

Bernd Wurst authored 6 years ago

232)         case 'summary':
Bernd Wurst anmerkungen ermöglicht

Bernd Wurst authored 6 years ago

233)             if (isset($_REQUEST['anmerkungen'])) {
234)                 $_SESSION['anmerkungen'] = htmlspecialchars($_REQUEST['anmerkungen']);
235)             }
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

236) 
237)             $_SESSION['complete'] = true;
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

238)             $redirect = 'finish.php';
Bernd Wurst Initial commit

Bernd Wurst authored 6 years ago

239)             break;
240) 
241)     }
242) }
243) 
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

244) /*
245)  * Um das Speichern in der API kümmern wir uns, wenn Kundendaten, Obstart und grundsätzliche Auftragsdaten feststehen
246)  */
247) if (isset($_SESSION['neue'])) {
248)     // Bevor dieses Datenfeld vorhanden ist, macht Speichern keinen Sinn
249)     $auftrag = [];
250)     /* Herunterladen bringt nichts, da wir einfach immer unsere bekannten Daten rein schieben. Parallelität ist nicht gewünscht
251)      * if (isset($auftrag['id'])) {
252)         // Auftrag ist schon in der API, aktuellen Stand herunter laden
253)         $auftrag = api_call('GET', 'orders/'.$auftrag['id']);
254)     }*/
255) 
256)     // customer
257)     if (isset($_SESSION['kundennr'])) {
258)         $auftrag['customer'] = $_SESSION['kundennr'];
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

259)         $auftrag['notificationName'] = $_SESSION['name'];
260)         $auftrag['notificationPhone'] = $_SESSION['phone'];
Bernd Wurst Speichere (neu eingegebene)...

Bernd Wurst authored 1 year ago

261)         $auftrag['notificationEmail'] = isset($_SESSION['email']) ? $_SESSION['email'] : null;
Bernd Wurst Auswahl, ob per E-Mail oder...

Bernd Wurst authored 1 month ago

262)         $auftrag['notificationPreference'] = $_SESSION['notificationPreference'];
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

263)     }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

264)     // fruitType
265)     $ret = api_call('GET', 'fruitTypes');
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

266)     $ret = $ret['data'];
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

267)     foreach ($ret as $fruit) {
268)         if ($_SESSION['obstart'] == $fruit['label']) {
269)             $auftrag['fruitType'] = $fruit['id'];
270)         }
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

271)     }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

272)     // containers
273)     if (isset($_SESSION['lieferart']) && $_SESSION['lieferart'] == 'gitterbox' && isset($_SESSION['gbcount']) && $_SESSION['gbcount'] > 0) {
274)         $auftrag['containers'] = array_fill(0, $_SESSION['gbcount'], [ "type" => "box", "weight" => 400 ]);
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

275)     }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

276)     if (isset($_SESSION['lieferart']) && $_SESSION['lieferart'] == 'anhaenger') {
277)         if (!isset($_SESSION['kennz'])) {
278)             $_SESSION['kennz'] = null;
279)         }
280)         $auftrag['containers'] = [
281)             ["type" => "trailer",
282)             "weight" => 0,
283)             "label" => $_SESSION['kennz']]
284)         ];
285)     }
286)     // usedPackages
287)     if (isset($_SESSION['kartons'])) {
288)         $auftrag['usedPackages'] = (bool) $_SESSION['kartons'];
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

289)     }
290) 
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

291)     // plannedPackagings
292)     if (isset($_SESSION['neue'])) {
293)         if ($_SESSION['neue'] == 'sonstiges') {
294)             $auftrag['notes'] = (isset($_SESSION['anmerkungen']) ? $_SESSION['anmerkungen'] . "\n\n" : '') . $_SESSION["sonstiges"];
Bernd Wurst Bugfix: Frischsaft wurde ni...

Bernd Wurst authored 1 year ago

295)         }
296)         $plan = [];
297)         $ret = api_call('GET', 'packageTypes');
298)         $ret = $ret['data'];
299)         foreach ($ret as $pt) {
300)             if ($pt['label'] == $_SESSION['neue']) {
301)                 $plan[] = [ "packageType" => $pt['id'],
302)                             "rest" => true ];
303)             }
304)             if ($pt['label'] == 'frischsaft' && isset($_SESSION['frischsaft']) && $_SESSION['frischsaft'] > 0) {
305)                 $plan[] = [ "packageType" => $pt['id'],
306)                             "count" => $_SESSION['frischsaft']];
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

307)             }
308)         }
Bernd Wurst Bugfix: Frischsaft wurde ni...

Bernd Wurst authored 1 year ago

309)         $auftrag['plannedPackagings'] = $plan;
310)         
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

311)     }
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

312) 
313) 
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

314)     // notes
Bernd Wurst Session zerstören wenn der...

Bernd Wurst authored 2 months ago

315)     if (!isset($auftrag['notes'])) {
316)         $auftrag['notes'] = '';
317)     }
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

318)     if (isset($_SESSION['anmerkungen']) && $_SESSION['anmerkungen'] != '') {
319)         $auftrag['notes'] = $_SESSION['anmerkungen'] . (isset($_SESSION["sonstiges"]) ? "\n\n" . $_SESSION["sonstiges"] : '');
320)     }
Bernd Wurst Session zerstören wenn der...

Bernd Wurst authored 2 months ago

321)     $auftrag['notes'] .= "\nAuftrag wurde " . ($_SESSION['mode'] == 'local' ? 'am Terminal' : 'mit einem eigenen Gerät') . ' erstellt.';
322)     if (!isset($_SESSION['complete']) || $_SESSION['complete'] == false) {
323)         $auftrag['notes'] .= "\nAuftrag unvollständig erfasst.";
324)     }
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

325) 
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

326)     // Auftrag lokal speichern
327)     $filename = "../data/".date('Y').'/'.time().'.json';
328)     if (isset($_SESSION['orderid'])) {
Bernd Wurst time() am Beginn der Datein...

Bernd Wurst authored 1 year ago

329)         $filename = "../data/".date('Y').'/'.time().'-'.$_SESSION['orderid'].'.json';
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

330)     }
331)     @file_put_contents($filename, json_encode($auftrag));
332)      if (isset($_SESSION['orderid']) && $_SESSION['orderid']) {
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

333)         // update
334)         $ret = api_call('PUT', 'orders/'.$_SESSION['orderid'], $auftrag);
335)     } else {
336)         // neu
337)         $ret = api_call('POST', 'orders', $auftrag);
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

338)     }
339)     if ($ret['status_code'] >= 400) {
340)         foreach ($ret['data']['validation_errors'] as $item) {
Bernd Wurst Fange ungültige Telefonnumm...

Bernd Wurst authored 1 year ago

341)             $_SESSION['warnings'][] = $item['key'].': '.$item['message'];
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

342)         }
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

343)         return showError();
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

344)     }
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

345)     $ret = $ret['data'];
346)     $_SESSION['orderid'] = $ret['id'];
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

347) 
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

348)     if (!isset($ret['id'])) {
349)         echo "Es gabe einen Fehler beim Abspeichern des Auftrags. Wir bitten dies zu entschuldigen und einen Papierauftrag auszufüllen.";
350)         file_put_contents("../error.log", 
351)             date("Y-m-d H:i:s") . ': '.json_encode($auftrag).
352)             print_r($ret, true).'\n', FILE_APPEND | LOCK_EX);
353)         die();
354)     }
355) 
356)     // Auftrag lokal speichern
357)     if (isset($_SESSION['orderid'])) {
Bernd Wurst time() am Beginn der Datein...

Bernd Wurst authored 1 year ago

358)         $filename = "../data/".date('Y').'/'.time().'-'.$_SESSION['orderid'].'.json';
Bernd Wurst API-Aufrufe über Guzzle um...

Bernd Wurst authored 1 year ago

359)     }
360)     @file_put_contents($filename, json_encode($auftrag));
Bernd Wurst Neue API 2023

Bernd Wurst authored 1 year ago

361)     /*
362)     if ($ret['status'] == 'error') {
363)         echo 'Es gibt ein Problem beim Speichern des Auftrags. Bitte verwenden Sie diesmal einen Papier-Auftrag.';
364)         die();
365)     }
366)     */
Bernd Wurst Erste Version, die über die...

Bernd Wurst authored 4 years ago

367) }
368)