manageproducts.html.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. /**
  3. * The manage product view file of project 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 Yanyi Cao<caoyanyi@easycorp.ltd>
  7. * @package project
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. jsVar('unmodifiableProducts', $unmodifiableProducts);
  12. jsVar('unmodifiableBranches', $unmodifiableBranches);
  13. jsVar('unmodifiableMainBranches', $unmodifiableMainBranches);
  14. jsVar('allProducts', $allProducts);
  15. jsVar('branchGroups', $branchGroups);
  16. jsVar('projectID', $project->id);
  17. jsVar('BRANCH_MAIN', BRANCH_MAIN);
  18. jsVar('unLinkProductTip', $lang->project->unLinkProductTip);
  19. jsVar('errorNoProduct', sprintf($lang->error->notempty, $lang->productCommon));
  20. $noticeSwitch = ($project->stageBy == 'project' and count($linkedProducts) == 1 and empty($executions) and in_array($project->model, array('waterfall', 'waterfallplus')));
  21. jsVar('linkedProducts', array_keys($linkedProducts));
  22. jsVar('noticeSwitch', $noticeSwitch);
  23. jsVar('noticeDivsion', $lang->project->noticeDivsion);
  24. jsVar('stageBySwitchList', $lang->project->stageBySwitchList);
  25. /* Link other product modal. */
  26. if($config->systemMode == 'ALM')
  27. {
  28. modal
  29. (
  30. setID('linkProduct'),
  31. set::modalProps(array('title' => $lang->project->manageOtherProducts)),
  32. form
  33. (
  34. setClass('text-center', 'py-4'),
  35. set::actions(array('submit')),
  36. formGroup
  37. (
  38. set::label($lang->project->selectProduct),
  39. set::required(true),
  40. picker
  41. (
  42. set::name('otherProducts[]'),
  43. set::multiple(true),
  44. set::items($otherProducts)
  45. )
  46. )
  47. )
  48. );
  49. }
  50. $index = 0;
  51. $linkedList = array();
  52. foreach($linkedProducts as $productID => $product)
  53. {
  54. if(empty($linkedBranches[$productID])) continue;
  55. $cannotUnlink = !empty($disabledProducts[$productID]);
  56. foreach($linkedBranches[$productID] as $branchID)
  57. {
  58. $linkedList[] = btn(setClass('product-block modal-content center-row justify-start text-left'), checkbox
  59. (
  60. set::rootClass('w-full p-4 pl-0 clip'),
  61. set::name("products[{$index}]"),
  62. set::text($product->name),
  63. set::checked(true),
  64. set::disabled($cannotUnlink),
  65. set::title($cannotUnlink ? $disabledProducts[$productID] : ''),
  66. set::value($productID),
  67. on::click('checkUnlink'),
  68. setClass('linked-product')
  69. ), isset($allBranches[$productID][$branchID]) ? picker
  70. (
  71. set::name("branch[{$index}]"),
  72. set::value($branchID),
  73. set::items($allBranches[$productID]),
  74. set::disabled(true),
  75. set::required(true)
  76. ) : null, $cannotUnlink ? input
  77. (
  78. set::type('hidden'),
  79. set::name("products[{$index}]"),
  80. set::value($productID)
  81. ) : null, $cannotUnlink || isset($allBranches[$productID][$branchID]) ? input
  82. (
  83. set::type('hidden'),
  84. set::name("branch[{$index}]"),
  85. set::value($branchID)
  86. ) : null);
  87. if(!isset($branchGroups[$productID]))
  88. {
  89. if($this->config->systemMode == 'ALM')
  90. {
  91. unset($currentProducts[$productID]);
  92. }
  93. else
  94. {
  95. unset($allProducts[$productID]);
  96. }
  97. }
  98. if(isset($branchGroups[$productID][$branchID])) unset($branchGroups[$productID][$branchID]);
  99. if(isset($branchGroups[$productID]) and empty($branchGroups[$productID]))
  100. {
  101. if($this->config->systemMode == 'ALM')
  102. {
  103. unset($currentProducts[$productID]);
  104. }
  105. else
  106. {
  107. unset($allProducts[$productID]);
  108. }
  109. }
  110. $index ++;
  111. }
  112. }
  113. $unlinkList = array();
  114. $unlinkedProducts = $config->systemMode == 'ALM' ? $currentProducts : $allProducts;
  115. foreach($unlinkedProducts as $productID => $productName)
  116. {
  117. $unlinkList[] = btn
  118. (
  119. setClass('product-block modal-content center-row justify-start text-left'),
  120. checkbox
  121. (
  122. set::rootClass('w-full p-4 pl-0 clip'),
  123. set::name("products[{$index}]"),
  124. set::text($productName),
  125. set::value($productID)
  126. ),
  127. isset($branchGroups[$productID]) ? picker
  128. (
  129. set::name("branch[{$index}]"),
  130. set::items($branchGroups[$productID]),
  131. set::required(true)
  132. ) : null
  133. );
  134. $index ++;
  135. }
  136. form
  137. (
  138. setID('manageProducts'),
  139. setClass('canvas pb-6'),
  140. sectionList
  141. (
  142. section
  143. (
  144. set::title($lang->execution->linkedProducts),
  145. div
  146. (
  147. setClass('flex flex-wrap'),
  148. $linkedList
  149. )
  150. ),
  151. $unlinkList ? h::hr() : null,
  152. section
  153. (
  154. set::title($lang->execution->unlinkedProducts),
  155. $config->systemMode == 'ALM' ? to::actions
  156. (
  157. btn
  158. (
  159. setClass('ghost text-primary ml-2'),
  160. set::url('#linkProduct'),
  161. set('data-toggle', 'modal'),
  162. set('data-size', 'sm'),
  163. icon('link'),
  164. p($lang->project->manageOtherProducts)
  165. )
  166. ) : null,
  167. $unlinkList ? div
  168. (
  169. setClass('flex flex-wrap'),
  170. $unlinkList
  171. ) : null
  172. ),
  173. h::hr()
  174. ),
  175. formHidden('post', 'post'),
  176. set::actions(array('submit'))
  177. );
  178. render();