queryform.html.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * The browse view file of company module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Mengyi Liu <liumengyi@easycorp.ltd>
  7. * @package company
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $fnGenerateQueryForm = function($viewType) use($metricRecordType, $current, $dateLabels, $defaultDate)
  12. {
  13. if(!$metricRecordType) return null;
  14. $formGroups = array();
  15. if($current->scope != 'system')
  16. {
  17. if(in_array($current->code, $this->config->metric->waterfallCode))
  18. {
  19. $objectPairs = $this->metric->getWaterfullProjectPairs();
  20. }
  21. else
  22. {
  23. $objectPairs = $this->metric->getPairsByScope($current->scope);
  24. }
  25. }
  26. if($metricRecordType == 'scope' || $metricRecordType == 'scope-date')
  27. {
  28. $name = $viewType == 'single' ? 'scope' : "scope_{$current->id}";
  29. $formGroups[] = formGroup
  30. (
  31. setClass('query-inline picker-nowrap w-40'),
  32. set::name($name),
  33. set::control(array('control' => 'picker', 'multiple' => true)),
  34. set::items($objectPairs),
  35. set::placeholder($this->lang->metric->placeholder->{$current->scope})
  36. );
  37. }
  38. if($metricRecordType == 'scope' || $metricRecordType == 'system')
  39. {
  40. $btnLabels = array();
  41. foreach($this->lang->metric->query->dayLabels as $key => $label)
  42. {
  43. $active = $key == '7' ? ' selected' : '';
  44. $btnLabels[] = btn
  45. (
  46. setClass("$active default w-16 p-0"),
  47. set::key($key),
  48. $label
  49. );
  50. }
  51. $formGroups[] = formGroup(setClass('query-calc-date query-inline w-64'), btngroup
  52. (
  53. $btnLabels
  54. ), on::click('.query-calc-date button.btn', 'window.handleCalcDateClick(target)'));
  55. }
  56. if($metricRecordType == 'date' || $metricRecordType == 'scope-date')
  57. {
  58. $btnLabels = array();
  59. foreach($dateLabels as $key => $label)
  60. {
  61. $active = $key == $defaultDate ? ' selected' : '';
  62. $btnLabels[] = btn
  63. (
  64. setClass("$active default w-16 p-0"),
  65. set::key($key),
  66. $label
  67. );
  68. }
  69. $formGroups[] = formGroup(setClass('query-date query-inline w-64'), btngroup
  70. (
  71. $btnLabels
  72. ), on::click('.query-date button.btn', 'window.handleDateLabelClick(target)'));
  73. $beginID = $viewType == 'single' ? 'dateBegin' : 'dateBegin' . $current->id;
  74. $endID = $viewType == 'single' ? 'dateEnd' : 'dateEnd' . $current->id;
  75. $formGroups[] = formGroup(setClass('query-inline w-80'), inputGroup
  76. (
  77. datePicker
  78. (
  79. setClass('query-date-picker'),
  80. set::name('dateBegin'),
  81. set('id', $beginID),
  82. set::placeholder($this->lang->metric->placeholder->select)
  83. ),
  84. $this->lang->metric->to,
  85. datePicker
  86. (
  87. setClass('query-date-picker'),
  88. set::name('dateEnd'),
  89. set('id', $endID),
  90. set::placeholder($this->lang->metric->placeholder->select)
  91. )
  92. ), on::change('.query-date-picker', 'window.handleDatePickerChange(target)'));
  93. }
  94. return form
  95. (
  96. set::id('queryForm' . $current->id),
  97. setClass('ml-4'),
  98. formRow
  99. (
  100. set::width('max'),
  101. $formGroups,
  102. !empty($formGroups) ? formGroup
  103. (
  104. setClass('query-btn'),
  105. btn
  106. (
  107. setClass('btn secondary'),
  108. set::text($this->lang->metric->query->action),
  109. set::onclick("window.handleQueryClick($current->id, '$viewType')")
  110. )
  111. ) : null
  112. ),
  113. set::actions(array())
  114. );
  115. };