git.schokokeks.org
Repositories
Help
Report an Issue
bibweb.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
2e26714
Branches
Tags
master
bibweb.git
lib
auftrag.php
Erlaube nachname vorname
Bernd Wurst
commited
2e26714
at 2023-08-07 07:46:21
auftrag.php
Blame
History
Raw
<?php require_once('api.php'); function suche_kunde($name, $number) { global $content; if (! $number) { return NULL; } $ret = api_call('GET', 'customerContacts/search/'.format_number_api($number)); if (count($ret) > 0) { $name = strtolower($name); foreach ($ret as $item) { $cust = $item['customer']; if ($name == strtolower($cust['lastname']) || $name == strtolower($cust['firstname']) || $name == strtolower($cust['firstname'] .' '. $cust['lastname']) || $name == strtolower($cust['lastname'] .' '. $cust['firstname']) ) { return $cust; } } } return null; /* $kundenliste = json_decode(file_get_contents('../kunden.json'), TRUE); foreach ($kundenliste as $k) { foreach ($k['kontakt'] as $kon) { if ($kon['wert'] == $number) { return $k; } } } */ } function erstelle_kunde($daten) { $json = [ "firstname" => $daten['fname'], "lastname" => $daten['lname'], "phone" => format_number_api($daten['phone']), "street" => $daten['address'], "zip" => $daten['zip'], "city" => $daten['city'], "contacts" => []]; $ret = api_call('POST', 'customers', $json); if (isset($ret['id'])) { return $ret['id']; } else { return null; } } require_once('vendor/autoload.php'); function format_number_national($number) { $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneNumberUtil->parse($number, 'DE'); } catch (Exception $e) { return NULL; } if ($phoneNumberUtil->isValidNumber($phoneNumber)) { return $phoneNumberUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::NATIONAL); } return NULL; } function format_number($number) { $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneNumberUtil->parse($number, 'DE'); } catch (Exception $e) { return NULL; } if ($phoneNumberUtil->isValidNumber($phoneNumber)) { return $phoneNumberUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::INTERNATIONAL); } return NULL; }