فهرست منبع

Ticket #4090 - Payments: Add support for multi-currency. Usage in Ads, Market.

AntonLV 4 سال پیش
والد
کامیت
3bb817eb2a

+ 8 - 0
modules/boonex/ads/classes/BxAdsFormEntry.php

@@ -157,6 +157,14 @@ class BxAdsFormEntry extends BxBaseModTextFormEntry
         return $iResult;
     }
 
+    public function genInputPrice(&$aInput)
+    {
+        if(!isset($aInput['value_currency']))
+            $aInput['value_currency'] = BxDolPayments::getInstance()->getCurrencyCode(bx_get_logged_profile_id());
+
+        return parent::genInputPrice($aInput);
+    }
+
     protected function genCustomInputCategoryView(&$aInput)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;

+ 7 - 1
modules/boonex/ads/classes/BxAdsGridOffers.php

@@ -63,7 +63,13 @@ class BxAdsGridOffers extends BxTemplGrid
 
     protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
     {
-        return parent::_getCellDefault(_t_format_currency($mixedValue), $sKey, $aField, $aRow);
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aContentInfo = $this->_oModule->_oDb->getContentInfoById((int)$aRow[$CNF['FIELD_OFR_CONTENT']]);
+
+        return parent::_getCellDefault(_t_format_currency_ext($mixedValue, [
+            'sign' => BxDolPayments::getInstance()->getCurrencySign((int)$aContentInfo[$CNF['FIELD_AUTHOR']])
+        ]), $sKey, $aField, $aRow);
     }
 
     protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)

+ 5 - 3
modules/boonex/ads/classes/BxAdsModule.php

@@ -130,7 +130,7 @@ class BxAdsModule extends BxBaseModTextModule
         $sJsObject = $this->_oConfig->getJsObject('entry');
 
         $iAuthorId = bx_get_logged_profile_id();
-        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        $iContentId = bx_process_input(bx_get('content_id'), BX_DATA_INT);
 
         if(empty($iAuthorId))
             return echoJson(array('code' => 1, 'eval' => 'window.open("' . BxDolPermalinks::getInstance()->permalink('page.php?i=login') . '", "_self");'));
@@ -163,7 +163,7 @@ class BxAdsModule extends BxBaseModTextModule
             return echoJson(array('code' => 4, 'msg' => _t('_bx_ads_txt_err_offer_accepted')));
 
         $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_OFFER'], $CNF['OBJECT_FORM_OFFER_DISPLAY_ADD']);
