Przeglądaj źródła

Ticket #4473 - Payments: Subscriptions pages are empty.

AntonLV 3 lat temu
rodzic
commit
e68b7d27d7

+ 1 - 187
modules/base/payment/classes/BxBaseModPaymentGridOrders.php

@@ -9,49 +9,11 @@
  * @{
  */
 
-class BxBaseModPaymentGridOrders extends BxTemplGrid
+class BxBaseModPaymentGridOrders extends BxBaseModPaymentGridTransactions
 {
-    protected $MODULE;
-    protected $_oModule;
-
-    protected $_sOrdersType;
-
-    protected $_bSingleSeller;
-    protected $_iSingleSeller;
-
-    protected $_sJsObject;
-    protected $_sLangsPrefix;
-    protected $_sCurrencySign;
-
     public function __construct ($aOptions, $oTemplate = false)
     {
         parent::__construct ($aOptions, $oTemplate);
-
-        $this->_oModule = BxDolModule::getInstance($this->MODULE);
-
-        $this->_bSingleSeller = $this->_oModule->_oConfig->isSingleSeller();
-
-        $this->_iSingleSeller = 0;
-        if($this->_bSingleSeller)
-            $this->_iSingleSeller = $this->_oModule->_oConfig->getSiteAdmin();
-
-        $this->_sLangsPrefix = $this->_oModule->_oConfig->getPrefix('langs');
-        $this->_sCurrencySign = $this->_oModule->_oConfig->getDefaultCurrencySign();
-
-        $this->_sDefaultSortingOrder = 'DESC';
-
-        $iSellerId = bx_get('seller_id');
-        if($iSellerId !== false) {
-            $iSellerId = (int)$iSellerId;
-            $this->_aQueryAppend['seller_id'] = $iSellerId;
-
-            if(!$this->_bSingleSeller)
-                $this->_sCurrencySign = $this->_oModule->getVendorCurrencySign($iSellerId);
-        }
-
-        $iClientId = bx_get('client_id');
-        if($iClientId !== false)
-            $this->_aQueryAppend['client_id'] = (int)$iClientId;
     }
 
     public function getCode ($isDisplayHeader = true)
@@ -62,30 +24,6 @@ class BxBaseModPaymentGridOrders extends BxTemplGrid
         return parent::getCode($isDisplayHeader);
     }
 
-    public function addQueryParam($sKey, $sValue)
-    {
-        if(empty($sKey) || !isset($sValue))
-            return;
-
-        $this->_aQueryAppend[$sKey] = $sValue;
-    }
-
-    public function performActionViewOrder()
-    {
-        $aIds = bx_get('ids');
-        if(!$aIds || !is_array($aIds)) 
-            return echoJson(array());
-
-        $iId = (int)$aIds[0];
-
-        $sKey = 'order_' . $this->_sOrdersType . '_view';
-        $sId = $this->_oModule->_oConfig->getHtmlIds($this->_sOrdersType, $sKey);
-        $sTitle = _t($this->_sLangsPrefix . 'popup_title_ods_' . $sKey);
-        $sContent = $this->_oModule->getObjectOrders()->getOrder($this->_sOrdersType, $iId);
-
-        return echoJson(array('popup' => BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $sContent)));
-    }
-
     public function performActionCancel()
     {
     	$aIds = bx_get('ids');
@@ -104,130 +42,6 @@ class BxBaseModPaymentGridOrders extends BxTemplGrid
 
         echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aAffected) : array('msg' => _t($this->_sLangsPrefix . 'err_cannot_perform')));
     }
