ipd.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. /**
  3. * @param string|int $shadow
  4. * @param int $programID
  5. * @param string $status
  6. * @param int $limit
  7. * @param int $line
  8. * @param string $fields
  9. */
  10. public function getList($programID = 0, $status = 'all', $limit = 0, $line = 0, $shadow = 0, $fields = '*')
  11. {
  12. $products = $this->dao->select("t1.$fields")->from(TABLE_PRODUCT)->alias('t1')
  13. ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
  14. ->where('t1.deleted')->eq(0)
  15. ->beginIF($shadow !== 'all')->andWhere('t1.shadow')->eq((int)$shadow)->fi()
  16. ->beginIF($programID)->andWhere('t1.program')->eq($programID)->fi()
  17. ->beginIF($line > 0)->andWhere('t1.line')->eq($line)->fi()
  18. ->beginIF(!$this->app->user->admin and strpos($status, 'feedback') === false)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
  19. ->beginIF(strpos($status, 'noclosed') === false && !in_array($status, array('all', 'mine', 'involved', 'review', 'feedback'), true))->andWhere('t1.status')->in($status)->fi()
  20. ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('t1.status')->ne('closed')->fi()
  21. ->beginIF(strpos($status, 'feedback') !== false)->andWhere("FIND_IN_SET('rnd', t1.vision)")->fi()
  22. ->beginIF($status == 'mine')->andWhere('t1.PO')->eq($this->app->user->account)->fi()
  23. ->filterTpl('skip')
  24. ->orderBy('t2.order_asc, t1.line_desc, t1.order_asc')
  25. ->beginIF($limit > 0)->limit($limit)->fi()
  26. ->fetchAll('id');
  27. return $products;
  28. }
  29. /**
  30. * 获取产品统计信息。
  31. * Get product stats.
  32. *
  33. * @param array $productIdList
  34. * @param string $orderBy order_asc|program_asc
  35. * @param object|null $pager
  36. * @param string $storyType requirement|story
  37. * @param int $programID
  38. * @access public
  39. * @return array
  40. */
  41. public function getStats($productIdList, $orderBy = 'order_asc', $pager = null, $storyType = 'story', $programID = 0)
  42. {
  43. if(commonModel::isTutorialMode()) return $this->loadModel('tutorial')->getProductStats();
  44. if(empty($productIdList)) return array();
  45. if($orderBy == 'program_asc')
  46. {
  47. $products = $this->dao->select('t1.id as id, t1.name, t1.program, t1.line, t1.PO, t1.status, t1.type, t1.PMT, 0 as draftStories, 0 as activeStories, 0 as launchedStories, 0 as developingStories, 0 as waitedRoadmaps, 0 as launchedRoadmaps, t1.plans, t1.releases, t1.unresolvedBugs, t1.createdDate')->from(TABLE_PRODUCT)->alias('t1')
  48. ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
  49. ->where('t1.id')->in($productIdList)
  50. ->filterTpl('skip')
  51. ->orderBy('t2.order_asc, t1.line_desc, t1.order_asc')
  52. ->page($pager)
  53. ->fetchAll('id');
  54. }
  55. else
  56. {
  57. $products = $this->dao->select('id, name, program, line, status, type, PO, PMT, 0 as draftStories, 0 as activeStories, 0 as launchedStories, 0 as developingStories, 0 as waitedRoadmaps, 0 as launchedRoadmaps, plans, releases, unresolvedBugs, createdDate')->from(TABLE_PRODUCT)
  58. ->where('id')->in($productIdList)
  59. ->orderBy($orderBy)
  60. ->page($pager)
  61. ->fetchAll('id');
  62. }
  63. /* Recalculate productKeys after paging. */
  64. $productKeys = array_keys($products);
  65. $linePairs = $this->getLinePairs();
  66. foreach($products as $product) $product->lineName = zget($linePairs, $product->line, '');
  67. $this->app->loadLang('project');
  68. if(empty($programID))
  69. {
  70. $programKeys = array(0 => 0);
  71. foreach($products as $product) $programKeys[] = $product->program;
  72. $programs = $this->dao->select('id,name,PM')->from(TABLE_PROGRAM)
  73. ->where('id')->in(array_unique($programKeys))
  74. ->fetchAll('id');
  75. foreach($products as $product)
  76. {
  77. $product->programName = (!empty($product->line) && empty($product->program)) ? $this->lang->project->future : (isset($programs[$product->program]) ? $programs[$product->program]->name : '');
  78. $product->programPM = isset($programs[$product->program]) ? $programs[$product->program]->PM : '';
  79. }
  80. }
  81. $stories = $this->dao->select('id,product,status')->from(TABLE_STORY)
  82. ->where('deleted')->eq(0)
  83. ->andWhere('status')->in('draft,active,launched,developing')
  84. ->andWhere('type')->eq('requirement')
  85. ->andWhere('product')->in($productKeys)
  86. ->fetchAll('id');
  87. foreach($stories as $story)
  88. {
  89. if($story->status == 'draft')
  90. {
  91. $products[$story->product]->draftStories++;
  92. }
  93. else if($story->status == 'active')
  94. {
  95. $products[$story->product]->activeStories++;
  96. }
  97. else if($story->status == 'launched')
  98. {
  99. $products[$story->product]->launchedStories++;
  100. }
  101. else if($story->status == 'developing')
  102. {
  103. $products[$story->product]->developingStories++;
  104. }
  105. }
  106. $roadmaps = $this->dao->select('id, product, status')->from(TABLE_ROADMAP)
  107. ->where('deleted')->eq(0)
  108. ->andWhere('status')->in('wait,launched')
  109. ->andWhere('product')->in($productKeys)
  110. ->fetchAll('id');
  111. foreach($roadmaps as $roadmap)
  112. {
  113. if($roadmap->status == 'wait')
  114. {
  115. $products[$roadmap->product]->waitedRoadmaps++;
  116. }
  117. else if($roadmap->status == 'launched')
  118. {
  119. $products[$roadmap->product]->launchedRoadmaps++;
  120. }
  121. }
  122. return $products;
  123. }
  124. /**
  125. * Get product by pool.
  126. *
  127. * @param int $poolID
  128. * @param string $status
  129. * @param string $append
  130. * @param bool $queryAll
  131. * @access public
  132. * @return array
  133. */
  134. public function getProductByPool($poolID, $status = '', $append = '', $queryAll = false)
  135. {
  136. $pool = $this->loadModel('demandpool')->getById($poolID);
  137. $productIdList = !empty($pool->products) ? trim(trim($pool->products, ',') . ',' . trim($append, ','), ',') : '';
  138. return $this->dao->select('*')->from(TABLE_PRODUCT)
  139. ->where('deleted')->eq(0)
  140. ->andWhere('shadow')->eq(0)
  141. ->beginIF($productIdList)->andWhere('id')->in($productIdList)->fi()
  142. ->beginIF(!$queryAll && !$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
  143. ->beginIF($status)->andWhere('status')->in($status)->fi()
  144. ->fetchPairs('id', 'name');
  145. }
  146. /**
  147. * Build operate menu.
  148. *
  149. * @param object $product
  150. * @param string $type
  151. * @access public
  152. * @return string
  153. */
  154. public function buildOrOperateMenu($product, $type = 'view')
  155. {
  156. $menu = '';
  157. $params = "product=$product->id";
  158. if($type == 'view')
  159. {
  160. $menu .= "<div class='divider'></div>";
  161. $menu .= $this->buildFlowMenu('product', $product, $type, 'direct');
  162. $menu .= "<div class='divider'></div>";
  163. if($product->status != 'closed') $menu .= $this->buildMenu('product', 'close', $params, $product, $type, '', '', 'iframe', true, "data-app='product'");
  164. if($product->status == 'closed') $menu .= $this->buildMenu('product', 'activate', $params, $product, $type, '', '', 'iframe', true, "data-app='product'");
  165. $menu .= "<div class='divider'></div>";
  166. $menu .= $this->buildMenu('product', 'edit', $params, $product, $type);
  167. }
  168. elseif($type == 'browse')
  169. {
  170. $menu .= $this->buildMenu('product', 'edit', $params, $product, $type);
  171. if($product->status != 'closed') $menu .= $this->buildMenu('product', 'close', $params, $product, $type, '', '', 'iframe', true, "data-app='product'");
  172. if($product->status == 'closed') $menu .= $this->buildMenu('product', 'activate', $params, $product, $type, '', '', 'iframe', true, "data-app='product'");
  173. }
  174. if($type != 'browse') $menu .= $this->buildMenu('product', 'delete', $params, $product, $type, 'trash', 'hiddenwin');
  175. return $menu;
  176. }