-        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'make_offer', array('id' => $iContentId));
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'make_offer', ['content_id' => $iContentId]);
         $oForm->initChecker();
 
         if($oForm->isSubmittedAndValid()) {
@@ -2033,7 +2033,9 @@ class BxAdsModule extends BxBaseModTextModule
 
         $sPrice = _t('_bx_ads_txt_free');
         if(!empty($CNF['FIELD_PRICE']) && !empty($aContentInfo[$CNF['FIELD_PRICE']]))
-            $sPrice = _t_format_currency((float)$aContentInfo[$CNF['FIELD_PRICE']]);
+            $sPrice = _t_format_currency_ext((float)$aContentInfo[$CNF['FIELD_PRICE']], [
+                'sign' => BxDolPayments::getInstance()->getCurrencySign((int)$aContentInfo[$CNF['FIELD_AUTHOR']])
+            ]);
 
         $sInclude = $this->_oTemplate->addCss(array('timeline.css'), $bDynamic);
 

+ 7 - 2
modules/boonex/ads/classes/BxAdsTemplate.php

@@ -27,15 +27,20 @@ class BxAdsTemplate extends BxBaseModTextTemplate
     {
         $CNF = &$this->_oConfig->CNF;
 
+        $oPayments = BxDolPayments::getInstance();
+        $iContentAuthorId = (int)$aContent[$CNF['FIELD_AUTHOR']];
+
         $sJsCodePay = $sJsMethodPay = '';
-        $aJsPay = BxDolPayments::getInstance()->getAddToCartJs($aContent[$CNF['FIELD_AUTHOR']], $this->MODULE, $aContent[$CNF['FIELD_ID']], $aOffer[$CNF['FIELD_OFR_QUANTITY']], true);
+        $aJsPay = $oPayments->getAddToCartJs($iContentAuthorId, $this->MODULE, $aContent[$CNF['FIELD_ID']], $aOffer[$CNF['FIELD_OFR_QUANTITY']], true);
         if(!empty($aJsPay) && is_array($aJsPay))
             list($sJsCodePay, $sJsMethodPay) = $aJsPay;
 
         return $this->parseHtmlByName('entry-offer-accepted.html', array(
             'js_object' => $this->_oConfig->getJsObject('entry'),
             'id' => $aOffer['id'],
-            'amount' => _t_format_currency($aOffer['amount']),
+            'amount' => _t_format_currency_ext($aOffer['amount'], [
+                'sign' => $oPayments->getCurrencySign($iContentAuthorId)
+            ]),
             'quantity' => _t('_bx_ads_txt_n_items', $aOffer['quantity']),
             'bx_if:show_pay' => array(
                 'condition' => !empty($sJsMethodPay),

+ 3 - 3
modules/boonex/ads/js/entry.js

@@ -31,7 +31,7 @@ BxAdsEntry.prototype.hide = function(oElement, iContentId) {
 };
 
 BxAdsEntry.prototype.makeOffer = function(oElement, iContentId) {
-    this._performAction(oElement, 'make_offer', iContentId);
+    this._performAction(oElement, 'make_offer', iContentId, 'content_id');
 };
 
 BxAdsEntry.prototype.onMakeOffer = function(oData) {};
@@ -88,10 +88,10 @@ BxAdsEntry.prototype.loadingInBox = function(e, bShow) {
     bx_loading(oParent, bShow);
 };
 
-BxAdsEntry.prototype._performAction = function(oElement, sAction, iContentId) {
+BxAdsEntry.prototype._performAction = function(oElement, sAction, iContentId, sContentIdKey) {
     var $this = this;
     var oParams = this._getDefaultData();
-    oParams['id'] = iContentId;
+    oParams[sContentIdKey ? sContentIdKey : 'id'] = iContentId;
 
     if(oElement)
         this.loadingInButton(oElement, true);

+ 8 - 0
modules/boonex/market/classes/BxMarketFormEntry.php

@@ -287,6 +287,14 @@ class BxMarketFormEntry extends BxBaseModTextFormEntry
     	return $aResult;
     }
 
+    function genInputPrice(&$aInput)
+    {
+        if(!isset($aInput['value_currency']))
+            $aInput['value_currency'] = BxDolPayments::getInstance()->getCurrencyCode(bx_get_logged_profile_id());
+
+        return parent::genInputPrice($aInput);
+    }
+
     protected function genCustomInputSubentries ($aInput)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;

+ 0 - 16
template/scripts/BxBaseFormView.php

@@ -1997,22 +1997,6 @@ BLAH;
 
     function genInputPrice(&$aInput)
     {
-        /*
-        if(!isset($aInput['attrs_wrapper']['class'])) {
-            if(!isset($aInput['attrs_wrapper'])) 
-                $aInput['attrs_wrapper'] = [];
-            $aInput['attrs_wrapper']['class'] = '';
-        }
-        $aInput['attrs_wrapper']['class'] .= 'bx-form-input-wrapper-text';
-
-        if(!isset($aInput['attrs']['class'])) {
-            if(!isset($aInput['attrs'])) 
-                $aInput['attrs'] = [];
-            $aInput['attrs']['class'] = '';
-        }
-        $aInput['attrs']['class'] .= 'bx-form-input-text';
-         */
-
         $sCurrency = '';
         if(!isset($aInput['value_currency'])) {
             $sCurrency = BxDolPayments::getInstance()->getOption('default_currency_code');