0277419db67fa1850d056e5b3f769a7d9621501e
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 3 years ago

1) <?php
Bernd Wurst Neue API 2023

Bernd Wurst authored 9 months ago

2) require_once('api.php');
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 3 years ago

3) 
4) function suche_kunde($name, $number) {
5)         global $content;
6)         if (! $number) {
7)             return NULL;
8)         }
Bernd Wurst Neue API 2023

Bernd Wurst authored 9 months ago

9)         $ret = api_call('GET', 'customerContacts/search/'.format_number_api($number));
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 3 years ago

10) 
Bernd Wurst Neue API 2023

Bernd Wurst authored 9 months ago

11)         if (count($ret) > 0) {
12)             $name = strtolower($name);
13)             foreach ($ret as $item) {
14)                 $cust = $item['customer'];
15)                 if ($name == strtolower($cust['lastname']) ||
16)                     $name == strtolower($cust['firstname']) ||
17)                     $name == strtolower($cust['firstname'] .' '. $cust['lastname'])
18)                     ) {
19)                     return $cust;
20)                 }
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 3 years ago

21)             }
22)         }
Bernd Wurst Neue API 2023

Bernd Wurst authored 9 months ago

23)         return null;
24) 
25)         /*
26)         $kundenliste = json_decode(file_get_contents('../kunden.json'), TRUE);
27)         foreach ($kundenliste as $k) {
28)                 foreach ($k['kontakt'] as $kon) {
29)                         if ($kon['wert'] == $number) {
30)                                 return $k;
31)                         }
32)                 }
33)         }
34)         */
Bernd Wurst API-Authtoken, Idle-Warnung...

Bernd Wurst authored 3 years ago

35) }
36) 
Bernd Wurst Neue API 2023

Bernd Wurst authored 9 months ago

37) function erstelle_kunde($daten) {
38)     $json = [
39)         "firstname" => $daten['fname'],
40)         "lastname" => $daten['lname'],
41)         "phone" => format_number_api($daten['phone']),
42)         "street" => $daten['address'],
43)         "zip" => $daten['zip'],
44)         "city" => $daten['city'],
45)         "contacts" => []];
46)     $ret = api_call('POST', 'customers', $json);
47)     if (isset($ret['id'])) {
48)         return $ret['id'];
49)     } else {
50)         return null;
51)     }
52) }