BxBaseModPaymentGridOrders.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BasePayment Base classes for Payment like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModPaymentGridOrders extends BxTemplGrid
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. protected $_sOrdersType;
  16. protected $_sLangsPrefix;
  17. protected $_sCurrencySign;
  18. public function __construct ($aOptions, $oTemplate = false)
  19. {
  20. parent::__construct ($aOptions, $oTemplate);
  21. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  22. $this->_sLangsPrefix = $this->_oModule->_oConfig->getPrefix('langs');
  23. $this->_sCurrencySign = $this->_oModule->_oConfig->getDefaultCurrencySign();
  24. $this->_sDefaultSortingOrder = 'DESC';
  25. $iSellerId = bx_get('seller_id');
  26. if($iSellerId !== false)
  27. $this->_aQueryAppend['seller_id'] = (int)$iSellerId;
  28. $iClientId = bx_get('client_id');
  29. if($iClientId !== false)
  30. $this->_aQueryAppend['client_id'] = (int)$iClientId;
  31. }
  32. public function addQueryParam($sKey, $sValue)
  33. {
  34. if(empty($sKey) || !isset($sValue))
  35. return;
  36. $this->_aQueryAppend[$sKey] = $sValue;
  37. }
  38. public function performActionViewOrder()
  39. {
  40. $aIds = bx_get('ids');
  41. if(!$aIds || !is_array($aIds))
  42. return echoJson(array());
  43. $iId = (int)$aIds[0];
  44. $sKey = 'order_' . $this->_sOrdersType . '_view';
  45. $sId = $this->_oModule->_oConfig->getHtmlIds($this->_sOrdersType, $sKey);
  46. $sTitle = _t($this->_sLangsPrefix . 'popup_title_ods_' . $sKey);
  47. $sContent = $this->_oModule->getObjectOrders()->getOrder($this->_sOrdersType, $iId);
  48. return echoJson(array('popup' => BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $sContent)));
  49. }
  50. public function performActionCancel()
  51. {
  52. $aIds = bx_get('ids');
  53. if(!$aIds || !is_array($aIds))
  54. return echoJson(array());
  55. $oOrders = $this->_oModule->getObjectOrders();
  56. $iAffected = 0;
  57. $aAffected = array();
  58. foreach($aIds as $iId)
  59. if($oOrders->cancel($this->_sOrdersType, $iId)) {
  60. $aAffected[] = $iId;
  61. $iAffected++;
  62. }
  63. echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aAffected) : array('msg' => _t($this->_sLangsPrefix . 'err_cannot_perform')));
  64. }
  65. protected function _getCellClientId($mixedValue, $sKey, $aField, $aRow)
  66. {
  67. return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
  68. }
  69. protected function _getCellSellerId($mixedValue, $sKey, $aField, $aRow)
  70. {
  71. return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink($mixedValue), $sKey, $aField, $aRow);
  72. }
  73. protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
  74. {
  75. return parent::_getCellDefault($this->_sCurrencySign . $mixedValue, $sKey, $aField, $aRow);
  76. }
  77. protected function _getCellDate($mixedValue, $sKey, $aField, $aRow)
  78. {
  79. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  80. }
  81. }
  82. /** @} */