From 16ce95adb841835edd13d9f1f069b77ae57a181d Mon Sep 17 00:00:00 2001 From: Freerk Minnema Date: Thu, 3 Dec 2020 14:39:22 +0100 Subject: [PATCH 1/3] Support added for reportAverageSpending --- Mplusqapiclient.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Mplusqapiclient.php b/Mplusqapiclient.php index 8d72e50..95e30cb 100755 --- a/Mplusqapiclient.php +++ b/Mplusqapiclient.php @@ -6900,6 +6900,14 @@ public function parseReportResult($method, $soapReportResult) } } break; + case "reportAverageSpending": + $data = array(); + if (isset($soapReportResult->averageSpendingList->averageSpending)) { + foreach ($soapReportResult->averageSpendingList->averageSpending as $soapAverageSpending) { + $data[] = $soapAverageSpending; + } + } + break; } return $data; } // END parseReportResult() @@ -9404,6 +9412,22 @@ public function convertReportRequest($method, $arguments) { 'branchNumbers', 'articleNumbers', 'perHour', 'turnoverGroups' ), ), + 'reportBranchPerformance' => array( + 'required' => array( + 'fromFinancialDate', 'throughFinancialDate', + ), + 'optional' => array( + 'branchNumbers' + ), + ), + 'reportAverageSpending' => array( + 'required' => array( + 'fromFinancialDate', 'throughFinancialDate', 'source' + ), + 'optional' => array( + 'branchNumbers', 'employeeNumbers' + ), + ), ); $request = []; if (array_key_exists($method, $fields)) { From 71c89e775232e705e025d09c1d19aeeadfe90bd7 Mon Sep 17 00:00:00 2001 From: Freerk Minnema Date: Fri, 4 Dec 2020 10:07:50 +0100 Subject: [PATCH 2/3] indent fixed the report function --- Mplusqapiclient.php | 50 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/Mplusqapiclient.php b/Mplusqapiclient.php index 95e30cb..52d1747 100755 --- a/Mplusqapiclient.php +++ b/Mplusqapiclient.php @@ -3819,33 +3819,31 @@ public function verifyCredentials($request, $attempts=0) //---------------------------------------------------------------------------- - public function report($arguments, $attempts = 0) { - try { - if (!is_array($arguments) || !array_key_exists('method', $arguments) || empty($arguments['method'])) { - throw new Exception("No method defined for group call : " . __FUNCTION__); - } - $method = __FUNCTION__ . $arguments['method']; - unset($arguments['method']); - $parameters = $this->parser->convertReportRequest($method, $arguments); - $result = call_user_func(array($this->client, $method), $parameters); - if ($this->returnRawResult) { - return $result; - } - return $this->parser->parseReportResult($method, $result); - } catch (SoapFault $e) { - $msg = $e->getMessage(); - if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { - sleep(1); - return $this->report($arguments, $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 report($arguments, $attempts = 0) { + try { + if (!is_array($arguments) || !array_key_exists('method', $arguments) || empty($arguments['method'])) { + throw new Exception("No method defined for group call : " . __FUNCTION__); + } + $method = __FUNCTION__ . $arguments['method']; + unset($arguments['method']); + $parameters = $this->parser->convertReportRequest($method, $arguments); + $result = call_user_func(array($this->client, $method), $parameters); + if ($this->returnRawResult) { + return $result; + } + return $this->parser->parseReportResult($method, $result); + } catch (SoapFault $e) { + $msg = $e->getMessage(); + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { + sleep(1); + return $this->report($arguments, $attempts + 1); + } else { + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); + } + } catch (Exception $e) { + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); } - // END report() - + } //---------------------------------------------------------------------------- From b8629ee704aab1646d80ec46730ab35e9ce5b569 Mon Sep 17 00:00:00 2001 From: Freerk Minnema Date: Fri, 4 Dec 2020 10:08:11 +0100 Subject: [PATCH 3/3] added support for the source parameter (and any other direct pass-through variables we might add) --- Mplusqapiclient.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Mplusqapiclient.php b/Mplusqapiclient.php index 52d1747..8301f4c 100755 --- a/Mplusqapiclient.php +++ b/Mplusqapiclient.php @@ -9471,6 +9471,9 @@ public function convertReportRequest($method, $arguments) { case "perHour": $request['perHour'] = $arguments['perHour'] === true ? true : false; break; + default: + $request[$callField] = $arguments[$callField]; + break; } } }