BxCreditsGridWithdrawalsAdministration.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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('BxCreditsGrid.php');
  12. class BxCreditsGridWithdrawalsAdministration extends BxCreditsGrid
  13. {
  14. protected $_bWithdraw;
  15. public function __construct ($aOptions, $oTemplate = false)
  16. {
  17. parent::__construct ($aOptions, $oTemplate);
  18. $this->_sDefaultSortingOrder = 'DESC';
  19. $this->_bWithdraw = $this->_oModule->_oConfig->isWithdraw();
  20. }
  21. public function performActionWithdrawConfirm()
  22. {
  23. if(!$this->_bWithdraw)
  24. return $this->_bIsApi ? [] : echoJson([]);
  25. $sAction = 'withdraw_confirm';
  26. $iId = $this->_getId();
  27. if(!$iId)
  28. return $this->_bIsApi ? [] : echoJson([]);
  29. $aResult = $this->_oModule->processWithdrawConfirm($this->_iUserId, $iId);
  30. $aResult = $this->_onPerformAction($aResult);
  31. return $this->_bIsApi ? $aResult : echoJson($aResult);
  32. }
  33. protected function _getActionWithdrawConfirm($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  34. {
  35. if(!$this->_bWithdraw || $aRow['status'] != BX_CREDITS_WITHDRAWAL_STATUS_REQUESTED)
  36. return $this->_bIsApi ? [] : '';
  37. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  38. }
  39. protected function _getCellProfileId($mixedValue, $sKey, $aField, $aRow)
  40. {
  41. return parent::_getCellDefault($this->_getProfile($mixedValue), $sKey, $aField, $aRow);
  42. }
  43. protected function _getCellPerformerId($mixedValue, $sKey, $aField, $aRow)
  44. {
  45. return parent::_getCellDefault(!empty($mixedValue) ? $this->_getProfile($mixedValue) : '', $sKey, $aField, $aRow);
  46. }
  47. protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
  48. {
  49. return parent::_getCellDefault($this->_oModule->convertC2S($mixedValue), $sKey, $aField, $aRow);
  50. }
  51. protected function _getCellOrder($mixedValue, $sKey, $aField, $aRow)
  52. {
  53. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  54. }
  55. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  56. {
  57. return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE, true), $sKey, $aField, $aRow);
  58. }
  59. protected function _getCellConfirmed($mixedValue, $sKey, $aField, $aRow)
  60. {
  61. return parent::_getCellDefault(!empty($mixedValue) ? bx_time_js($mixedValue, BX_FORMAT_DATE, true) : '', $sKey, $aField, $aRow);
  62. }
  63. protected function _getCellStatus($mixedValue, $sKey, $aField, $aRow)
  64. {
  65. return parent::_getCellDefault(_t('_bx_credits_txt_withdrawal_status_' . $mixedValue), $sKey, $aField, $aRow);
  66. }
  67. protected function _addJsCss()
  68. {
  69. parent::_addJsCss();
  70. $this->_oModule->_oTemplate->addJs([
  71. 'jquery.form.min.js',
  72. 'withdraw.js'
  73. ]);
  74. $this->_oModule->_oTemplate->addCss([
  75. 'main.css',
  76. 'withdraw.css'
  77. ]);
  78. $oForm = new BxTemplFormView([]);
  79. $oForm->addCssJs();
  80. }
  81. }
  82. /** @} */