batchcreate.html.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * The UI file of story 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 story
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. !isAjaxRequest() && dropmenu();
  13. $showFields = array('module', 'title', 'spec', 'parent', 'grade', 'pri', 'estimate', 'reviewer', 'keywords');
  14. foreach($fields as $fieldKey => $fieldConfig)
  15. {
  16. if(!in_array($fieldKey, $showFields)) unset($fields[$fieldKey]);
  17. }
  18. /* Generate fields for the batch create form. */
  19. $fnGenerateFields = function() use ($lang, $fields, $stories, $config)
  20. {
  21. /* Generate fields with the appropriate properties. */
  22. $items = array();
  23. $items[] = array('name' => 'id', 'label' => $lang->idAB, 'control' => 'index', 'width' => '32px');
  24. if($stories) $items[] = array('name' => 'uploadImage', 'label' => '', 'control' => 'hidden', 'hidden' => true);
  25. $cols = array_merge($items, array_map(function($name, $field)
  26. {
  27. $field['name'] = $name;
  28. if($field['name'] == 'grade') $field['hidden'] = true;
  29. if($field['name'] == 'parent') $field['items'] = array();
  30. if(!empty($field['options'])) $field['items'] = $field['options'];
  31. if(!empty($field['default'])) $field['value'] = $field['default'];
  32. if($field['control'] == 'select') $field['control'] = 'picker';
  33. unset($field['options']);
  34. return $field;
  35. }, array_keys($fields), array_values($fields)));
  36. foreach($cols as $index => $col)
  37. {
  38. $colName = $col['name'];
  39. if(strpos(",{$config->story->create->requiredFields},", ",{$colName},") !== false) $cols[$index]['required'] = true;
  40. }
  41. return $cols;
  42. };
  43. formBatchPanel
  44. (
  45. set::id('dataform'),
  46. set::ajax(array('beforeSubmit' => jsRaw('clickSubmit'))),
  47. $stories ? set::data($stories) : null,
  48. set::title($storyID ? $storyTitle . $lang->hyphen . $this->lang->story->subdivide : $this->lang->story->batchCreate),
  49. set::uploadParams('module=story&params=' . helper::safe64Encode("productID=$productID&branch=$branch&moduleID=$moduleID&storyID=$storyID&executionID=$executionID&plan=&type=$type")),
  50. set::pasteField('title'),
  51. set::customFields(array('list' => array(), 'show' => $showFields, 'key' => 'batchCreateFields')),
  52. set::items($fnGenerateFields()),
  53. set::actions(array
  54. (
  55. array('text' => $lang->save, 'data-status' => 'active', 'class' => 'primary', 'btnType' => 'submit'),
  56. array('text' => $lang->story->saveDraft, 'data-status' => 'draft', 'class' => 'secondary', 'btnType' => 'submit'),
  57. array('text' => $lang->goback, 'data-back' => 'APP', 'class' => 'open-url')
  58. )),
  59. formHidden('type', $type),
  60. formHidden('status', '')
  61. );
  62. render();