BxMassMailerGridLetters.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 MassMailer Mass Mailer
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxMassMailerGridLetters extends BxTemplGrid
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_iContentId;
  16. public function __construct ($aOptions, $oTemplate = false)
  17. {
  18. $this->_sModule = 'bx_massmailer';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. parent::__construct ($aOptions, $oTemplate);
  21. $this->_iContentId = 0;
  22. if(($iContentId = bx_get('content_id')) !== false)
  23. $this->setContentId($iContentId);
  24. }
  25. public function setContentId($iContentId)
  26. {
  27. $this->_iContentId = (int)$iContentId;
  28. $this->_aQueryAppend['content_id'] = $this->_iContentId;
  29. }
  30. public function getFormCallBackUrlAPI($sAction, $iId = 0)
  31. {
  32. return '/api.php?r=system/perfom_action_api/TemplServiceGrid/&params[]=&o=' . $this->_sObject . '&a=' . $sAction . '&content_id=' . $this->_iContentId . '&id=' . $iId;
  33. }
  34. protected function _getCellDateSent($mixedValue, $sKey, $aField, $aRow)
  35. {
  36. return $this->_getCellDate($mixedValue, $sKey, $aField, $aRow);
  37. }
  38. protected function _getCellDateSeen($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. return $this->_getCellDate($mixedValue, $sKey, $aField, $aRow);
  41. }
  42. protected function _getCellDateClick($mixedValue, $sKey, $aField, $aRow)
  43. {
  44. return $this->_getCellDate($mixedValue, $sKey, $aField, $aRow);
  45. }
  46. protected function _getCellDate($mixedValue, $sKey, $aField, $aRow)
  47. {
  48. if($this->_bIsApi)
  49. return ['type' => 'time', 'data' => $mixedValue];
  50. return parent::_getCellDefault($mixedValue != '0' ? bx_time_js($mixedValue, BX_FORMAT_DATE, true) : _t('_bx_massmailer_txt_never_sent'), $sKey, $aField, $aRow);
  51. }
  52. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  53. {
  54. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `campaign_id`=?", $this->_iContentId);
  55. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  56. }
  57. }
  58. /** @} */