1
0

BxTasksMenuTimers.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * @defgroup Tasks Tasks
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. class BxTasksMenuTimers extends BxTemplMenuCustom
  11. {
  12. protected $_sModule;
  13. protected $_oModule;
  14. protected $_iProfileId;
  15. protected $_bShowAsButton;
  16. protected $_bShowTitle;
  17. public function __construct($aObject, $oTemplate = false)
  18. {
  19. parent::__construct($aObject, $oTemplate);
  20. $this->_sModule = 'bx_tasks';
  21. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  22. $this->_iProfileId = 0;
  23. $this->_bShowAsButton = true;
  24. $this->_bShowTitle = true;
  25. }
  26. public function setParams($iProfileId)
  27. {
  28. $this->_iProfileId = $iProfileId;
  29. }
  30. protected function getMenuItemsRaw()
  31. {
  32. $sJsObject = $this->_oModule->_oConfig->getJsObject('timer');
  33. return [
  34. ['name' => 'clear-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.clearAll(this, ' . $this->_iProfileId . ')', 'target' => '_self', 'title' => _t('_bx_tasks_txt_timers_clear')],
  35. ['name' => 'log-all', 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.logAll(this, ' . $this->_iProfileId . ')', 'target' => '_self', 'title' => _t('_bx_tasks_txt_timers_log')],
  36. ];
  37. }
  38. protected function _getMenuItemClearAll($aItem)
  39. {
  40. if($this->_bIsApi) {
  41. return array_merge($aItem, [
  42. 'display_type' => 'callback',
  43. 'data' => [
  44. 'request_url' => $this->_sModule . '/process_timer/&params[]=clear_all&params[]=0&params[]=' . $this->_iProfileId,
  45. 'on_callback' => 'hide'
  46. ]
  47. ]);
  48. }
  49. return true;
  50. }
  51. protected function _getMenuItemLogAll($aItem)
  52. {
  53. if($this->_bIsApi) {
  54. return array_merge($aItem, [
  55. 'display_type' => 'callback',
  56. 'data' => [
  57. 'request_url' => $this->_sModule . '/process_timer/&params[]=log_all&params[]=0&params[]=' . $this->_iProfileId,
  58. 'on_callback' => 'hide'
  59. ]
  60. ]);
  61. }
  62. return true;
  63. }
  64. protected function _getMenuItemDefault($aItem)
  65. {
  66. if($this->_bIsApi)
  67. return $aItem;
  68. $aItem['class_wrp'] = 'bx-tasks-timer-action' . (!empty($aItem['class_wrp']) ? ' ' . $aItem['class_wrp'] : '');
  69. if($this->_bShowAsButton)
  70. $aItem['class_link'] = 'bx-btn' . (isset($aItem['primary']) && (int)$aItem['primary'] == 1 ? ' bx-btn-primary' : '') . (!empty($aItem['class_link']) ? ' ' . $aItem['class_link'] : '');
  71. if(!$this->_bShowTitle)
  72. $aItem['bx_if:title']['condition'] = false;
  73. return parent::_getMenuItemDefault ($aItem);
  74. }
  75. }
  76. /** @} */