BxCreditsGridWithdrawalsCommon.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 Credits Credits
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. require_once('BxCreditsGridWithdrawalsAdministration.php');
  12. class BxCreditsGridWithdrawalsCommon extends BxCreditsGridWithdrawalsAdministration
  13. {
  14. public function __construct ($aOptions, $oTemplate = false)
  15. {
  16. parent::__construct ($aOptions, $oTemplate);
  17. }
  18. public function performActionWithdrawRequest()
  19. {
  20. if(!$this->_bWithdraw)
  21. return $this->_bIsApi ? [] : echoJson([]);
  22. $sAction = 'withdraw_request';
  23. return $this->_performActionWithProfileAmount($sAction);
  24. }
  25. public function performActionWithdrawCancel()
  26. {
  27. if(!$this->_bWithdraw)
  28. return $this->_bIsApi ? [] : echoJson([]);
  29. $sAction = 'withdraw_cancel';
  30. $iId = $this->_getId();
  31. if(!$iId)
  32. return $this->_bIsApi ? [] : echoJson([]);
  33. $aResult = $this->_oModule->processWithdrawCancel($iId);
  34. $aResult = $this->_onPerformAction($aResult);
  35. return $this->_bIsApi ? $aResult : echoJson($aResult);
  36. }
  37. public function getCode($isDisplayHeader = true)
  38. {
  39. $sResult = parent::getCode($isDisplayHeader);
  40. if(!empty($sResult) && $isDisplayHeader)
  41. $sResult = $this->_oModule->_oTemplate->getJsCode('withdraw') . $sResult;
  42. return $sResult;
  43. }
  44. protected function _getActionWithdrawRequest($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  45. {
  46. if(!$this->_bWithdraw)
  47. return $this->_bIsApi ? [] : '';
  48. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  49. }
  50. protected function _getActionWithdrawCancel($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  51. {
  52. if(!$this->_bWithdraw || $aRow['status'] != BX_CREDITS_WITHDRAWAL_STATUS_REQUESTED)
  53. return $this->_bIsApi ? [] : '';
  54. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  55. }
  56. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  57. {
  58. if(empty($this->_iUserId) || $this->_iUserId != bx_get_logged_profile_id())
  59. return [];
  60. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `profile_id`=?", $this->_iUserId);
  61. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  62. }
  63. }
  64. /** @} */