ajaxgetdropmenu.html.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * The ajaxgetdropmenu view file of kanban module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @author Sun Guangming<sunguangming@easycorp.ltd>
  7. * @package kanban
  8. * @version $Id
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. $getKanbanGroup = function($kanban): string
  13. {
  14. if($kanban->status == 'closed') return 'closed';
  15. if($kanban->owner == $this->app->user->account) return 'my';
  16. return 'other';
  17. };
  18. $data = array();
  19. $kanbanGroup = array();
  20. foreach($spaceList as $spaceID => $space)
  21. {
  22. $spaceItem = array();
  23. $spaceItem['type'] = $lang->kanban->spaceCommon;
  24. $spaceItem['text'] = $space;
  25. $spaceItem['items'] = array();
  26. $kanbans = zget($kanbanList, $spaceID, array());
  27. foreach($kanbans as $id => $kanban)
  28. {
  29. $kanbanType = $kanbanGroup[$id] = $getKanbanGroup($kanban);
  30. $item = array();
  31. $item['id'] = $kanban->id;
  32. $item['text'] = $kanban->name;
  33. $item['keys'] = zget(common::convert2Pinyin(array($kanban->name)), $kanban->name, '');
  34. if(!isset($data[$kanbanType][$spaceID])) $data[$kanbanType][$spaceID] = $spaceItem;
  35. $data[$kanbanType][$spaceID]['items'][] = $item;
  36. }
  37. }
  38. /**
  39. * 定义每个分组名称信息,包括可展开的已关闭分组。
  40. * Define every group name, include expanded group.
  41. */
  42. $tabs = array();
  43. if(!empty($data['my'])) $tabs[] = array('name' => 'my', 'text' => $lang->kanban->my, 'active' => zget($kanbanGroup, $kanbanID, '') === 'my');
  44. if(!empty($data['other'])) $tabs[] = array('name' => 'other', 'text' => $lang->kanban->other, 'active' => zget($kanbanGroup, $kanbanID, '') === 'other');
  45. if(!empty($data['closed'])) $tabs[] = array('name' => 'closed', 'text' => $lang->kanban->closed);
  46. /* 将分组数据转换为索引数组。Format grouped data to indexed array. */
  47. foreach ($data as $key => $value) $data[$key] = array_values($value);
  48. /**
  49. * 定义最终的 JSON 数据。
  50. * Define the final json data.
  51. */
  52. $json = array();
  53. $json['data'] = $data;
  54. $json['tabs'] = $tabs;
  55. $json['searchHint'] = $lang->searchAB;
  56. $json['link'] = array('kanban' => sprintf($link, '{id}'));
  57. $json['expandName'] = 'closed';
  58. $json['itemType'] = 'kanban';
  59. /**
  60. * 渲染 JSON 字符串并发送到客户端。
  61. * Render json data to string and send to client.
  62. */
  63. renderJson($json);