all.html.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * The UI file of product module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author chen.tao <chentao@easycorp.ltd>
  8. * @package product
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. jsVar('orderBy', $orderBy);
  13. /* Get field list for data table. */
  14. if(strpos($orderBy, 'line') !== false) $orderBy = str_replace('line', 'productLine', $orderBy);
  15. $cols = $this->loadModel('datatable')->getSetting('product');
  16. /* Closure function for generating table data. */
  17. $productStats = initTableData($productStats, $cols, $this->product);
  18. /* Closure function for generating program menu. */
  19. $fnGenerateProgramMenu = function($programList) use($lang, $programID, $browseType, $orderBy, $param, $recTotal, $recPerPage, $pageID)
  20. {
  21. $programMenuLink = createLink(
  22. $this->app->rawModule,
  23. $this->app->rawMethod,
  24. array(
  25. 'browseType' => $browseType == 'bySearch' ? 'noclosed' : $browseType,
  26. 'orderBy' => $orderBy,
  27. 'param' => $browseType == 'bySearch' ? 0 : $param,
  28. 'recTotal' => 0,
  29. 'recPerPage' => $recPerPage,
  30. 'pageID' => $pageID,
  31. 'programID' => '{id}'
  32. )
  33. );
  34. return programMenu
  35. (
  36. set::title($lang->program->all),
  37. set::programs($programList),
  38. set::activeKey(!empty($programList) ? $programID : null),
  39. set::link(sprintf($programMenuLink, 0)),
  40. set::leadingAngle(false)
  41. );
  42. };
  43. jsVar('langSummary', $lang->product->pageSummary);
  44. /* ====== Define the page structure with zin widgets ====== */
  45. featureBar
  46. (
  47. (($config->systemMode != 'ALM' && $config->systemMode != 'PLM') || !helper::hasFeature('program')) ? null : to::leading($fnGenerateProgramMenu($programList)),
  48. set::link(createLink
  49. (
  50. $this->app->rawModule,
  51. $this->app->rawMethod,
  52. array
  53. (
  54. 'browseType' => '{key}',
  55. 'orderBy' => $orderBy,
  56. 'param' => $param,
  57. 'recTotal' => 0,
  58. 'recPerPage' => $recPerPage,
  59. 'pageID' => $pageID,
  60. 'programID' => $programID
  61. )
  62. )),
  63. li(searchToggle(set::open($browseType == 'bySearch')))
  64. );
  65. $canCreate = hasPriv('product', 'create');
  66. $canExport = hasPriv('product', 'export');
  67. $canManageLine = in_array($this->config->systemMode, array('ALM', 'PLM')) && hasPriv('product', 'manageLine');
  68. toolbar
  69. (
  70. $canExport ? btn
  71. (
  72. set::className('ghost text-darker pr-0'),
  73. set::icon('export'),
  74. toggle::modal(array('url' => createLink('product', 'export', "programID=$programID&status=$browseType&orderBy=$orderBy&param=$param"))),
  75. $lang->export
  76. ) : null,
  77. $canExport && $canManageLine ? div
  78. (
  79. setClass('divider')
  80. ) : null,
  81. $canManageLine ? btn
  82. (
  83. set::id('manageLineBtn'),
  84. set::className('ghost text-primary pl-0'),
  85. set::icon('edit'),
  86. toggle::modal(array('url' => createLink('product', 'manageLine', $browseType), 'id' => 'manageLineModal')),
  87. $lang->product->line
  88. ) : null,
  89. $canCreate ? btn
  90. (
  91. set::text($lang->product->create),
  92. set::icon('plus'),
  93. set::type('primary'),
  94. set::url(createLink('product', 'create')),
  95. set::className('create-product-btn')
  96. ) : null
  97. );
  98. $canBatchEdit = hasPriv('product', 'batchEdit');
  99. $canUpdateOrder = hasPriv('product', 'updateOrder') && $orderBy == 'order_asc';
  100. dtable
  101. (
  102. set::id('products'),
  103. set::sortable($canUpdateOrder),
  104. set::onSortEnd($canUpdateOrder ? jsRaw('window.onSortEnd') : null),
  105. set::canSortTo($canUpdateOrder ? jsRaw('window.canSortTo') : null),
  106. set::cols($cols),
  107. set::data($productStats),
  108. set::userMap($users),
  109. set::customCols(true),
  110. set::checkable($canBatchEdit),
  111. set::sortLink(createLink('product', 'all', "browseType={$browseType}&orderBy={name}_{sortType}&param={$param}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}&programID={$programID}")),
  112. set::orderBy($orderBy),
  113. set::plugins(array('header-group', 'sortable')),
  114. $canBatchEdit ? set::footToolbar
  115. (
  116. item
  117. (
  118. set::url('product', 'batchEdit'),
  119. set::text($lang->edit),
  120. setData('load', 'post'),
  121. setData('dataMap', 'productIDList[]:#products~checkedIDList')
  122. )
  123. ) : null,
  124. set::footPager(usePager()),
  125. set::emptyTip($lang->product->noProduct),
  126. set::createTip($lang->product->create),
  127. set::createLink($canCreate ? createLink('product', 'create') : '')
  128. );
  129. render();