From 844036e23003322923dfa4c8363818217213f7a0 Mon Sep 17 00:00:00 2001 From: Freerk Minnema Date: Wed, 6 May 2020 10:55:06 +0200 Subject: [PATCH] getKitchenTickets added --- Mplusqapiclient.php | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Mplusqapiclient.php b/Mplusqapiclient.php index 706beef..2136f64 100755 --- a/Mplusqapiclient.php +++ b/Mplusqapiclient.php @@ -1070,6 +1070,29 @@ public function getTableListV3($request, $attempts=0) //---------------------------------------------------------------------------- + public function getKitchenTickets($request=null, $attempts=0) + { + try { + $result = $this->client->getKitchenTickets($this->parser->convertGetKitchenTicketsRequest($request)); + if ($this->returnRawResult) { + return $result; + } + return $this->parser->parseGetKitchenTickets($result); + } catch (SoapFault $e) { + $msg = $e->getMessage(); + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { + sleep(1); + return $this->getKitchenTickets($request, $attempts+1); + } else { + throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e); + } + } catch (Exception $e) { + throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e); + } + } + + //---------------------------------------------------------------------------- + public function getCurrentTableOrders($request=null, $attempts=0) { try { @@ -5416,6 +5439,29 @@ public function parseGetInvoicesResult($soapInvoicesResult) { //---------------------------------------------------------------------------- + public function parseGetKitchenTickets($soapResult) + { + $kitchenTickets = []; + if (isset($soapResult->kitchenTicketList->kitchenTicket)) { + $kitchenTickets = objectToArray($soapResult->kitchenTicketList->kitchenTicket); + foreach ($kitchenTickets as $kitchenTicketIdx => $kitchenTicket) { + if (isset($kitchenTicket['kitchenTicketCourseList']['kitchenTicketCourse'])) { + $kitchenTicket['kitchenTicketCourseList'] = $kitchenTicket['kitchenTicketCourseList']['kitchenTicketCourse']; + } + foreach ($kitchenTicket['kitchenTicketCourseList'] as $kitchenTicketCourseIdx => $kitchenTicketCourse) { + if (isset($kitchenTicketCourse['kitchenTicketLineList']['kitchenTicketLine'])) { + $kitchenTicketCourse['kitchenTicketLineList'] = $kitchenTicketCourse['kitchenTicketLineList']['kitchenTicketLine']; + } + $kitchenTicket['kitchenTicketCourseList'][$kitchenTicketCourseIdx] = $kitchenTicketCourse; + } + $kitchenTickets[$kitchenTicketIdx] = $kitchenTicket; + } + } + return $kitchenTickets; + } + + //---------------------------------------------------------------------------- + public function parseGetOrdersResult($soapOrdersResult) { $orders = array(); @@ -8581,6 +8627,17 @@ public function convertGetTableListV3Request($request) //---------------------------------------------------------------------------- + public function convertGetKitchenTicketsRequest($request) + { + if (is_null($request)) { + $request = []; + } + $object = arrayToObject(['request'=>$request]); + return $object; + } + + //---------------------------------------------------------------------------- + public function convertGetCurrentTableOrdersRequest($request) { if (is_null($request)) {