Explorar o código

Ticket #5416 - Payments: Update All Subscriptions block.

AntonLV hai 7 meses
pai
achega
c632730ca7

+ 10 - 0
modules/base/payment/classes/BxBaseModPaymentModule.php

@@ -216,6 +216,16 @@ class BxBaseModPaymentModule extends BxBaseModGeneralModule
         return $aResult;
     }
 
+    public function _isModeratorForProfile($isPerformAction = false, $iProfileId = false)
+    {
+        return BxDolAcl::getInstance()->isMemberLevelInSet([MEMBERSHIP_ID_MODERATOR, MEMBERSHIP_ID_ADMINISTRATOR], $iProfileId) || (($oProfile = BxDolProfile::getInstance()) !== false && isAdmin($oProfile->getAccountId()));
+    }
+
+    public function _isAdministratorForProfile($isPerformAction = false, $iProfileId = false)
+    {
+        return BxDolAcl::getInstance()->isMemberLevelInSet([MEMBERSHIP_ID_ADMINISTRATOR], $iProfileId) || (($oProfile = BxDolProfile::getInstance()) !== false && isAdmin($oProfile->getAccountId()));
+    }
+
     public function isSingleSeller()
     {
         return $this->_oConfig->isSingleSeller();

+ 15 - 0
modules/boonex/payment/classes/BxPaymentGridSbsAdministration.php

@@ -70,6 +70,21 @@ class BxPaymentGridSbsAdministration extends BxBaseModPaymentGridTransactions
         return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
     }
 
+    protected function _getCellItems($mixedValue, $sKey, $aField, $aRow)
+    {
+        $aInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $aRow['client_id'], $aRow['seller_id'], $mixedValue);
+
+        $mixedValue = [];
+        if(($sK = 'items') && !empty($aInfo[$sK]) && is_array($aInfo[$sK]))
+        foreach($aInfo[$sK] as $aItem)
+            if($this->_bIsApi)
+                $mixedValue[] = $aItem['title'];
+            else
+                $mixedValue[] = $this->_oTemplate->parseLink($aItem['url'], $aItem['title']);
+
+        return parent::_getCellDefault(implode(', ', $mixedValue), $sKey, $aField, $aRow);
+    }
+
     protected function _getCellDateAdd($mixedValue, $sKey, $aField, $aRow)
     {
         return $this->_getCellDefaultDateTime($mixedValue, $sKey, $aField, $aRow);

+ 0 - 15
modules/boonex/payment/classes/BxPaymentGridSbsList.php

@@ -31,21 +31,6 @@ class BxPaymentGridSbsList extends BxPaymentGridSbsAdministration
         return parent::getCode($isDisplayHeader);
     }
 
-    protected function _getCellItems($mixedValue, $sKey, $aField, $aRow)
-    {
-        $aInfo = $this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_RECURRING, $aRow['client_id'], $aRow['seller_id'], $mixedValue);
-
-        $mixedValue = [];
-        if(($sK = 'items') && !empty($aInfo[$sK]) && is_array($aInfo[$sK]))
-        foreach($aInfo[$sK] as $aItem)
-            if($this->_bIsApi)
-                $mixedValue[] = $aItem['title'];
-            else
-                $mixedValue[] = $this->_oTemplate->parseLink($aItem['url'], $aItem['title']);
-
-        return parent::_getCellDefault(implode(', ', $mixedValue), $sKey, $aField, $aRow);
-    }
-
     protected function _getActionActions ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
     	$sJsCode = '';

+ 1 - 1
modules/boonex/payment/classes/BxPaymentModule.php

@@ -1288,7 +1288,7 @@ class BxPaymentModule extends BxBaseModPaymentModule
 
     public function isAllowedManageInvoices($bPerform = false)
     {
-        if(BxDolAcl::getInstance()->isMemberLevelInSet(array(MEMBERSHIP_ID_MODERATOR, MEMBERSHIP_ID_ADMINISTRATOR)) || isAdmin())
+        if($this->_isModerator())
             return true;
 
         return _t('_sys_txt_access_denied');

+ 21 - 6
modules/boonex/payment/classes/BxPaymentTemplate.php

@@ -291,6 +291,11 @@ class BxPaymentTemplate extends BxBaseModPaymentTemplate
         $aSeller = $oModule->getVendorInfo((int)$aOrder['seller_id']);
         $aClient = $oModule->getProfileInfo((int)$aOrder['client_id']);
 
+        if(in_array($sType, [BX_PAYMENT_ORDERS_TYPE_PENDING, BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION]))
+            $aItems = $this->_oConfig->descriptorsM2A($aOrder['items']);
+        else
+            $aItems = $this->_oConfig->descriptorsM2A($this->_oConfig->descriptorA2S([$aOrder['seller_id'], $aOrder['module_id'], $aOrder['item_id'], $aOrder['item_count']]));
+
         $aTmplVarsLicense = array();
         if(in_array($sType, array(BX_PAYMENT_ORDERS_TYPE_PROCESSED, BX_PAYMENT_ORDERS_TYPE_HISTORY)))
             $aTmplVarsLicense = array(
@@ -329,12 +334,27 @@ class BxPaymentTemplate extends BxBaseModPaymentTemplate
         );
 
         $aTmplVarsCustom = [];
-        if(in_array($sType, [BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION]))
+        if(in_array($sType, [BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION])) {
+            $sOrder = $aOrder['order'];
+            if($oModule->_isModerator() && ($aItem = array_shift($aItems))) {
+                $aItemModule = bx_srv((int)$aItem['module_id'], 'get_payment_data');
+                if(($sUrlBrowse = $aItemModule['url_browse_order_administration'] ?? false)) 
+                    $sOrder = $this->displayLink('link', [
+                        'href' => bx_replace_markers($sUrlBrowse, [
+                            'order' => $sOrder
+                        ]),
+                        'title' => bx_html_attribute($sOrder),
+                        'content' => $sOrder
+                    ]);
+            }
+
             $aTmplVarsCustom = [
                 'txt_order' => _t($this->_sLangsPrefix . 'txt_subscription'),
+                'order' => $sOrder,
                 'txt_customer_id' => _t($this->_sLangsPrefix . 'txt_customer_id'),
                 'customer_id' => $aOrder['customer_id'],
             ];
+        }
 
         $aResult = array_merge(array(
             'txt_client' => _t($this->_sLangsPrefix . 'txt_client'),
@@ -364,11 +384,6 @@ class BxPaymentTemplate extends BxBaseModPaymentTemplate
             'bx_repeat:items' => array()
         ), $aTmplVarsSeller, $aTmplVarsCustom);
 
-        if(in_array($sType, array(BX_PAYMENT_ORDERS_TYPE_PENDING, BX_PAYMENT_ORDERS_TYPE_SUBSCRIPTION)))
-            $aItems = $this->_oConfig->descriptorsM2A($aOrder['items']);
-        else
-            $aItems = $this->_oConfig->descriptorsM2A($this->_oConfig->descriptorA2S(array($aOrder['seller_id'], $aOrder['module_id'], $aOrder['item_id'], $aOrder['item_count'])));
-
         foreach($aItems as $aItem) {
             $aInfo = $oModule->callGetCartItem((int)$aItem['module_id'], array($aItem['item_id'], $aOrder['client_id']));
             if(!empty($aInfo) && is_array($aInfo))