浏览代码

Ticket #259 - Core changes and Base module.

AntonLV 10 年之前
父节点
当前提交
a1f9fa3656

+ 11 - 0
inc/js/classes/BxDolGrid.js

@@ -334,6 +334,7 @@ BxDolGrid.prototype._bindActionsSingle = function (eElement) {
         var sActionData = $(this).attr('bx_grid_action_data');
         var iActionResetPaginate = parseInt($(this).attr('bx_grid_action_reset_paginate'));
         var oData = iActionResetPaginate ? {} : $this._getActionDataForReload();
+        oData = $this._checkAppend(this, oData);
         $this.actionWithId (sActionData, sAction, oData, '', false, sActionConfirm);
     });
 
@@ -350,6 +351,7 @@ BxDolGrid.prototype._bindActions = function (isSkipSearchInput) {
         var sActionData = $(this).attr('bx_grid_action_data');
         var iActionResetPaginate = parseInt($(this).attr('bx_grid_action_reset_paginate'));
         var oData = iActionResetPaginate ? {} : $this._getActionDataForReload();
+        oData = $this._checkAppend(this, oData);
         $this.actionWithSelected (sActionData, sAction, oData, '', false, sActionConfirm);
     });
 
@@ -375,6 +377,7 @@ BxDolGrid.prototype._bindActions = function (isSkipSearchInput) {
             var sActionConfirm = $(this).attr('bx_grid_action_confirm');
             var iActionResetPaginate = parseInt($(this).attr('bx_grid_action_reset_paginate'));
             var oData = iActionResetPaginate ? {} : $this._getActionDataForReload();
+            oData = $this._checkAppend(this, oData);
             $this.action (sAction, oData, '', false, sActionConfirm);
         });    
 
@@ -415,4 +418,12 @@ BxDolGrid.prototype._onDataReloaded = function (isSkipSearchInput) {
 
 BxDolGrid.prototype.onDataReloaded = function (isSkipSearchInput) {}
 
+BxDolGrid.prototype._checkAppend = function (oInput, oData) {
+	var oAppend = $.parseJSON($(oInput).attr('bx_grid_action_append'));
+    if(typeof(oAppend) == 'object')
+        oData = $.extend({}, oData, oAppend);
+
+    return oData;
+};
+
 /** @} */

+ 1 - 1
modules/base/payment/classes/BxBaseModPaymentCart.php

@@ -26,7 +26,7 @@ class BxBaseModPaymentCart extends BxDol
     	if(!$this->_oModule->isLogged())
             return '';
 
-    	return $this->_oModule->_oConfig->getUrl('URL_CART');
+    	return $this->_oModule->_oConfig->getUrl('URL_CARTS');
     }
 
     public function serviceGetCartJs($bWrapped = true)

+ 3 - 1
modules/base/payment/classes/BxBaseModPaymentConfig.php

@@ -52,7 +52,9 @@ class BxBaseModPaymentConfig extends BxBaseModGeneralConfig
 
 			'grid_history' => $this->_sName . '_grid_orders_history',
 			'grid_processed' => $this->_sName . '_grid_orders_processed',
-			'grid_pending' => $this->_sName . '_grid_orders_pending'
+			'grid_pending' => $this->_sName . '_grid_orders_pending',
+			'grid_carts' => $this->_sName . '_grid_carts',
+			'grid_cart' => $this->_sName . '_grid_cart',
 		));
 
 		$this->_aPerPage = array();

+ 50 - 0
modules/base/payment/classes/BxBaseModPaymentGridCarts.php

@@ -0,0 +1,50 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BasePayment Base classes for Payment like modules
+ * @ingroup     TridentModules
+ * 
+ * @{
+ */
+
+class BxBaseModPaymentGridCarts extends BxTemplGrid
+{
+	protected $MODULE;
+
+	protected $_oModule;
+	protected $_oCart;
+
+	protected $_sCurrencySign;
+
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        parent::__construct ($aOptions, $oTemplate);
+
+        $this->_oModule = BxDolModule::getInstance($this->MODULE);
+        $this->_oCart = $this->_oModule->getObjectCart();
+
+        $this->_sCurrencySign = $this->_oModule->_oConfig->getCurrencySign();
+
+        $this->_sDefaultSortingOrder = 'DESC';
+
+		$iClientId = bx_get('client_id');
+        if($iClientId !== false)
+            $this->_aQueryAppend['client_id'] = (int)$iClientId;
+
+	    $iSellerId = bx_get('seller_id');
+        if($iSellerId !== false)
+            $this->_aQueryAppend['seller_id'] = (int)$iSellerId;
+    }
+
+	public function addQueryParam($sKey, $sValue)
+    {
+    	if(empty($sKey) || !isset($sValue))
+    		return;
+
+		$this->_aQueryAppend[$sKey] = $sValue;
+    }
+}
+
+/** @} */

+ 3 - 16
modules/base/payment/classes/BxBaseModPaymentGridOrders.php

@@ -57,7 +57,7 @@ class BxBaseModPaymentGridOrders extends BxTemplGrid
 
         $sKey = 'order_' . $this->_sOrdersType . '_view';
     	$sId = $this->_oModule->_oConfig->getHtmlIds($sKey);
