BxBaseModGroupsGridPrices.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGroupsGridPrices extends BxTemplGrid
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_sParamsDivider = '#-#';
  16. protected $_iGroupProfileId;
  17. protected $_iGroupContentId;
  18. protected $_aGroupContentInfo;
  19. protected $_aRoles;
  20. protected $_aPeriodUnits;
  21. public function __construct ($aOptions, $oTemplate = false)
  22. {
  23. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  24. parent::__construct ($aOptions, $oTemplate);
  25. $CNF = $this->_oModule->_oConfig->CNF;
  26. $this->_aRoles = BxDolFormQuery::getDataItems($CNF['OBJECT_PRE_LIST_ROLES']);
  27. $this->_aPeriodUnits = BxDolForm::getDataItems($CNF['OBJECT_PRE_LIST_PERIOD_UNITS']);
  28. $this->_iGroupProfileId = 0;
  29. $this->_iGroupContentId = 0;
  30. $this->_aGroupContentInfo = array();
  31. if(($iGroupProfileId = bx_get('profile_id')) !== false)
  32. $this->setProfileId($iGroupProfileId);
  33. }
  34. public function setProfileId($iProfileId)
  35. {
  36. $this->_iGroupProfileId = (int)$iProfileId;
  37. $this->_aQueryAppend['profile_id'] = $this->_iGroupProfileId;
  38. $oGroupProfile = BxDolProfile::getInstance($this->_iGroupProfileId);
  39. if($oGroupProfile) {
  40. $this->_iGroupContentId = (int)$oGroupProfile->getContentId();
  41. $this->_aGroupContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iGroupContentId);
  42. }
  43. }
  44. protected function _getCellPeriod($mixedValue, $sKey, $aField, $aRow)
  45. {
  46. $CNF = $this->_oModule->_oConfig->CNF;
  47. if((int)$mixedValue == 0)
  48. $mixedValue = _t('_lifetime');
  49. else
  50. $mixedValue = _t($CNF['T']['txt_n_unit'], $mixedValue, _t($this->_aPeriodUnits[$aRow['period_unit']]));
  51. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  52. }
  53. protected function _getCellPrice($mixedValue, $sKey, $aField, $aRow)
  54. {
  55. if((float)$mixedValue != 0) {
  56. $aCurrency = $this->_oModule->_oConfig->getCurrency();
  57. $mixedValue = html_entity_decode($aCurrency['sign']) . $mixedValue;
  58. }
  59. else
  60. $mixedValue = _t('_free');
  61. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  62. }
  63. protected function _getIds()
  64. {
  65. $aIds = bx_get('ids');
  66. if(!$aIds || !is_array($aIds)) {
  67. $iId = (int)bx_get('id');
  68. if(!$iId)
  69. return false;
  70. $aIds = array($iId);
  71. }
  72. return $aIds;
  73. }
  74. }
  75. /** @} */