dynamic.html.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * The dynamic view file of product module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author chen.tao <chentao@easycorp.ltd>
  7. * @package product
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. jsVar('productID', $productID);
  12. featureBar
  13. (
  14. set::current($type),
  15. set::linkParams("productID={$productID}&type={key}"),
  16. set::labelCount($recTotal < \actionModel::MAXCOUNT ? $recTotal : (\actionModel::MAXCOUNT - 1) . '+'),
  17. li
  18. (
  19. setClass('w-40'),
  20. picker
  21. (
  22. set::name('user'),
  23. set::placeholder($lang->product->viewByUser),
  24. set::items($userIdPairs),
  25. set::value($param),
  26. on::change('onChangeUser')
  27. )
  28. )
  29. );
  30. /* No dynamic data. */
  31. if(empty($dateGroups))
  32. {
  33. $content = div
  34. (
  35. setClass('flex bg-canvas items-center justify-center h-64'),
  36. span
  37. (
  38. setClass('text-gray'),
  39. $lang->action->noDynamic
  40. )
  41. );
  42. return;
  43. }
  44. /* Render dynamic data. */
  45. $dynamicsGroup = array();
  46. $firstAction = null;
  47. $lastAction = null;
  48. foreach($dateGroups as $date => $actions)
  49. {
  50. $lastAction = end($actions);
  51. $isToday = date(DT_DATE4) == $date;
  52. if(empty($firstAction)) $firstAction = reset($actions);
  53. $dynamicsGroup[] = li
  54. (
  55. div
  56. (
  57. setClass('cursor-pointer leading-5'),
  58. span(icon('angle-down text-primary border-2 rounded-full z-10 bg-canvas align-middle dynamic-collapse-icon')),
  59. span
  60. (
  61. setClass('ml-2'),
  62. $isToday ? $lang->action->dynamic->today : $date
  63. )
  64. ),
  65. div
  66. (
  67. setClass('border-l border-l-1 mx-2 px-4 py-3'),
  68. div
  69. (
  70. setClass('flex-auto px-4 alert actions-box'),
  71. setClass($type == 'today' ? 'border-secondary' : ''),
  72. dynamic
  73. (
  74. set::dynamics($actions),
  75. set::users($accountPairs)
  76. )
  77. )
  78. )
  79. );
  80. }
  81. global $app;
  82. $hasMore = $app->control->loadModel('action')->hasMoreAction($lastAction);
  83. if($hasMore)
  84. {
  85. $dynamicsGroup[] = li
  86. (
  87. a
  88. (
  89. setID('showMoreDynamic'),
  90. setClass('block text-center'),
  91. setData(array('lastid' => $lastAction->id)),
  92. set::href('###'),
  93. on::click('showMore'),
  94. icon('chevron-double-down')
  95. )
  96. );
  97. }
  98. $content = ul(setClass('timeline list-none pl-0'), $dynamicsGroup);
  99. panel($content);
  100. /* Render previous and next float buttons. */
  101. if(empty($firstAction)) return;
  102. $firstDate = date('Y-m-d', strtotime($firstAction->originalDate) + 24 * 3600);
  103. $lastDate = substr($lastAction->originalDate, 0, 10);
  104. $hasPre = $this->action->hasPreOrNext($firstDate, 'pre', $type);
  105. $hasNext = $this->action->hasPreOrNext($lastDate, 'next', $type);
  106. $preLink = $hasPre ? inlink('dynamic', "productID=$productID&type=$type&param=$param&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;';
  107. $nextLink = $hasNext ? inlink('dynamic', "productID=$productID&type=$type&param=$param&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;';
  108. if($hasPre || $hasNext)
  109. {
  110. floatPreNextBtn
  111. (
  112. empty($hasNext) ? null : set::preLink($nextLink),
  113. empty($hasPre) ? null : set::nextLink($preLink)
  114. );
  115. }