@@ -3283,6 +3283,25 @@ public function getBranchGroups($attempts = 0)
32833283 }
32843284} // END getBranchGroups()
32853285
3286+ //----------------------------------------------------------------------------
3287+ public function getSalePromotions ($ branchNumbers = [], $ attempts =0 )
3288+ {
3289+ try {
3290+ $ result = $ this ->client ->getSalePromotions ($ this ->parser ->convertGetSalePromotionsRequest ($ branchNumbers ));
3291+ return $ this ->parser ->parseGetSalePromotionsResult ($ result );
3292+ } catch (SoapFault $ e ) {
3293+ $ msg = $ e ->getMessage ();
3294+ if (false !== stripos ($ msg , 'Could not connect to host ' ) and $ attempts < 3 ) {
3295+ sleep (1 );
3296+ return $ this ->getSalePromotions ($ attempts +1 );
3297+ } else {
3298+ throw new MplusQAPIException ('SoapFault occurred: ' .$ msg , 0 , $ e );
3299+ }
3300+ } catch (Exception $ e ) {
3301+ throw new MplusQAPIException ('Exception occurred: ' .$ e ->getMessage (), 0 , $ e );
3302+ }
3303+ } // END getSalePromotions()
3304+
32863305}
32873306
32883307//==============================================================================
@@ -5707,6 +5726,29 @@ public function parseReportResult($method, $soapReportResult)
57075726 return $ data ;
57085727 } // END parseReportResult()
57095728
5729+ //----------------------------------------------------------------------------
5730+
5731+ public function parseGetSalePromotionsResult ($ soapGetSalePromotionsResult ) {
5732+ $ salePromotions = array ();
5733+ if (isset ($ soapGetSalePromotionsResult ->salePromotionsList ->salePromotions )) {
5734+ $ soapSalePromotions = $ soapGetSalePromotionsResult ->salePromotionsList ->salePromotions ;
5735+ $ salePromotions = objectToArray ($ soapSalePromotions );
5736+ foreach ($ salePromotions as $ idx => $ salePromotion ) {
5737+ if (isset ($ salePromotion ['salePromotionLineList ' ]['salePromotionLineList ' ])) {
5738+ if (isset ($ salePromotion ['salePromotionLineList ' ]['salePromotionLineList ' ])) {
5739+ $ salePromotions [$ idx ]['salePromotionLineList ' ] = $ salePromotion ['salePromotionLineList ' ]['salePromotionLineList ' ];
5740+ foreach ($ salePromotions [$ idx ]['salePromotionLineList ' ] as $ idy =>$ salePromotionLine ) {
5741+ if (isset ($ salePromotionLine ['salePromotionLineDiscountList ' ]['salePromotionLineDiscountList ' ])) {
5742+ $ salePromotions [$ idx ]['salePromotionLineList ' ][$ idy ]['salePromotionLineDiscountList ' ] = $ salePromotions [$ idx ]['salePromotionLineList ' ][$ idy ]['salePromotionLineDiscountList ' ]['salePromotionLineDiscountList ' ];
5743+ }
5744+ }
5745+ }
5746+ }
5747+ }
5748+ }
5749+ return $ salePromotions ;
5750+ } // END parseGetSalePromotionsResult()
5751+
57105752
57115753 //----------------------------------------------------------------------------
57125754
@@ -7970,6 +8012,21 @@ public function convertReportRequest($method, $arguments)
79708012 $ object = arrayToObject (array ('request ' => $ request ));
79718013 return $ object ;
79728014 } // END convertReportRequest()
8015+
8016+ public function convertGetSalePromotionsRequest ($ branchNumbers )
8017+ {
8018+ $ array = [ 'request ' => [] ];
8019+
8020+ if ($ branchNumbers !== null ) {
8021+ if (!is_array ($ branchNumbers )) {
8022+ $ branchNumbers = array ($ branchNumbers );
8023+ }
8024+ $ array ['request ' ]['branchFilter ' ] = $ branchNumbers ;
8025+ }
8026+
8027+ $ object = arrayToObject ($ array );
8028+ return $ object ;
8029+ } // END convertGetSalePromotionsRequest()
79738030
79748031 //----------------------------------------------------------------------------
79758032
0 commit comments