BxBaseStudioGridAgents.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioGridAgents extends BxTemplStudioGrid
  11. {
  12. public function __construct($aOptions, $oTemplate = false)
  13. {
  14. parent::__construct($aOptions, $oTemplate);
  15. }
  16. protected function _getCellModelId($mixedValue, $sKey, $aField, $aRow)
  17. {
  18. $aModel = $this->_oDb->getModelsBy(['sample' => 'id', 'id' => $mixedValue]);
  19. if(!empty($aModel) && is_array($aModel))
  20. $mixedValue = $aModel['title'];
  21. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  22. }
  23. protected function _getCellProfileId($mixedValue, $sKey, $aField, $aRow)
  24. {
  25. return parent::_getCellDefault(BxDolProfile::getInstanceMagic($mixedValue)->getDisplayName(), $sKey, $aField, $aRow);
  26. }
  27. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  28. {
  29. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  30. }
  31. protected function _getActionTune($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = [])
  32. {
  33. $a['attr'] = array_merge($a['attr'], [
  34. "onclick" => "window.open('" . $this->_sUrlPage . '&id=' . $aRow['id'] . "', '_self');"
  35. ]);
  36. return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  37. }
  38. protected function _addJsCss()
  39. {
  40. parent::_addJsCss();
  41. $this->_oTemplate->addJs(['jquery.form.min.js']);
  42. $oForm = new BxTemplStudioFormView([]);
  43. $oForm->addCssJs();
  44. }
  45. protected function _isCheckboxDisabled($aRow)
  46. {
  47. return false;
  48. }
  49. protected function _getActionsDisabledBehavior($aRow)
  50. {
  51. return false;
  52. }
  53. protected function _getFormControls()
  54. {
  55. return [
  56. 'type' => 'input_set',
  57. 0 => [
  58. 'type' => 'submit',
  59. 'name' => 'do_submit',
  60. 'value' => _t('_sys_submit'),
  61. ],
  62. 1 => [
  63. 'type' => 'reset',
  64. 'name' => 'close',
  65. 'value' => _t('_sys_close'),
  66. 'attrs' => ['class' => 'bx-def-margin-sec-left', 'onclick' => '$(\'.bx-popup-applied:visible\').dolPopupHide();'],
  67. ],
  68. ];
  69. }
  70. protected function _getId()
  71. {
  72. $aIds = bx_get('ids');
  73. if(!empty($aIds) && is_array($aIds))
  74. return array_shift($aIds);
  75. $iId = (int)bx_get('id');
  76. if(!$iId)
  77. return false;
  78. return $iId;
  79. }
  80. }
  81. /** @} */