-
-    protected function _getCellHeaderAuthorId ($sKey, $aField)
-    {
-        if(!$this->_bSingleSeller)
-            return '';
-
-        if($this->_aQueryAppend['seller_id'] != $this->_iSingleSeller)
-            $aField['title'] = _t('_bx_payment_grid_column_title_ods_seller_id');
-
-        return parent::_getCellHeaderDefault($sKey, $aField);
-    }
-
-    protected function _getCellClientId($mixedValue, $sKey, $aField, $aRow)
-    {
-        return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
-    }
-
-    protected function _getCellSellerId($mixedValue, $sKey, $aField, $aRow)
-    {
-        return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
-    }
-    
-    protected function _getCellAuthorId($mixedValue, $sKey, $aField, $aRow)
-    {
-        if(!$this->_bSingleSeller)
-            return '';
-
-        if($this->_aQueryAppend['seller_id'] != $this->_iSingleSeller)
-            $mixedValue = $aRow['seller_id'];
-        
-        $sResult = '';
-        if(!empty($mixedValue) && is_numeric($mixedValue))
-            $sResult = $this->_oModule->_oTemplate->displayProfileLink($mixedValue);
-
-        return parent::_getCellDefault($sResult, $sKey, $aField, $aRow);
-    }
-
-    protected function _getCellItem($mixedValue, $sKey, $aField, $aRow)
-    {
-        $sTxtUnknown = _t('_uknown');
-
-        if(empty($aRow['module_id']) || empty($aRow['item_id']))
-            return parent::_getCellDefault($sTxtUnknown, $sKey, $aField, $aRow);
-
-        $aItemInfo = $this->_oModule->callGetCartItem((int)$aRow['module_id'], array((int)$aRow['item_id'], $aRow['client_id']));
-        if(empty($aItemInfo) || !is_array($aItemInfo))
-            return parent::_getCellDefault($sTxtUnknown, $sKey, $aField, $aRow);
-
-        return parent::_getCellDefault($this->_oModule->_oTemplate->displayLink('link', array(
-            'href' => $aItemInfo['url'],
-            'title' => bx_html_attribute($aItemInfo['title']),
-            'content' => $aItemInfo['title']
-    	)), $sKey, $aField, $aRow);
-    }
-
-    protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
-    {
-        $sSign = '';
-        if(!empty($aRow['currency']))
-            $sSign = $this->_oModule->_oConfig->retrieveCurrencySign($aRow['currency']);
-        else
-            $sSign = !$this->_bSingleSeller ? $this->_oModule->getVendorCurrencySign((int)$aRow['seller_id']) : $this->_sCurrencySign;
-
-        return parent::_getCellDefault(_t_format_currency_ext($mixedValue, ['sign' => $sSign]), $sKey, $aField, $aRow);
-    }
-
-    protected function _getCellDate($mixedValue, $sKey, $aField, $aRow)
-    {
-        return $this->_getCellDefaultDateTime($mixedValue, $sKey, $aField, $aRow);
-    }
-    
-    protected function _getCellDefaultDate($mixedValue, $sKey, $aField, $aRow)
-    {
-        return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE, true), $sKey, $aField, $aRow);
-    }
-
-    protected function _getCellDefaultDateTime($mixedValue, $sKey, $aField, $aRow)
-    {
-        return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE_TIME, true), $sKey, $aField, $aRow);
-    }
-
-    protected function _getFilterSelectAll($sName, $aParams = array())
-    {
-        $sJsObject = !empty($aParams['js_object']) ? $aParams['js_object'] : $this->_sJsObject;
-        $sJsOnChange = !empty($aParams['js_onchange']) ? $aParams['js_onchange'] : 'onChangeFilter(this)';
-        
-        $aAttrs = array(
-            'id' => 'bx-grid-' . $sName . '-' . $this->_sObject,
-            'onChange' => 'javascript:$(this).off(\'keyup focusout\'); ' . $sJsObject . '.' . $sJsOnChange,
-            'onBlur' => 'javascript:' . $sJsObject . '.' . $sJsOnChange,
-        );
-        if(!empty($aParams['attrs']) && is_array($aParams['attrs']))
-            $aAttrs = array_merge($aAttrs, $aParams['attrs']);
-
-        $aInput = array(
-            'type' => 'select',
-            'name' => $sName,
-            'tr_attrs' => array(
-                'class' => 'bx-grid-filter-' . $sName,
-            ),
-            'attrs' => $aAttrs,
-            'value' => !empty($aParams['value']) ? $aParams['value'] : '',
-            'values' => !empty($aParams['values']) && is_array($aParams['values']) ? $aParams['values'] : array()
-        );
-
-        $oForm = new BxTemplFormView(array());
-        return $oForm->genRow($aInput);
-    }
-
-    protected function _getSearchInput()
-    {
-        $aInput = array(
-            'type' => 'text',
-            'name' => 'keyword',
-            'attrs' => array(
-                'id' => 'bx-grid-search-' . $this->_sObject,
-                'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $this->_sJsObject . '.onChangeFilter(this)',
-                'placeholder' => bx_html_attribute(_t('_sys_grid_search'))
-            )
-        );
-
-        $oForm = new BxTemplFormView(array());
-        return $oForm->genRow($aInput);
-    }
 }
 
 /** @} */

