browseunits.html.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * The browse units view file of testtask 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 Tingting Dai <daitingting@easycorp.ltd>
  7. * @package testtask
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $canSwitch = $this->app->tab == 'qa';
  12. if($canSwitch)
  13. {
  14. $caseTypeItems = array();
  15. foreach($lang->testcase->typeList as $type => $typeName)
  16. {
  17. if($type == 'unit')
  18. {
  19. $url = createLink('testtask', 'browseUnits', "productID={$product->id}&browseType=newest&orderBy=id_desc&recTotal=0&recPerPage=20&pageID=1");
  20. }
  21. else
  22. {
  23. $url = createLink('testcase', 'browse', "productID={$product->id}&branch=&browseType=all&param=0&caseType={$type}");
  24. }
  25. $caseTypeItems[] = array('text' => $typeName ?: $lang->testcase->allType, 'url' => $url, 'active' => $type == 'unit');
  26. }
  27. }
  28. $lang->testcase->featureBar['browseunits'] = $lang->testtask->featureBar['browseunits'];
  29. featureBar
  30. (
  31. $canSwitch ? to::before
  32. (
  33. dropdown
  34. (
  35. btn($lang->testcase->typeList['unit'], setClass('ghost')),
  36. set::items($caseTypeItems),
  37. set::trigger('click')
  38. )
  39. ) : null,
  40. set::link(createLink('testtask', 'browseUnits', "productID={$product->id}&browseType={key}"))
  41. );
  42. $canModify = common::canModify('product', $product);
  43. $canImport = hasPriv('testtask', 'importUnitResult');
  44. if($canImport && (empty($product) || $canModify))
  45. {
  46. toolbar
  47. (
  48. btn
  49. (
  50. set::className('btn primary'),
  51. set::icon('import'),
  52. set::url(createLink('testtask', 'importUnitResult', "product={$product->id}")),
  53. $lang->testtask->importUnitResult
  54. )
  55. );
  56. }
  57. $cols = $this->config->testtask->browseUnits->dtable->fieldList;
  58. $tasks = initTableData($tasks, $cols, $this->testtask);
  59. $summary = sprintf($lang->testtask->unitSummary, $pager->recTotal);
  60. if($browseType == 'newest')
  61. {
  62. foreach($cols as $key => $col) $cols[$key]['sortType'] = false;
  63. }
  64. dtable
  65. (
  66. set::cols($cols),
  67. set::data(array_values($tasks)),
  68. set::emptyTip($lang->testtask->emptyUnitTip),
  69. set::userMap($users),
  70. set::sortLink(createLink('testtask', 'browseUnits', "productID={$product->id}&browseType={$browseType}&orderBy={name}_{sortType}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}")),
  71. set::footer(array(array('html' => $summary), 'flex', 'pager')),
  72. set::footPager($browseType !== 'newest' ? usePager() : null)
  73. );
  74. render();