create.html.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <?php
  2. /**
  3. * The create view of task module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package task
  9. * @version $Id: create.html.php 5090 2013-07-10 05:49:24Z zhujinyonging@gmail.com $
  10. * @link http://www.zentao.net
  11. */
  12. ?>
  13. <?php include $this->app->getModuleRoot() . '/common/view/header.html.php';?>
  14. <?php include $this->app->getModuleRoot() . '/common/view/kindeditor.html.php';?>
  15. <?php include $this->app->getModuleRoot() . '/common/view/sortable.html.php';?>
  16. <?php js::set('toTaskList', !empty($task->id));?>
  17. <?php js::set('blockID', $blockID);?>
  18. <?php js::set('vision', $this->config->vision);?>
  19. <?php js::set('projectID', $projectID);?>
  20. <?php js::set('productID', $productID);?>
  21. <?php js::set('teamMemberError', $lang->task->error->teamMember);?>
  22. <?php js::set('estimateNotEmpty', sprintf($lang->error->gt, $lang->task->estimate, '0'))?>
  23. <?php if(!empty($storyID)):?>
  24. <?php endif;?>
  25. <div id='mainContent' class='main-content'>
  26. <div class='center-block'>
  27. <div class='main-header'>
  28. <h2><?php echo $lang->task->create;?></h2>
  29. <div class='btn-toolbar pull-right'>
  30. <?php $customLink = $this->createLink('custom', 'ajaxSaveCustomFields', 'module=task&section=custom&key=createFields')?>
  31. <?php include $this->app->getModuleRoot() . '/common/view/customfield.html.php';?>
  32. </div>
  33. </div>
  34. <?php
  35. foreach(explode(',', $config->task->create->requiredFields) as $field)
  36. {
  37. if($field and strpos($showFields, $field) === false) $showFields .= ',' . $field;
  38. }
  39. ?>
  40. <form class='main-form form-ajax' method='post' enctype='multipart/form-data' id='dataform'>
  41. <table class='table table-form'>
  42. <?php if($execution->type != 'kanban' or $this->config->vision == 'lite'):?>
  43. <tr>
  44. <th><?php echo $lang->task->execution;?></th>
  45. <td><?php echo html::select('execution', $executions, $execution->id, "class='form-control chosen' onchange='loadPage(this.value)' required");?></td><td></td><td></td>
  46. </tr>
  47. <?php endif;?>
  48. <?php if(count($regionList) > 1 or count($laneList) > 1 or empty($extra)):?>
  49. <tr>
  50. <th><?php echo $lang->task->region;?></th>
  51. <td><?php echo html::select('region', $regionList, isset($regionID) ? $regionID : '', "class='form-control chosen' onchange='loadLaneGroup(this.value)' required");?>
  52. </tr>
  53. <tr>
  54. <th><?php echo $lang->task->lane;?></th>
  55. <td class='required'><?php echo html::select('otherLane', '', '', "class='form-control chosen' required");?>
  56. </tr>
  57. <?php endif;?>
  58. <tr>
  59. <th><?php echo $lang->task->type;?></th>
  60. <td><?php echo html::select('type', $lang->task->typeList, $task->type, "class='form-control chosen' onchange='setOwners(this.value)' required");?></td>
  61. <td>
  62. <div class="checkbox-primary hidden" id='selectTestStoryBox'>
  63. <input type="checkbox" name='selectTestStory' id="selectTestStory" value='1' onchange='toggleSelectTestStory()' /><label for="selectTestStory" class="no-margin"><?php echo $lang->task->selectTestStory;?></label>
  64. </div>
  65. </td>
  66. </tr>
  67. <tr>
  68. <th><?php echo $lang->task->module;?></th>
  69. <td id='moduleIdBox'><?php echo html::select('module', $moduleOptionMenu, $task->module, "class='form-control chosen' onchange='setStories(this.value, $execution->id)'");?></td>
  70. <td>
  71. <div class="checkbox-primary">
  72. <input type="checkbox" id="showAllModule" <?php if($showAllModule) echo 'checked';?>><label for="showAllModule" class="no-margin"><?php echo $lang->task->allModule;?></label>
  73. </div>
  74. </td>
  75. <td></td>
  76. </tr>
  77. <tr>
  78. <th><?php echo $lang->task->assignedTo;?></th>
  79. <td>
  80. <div class="input-group" id="dataPlanGroup">
  81. <?php echo html::select('assignedTo[]', $members, $task->assignedTo, "class='form-control chosen'");?>
  82. <?php echo html::input('teamMember', '', "class='form-control team-group fix-border hidden' readonly='readonly'");?>
  83. <span class="input-group-btn team-group hidden"><a class="btn br-0" href="#modalTeam" data-toggle="modal"><?php echo $lang->task->team;?></a></span>
  84. </div>
  85. </td>
  86. <td>
  87. <div class="checkbox-primary affair">
  88. <input type="checkbox" name="multiple" value="1" id="multipleBox"><label for="multipleBox" class="no-margin"><?php echo $lang->task->multiple;?></label>
  89. </div>
  90. <button id='selectAllUser' type="button" class="btn btn-link<?php if($task->type !== 'affair') echo ' hidden';?>"><?php echo $lang->task->selectAllUser;?></button>
  91. </td>
  92. </tr>
  93. <tr class='hidden modeBox'>
  94. <th><?php echo $lang->task->mode;?></th>
  95. <td><?php echo html::select('mode', $lang->task->modeList, '', "class='form-control chosen'");?></td>
  96. </tr>
  97. <tr class='hide'>
  98. <th><?php echo $lang->task->status;?></th>
  99. <td><?php echo html::hidden('status', 'wait');?></td>
  100. </tr>
  101. <?php $this->printExtendFields('', 'table', 'columns=3');?>
  102. <?php if(strpos(",$showFields,", ',story,') !== false and $execution->lifetime != 'ops'):?>
  103. <tr>
  104. <th><?php echo $lang->task->story;?></th>
  105. <td colspan='3'>
  106. <span id='storyBox' class="<?php if(!empty($stories)) echo 'hidden';?> "><?php printf($lang->task->noticeLinkStory, html::a($this->createLink('story', 'create', "productID=$productID&branch=0&moduleID=0&storyID=0&projectID=$projectID&bugID=0&planID=0&todoID=0&extra=&type=story&_single"), $lang->execution->linkStory, '', 'class="text-primary"'), html::a("javascript:loadStories($execution->id)", $lang->refresh, '', 'class="text-primary"'));?></span>
  107. <div class='input-group <?php if(empty($stories)) echo "hidden";?>'>
  108. <?php echo html::select('story', $stories, $task->story, "class='form-control chosen' onchange='setStoryRelated();'");?>
  109. <span class='input-group-btn' id='preview'><a href='#' class='btn iframe'><?php echo $lang->preview;?></a></span>
  110. </div>
  111. </td>
  112. </tr>
  113. <?php endif;?>
  114. <?php if($execution->type != 'ops'):?>
  115. <tr id='testStoryBox' class='hidden'>
  116. <th><?php echo $lang->task->selectTestStory;?></th>
  117. <td colspan='3'>
  118. <table class='table table-form mg-0 table-bordered'>
  119. <thead>
  120. <tr>
  121. <th class='w-150px'><?php echo $lang->task->storyAB;?></th>
  122. <th class='w-80px'><?php echo $lang->task->pri;?></th>
  123. <th class='w-300px'><?php echo $lang->task->datePlan;?></th>
  124. <th class='w-150px'><?php echo $lang->task->assignedTo;?></th>
  125. <th class='w-80px'><?php echo $lang->task->estimate;?></th>
  126. <th class='w-80px'><?php echo $lang->actions;?></th>
  127. </tr>
  128. </thead>
  129. <tbody>
  130. <?php $i = 0;?>
  131. <?php foreach($stories as $storyID => $storyTitle):?>
  132. <?php if(empty($storyID) or isset($testStoryIdList[$storyID])) continue;?>
  133. <tr>
  134. <td><?php echo html::select("testStory[]", array($storyID => $storyTitle), $storyID, "class='form-control chosen'");?></td>
  135. <td><?php echo html::select("testPri[]", $lang->task->priList, $task->pri, "class='form-control chosen'");?></td>
  136. <td>
  137. <div class='input-group'>
  138. <?php echo html::input("testEstStarted[]", $task->estStarted, "class='form-control form-date' placeholder='{$lang->task->estStarted}'");?>
  139. <span class='input-group-addon fix-border'>~</span>
  140. <?php echo html::input("testDeadline[]", $task->deadline, "class='form-control form-date' placeholder='{$lang->task->deadline}'");?>
  141. </div>
  142. </td>
  143. <td><?php echo html::select("testAssignedTo[]", $members, $task->assignedTo, "class='form-control chosen'");?></td>
  144. <td><?php echo html::input("testEstimate[]", '', "class='form-control'");?></td>
  145. <td class='text-center'>
  146. <div class="btn-group">
  147. <button type="button" class="btn btn-sm" tabindex="-1" onclick='addItem(this)'><i class="icon icon-plus"></i></button>
  148. <button type="button" class="btn btn-sm" tabindex="-1" onclick='removeItem(this)'><i class="icon icon-close"></i></button>
  149. </div>
  150. </td>
  151. </tr>
  152. <?php $i++;?>
  153. <?php if($i > 30) break;?>
  154. <?php endforeach;?>
  155. </tbody>
  156. </table>
  157. </td>
  158. </tr>
  159. <?php endif;?>
  160. <tr>
  161. <th><?php echo $lang->task->name;?></th>
  162. <td colspan='3'>
  163. <div class="input-group title-group">
  164. <div class="input-control has-icon-right">
  165. <div class="colorpicker">
  166. <button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown"><span class="cp-title"></span><span class="color-bar"></span><i class="ic"></i></button>
  167. <ul class="dropdown-menu clearfix">
  168. <li class="heading"><?php echo $lang->task->colorTag;?><i class="icon icon-close"></i></li>
  169. </ul>
  170. <input type="hidden" class="colorpicker" id="color" name="color" value="" data-icon="color" data-wrapper="input-control-icon-right" data-update-color="#name" data-provide="colorpicker">
  171. </div>
  172. <?php echo html::input('name', $task->name, "class='form-control' required");?>
  173. <a href='javascript:copyStoryTitle();' id='copyButton' class='input-control-icon-right'><?php echo $lang->task->copyStoryTitle;?></a>
  174. <?php echo html::hidden("storyEstimate") . html::hidden("storyDesc") . html::hidden("storyPri");?>
  175. </div>
  176. <?php if(strpos(",$showFields,", ',pri,') !== false): // begin print pri selector?>
  177. <span class="input-group-addon fix-border br-0"><?php echo $lang->task->pri;?></span>
  178. <?php
  179. $hasCustomPri = false;
  180. foreach($lang->task->priList as $priKey => $priValue)
  181. {
  182. if(!empty($priKey) and (string)$priKey != (string)$priValue)
  183. {
  184. $hasCustomPri = true;
  185. break;
  186. }
  187. }
  188. $priList = $lang->task->priList;
  189. if(end($priList)) unset($priList[0]);
  190. if(!isset($priList[$task->pri]))
  191. {
  192. reset($priList);
  193. $task->pri = key($priList);
  194. }
  195. ?>
  196. <?php if($hasCustomPri):?>
  197. <?php echo html::select('pri', (array)$priList, $task->pri, "class='form-control'");?>
  198. <?php else: ?>
  199. <div class="input-group-btn pri-selector" data-type="pri">
  200. <button type="button" class="btn dropdown-toggle br-0" data-toggle="dropdown">
  201. <span class="pri-text"><span class="label-pri label-pri-<?php echo empty($task->pri) ? '0' : $task->pri?>" title="<?php echo $task->pri?>"><?php echo $task->pri?></span></span> &nbsp;<span class="caret"></span>
  202. </button>
  203. <div class='dropdown-menu pull-right'>
  204. <?php echo html::select('pri', (array)$priList, $task->pri, "class='form-control' data-provide='labelSelector' data-label-class='label-pri'");?>
  205. </div>
  206. </div>
  207. <?php endif; ?>
  208. <?php endif; // end print pri selector ?>
  209. <?php if(strpos(",$showFields,", ',estimate,') !== false):?>
  210. <div class='table-col w-120px'>
  211. <div class="input-group">
  212. <span class="input-group-addon fix-border br-0"><?php echo $lang->task->estimateAB;?></span>
  213. <input type="text" name="estimate" id="estimate" value="<?php echo $task->estimate;?>" class="form-control" autocomplete="off">
  214. </div>
  215. </div>
  216. <?php endif;?>
  217. </div>
  218. </td>
  219. </tr>
  220. <tr>
  221. <th><?php echo $lang->task->desc;?></th>
  222. <td colspan='3'>
  223. <?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=task&link=desc');?>
  224. <?php echo html::textarea('desc', htmlSpecialString($task->desc), "rows='10' class='form-control'");?>
  225. </td>
  226. </tr>
  227. <tr>
  228. <th><?php echo $lang->files;?></th>
  229. <td colspan='3'><?php echo $this->fetch('file', 'buildform');?></td>
  230. </tr>
  231. <?php
  232. $hiddenEstStarted = strpos(",$showFields,", ',estStarted,') === false;
  233. $hiddenDeadline = strpos(",$showFields,", ',deadline,') === false;
  234. ?>
  235. <?php if(!$hiddenEstStarted or !$hiddenDeadline):?>
  236. <tr>
  237. <th><?php echo $lang->task->datePlan;?></th>
  238. <td colspan='2'>
  239. <div class='input-group'>
  240. <?php if(!$hiddenEstStarted):?>
  241. <?php echo html::input('estStarted', $task->estStarted, "class='form-control form-date' placeholder='{$lang->task->estStarted}'");?>
  242. <?php endif;?>
  243. <?php if(!$hiddenEstStarted and !$hiddenDeadline):?>
  244. <span class='input-group-addon fix-border'>~</span>
  245. <?php endif;?>
  246. <?php if(!$hiddenDeadline):?>
  247. <?php echo html::input('deadline', $task->deadline, "class='form-control form-date' placeholder='{$lang->task->deadline}'");?>
  248. <?php endif;?>
  249. </div>
  250. </td>
  251. </tr>
  252. <?php endif;?>
  253. <?php if(strpos(",$showFields,", ',mailto,') !== false):?>
  254. <tr>
  255. <th><?php echo $lang->story->mailto;?></th>
  256. <td colspan='3'>
  257. <div class="input-group">
  258. <?php echo html::select('mailto[]', $execution->acl == 'private' ? $members : $users, str_replace(' ', '', $task->mailto), "class='form-control chosen' data-placeholder='{$lang->chooseUsersToMail}' multiple");?>
  259. <?php if($execution->acl != 'private') echo $this->fetch('my', 'buildContactLists');?>
  260. </div>
  261. </td>
  262. </tr>
  263. <?php endif;?>
  264. <?php if(!isonlybody()):?>
  265. <tr id='after-tr'>
  266. <th><?php echo $lang->task->afterSubmit;?></th>
  267. <td colspan='3'><?php echo html::radio('after', $lang->task->afterChoices, !empty($task->id) ? 'toTaskList' : 'continueAdding');?></td>
  268. </tr>
  269. <?php endif;?>
  270. <tr>
  271. <td colspan='4' class='text-center form-actions'>
  272. <?php echo html::submitButton();?>
  273. <?php echo $gobackLink ? html::a($gobackLink, $lang->goback, '', 'class="btn btn-wide"') : html::backButton();?>
  274. </td>
  275. </tr>
  276. </table>
  277. <div class='modal fade modal-team' id='modalTeam' data-scroll-inside='false'>
  278. <div class='modal-dialog'>
  279. <div class='modal-content with-padding'>
  280. <div class='modal-header'>
  281. <button type='button' class='close' data-dismiss='modal'>
  282. <i class="icon icon-close"></i>
  283. </button>
  284. <h4 class='modal-title'><?php echo $lang->task->team;?></h4>
  285. </div>
  286. <div class='modal-body'>
  287. <table class="table table-form" id='taskTeamEditor'>
  288. <tbody class='sortable'>
  289. <?php include $app->getModuleRoot() . 'task/view/taskteam.html.php';?>
  290. </tbody>
  291. <tfoot>
  292. <tr>
  293. <td colspan='4' class='text-center'><?php echo html::a('javascript:void(0)', $lang->confirm, '', "class='btn btn-primary'");?></td>
  294. </tr>
  295. </tfoot>
  296. </table>
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. </form>
  302. </div>
  303. </div>
  304. <table class='hidden' id='testStoryTemplate'>
  305. <tr>
  306. <td><?php echo html::select("testStory[]", array(0 => ''), 0, "class='form-control chosen'");?></td>
  307. <td><?php echo html::select("testPri[]", $lang->task->priList, '', "class='form-control chosen'");?></td>
  308. <td>
  309. <div class='input-group'>
  310. <?php echo html::input("testEstStarted[]", '', "class='form-control form-date' placeholder='{$lang->task->estStarted}'");?>
  311. <span class='input-group-addon fix-border'>~</span>
  312. <?php echo html::input("testDeadline[]", '', "class='form-control form-date' placeholder='{$lang->task->deadline}'");?>
  313. </div>
  314. </td>
  315. <td><?php echo html::select("testAssignedTo[]", array('' => ''), '', "class='form-control chosen'");?></td>
  316. <td><?php echo html::input("testEstimate[]", '', "class='form-control'");?></td>
  317. <td class='text-center'>
  318. <div class="btn-group">
  319. <button type="button" class="btn btn-sm" tabindex="-1" onclick='addItem(this)'><i class="icon icon-plus"></i></button>
  320. <button type="button" class="btn btn-sm" tabindex="-1" onclick='removeItem(this)'><i class="icon icon-close"></i></button>
  321. </div>
  322. </td>
  323. </tr>
  324. </table>
  325. <?php js::set('stories', $stories);?>
  326. <?php js::set('storyPinYin', (empty($config->isINT) and class_exists('common')) ? common::convert2Pinyin($stories) : array());?>
  327. <?php js::set('testStoryIdList', $testStoryIdList);?>
  328. <?php js::set('executionID', $execution->id);?>
  329. <?php js::set('executionType', $execution->type);?>
  330. <?php if(isonlybody()):?>
  331. <style>
  332. .body-modal .main-header {padding-right: 0px; z-index: 1000;}
  333. .btn-toolbar > .dropdown {margin: 0px;}
  334. </style>
  335. <?php $html = '<div class="divider"></div><button id="closeModal" type="button" class="btn btn-link" data-dismiss="modal"><i class="icon icon-close"></i></button>';?>
  336. <script>
  337. $(function()
  338. {
  339. parent.$('#triggerModal .modal-content .modal-header .close').hide();
  340. $('#mainContent .main-header .pull-right.btn-toolbar').append(<?php echo json_encode($html)?>);
  341. })
  342. </script>
  343. <?php endif;?>
  344. <?php js::set('newRowCount', 5);?>
  345. <script>
  346. $(function()
  347. {
  348. var regionID = $('#region').val();
  349. loadLaneGroup(regionID);
  350. parent.$('body.hide-modal-close').removeClass('hide-modal-close');
  351. })
  352. function loadLaneGroup(regionID)
  353. {
  354. var link = createLink('kanban', 'ajaxGetLanes', 'regionID=' + regionID + '&type=task');
  355. $.post(link, function(data)
  356. {
  357. $('#otherLane').replaceWith(data);
  358. $('#otherLane_chosen').remove();
  359. $('#otherLane').chosen();
  360. /* Hide region and lane select if there are only one of each. */
  361. if($('#otherLane').children().length < 2 && $('#region').children().length < 2)
  362. {
  363. $('#region').parent().parent().addClass('hide');
  364. $('#otherLane').parent().parent().addClass('hide');
  365. }
  366. })
  367. }
  368. function loadPage(executionID)
  369. {
  370. var link = createLink('task', 'create', 'executionID=' + executionID);
  371. window.location.replace(link)
  372. }
  373. </script>
  374. <?php include $this->app->getModuleRoot() . '/common/view/footer.html.php';?>