-    	$sTitle = _t($this->_sLangsPrefix . 'grid_orders_popup_' . $sKey);
+    	$sTitle = _t($this->_sLangsPrefix . 'grid_popup_title_ods_' . $sKey);
     	$sContent = $this->_oModule->getObjectOrders()->getOrder($this->_sOrdersType, $iId);
 
     	return echoJson(array('popup' => BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $sContent)));
@@ -84,12 +84,12 @@ class BxBaseModPaymentGridOrders extends BxTemplGrid
 
 	protected function _getCellClientId($mixedValue, $sKey, $aField, $aRow)
     {
-    	return parent::_getCellDefault($this->_toProfile($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->_toProfile($mixedValue), $sKey, $aField, $aRow);
+    	return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
     }
 
 	protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
@@ -101,19 +101,6 @@ class BxBaseModPaymentGridOrders extends BxTemplGrid
     {
         return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
     }
-
-    protected function _toProfile($mixedValue)
-    {
-    	$aProfile = $this->_oModule->getProfileInfo((int)$mixedValue);
-
-    	return $this->_oModule->_oTemplate->parseHtmlByName('profile_link.html', array(
-            'href' => $aProfile['link'],
-            'title' => bx_html_attribute($aProfile['name']),
-            'content' => $aProfile['name']
-        ));
-    }
-    
-    
 }
 
 /** @} */

+ 21 - 0
modules/base/payment/classes/BxBaseModPaymentTemplate.php

@@ -107,6 +107,27 @@ class BxBaseModPaymentTemplate extends BxBaseModGeneralTemplate
     	);
     	$this->displayPageCode($aParams);
     }
+
+	public function displayProfileLink($mixedProfile)
+    {
+    	if(!is_array($mixedProfile))
+    		$mixedProfile = BxDolModule::getInstance($this->MODULE)->getProfileInfo((int)$mixedProfile);
+
+    	return $this->displayLink('link', array(
+    		'href' => $mixedProfile['link'],
+            'title' => bx_html_attribute(!empty($mixedProfile['title']) ? $mixedProfile['title'] : $mixedProfile['name']),
+            'content' => $mixedProfile['name']
+    	));
+    }
+
+    public function displayLink($sTemplate, $aParams)
+    {
+    	return $this->parseHtmlByName($sTemplate . '.html', array(
+            'href' => $aParams['href'],
+            'title' => $aParams['title'],
+            'content' => $aParams['content']
+        ));
+    }
 }
 
 /** @} */

+ 0 - 0
modules/boonex/payment/template/profile_link.html → modules/base/payment/template/link.html


+ 15 - 3
template/scripts/BxBaseGrid.php

@@ -17,6 +17,7 @@ class BxBaseGrid extends BxDolGrid
     protected $_aPopupOptions = false;
     protected $_aQueryAppend = false;
     protected $_aConfirmMessages = false;
+    protected $_bSelectAll = false;
     protected $_isDisplayPopupOnTextOverflow = true;
 
     public function __construct ($aOptions, $oTemplate)
@@ -275,12 +276,23 @@ class BxBaseGrid extends BxDolGrid
 
     protected function _getCellHeaderCheckbox ($sKey, $aField)
     {
-        $sAttr = $this->_convertAttrs(
+    	$aAttr = array(
+    		'type' => 'checkbox',
+    		'id' => $this->_sObject . '_check_all',
+    		'name' => $this->_sObject . '_check_all',
+    		'onclick' => "$('input[name=" . $this->_sObject . "_check]:not([disabled])').attr('checked', this.checked)"
+    	);
+    	if($this->_bSelectAll)
+    		$aAttr['checked'] = 'checked';
+
+    	$aField['attr'] = isset($aField['attr']) && is_array($aField['attr']) ? array_merge($aAttr, $aField['attr']) : $aAttr;
+
+        $sAttrHead = $this->_convertAttrs(
             $aField, 'attr_head',
             'bx-def-padding-sec-bottom bx-def-padding-sec-top bx-grid-header-' . $sKey, // add default classes
             isset($aField['width']) ? 'width:' . $aField['width'] : false // add default styles
         );
-        return $this->_getCellHeaderWrapper ($sKey, $aField, ' <input type="checkbox" id="'. $this->_sObject . '_check_all" name="'. $this->_sObject . '_check_all" onclick="$(\'input[name='. $this->_sObject . '_check]:not([disabled])\').attr(\'checked\', this.checked)" /> ', $sAttr);
+        return $this->_getCellHeaderWrapper ($sKey, $aField, ' <input ' . $this->_convertAttrs($aField, 'attr') . ' /> ', $sAttrHead);
     }
 
     protected function _getCellHeaderWrapper ($sKey, $aField, $sHeader, $sAttr)
@@ -329,7 +341,7 @@ class BxBaseGrid extends BxDolGrid
      */
     protected function _isCheckboxSelected($mixedValue, $sKey, $aField, $aRow)
     {
-        return false;
+        return $this->_bSelectAll;
     }
 
     /**