BxPaymentGridCarts.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 Payment Payment
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxPaymentGridCarts extends BxBaseModPaymentGridCarts
  12. {
  13. public function __construct ($aOptions, $oTemplate = false)
  14. {
  15. $this->MODULE = 'bx_payment';
  16. parent::__construct ($aOptions, $oTemplate);
  17. }
  18. public function getCodeAPI($bForceReturn = false)
  19. {
  20. $aData = parent::getCodeAPI($bForceReturn);
  21. $aData['settings']['field_id'] = 'id';
  22. foreach ($aData['data'] as &$aRow){
  23. $aRow['id'] = $aRow['checkbox']['data'];
  24. $aRow['vendor_id']['value'] = strip_tags($aRow['vendor_id']['value']);
  25. $aRow['items_price']['value'] = str_replace('&#36; ','$', $aRow['items_price']['value']);
  26. }
  27. return $aData;
  28. }
  29. protected function _getCellVendorId($mixedValue, $sKey, $aField, $aRow)
  30. {
  31. return parent::_getCellDefault($this->_oModule->_oTemplate->displayProfileLink(array(
  32. 'id' => $mixedValue,
  33. 'name' => $aRow['vendor_name'],
  34. 'title' => _t('_bx_payment_txt_checkout_to', $aRow['vendor_name']),
  35. 'link' => bx_append_url_params($this->_oModule->_oConfig->getUrl('URL_CART'), array('seller_id' => (int)$mixedValue))
  36. )), $sKey, $aField, $aRow);
  37. }
  38. protected function _getCellItemsPrice($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. $sSign = $this->_sCurrencySign;
  41. if(!$this->_bSingleSeller && !empty($aRow['vendor_currency_sign']))
  42. $sSign = $aRow['vendor_currency_sign'];
  43. return parent::_getCellDefault(_t_format_currency_ext($mixedValue, ['sign' => $sSign]), $sKey, $aField, $aRow);
  44. }
  45. protected function _getActionContinue ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  46. {
  47. $sUrl = bx_append_url_params($this->_oModule->_oConfig->getUrl('URL_CART'), array('seller_id' => $aRow['vendor_id']));
  48. if($this->_bIsApi)
  49. return array_merge($a, [
  50. 'type' => 'link',
  51. 'name' => $sKey,
  52. 'url' => $sUrl
  53. ]);
  54. unset($a['attr']['bx_grid_action_single']);
  55. $a['attr'] = array_merge($a['attr'], array(
  56. "onclick" => "window.open('" . $sUrl . "','_self');"
  57. ));
  58. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  59. }
  60. protected function _getFilterControls ()
  61. {
  62. return '';
  63. }
  64. protected function _getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  65. {
  66. if(empty($this->_aQueryAppend['client_id']))
  67. return array();
  68. $this->_aOptions['source'] = array_values($this->_oModule->getObjectCart()->getInfo(BX_PAYMENT_TYPE_SINGLE, $this->_aQueryAppend['client_id']));
  69. return parent::_getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  70. }
  71. protected function _delete($mixedId)
  72. {
  73. return $this->_oCart->serviceDeleteFromCart($mixedId);
  74. }
  75. }
  76. /** @} */