edit.field.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <?php
  2. namespace zin;
  3. global $app, $lang, $config;
  4. $fields = defineFieldList('execution.edit');
  5. $project = data('project');
  6. $execution = data('execution');
  7. $productBranches = data('product.branches');
  8. $linkedPlans = data('product.plans');
  9. $linkedProducts = data('linkedProducts');
  10. $branchGroups = data('branchGroups');
  11. $productPlans = data('productPlans');
  12. if($project)
  13. {
  14. if(!$project->hasProduct || !$project->multiple)
  15. {
  16. $fields->field('project')
  17. ->className('hidden')
  18. ->value(data('execution.project'));
  19. }
  20. elseif($project->model == 'scrum')
  21. {
  22. $fields->field('project')
  23. ->label($lang->execution->projectName)
  24. ->control(array(
  25. 'control' => 'picker',
  26. 'required' => true,
  27. 'items' => data('allProjects'),
  28. 'value' => data('execution.project')
  29. ));
  30. }
  31. elseif($project->model == 'kanban')
  32. {
  33. $fields->field('project')
  34. ->className('hidden')
  35. ->value(data('execution.project'));
  36. }
  37. elseif($project->model == 'agileplus')
  38. {
  39. $fields->field('type')
  40. ->label($lang->execution->method)
  41. ->disabled()
  42. ->value(zget($lang->execution->typeList, data('execution.type')));
  43. }
  44. elseif($app->tab == 'project' && $project->model == 'waterfallplus')
  45. {
  46. $fields->field('parent')
  47. ->label($lang->programplan->parent)
  48. ->items(data('parentStageList'))
  49. ->value(data('execution.parent'));
  50. }
  51. if(in_array($project->model, array('waterfall', 'waterfallplus')))
  52. {
  53. $fields->field('attribute')
  54. ->label($lang->stage->type)
  55. ->wrapAfter()
  56. ->labelHint($lang->execution->typeTip);
  57. if(data('enableOptionalAttr'))
  58. {
  59. $fields->field('attribute')
  60. ->required()
  61. ->items($lang->stage->typeList)
  62. ->value(data('execution.attribute'));
  63. }
  64. else
  65. {
  66. $fields->field('attribute')
  67. ->control(array('control' => 'picker', 'disabled' => true))
  68. ->items($lang->stage->typeList)
  69. ->value(data('execution.attribute'));
  70. }
  71. }
  72. elseif($execution->type != 'kanban' && $project->model != 'ipd')
  73. {
  74. $fields->field('lifetime')
  75. ->required()
  76. ->id('lifetime')
  77. ->label($lang->execution->type)
  78. ->items($lang->execution->lifeTimeList)
  79. ->value(data('execution.lifetime'));
  80. }
  81. }
  82. $fields->field('name')
  83. ->required()
  84. ->label($lang->execution->name)
  85. ->value(data('execution.name'))
  86. ->wrapAfter(empty($config->setCode) && $project->model == 'ipd');
  87. $fields->field('code')
  88. ->label($lang->execution->code)
  89. ->value(data('execution.code'))
  90. ->hidden(empty($config->setCode))
  91. ->required(in_array('code', explode(',', $config->execution->edit->requiredFields)))
  92. ->width('1/4');
  93. if($project && $project->model != 'ipd')
  94. {
  95. $fields->field('status')
  96. ->required()
  97. ->label($lang->execution->status)
  98. ->items($lang->execution->statusList)
  99. ->value(data('execution.status'))
  100. ->width(empty($config->setCode) ? '1/2' : '1/4');
  101. }
  102. $fields->field('planDate')
  103. ->width('1/2')
  104. ->label($lang->execution->dateRange)
  105. ->control('inputGroup')
  106. ->itemBegin('dateRangePicker')
  107. ->control('dateRangePicker')
  108. ->beginName('begin')
  109. ->beginPlaceholder($lang->execution->begin)
  110. ->beginValue(data('execution.begin'))
  111. ->endName('end')
  112. ->endPlaceholder($lang->execution->end)
  113. ->endValue(data('execution.end'))
  114. ->endList($lang->execution->endList)
  115. ->itemEnd();
  116. $hasPercent = data('execution.type') == 'stage' && isset($config->setPercent) && $config->setPercent == 1;
  117. $fields->field('days')
  118. ->label("{$lang->execution->days} ({$lang->execution->day})")
  119. ->required(strpos(",{$config->execution->edit->requiredFields},", ",days,") !== false)
  120. ->value(data('execution.days'))
  121. ->width($hasPercent ? '1/4' : '1/2');
  122. if($hasPercent && $project && $project->model != 'ipd')
  123. {
  124. $fields->field('percent')
  125. ->label($lang->stage->percent)
  126. ->control('inputGroup')
  127. ->itemBegin('percent')->control('input')->value(data('execution.percent'))->itemEnd()
  128. ->itemBegin()->control('addon')->text('%')->itemEnd()
  129. ->width('1/4');
  130. }
  131. $fields->field('productsBox')
  132. ->id('productsBox')
  133. ->width(!empty($project->hasProduct) ? 'full' : '1/2')
  134. ->control(array(
  135. 'control' => 'productsBox',
  136. 'productItems' => data('allProducts'),
  137. 'branchGroups' => data('branchGroups'),
  138. 'planGroups' => data('productPlans'),
  139. 'linkedProducts' => data('linkedProducts'),
  140. 'linkedBranches' => data('linkedBranches'),
  141. 'productPlans' => data('productPlan'),
  142. 'currentPlan' => data('currentPlan'),
  143. 'project' => data('project'),
  144. 'isStage' => isset($project->model) && in_array($project->model, array('waterfall', 'waterfallplus')),
  145. 'errorSameProducts' => $lang->execution->errorSameProducts,
  146. 'from' => 'execution'
  147. ));
  148. if($execution->attribute != 'review')
  149. {
  150. $fields->field('PO')
  151. ->label($lang->execution->PO)
  152. ->required(in_array('PO', explode(',', $config->execution->edit->requiredFields)))
  153. ->items(data('poUsers'))
  154. ->value(data('execution.PO'));
  155. }
  156. if(!in_array($execution->attribute, array('request', 'design', 'review')))
  157. {
  158. $fields->field('QD')
  159. ->label($lang->execution->QD)
  160. ->required(in_array('QD', explode(',', $config->execution->edit->requiredFields)))
  161. ->items(data('qdUsers'))
  162. ->value(data('execution.QD'));
  163. }
  164. $fields->field('PM')
  165. ->label($lang->execution->PM)
  166. ->required(in_array('PM', explode(',', $config->execution->edit->requiredFields)))
  167. ->items(data('pmUsers'))
  168. ->value(data('execution.PM'));
  169. if(!in_array($execution->attribute, array('request', 'design', 'review')))
  170. {
  171. $fields->field('RD')
  172. ->label($lang->execution->RD)
  173. ->required(in_array('RD', explode(',', $config->execution->edit->requiredFields)))
  174. ->items(data('rdUsers'))
  175. ->value(data('execution.RD'));
  176. }
  177. $fields->field('team')
  178. ->width('full')
  179. ->label($lang->execution->teamName)
  180. ->value(data('execution.team'));
  181. $teamMembers = data('teamMembers');
  182. $fields->field('teamMembers')
  183. ->width('full')
  184. ->name('teamMembers[]')
  185. ->label($lang->execution->team)
  186. ->multiple()
  187. ->items(data('users'))
  188. ->value($teamMembers ? array_keys($teamMembers) : array());
  189. $fields->field('desc')
  190. ->width('full')
  191. ->required(in_array('desc', explode(',', $config->execution->edit->requiredFields)))
  192. ->control('editor')
  193. ->value(data('execution.desc'));
  194. $fields->field('acl')
  195. ->foldable()
  196. ->width('full')
  197. ->control(array(
  198. 'type' => 'aclBox',
  199. 'aclItems' => $lang->execution->aclList,
  200. 'aclValue' => data('execution.acl'),
  201. 'whitelistLabel' => $lang->whitelist,
  202. 'userItems' => data('users'),
  203. 'userValue' => data('execution.whitelist')
  204. ));
  205. if($project->model == 'ipd') $fields->field('attribute')->hidden();