task.excel.html.hook.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace zin;
  3. global $app;
  4. $lang = data('lang');
  5. $execution = data('execution');
  6. $moduleID = data('moduleID');
  7. $browseType = data('browseType');
  8. $orderBy = data('orderBy');
  9. $param = data('param');
  10. /* zin: Define the toolbar on main menu. */
  11. $canCreate = common::canModify('execution', $execution) && hasPriv('task', 'create');
  12. $canBatchCreate = common::canModify('execution', $execution) && hasPriv('task', 'batchCreate');
  13. $canImport = common::canModify('execution', $execution) && hasPriv('task', 'import');
  14. $canImportTask = common::canModify('execution', $execution) && hasPriv('execution', 'importTask');
  15. $canImportBug = common::canModify('execution', $execution) && hasPriv('execution', 'importBug');
  16. $importItems = array();
  17. if(common::canModify('execution', $execution))
  18. {
  19. $params = isset($moduleID) ? "&storyID=0&moduleID=$moduleID" : "";
  20. $batchCreateLink = createLink('task', 'batchCreate', "executionID={$execution->id}{$params}") . ($app->tab == 'project' ? '#app=project' : '');
  21. $createLink = createLink('task', 'create', "executionID={$execution->id}{$params}") . ($app->tab == 'project' ? '#app=project' : '');
  22. if(commonModel::isTutorialMode())
  23. {
  24. $wizardParams = helper::safe64Encode("executionID={$execution->id}{$params}");
  25. $taskCreateLink = createLink('tutorial', 'wizard', "module=task&method=create&params=$wizardParams");
  26. }
  27. $createItem = array('text' => $lang->task->create, 'url' => $createLink);
  28. $batchCreateItem = array('text' => $lang->task->batchCreate, 'url' => $batchCreateLink);
  29. if($canImport) $importItems[] = array('text' => $lang->task->import, 'data-toggle' => 'modal', 'data-size' => 'sm', 'url' => createLink('task', 'import', "executionID={$execution->id}"));
  30. if($canImportTask && $execution->multiple) $importItems[] = array('text' => $lang->execution->importTask, 'url' => createLink('execution', 'importTask', "execution={$execution->id}"));
  31. if($canImportBug && $execution->lifetime != 'ops' && !in_array($execution->attribute, array('request', 'review')))
  32. {
  33. $importItems[] = array('text' => $lang->execution->importBug, 'url' => createLink('execution', 'importBug', "execution={$execution->id}"), 'className' => 'importBug', 'data-app' => $execution->multiple ? '' : 'project');
  34. }
  35. }
  36. $exportItems = array();
  37. if(hasPriv('task', 'export')) $exportItems[] = array('text' => $lang->task->export, 'data-toggle' => 'modal', 'data-size' => 'sm', 'url' => createLink('task', 'export', "execution={$execution->id}&orderBy={$orderBy}&type={$browseType}"));
  38. if(hasPriv('task', 'exportTemplate')) $exportItems[] = array('text' => $lang->task->exportTemplate, 'data-toggle' => 'modal', 'data-size' => 'sm', 'url' => createLink('task', 'exportTemplate', "executionID={$execution->id}"));
  39. $viewType = isset($_COOKIE['taskViewType']) ? $_COOKIE['taskViewType'] : 'tree';
  40. $toolbar = toolbar
  41. (
  42. item(set(array
  43. (
  44. 'type' => 'btnGroup',
  45. 'items' => array(array
  46. (
  47. 'icon' => 'list',
  48. 'class' => 'btn-icon switchButton' . ($viewType == 'tiled' ? ' text-primary' : ''),
  49. 'data-type' => 'tiled',
  50. 'hint' => $lang->task->viewTypeList['tiled']
  51. ), array
  52. (
  53. 'icon' => 'treeview',
  54. 'class' => 'switchButton btn-icon' . ($viewType == 'tree' ? ' text-primary' : ''),
  55. 'data-type' => 'tree',
  56. 'hint' => $lang->task->viewTypeList['tree']
  57. ))
  58. ))),
  59. hasPriv('task', 'report') && empty($execution->isTpl) ? item(set(array
  60. (
  61. 'icon' => 'bar-chart',
  62. 'class' => 'ghost',
  63. 'data-app' => $app->tab,
  64. 'hint' => $lang->task->report->common,
  65. 'url' => createLink('task', 'report', "execution={$execution->id}&browseType={$browseType}&param={$param}")
  66. ))) : null,
  67. $exportItems ? dropdown(
  68. btn
  69. (
  70. setClass('ghost btn square btn-default'),
  71. set::icon('export')
  72. ),
  73. set::items($exportItems),
  74. set::placement('bottom-end')
  75. ) : null,
  76. $importItems ? dropdown(
  77. btn
  78. (
  79. setClass('ghost btn square btn-default'),
  80. set::icon('import')
  81. ),
  82. set::items($importItems),
  83. set::placement('bottom-end')
  84. ) : null,
  85. $canCreate && $canBatchCreate ? btngroup
  86. (
  87. btn(setClass('btn primary createTask-btn'), set::icon('plus'), set::url($createLink), $lang->task->create),
  88. dropdown
  89. (
  90. btn(setClass('btn primary dropdown-toggle'),
  91. setStyle(array('padding' => '6px', 'border-radius' => '0 2px 2px 0'))),
  92. set::items(array_filter(array($createItem, $batchCreateItem))),
  93. set::placement('bottom-end')
  94. )
  95. ) : null,
  96. $canCreate && !$canBatchCreate ? item(set($createItem + array('class' => 'btn primary createTask-btn', 'icon' => 'plus'))) : null,
  97. $canBatchCreate && !$canCreate ? item(set($batchCreateItem + array('class' => 'btn primary', 'icon' => 'plus'))) : null
  98. );
  99. query('#actionBar')->replaceWith($toolbar);
  100. pageJS('$(function(){$("#mainMenu .toolbar").prop("id", "actionBar"); });');