BxCreditsGridHistoryAdministration.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 BxCreditsGridHistoryAdministration extends BxCreditsGrid
  13. {
  14. public function __construct ($aOptions, $oTemplate = false)
  15. {
  16. parent::__construct ($aOptions, $oTemplate);
  17. $this->_sDefaultSortingOrder = 'DESC';
  18. }
  19. public function performActionGrant()
  20. {
  21. $sAction = 'grant';
  22. return $this->_performActionWithProfileAmount($sAction);
  23. }
  24. protected function _getCellDirection($mixedValue, $sKey, $aField, $aRow)
  25. {
  26. if(in_array($mixedValue, [BX_CREDITS_DIRECTION_IN, BX_CREDITS_DIRECTION_OUT]))
  27. $mixedValue = _t('_bx_credits_txt_direction_' . $mixedValue);
  28. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  29. }
  30. protected function _getCellFirstPid($mixedValue, $sKey, $aField, $aRow)
  31. {
  32. return parent::_getCellDefault($this->_getProfile($mixedValue), $sKey, $aField, $aRow);
  33. }
  34. protected function _getCellSecondPid($mixedValue, $sKey, $aField, $aRow)
  35. {
  36. return parent::_getCellDefault($this->_getProfile($mixedValue), $sKey, $aField, $aRow);
  37. }
  38. protected function _getCellAmount($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. return parent::_getCellDefault($this->_oModule->convertC2S($mixedValue), $sKey, $aField, $aRow);
  41. }
  42. protected function _getCellOrder($mixedValue, $sKey, $aField, $aRow)
  43. {
  44. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  45. }
  46. protected function _getCellDate($mixedValue, $sKey, $aField, $aRow)
  47. {
  48. return parent::_getCellDefault(bx_time_js($mixedValue, BX_FORMAT_DATE, true), $sKey, $aField, $aRow);
  49. }
  50. protected function _getCellCleared($mixedValue, $sKey, $aField, $aRow)
  51. {
  52. $CNF = &$this->_oModule->_oConfig->CNF;
  53. if($aRow[$CNF['FIELD_H_DIRECTION']] == BX_CREDITS_DIRECTION_IN) {
  54. if(empty($mixedValue)) {
  55. $iPeriod = (int)$aRow['wdw_clearing'];
  56. if($iPeriod == 0) {
  57. $iPeriod = $this->_oModule->_oConfig->getWithdrawClearing();
  58. if($iPeriod == 0)
  59. $iPeriod = 1;
  60. }
  61. $oDate = date_create('@' . $aRow[$CNF['FIELD_H_DATE']]);
  62. date_add($oDate, new DateInterval('P' . $iPeriod . 'D'));
  63. $mixedValue = date_format($oDate, 'U');
  64. }
  65. $mixedValue = bx_time_js($mixedValue, BX_FORMAT_DATE, true);
  66. }
  67. else
  68. $mixedValue = '';
  69. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  70. }
  71. protected function _addJsCss()
  72. {
  73. parent::_addJsCss();
  74. $this->_oModule->_oTemplate->addJs([
  75. 'jquery.form.min.js'
  76. ]);
  77. $this->_oModule->_oTemplate->addCss([
  78. 'main.css'
  79. ]);
  80. $oForm = new BxTemplFormView([]);
  81. $oForm->addCssJs();
  82. }
  83. }
  84. /** @} */