+ 206 - 0
modules/base/payment/classes/BxBaseModPaymentGridTransactions.php

@@ -0,0 +1,206 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    BasePayment Base classes for Payment like modules
+ * @ingroup     UnaModules
+ * 
+ * @{
+ */
+
+class BxBaseModPaymentGridTransactions extends BxTemplGrid
+{
+    protected $MODULE;
+    protected $_oModule;
+
+    protected $_sOrdersType;
+
+    protected $_bSingleSeller;
+    protected $_iSingleSeller;
+
+    protected $_sJsObject;
+    protected $_sLangsPrefix;
+    protected $_sCurrencySign;
+
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        parent::__construct ($aOptions, $oTemplate);
+
+        $this->_oModule = BxDolModule::getInstance($this->MODULE);
+
+        $this->_bSingleSeller = $this->_oModule->_oConfig->isSingleSeller();
+
+        $this->_iSingleSeller = 0;
+        if($this->_bSingleSeller)
+            $this->_iSingleSeller = $this->_oModule->_oConfig->getSiteAdmin();
+
+        $this->_sLangsPrefix = $this->_oModule->_oConfig->getPrefix('langs');
+        $this->_sCurrencySign = $this->_oModule->_oConfig->getDefaultCurrencySign();
+
+        $this->_sDefaultSortingOrder = 'DESC';
+
+        $iSellerId = bx_get('seller_id');
+        if($iSellerId !== false) {
+            $iSellerId = (int)$iSellerId;
+            $this->_aQueryAppend['seller_id'] = $iSellerId;
+
+            if(!$this->_bSingleSeller)
+                $this->_sCurrencySign = $this->_oModule->getVendorCurrencySign($iSellerId);
+        }
+
+        $iClientId = bx_get('client_id');
+        if($iClientId !== false)
+            $this->_aQueryAppend['client_id'] = (int)$iClientId;
+    }
+
+    public function addQueryParam($sKey, $sValue)
+    {
+        if(empty($sKey) || !isset($sValue))
+            return;
+
+        $this->_aQueryAppend[$sKey] = $sValue;
+    }
+
+    public function performActionViewOrder()
+    {
+        $aIds = bx_get('ids');
+        if(!$aIds || !is_array($aIds)) 
+            return echoJson(array());
+
+        $iId = (int)$aIds[0];
+
+        $sKey = 'order_' . $this->_sOrdersType . '_view';
+        $sId = $this->_oModule->_oConfig->getHtmlIds($this->_sOrdersType, $sKey);
+        $sTitle = _t($this->_sLangsPrefix . 'popup_title_ods_' . $sKey);
+        $sContent = $this->_oModule->getObjectOrders()->getOrder($this->_sOrdersType, $iId);
+
+        return echoJson(array('popup' => BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $sContent)));
+    }
+
+    protected function _getCellHeaderAuthorId ($sKey, $aField)
+    {
+        if(!$this->_bSingleSeller)
+            return '';
+
+        if($this->_aQueryAppend['seller_id'] != $this->_iSingleSeller)
+            $aField['title'] = _t('_bx_payment_grid_column_title_ods_seller_id');
+
+        return parent::_getCellHeaderDefault($sKey, $aField);
+    }
+
+    protected function _getCellClientId($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellSellerId($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
+    }
+    
+    protected function _getCellAuthorId($mixedValue, $sKey, $aField, $aRow)
+    {
+        if(!$this->_bSingleSeller)
+            return '';
+
+        if($this->_aQueryAppend['seller_id'] != $this->_iSingleSeller)
+            $mixedValue = $aRow['seller_id'];
+        
+        $sResult = '';
+        if(!empty($mixedValue) && is_numeric($mixedValue))
+            $sResult = $this->_oModule->_oTemplate->displayProfileLink($mixedValue);
+
+        return parent::_getCellDefault($sResult, $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellItem($mixedValue, $sKey, $aField, $aRow)
+    {
+        $sTxtUnknown = _t('_uknown');
+
+        if(empty($aRow['module_id']) || empty($aRow['item_id']))
+            return parent::_getCellDefault($sTxtUnknown, $sKey, $aField, $aRow);
+
+        $aItemInfo = $this->_oModule->callGetCartItem((int)$aRow['module_id'], array((int)$aRow['item_id'], $aRow['client_id']));
+        if(empty($aItemInfo) || !is_array($aItemInfo))
+            return parent::_getCellDefault($sTxtUnknown, $sKey, $aField, $aRow);
+
+        return parent::_getCellDefault($this->_oModule->_oTemplate->displayLink('link', array(
+            'href' => $aItemInfo['url'],
+            'title' => bx_html_attribute($aItemInfo['title']),
+            'content' => $aItemInfo['title']
+    	)), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
+    {
+        $sSign = '';
+        if(!empty($aRow['currency']))
+            $sSign = $this->_oModule->_oConfig->retrieveCurrencySign($aRow['currency']);
+        else
+            $sSign = !$this->_bSingleSeller ? $this->_oModule->getVendorCurrencySign((int)$aRow['seller_id']) : $this->_sCurrencySign;
+
+        return parent::_getCellDefault(_t_format_currency_ext($mixedValue, ['sign' => $sSign]), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellDate($mixedValue, $sKey, $aField, $aRow)
+    {
+        return $this->_getCellDefaultDateTime($mixedValue, $sKey, $aField, $aRow);
+    }
+    
+    protected function _getCellDefaultDate($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE, true), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellDefaultDateTime($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE_TIME, true), $sKey, $aField, $aRow);
+    }
+
+    protected function _getFilterSelectAll($sName, $aParams = array())
+    {
+        $sJsObject = !empty($aParams['js_object']) ? $aParams['js_object'] : $this->_sJsObject;
+        $sJsOnChange = !empty($aParams['js_onchange']) ? $aParams['js_onchange'] : 'onChangeFilter(this)';
+        
+        $aAttrs = array(
+            'id' => 'bx-grid-' . $sName . '-' . $this->_sObject,
+            'onChange' => 'javascript:$(this).off(\'keyup focusout\'); ' . $sJsObject . '.' . $sJsOnChange,
+            'onBlur' => 'javascript:' . $sJsObject . '.' . $sJsOnChange,
+        );
+        if(!empty($aParams['attrs']) && is_array($aParams['attrs']))
+            $aAttrs = array_merge($aAttrs, $aParams['attrs']);
+
+        $aInput = array(
+            'type' => 'select',
+            'name' => $sName,
+            'tr_attrs' => array(
+                'class' => 'bx-grid-filter-' . $sName,
+            ),
+            'attrs' => $aAttrs,
+            'value' => !empty($aParams['value']) ? $aParams['value'] : '',
+            'values' => !empty($aParams['values']) && is_array($aParams['values']) ? $aParams['values'] : array()
+        );
+
+        $oForm = new BxTemplFormView(array());
+        return $oForm->genRow($aInput);
+    }
+
+    protected function _getSearchInput()
+    {
+        $aInput = array(
+            'type' => 'text',
+            'name' => 'keyword',
+            'attrs' => array(
+                'id' => 'bx-grid-search-' . $this->_sObject,
+                'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $this->_sJsObject . '.onChangeFilter(this)',
+                'placeholder' => bx_html_attribute(_t('_sys_grid_search'))
+            )
+        );
+
+        $oForm = new BxTemplFormView(array());
+        return $oForm->genRow($aInput);
+    }
+}
+
+/** @} */

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

@@ -10,7 +10,7 @@
  */
 
 
-class BxPaymentGridHistory extends BxBaseModPaymentGridOrders
+class BxPaymentGridHistory extends BxBaseModPaymentGridTransactions
 {
     public function __construct ($aOptions, $oTemplate = false)
     {

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

@@ -10,7 +10,7 @@
  */
 
 
-class BxPaymentGridSbsAdministration extends BxBaseModPaymentGridOrders
+class BxPaymentGridSbsAdministration extends BxBaseModPaymentGridTransactions
 {
     protected $_iNow;
     protected $_sManageType;

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

@@ -23,6 +23,14 @@ class BxPaymentGridSbsList extends BxPaymentGridSbsAdministration
         $this->_aProvidersAttached = array();
     }
 
+    public function getCode ($isDisplayHeader = true)
+    {
+        if(empty($this->_aQueryAppend['client_id']) || $this->_aQueryAppend['client_id'] != bx_get_logged_profile_id())
+            return '';
+
+        return parent::getCode($isDisplayHeader);
+    }
+
     protected function _getActionActions ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
     	$sJsCode = '';