BxInvGrid.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 Invites Invites
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxInvGrid extends BxBaseModGeneralGrid
  12. {
  13. protected $_sFilter1Name;
  14. protected $_sFilter1Value;
  15. protected $_aFilter1Values;
  16. protected $_sParamsDivider;
  17. public function __construct ($aOptions, $oTemplate = false)
  18. {
  19. $this->_sModule = 'bx_invites';
  20. parent::__construct ($aOptions, $oTemplate);
  21. }
  22. public function getFormCallBackUrlAPI($sAction, $iId = 0)
  23. {
  24. return '/api.php?r=system/perfom_action_api/TemplServiceGrid/&params[]=&o=' . $this->_sObject . '&a=' . $sAction;
  25. }
  26. public function performActionAdd()
  27. {
  28. $sAction = 'add';
  29. $oForm = $this->_oModule->getFormObjectInvite();
  30. if(!$oForm)
  31. return $this->_getActionResult([]);
  32. $oForm->aInputs['text']['value'] = _t('_bx_invites_msg_invitation');
  33. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?' . bx_encode_url_params($_GET, array('ids', '_r'));
  34. $oForm->initChecker();
  35. $aResult = [];
  36. if($oForm->isSubmittedAndValid()) {
  37. $sResult = $this->_oModule->processFormObjectInvite($oForm);
  38. if($this->_bIsApi)
  39. $aResult = [bx_api_get_msg($sResult)];
  40. else
  41. $aResult = ['msg' => $sResult];
  42. }
  43. else {
  44. if($this->_bIsApi)
  45. $aResult = $this->getFormBlockAPI($oForm, $sAction);
  46. else
  47. $aResult = ['popup' => [
  48. 'html' => BxTemplFunctions::getInstance()->popupBox('_bx_invites_form_invite', _t('_bx_invites_form_invite'), $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', [
  49. 'form_id' => $oForm->id,
  50. 'form' => $oForm->getCode(true),
  51. 'object' => $this->_sObject,
  52. 'action' => $sAction
  53. ])),
  54. 'options' => ['closeOnOuterClick' => true]
  55. ]];
  56. }
  57. return $this->_getActionResult($aResult);
  58. }
  59. protected function _getFilterControls ()
  60. {
  61. parent::_getFilterControls();
  62. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . $this->_getSearchInput();
  63. }
  64. protected function _getFilterOnChange()
  65. {
  66. return $this->_oModule->_oConfig->getJsObject('main') . '.onChangeFilter(this)';
  67. }
  68. protected function _getId()
  69. {
  70. $iId = 0;
  71. if(($aIds = bx_get('ids')) !== false) {
  72. if(!$aIds || !is_array($aIds))
  73. return 0;
  74. $iId = (int)array_shift($aIds);
  75. }
  76. else if(($iId = bx_get('id')) !== false)
  77. $iId = (int)$iId;
  78. return $iId;
  79. }
  80. protected function _getIds()
  81. {
  82. $aIds = [];
  83. if(($aIds = bx_get('ids')) !== false) {
  84. if(!$aIds || !is_array($aIds))
  85. return [];
  86. $aIds = bx_process_input($aIds, BX_DATA_INT);
  87. }
  88. else if(($iId = bx_get('id')) !== false)
  89. $aIds = [(int)$iId];
  90. return $aIds;
  91. }
  92. }
  93. /** @} */