control.php 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616
  1. <?php
  2. /**
  3. * The control file of dashboard module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package dashboard
  9. * @version $Id: control.php 5020 2013-07-05 02:03:26Z wyd621@gmail.com $
  10. * @link https://www.zentao.net
  11. */
  12. class my extends control
  13. {
  14. /**
  15. * Construct function.
  16. *
  17. * @access public
  18. * @return void
  19. */
  20. public function __construct($module = '', $method = '')
  21. {
  22. parent::__construct($module, $method);
  23. $this->loadModel('user');
  24. $this->loadModel('dept');
  25. }
  26. /**
  27. * Index page, goto todo.
  28. *
  29. * @access public
  30. * @return void
  31. */
  32. public function index()
  33. {
  34. $this->view->title = $this->lang->my->common;
  35. echo $this->fetch('block', 'dashboard', 'dashboard=my');
  36. }
  37. /**
  38. * 积分列表。
  39. * Get score list
  40. *
  41. * @param int $recTotal
  42. * @param int $recPerPage
  43. * @param int $pageID
  44. * @access public
  45. * @return void
  46. */
  47. public function score($recTotal = 0, $recPerPage = 20, $pageID = 1)
  48. {
  49. $this->app->loadClass('pager', true);
  50. $pager = new pager($recTotal, $recPerPage, $pageID);
  51. $scores = $this->loadModel('score')->getListByAccount($this->app->user->account, $pager);
  52. $this->view->title = $this->lang->score->common;
  53. $this->view->user = $this->user->getById($this->app->user->account);
  54. $this->view->pager = $pager;
  55. $this->view->scores = $scores;
  56. $this->display();
  57. }
  58. /**
  59. * 日程列表。
  60. * My calendar.
  61. *
  62. * @access public
  63. * @return void
  64. */
  65. public function calendar()
  66. {
  67. $this->locate($this->createLink('my', 'todo', 'type=all&userID=&status=all'));
  68. }
  69. /**
  70. * 待处理列表。
  71. * My work view.
  72. *
  73. * @param string $mode
  74. * @param string $type
  75. * @param int $param
  76. * @param string $orderBy
  77. * @param int $recTotal
  78. * @param int $recPerPage
  79. * @param int $pageID
  80. * @access public
  81. * @return void
  82. */
  83. public function work($mode = 'task', $type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  84. {
  85. if(in_array($mode, array('testcase', 'feedback')) && $type == 'assignedTo') $type = 'assigntome';
  86. $this->lang->my->featureBar[$this->app->rawMethod] = $this->lang->my->featureBar[$this->app->rawMethod][strtolower($mode)];
  87. echo $this->fetch('my', $mode, "type={$type}&param={$param}&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  88. }
  89. /**
  90. * 贡献列表。
  91. * My contribute view.
  92. *
  93. * @param string $mode
  94. * @param string $type
  95. * @param int $param
  96. * @param string $orderBy
  97. * @param int $recTotal
  98. * @param int $recPerPage
  99. * @param int $pageID
  100. * @access public
  101. * @return void
  102. */
  103. public function contribute($mode = 'task', $type = 'openedBy', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  104. {
  105. if((in_array($mode, array('issue', 'risk', 'reviewissue'))) && $type == 'openedBy') $type = 'createdBy';
  106. if($mode == 'testtask' && $type == 'openedBy') $type = 'done';
  107. if(($mode == 'doc' || $mode == 'testcase') && $type == 'openedBy') $type = 'openedbyme';
  108. $this->lang->my->featureBar[$this->app->rawMethod] = $this->lang->my->featureBar[$this->app->rawMethod][strtolower($mode)];
  109. echo $this->fetch('my', $mode, "type={$type}&param={$param}&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  110. }
  111. /**
  112. * 待办列表。
  113. * My todos.
  114. *
  115. * @param string $type
  116. * @param string $userID
  117. * @param string $status
  118. * @param string $orderBy
  119. * @param int $recTotal
  120. * @param int $recPerPage
  121. * @param int $pageID
  122. * @access public
  123. * @return void
  124. */
  125. public function todo($type = 'before', $userID = '', $status = 'all', $orderBy = "date_desc,status,begin", $recTotal = 0, $recPerPage = 20, $pageID = 1)
  126. {
  127. /* Save session. */
  128. $uri = $this->app->getURI(true);
  129. $this->session->set('todoList', $uri, 'my');
  130. $this->session->set('bugList', $uri, 'my');
  131. $this->session->set('taskList', $uri, 'my');
  132. $this->session->set('storyList', $uri, 'my');
  133. $this->session->set('testtaskList', $uri, 'my');
  134. /* Load pager. */
  135. $this->app->loadClass('pager', true);
  136. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  137. $pager = new pager($recTotal, $recPerPage, $pageID);
  138. if(empty($userID)) $userID = $this->app->user->id;
  139. $user = $this->user->getById($userID, 'id');
  140. $account = $user->account;
  141. /* Append id for second sort, get todos and tasks. */
  142. $sort = common::appendOrder($orderBy);
  143. if($type == 'before') $status = 'undone';
  144. $todos = $this->loadModel('todo')->getList($type, $account, $status, 0, $pager, $sort);
  145. $tasks = $this->loadModel('task')->getUserSuspendedTasks($account);
  146. $count = array('wait' => 0, 'doing' => 0);
  147. foreach($todos as $key => $todo)
  148. {
  149. if($todo->type == 'task' && isset($tasks[$todo->objectID])) unset($todos[$key]);
  150. if($todo->status == 'wait' || $todo->status == 'doing') $count[$todo->status] ++;
  151. if($todo->date == '2030-01-01') $todo->date = $this->lang->todo->future;
  152. }
  153. /* Assign. */
  154. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->todo;
  155. $this->view->todos = $todos;
  156. $this->view->date = (int)$type == 0 ? date(DT_DATE1) : date(DT_DATE1, strtotime($type));
  157. $this->view->type = $type;
  158. $this->view->status = $status;
  159. $this->view->user = $user;
  160. $this->view->users = $this->user->getPairs('noletter');
  161. $this->view->account = $this->app->user->account;
  162. $this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
  163. $this->view->time = date::now();
  164. $this->view->waitCount = $count['wait'];
  165. $this->view->doingCount = $count['doing'];
  166. $this->view->pager = $pager;
  167. $this->view->orderBy = $orderBy;
  168. $this->display();
  169. }
  170. /**
  171. * 需求列表。
  172. * My stories.
  173. *
  174. * @param string $type
  175. * @param int $param
  176. * @param string $orderBy
  177. * @param int $recTotal
  178. * @param int $recPerPage
  179. * @param int $pageID
  180. * @access public
  181. * @return void
  182. */
  183. public function story($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  184. {
  185. /* Save session. */
  186. if($this->app->viewType != 'json') $this->session->set('storyList', $this->app->getURI(true), 'my');
  187. /* Load pager. */
  188. $this->app->loadClass('pager', true);
  189. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  190. $pager = pager::init($recTotal, $recPerPage, $pageID);
  191. /* Append id for second sort. */
  192. $sort = common::appendOrder($orderBy);
  193. if(strpos($sort, 'planTitle') !== false) $sort = str_replace('planTitle', 'plan', $sort);
  194. if(strpos($sort, 'pri_') !== false) $sort = str_replace('pri_', 'priOrder_', $sort);
  195. $queryID = $type == 'bysearch' ? (int)$param : 0;
  196. $this->loadModel('story');
  197. if($type == 'assignedBy')
  198. {
  199. $stories = $this->my->getAssignedByMe($this->app->user->account, $pager, $sort, 'story');
  200. }
  201. elseif($type == 'bysearch')
  202. {
  203. $stories = $this->my->getStoriesBySearch($queryID, $this->app->rawMethod, $sort, $pager);
  204. }
  205. else
  206. {
  207. $stories = $this->story->getUserStories($this->app->user->account, $type, $sort, $pager, 'story', false, 'all');
  208. }
  209. if(!empty($stories)) $stories = $this->story->mergeReviewer($stories);
  210. foreach($stories as $story) $story->estimate = $story->estimate . $this->config->hourUnit;
  211. /* Build the search form. */
  212. $currentMethod = $this->app->rawMethod;
  213. $actionURL = $this->createLink('my', $currentMethod, "mode=story&type=bysearch&param=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  214. $this->my->buildStorySearchForm($queryID, $actionURL, $currentMethod);
  215. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  216. /* Assign. */
  217. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->story;
  218. $this->view->stories = $stories;
  219. $this->view->users = $this->user->getPairs('noletter');
  220. $this->view->type = $type;
  221. $this->view->param = $param;
  222. $this->view->mode = 'story';
  223. $this->view->pager = $pager;
  224. $this->view->orderBy = $orderBy;
  225. $this->view->gradeGroup = $this->story->getGradeGroup();
  226. $this->view->showGrade = $this->config->edition == 'ipd';
  227. $this->display();
  228. }
  229. /**
  230. * 业务需求列表。
  231. * My epics.
  232. *
  233. * @param string $type
  234. * @param int $param
  235. * @param string $orderBy
  236. * @param int $recTotal
  237. * @param int $recPerPage
  238. * @param int $pageID
  239. * @access public
  240. * @return void
  241. */
  242. public function epic($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  243. {
  244. /* Save session. */
  245. if($this->app->viewType != 'json') $this->session->set('storyList', $this->app->getURI(true), 'my');
  246. /* Load pager. */
  247. $this->app->loadClass('pager', true);
  248. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  249. $pager = pager::init($recTotal, $recPerPage, $pageID);
  250. /* Append id for second sort. */
  251. $sort = common::appendOrder($orderBy);
  252. if(strpos($sort, 'productTitle') !== false) $sort = str_replace('productTitle', 'product', $sort);
  253. if(strpos($sort, 'pri_') !== false) $sort = str_replace('pri_', 'priOrder_', $sort);
  254. $queryID = ($type == 'bysearch') ? (int)$param : 0;
  255. $this->loadModel('story');
  256. $this->loadModel('epic');
  257. if($type == 'assignedBy')
  258. {
  259. $stories = $this->my->getAssignedByMe($this->app->user->account, $pager, $sort, 'epic');
  260. }
  261. elseif($type == 'bysearch')
  262. {
  263. $stories = $this->my->getEpicsBySearch($queryID, $this->app->rawMethod, $sort, $pager);
  264. }
  265. else
  266. {
  267. $stories = $this->story->getUserStories($this->app->user->account, $type, $sort, $pager, 'epic', false, 'all');
  268. }
  269. if(!empty($stories)) $stories = $this->story->mergeReviewer($stories);
  270. foreach($stories as $story) $story->estimate = $story->estimate . $this->config->hourUnit;
  271. /* Build the search form. */
  272. $currentMethod = $this->app->rawMethod;
  273. $actionURL = $this->createLink('my', $currentMethod, "mode=epic&type=bysearch&param=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  274. $this->my->buildEpicSearchForm($queryID, $actionURL, $currentMethod);
  275. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  276. /* Assign. */
  277. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->story;
  278. $this->view->stories = $stories;
  279. $this->view->users = $this->user->getPairs('noletter');
  280. $this->view->type = $type;
  281. $this->view->param = $param;
  282. $this->view->mode = 'epic';
  283. $this->view->pager = $pager;
  284. $this->view->orderBy = $orderBy;
  285. $this->view->gradeGroup = $this->story->getGradeGroup();
  286. $this->view->showGrade = $this->config->edition == 'ipd';
  287. $this->display();
  288. }
  289. /**
  290. * 用户需求列表。
  291. * My requirements.
  292. *
  293. * @param string $type
  294. * @param int $param
  295. * @param string $orderBy
  296. * @param int $recTotal
  297. * @param int $recPerPage
  298. * @param int $pageID
  299. * @access public
  300. * @return void
  301. */
  302. public function requirement($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  303. {
  304. /* Save session. */
  305. if($this->app->viewType != 'json') $this->session->set('storyList', $this->app->getURI(true), 'my');
  306. /* Load pager. */
  307. $this->app->loadClass('pager', true);
  308. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  309. $pager = pager::init($recTotal, $recPerPage, $pageID);
  310. /* Append id for second sort. */
  311. $sort = common::appendOrder($orderBy);
  312. if(strpos($sort, 'productTitle') !== false) $sort = str_replace('productTitle', 'product', $sort);
  313. if(strpos($sort, 'pri_') !== false) $sort = str_replace('pri_', 'priOrder_', $sort);
  314. $queryID = ($type == 'bysearch') ? (int)$param : 0;
  315. $this->loadModel('story');
  316. $this->loadModel('requirement');
  317. if($type == 'assignedBy')
  318. {
  319. $stories = $this->my->getAssignedByMe($this->app->user->account, $pager, $sort, 'requirement');
  320. }
  321. elseif($type == 'bysearch')
  322. {
  323. $stories = $this->my->getRequirementsBySearch($queryID, $this->app->rawMethod, $sort, $pager);
  324. }
  325. else
  326. {
  327. $stories = $this->story->getUserStories($this->app->user->account, $type, $sort, $pager, 'requirement', false, 'all');
  328. }
  329. if(!empty($stories)) $stories = $this->story->mergeReviewer($stories);
  330. foreach($stories as $story) $story->estimate = $story->estimate . $this->config->hourUnit;
  331. /* Build the search form. */
  332. $currentMethod = $this->app->rawMethod;
  333. $actionURL = $this->createLink('my', $currentMethod, "mode=requirement&type=bysearch&param=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  334. $this->my->buildRequirementSearchForm($queryID, $actionURL, $currentMethod);
  335. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  336. /* Assign. */
  337. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->story;
  338. $this->view->stories = $stories;
  339. $this->view->users = $this->user->getPairs('noletter');
  340. $this->view->type = $type;
  341. $this->view->param = $param;
  342. $this->view->mode = 'requirement';
  343. $this->view->pager = $pager;
  344. $this->view->orderBy = $orderBy;
  345. $this->view->gradeGroup = $this->story->getGradeGroup();
  346. $this->view->showGrade = $this->config->edition == 'ipd';
  347. $this->display();
  348. }
  349. /**
  350. * 任务列表。
  351. * My tasks
  352. *
  353. * @param string $type
  354. * @param int $param
  355. * @param string $orderBy
  356. * @param int $recTotal
  357. * @param int $recPerPage
  358. * @param int $pageID
  359. * @access public
  360. * @return void
  361. */
  362. public function task($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  363. {
  364. /* Save session. */
  365. if($type != 'bySearch') $this->session->set('myTaskType', $type);
  366. if($this->app->viewType != 'json') $this->session->set('taskList', $this->app->getURI(true), 'my');
  367. /* Load pager. */
  368. $this->app->loadClass('pager', true);
  369. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  370. $pager = pager::init($recTotal, $recPerPage, $pageID);
  371. /* append id for second sort. */
  372. $sort = common::appendOrder($orderBy);
  373. if(strpos($orderBy, 'estimateLabel') !== false || strpos($orderBy, 'consumedLabel') !== false || strpos($orderBy, 'leftLabel') !== false) $sort = str_replace('Label', '', $sort);
  374. /* Get tasks. */
  375. $this->loadModel('task');
  376. $queryID = $type == 'bySearch' ? (int)$param : 0;
  377. if($type == 'assignedBy')
  378. {
  379. $tasks = $this->my->getAssignedByMe($this->app->user->account, $pager, $sort, 'task');
  380. }
  381. elseif($type == 'bySearch')
  382. {
  383. $tasks = $this->my->getTasksBySearch($this->app->user->account, 0, $pager, $sort, $queryID);
  384. }
  385. else
  386. {
  387. $tasks = $this->task->getUserTasks($this->app->user->account, $type, 0, $pager, $sort, $queryID);
  388. }
  389. $summary = $this->loadModel('execution')->summary($tasks);
  390. $tasks = $this->myZen->buildTaskData($tasks);
  391. $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=task&browseType=bySearch&queryID=myQueryID");
  392. $this->my->buildTaskSearchForm($queryID, $actionURL, $this->app->rawMethod . 'Task');
  393. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  394. /* Assign. */
  395. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->task;
  396. $this->view->tabID = 'task';
  397. $this->view->tasks = $this->app->viewType == 'json' ? array_values($tasks) : $tasks;
  398. $this->view->summary = $summary;
  399. $this->view->type = $type;
  400. $this->view->kanbanList = $this->execution->getPairs(0, 'kanban');
  401. $this->view->users = $this->user->getPairs('noletter');
  402. $this->view->pager = $pager;
  403. $this->view->mode = 'task';
  404. $this->view->orderBy = $orderBy;
  405. $this->view->param = $param;
  406. $this->display();
  407. }
  408. /**
  409. * bug 列表。
  410. * My bugs.
  411. *
  412. * @param string $type
  413. * @param string $orderBy
  414. * @param int $recTotal
  415. * @param int $recPerPage
  416. * @param int $pageID
  417. * @access public
  418. * @return void
  419. * @param int $param
  420. */
  421. public function bug($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  422. {
  423. /* Save session. load Lang. */
  424. $this->loadModel('bug');
  425. $queryID = $type == 'bySearch' ? (int)$param : 0;
  426. if($type != 'bySearch') $this->session->set('myBugType', $type);
  427. if($this->app->viewType != 'json') $this->session->set('bugList', $this->app->getURI(true), 'qa');
  428. /* Load pager. */
  429. $this->app->loadClass('pager', true);
  430. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  431. $pager = pager::init($recTotal, $recPerPage, $pageID);
  432. /* Append id for second sort. */
  433. $sort = common::appendOrder($orderBy);
  434. if(strpos($sort, 'pri_') !== false) $sort = str_replace('pri_', 'priOrder_', $sort);
  435. if(strpos($sort, 'severity_') !== false) $sort = str_replace('severity_', 'severityOrder_', $sort);
  436. if($type == 'assignedBy')
  437. {
  438. $bugs = $this->my->getAssignedByMe($this->app->user->account, $pager, $sort, 'bug');
  439. }
  440. else
  441. {
  442. $bugs = $this->bug->getUserBugs($this->app->user->account, $type, $sort, 0, $pager, 0, $queryID);
  443. }
  444. $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug', false);
  445. $bugs = $this->bug->batchAppendDelayedDays($bugs);
  446. $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=bug&browseType=bySearch&queryID=myQueryID");
  447. $this->my->buildBugSearchForm($queryID, $actionURL);
  448. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  449. if($type == 'resolvedBy')
  450. {
  451. $unclosedCount = 0;
  452. foreach($bugs as $bug)
  453. {
  454. if($bug->status != 'closed') $unclosedCount ++;
  455. }
  456. $this->view->summary = sprintf($this->lang->bug->notice->unClosedSummary, count($bugs), $unclosedCount);
  457. $this->view->checkedSummary = str_replace('{total}', (string)count($bugs), $this->lang->bug->notice->checkedSummary);
  458. }
  459. /* 检查是否需要确认撤销/移除。*/
  460. /* Build confirmeObject. */
  461. if($this->config->edition == 'ipd') $bugs = $this->loadModel('story')->getAffectObject($bugs, 'bug');
  462. /* assign. */
  463. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->bug;
  464. $this->view->bugs = $bugs;
  465. $this->view->users = $this->user->getPairs('noletter');
  466. $this->view->memberPairs = $this->user->getPairs('noletter|nodeleted|noclosed');
  467. $this->view->tabID = 'bug';
  468. $this->view->type = $type;
  469. $this->view->recTotal = $recTotal;
  470. $this->view->recPerPage = $recPerPage;
  471. $this->view->pageID = $pageID;
  472. $this->view->orderBy = $orderBy;
  473. $this->view->pager = $pager;
  474. $this->view->mode = 'bug';
  475. $this->view->param = $param;
  476. $this->display();
  477. }
  478. /**
  479. * 测试单列表。
  480. * My test task.
  481. *
  482. * @param string $type wait|done
  483. * @param int $param
  484. * @param string $orderBy
  485. * @param int $recTotal
  486. * @param int $recPerPage
  487. * @param int $pageID
  488. * @access public
  489. * @return void
  490. */
  491. public function testtask($type = 'wait', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  492. {
  493. /* Load pager. */
  494. $this->app->loadClass('pager', $static = true);
  495. $pager = pager::init($recTotal, $recPerPage, $pageID);
  496. /* Save session. */
  497. if($this->app->viewType != 'json')
  498. {
  499. $uri = $this->app->getURI(true);
  500. $this->session->set('testtaskList', $uri, 'qa');
  501. $this->session->set('reportList', $uri, 'qa');
  502. $this->session->set('buildList', $uri, 'execution');
  503. }
  504. /* Append id for second sort. */
  505. $this->app->loadLang('project');
  506. $sort = common::appendOrder($orderBy);
  507. $count = array('wait' => 0, 'doing' => 0, 'blocked' => 0);
  508. $tasks = $this->loadModel('testtask')->getByUser($this->app->user->account, $pager, $sort, $type == 'assignedTo' ? 'wait' : $type);
  509. foreach($tasks as $task)
  510. {
  511. if($task->status == 'wait' || $task->status == 'doing' || $task->status == 'blocked') $count[$task->status] ++;
  512. if($task->build == 'trunk' || empty($task->buildName)) $task->buildName = $this->lang->trunk;
  513. if(empty($task->executionMultiple)) $task->executionName = $task->projectName . "({$this->lang->project->disableExecution})";
  514. }
  515. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  516. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->myTestTask;
  517. $this->view->tasks = $tasks;
  518. $this->view->type = $type;
  519. $this->view->waitCount = $count['wait'];
  520. $this->view->testingCount = $count['doing'];
  521. $this->view->blockedCount = $count['blocked'];
  522. $this->view->mode = 'testtask';
  523. $this->view->pager = $pager;
  524. $this->view->param = $param;
  525. $this->view->orderBy = $orderBy;
  526. $this->display();
  527. }
  528. /**
  529. * 用例列表。
  530. * My test case.
  531. *
  532. * @param string $type assigntome|openedbyme
  533. * @param int $param
  534. * @param string $orderBy
  535. * @param int $recTotal
  536. * @param int $recPerPage
  537. * @param int $pageID
  538. * @access public
  539. * @return void
  540. */
  541. public function testcase($type = 'assigntome', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  542. {
  543. /* Save session. */
  544. $uri = $this->app->getURI(true);
  545. $this->session->set('caseList', $uri, 'qa');
  546. $this->session->set('bugList', $uri . "#app={$this->app->tab}", 'qa');
  547. /* Load pager. */
  548. $this->app->loadClass('pager', true);
  549. $pager = pager::init($recTotal, $recPerPage, $pageID);
  550. /* Append id for second sort. */
  551. $sort = common::appendOrder($orderBy);
  552. $queryID = $type == 'bysearch' ? (int)$param : 0;
  553. $this->loadModel('testcase');
  554. $cases = array();
  555. if($type == 'assigntome') $cases = $this->testcase->getByAssignedTo($this->app->user->account, 'skip|run', $sort, $pager);
  556. if($type == 'openedbyme') $cases = $this->testcase->getByOpenedBy($this->app->user->account, 'skip', $sort, $pager);
  557. if($type == 'bysearch' && $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'contribute', $orderBy, $pager);
  558. if($type == 'bysearch' && $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'work', $orderBy, $pager);
  559. $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
  560. $cases = $this->myZen->buildCaseData($cases, $type);
  561. /* Build the search form. */
  562. $currentMethod = $this->app->rawMethod;
  563. $actionURL = $this->createLink('my', $currentMethod, "mode=testcase&type=bysearch&param=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  564. $this->my->buildTestCaseSearchForm($queryID, $actionURL, $currentMethod);
  565. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  566. /* Assign. */
  567. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->myTestCase;
  568. $this->view->cases = $cases;
  569. $this->view->users = $this->user->getPairs('noletter');
  570. $this->view->tabID = 'test';
  571. $this->view->type = $type;
  572. $this->view->param = $param;
  573. $this->view->recTotal = $recTotal;
  574. $this->view->recPerPage = $recPerPage;
  575. $this->view->pageID = $pageID;
  576. $this->view->orderBy = $orderBy;
  577. $this->view->pager = $pager;
  578. $this->view->mode = 'testcase';
  579. $this->display();
  580. }
  581. /**
  582. * 文档列表。
  583. * Doc page of my.
  584. *
  585. * @param string $type
  586. * @param int $param
  587. * @param string $orderBy
  588. * @param int $recTotal
  589. * @param int $recPerPage
  590. * @param int $pageID
  591. * @access public
  592. * @return void
  593. */
  594. public function doc($type = 'openedbyme', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  595. {
  596. /* Save session, load lang. */
  597. $uri = $this->app->getURI(true);
  598. $this->session->set('productList', $uri, 'product');
  599. $this->session->set('executionList', $uri, 'execution');
  600. $this->session->set('projectList', $uri, 'project');
  601. if($this->app->viewType != 'json') $this->session->set('docList', $uri, 'doc');
  602. /* Load pager. */
  603. $this->app->loadClass('pager', true);
  604. $pager = pager::init($recTotal, $recPerPage, $pageID);
  605. /* Append id for second sort. */
  606. $sort = common::appendOrder($orderBy);
  607. $queryID = $type == 'bySearch' ? (int)$param : 0;
  608. $docs = $this->loadModel('doc')->getDocsByBrowseType($type, $queryID, 0, $sort, $pager);
  609. $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=doc&browseType=bySearch&queryID=myQueryID");
  610. $this->loadModel('doc')->buildSearchForm(0, array(), $queryID, $actionURL, 'contribute');
  611. /* Assign. */
  612. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->doc;
  613. $this->view->docs = $docs;
  614. $this->view->users = $this->user->getPairs('noletter');
  615. $this->view->type = $type;
  616. $this->view->recTotal = $recTotal;
  617. $this->view->recPerPage = $recPerPage;
  618. $this->view->pageID = $pageID;
  619. $this->view->orderBy = $orderBy;
  620. $this->view->pager = $pager;
  621. $this->view->param = $param;
  622. $this->display();
  623. }
  624. /**
  625. * 我的项目列表。
  626. * My projects.
  627. *
  628. * @param string $status doing|wait|suspended|closed|openedbyme
  629. * @param int $recTotal
  630. * @param int $recPerPage
  631. * @param int $pageID
  632. * @param string $orderBy
  633. * @access public
  634. * @return void
  635. */
  636. public function project($status = 'doing', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
  637. {
  638. $this->app->loadLang('project');
  639. $uri = $this->app->getURI(true);
  640. $this->app->session->set('programList', $uri, 'program');
  641. $this->app->session->set('projectList', $uri, 'my');
  642. /* Set the pager. */
  643. $this->app->loadClass('pager', true);
  644. $pager = new pager($recTotal, $recPerPage, $pageID);
  645. /* Get PM id list. */
  646. $accounts = array();
  647. $projects = $this->user->getProjects($this->app->user->account, $status, $orderBy, $pager);
  648. foreach($projects as $project)
  649. {
  650. if(!empty($project->PM) && !in_array($project->PM, $accounts)) $accounts[] = $project->PM;
  651. }
  652. $PMList = $this->user->getListByAccounts($accounts, 'account');
  653. foreach($projects as $project) $project->PMUserID = isset($PMList[$project->PM]) ? (int)$PMList[$project->PM]->id : 0;
  654. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->project;
  655. $this->view->users = $this->user->getPairs('noletter');
  656. $this->view->projects = $projects;
  657. $this->view->PMList = $PMList;
  658. $this->view->pager = $pager;
  659. $this->view->status = $status;
  660. $this->view->recTotal = $recTotal;
  661. $this->view->recPerPage = $recPerPage;
  662. $this->view->pageID = $pageID;
  663. $this->view->orderBy = $orderBy;
  664. $this->view->usersAvatar = $this->user->getAvatarPairs('');
  665. $this->display();
  666. }
  667. /**
  668. * 我的执行列表。
  669. * My executions.
  670. *
  671. * @param string $type undone|done
  672. * @param string $orderBy
  673. * @param int $recTotal
  674. * @param int $recPerPage
  675. * @param int $pageID
  676. * @access public
  677. * @return void
  678. */
  679. public function execution($type = 'undone', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
  680. {
  681. $this->app->loadLang('execution');
  682. /* Set the pager. */
  683. $this->app->loadClass('pager', $static = true);
  684. $pager = new pager($recTotal, $recPerPage, $pageID);
  685. $executions = $this->user->getExecutions($this->app->user->account, $type, $orderBy, $pager);
  686. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->execution;
  687. $this->view->tabID = 'project';
  688. $this->view->executions = $executions;
  689. $this->view->parentGroup = $this->loadModel('execution')->getChildIdGroup(array_keys($executions));
  690. $this->view->type = $type;
  691. $this->view->pager = $pager;
  692. $this->view->orderBy = $orderBy;
  693. $this->view->mode = 'execution';
  694. $this->display();
  695. }
  696. /**
  697. * 问题列表。
  698. * My issues.
  699. *
  700. * @param string $type
  701. * @param int $param
  702. * @param string $orderBy
  703. * @param int $recTotal
  704. * @param int $recPerPage
  705. * @param int $pageID
  706. * @access public
  707. * @return void
  708. */
  709. public function issue($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  710. {
  711. /* Set session. */
  712. $this->app->session->set('issueList', $this->app->getURI(true), 'project');
  713. /* Set the pager. */
  714. $this->app->loadClass('pager', true);
  715. $pager = new pager($recTotal, $recPerPage, $pageID);
  716. /* Build the search form. */
  717. $queryID = $type == 'bysearch' ? (int)$param : 0;
  718. $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=issue&type=bysearch&param=myQueryID");
  719. $this->loadModel('issue')->buildSearchForm($actionURL, $queryID);
  720. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  721. $this->view->title = $this->lang->my->issue;
  722. $this->view->mode = 'issue';
  723. $this->view->users = $this->user->getPairs('noclosed|noletter');
  724. $this->view->orderBy = $orderBy;
  725. $this->view->pager = $pager;
  726. $this->view->type = $type;
  727. $this->view->param = $param;
  728. $this->view->issues = $type == 'assignedBy' ? $this->my->getAssignedByMe($this->app->user->account, $pager, $orderBy, 'issue') : $this->loadModel('issue')->getUserIssues($type, $queryID, $this->app->user->account, $orderBy, $pager);
  729. $this->view->projectList = $this->loadModel('project')->getPairsByProgram();
  730. $this->display();
  731. }
  732. /**
  733. * 风险列表。
  734. * My risks.
  735. *
  736. * @param string $type
  737. * @param int $param
  738. * @param string $orderBy
  739. * @param int $recTotal
  740. * @param int $recPerPage
  741. * @param int $pageID
  742. * @access public
  743. * @return void
  744. */
  745. public function risk($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  746. {
  747. $this->loadModel('risk');
  748. /* Set session. */
  749. $this->app->session->set('riskList', $this->app->getURI(true), 'project');
  750. /* Set the pager. */
  751. $this->app->loadClass('pager', true);
  752. $pager = new pager($recTotal, $recPerPage, $pageID);
  753. /* Build the search form. */
  754. $currentMethod = $this->app->rawMethod;
  755. $queryID = $type == 'bysearch' ? (int)$param : 0;
  756. $actionURL = $this->createLink('my', $currentMethod, "mode=risk&type=bysearch&param=myQueryID");
  757. $this->my->buildRiskSearchForm($queryID, $actionURL, $currentMethod);
  758. /* Get risks by type*/
  759. if($type == 'assignedBy')
  760. {
  761. $risks = $this->my->getAssignedByMe($this->app->user->account, $pager, $orderBy, 'risk');
  762. }
  763. elseif($type == 'bysearch')
  764. {
  765. $risks = $this->my->getRisksBySearch($queryID, $currentMethod, $orderBy, $pager);
  766. }
  767. else
  768. {
  769. $risks = $this->risk->getUserRisks($type, $this->app->user->account, $orderBy, $pager);
  770. }
  771. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  772. $this->view->title = $this->lang->my->risk;
  773. $this->view->risks = $risks;
  774. $this->view->users = $this->user->getPairs('noclosed|noletter');
  775. $this->view->orderBy = $orderBy;
  776. $this->view->pager = $pager;
  777. $this->view->type = $type;
  778. $this->view->param = $param;
  779. $this->view->mode = 'risk';
  780. $this->view->projectList = array(0 => '') + $this->loadModel('project')->getPairsByProgram();
  781. $this->display();
  782. }
  783. /**
  784. * 评审意见列表。
  785. * My reviewissues.
  786. *
  787. * @param string $type
  788. * @param int $param
  789. * @param string $orderBy
  790. * @param int $recTotal
  791. * @param int $recPerPage
  792. * @param int $pageID
  793. * @access public
  794. * @return void
  795. */
  796. public function reviewissue($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  797. {
  798. $this->loadModel('reviewissue');
  799. /* Set the pager. */
  800. $this->app->loadClass('pager', true);
  801. $pager = new pager($recTotal, $recPerPage, $pageID);
  802. /* Build the search form. */
  803. $currentMethod = $this->app->rawMethod;
  804. $queryID = $type == 'bysearch' ? (int)$param : 0;
  805. $actionURL = $this->createLink('my', $currentMethod, "mode=reviewissue&type=bysearch&param=myQueryID");
  806. $this->my->buildReviewissueSearchForm($queryID, $actionURL);
  807. /* Get reviewissues by type*/
  808. if($type == 'assignedBy')
  809. {
  810. $reviewissues = $this->my->getAssignedByMe($this->app->user->account, $pager, $orderBy, 'reviewissue');
  811. }
  812. elseif($type == 'bysearch')
  813. {
  814. $reviewissues = $this->my->getReviewissuesBySearch($queryID, $currentMethod, $orderBy, $pager);
  815. }
  816. else
  817. {
  818. $reviewissues = $this->reviewissue->getUserReviewissues($type, $this->app->user->account, $orderBy, $pager);
  819. }
  820. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  821. $this->view->title = $this->lang->my->reviewissue;
  822. $this->view->reviewissues = $reviewissues;
  823. $this->view->users = $this->user->getPairs('noclosed|noletter');
  824. $this->view->orderBy = $orderBy;
  825. $this->view->pager = $pager;
  826. $this->view->type = $type;
  827. $this->view->param = $param;
  828. $this->view->mode = 'reviewissue';
  829. $this->view->projectList = array(0 => '') + $this->loadModel('project')->getPairsByProgram();
  830. $this->display();
  831. }
  832. /**
  833. * 评审列表。
  834. * My audits.
  835. *
  836. * @param string $browseType
  837. * @param int $param
  838. * @param string $orderBy
  839. * @param int $recTotal
  840. * @param int $recPerPage
  841. * @param int $pageID
  842. * @access public
  843. * @return void
  844. */
  845. public function audit($browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  846. {
  847. $this->loadModel('epic');
  848. $this->loadModel('requirement');
  849. $this->session->set('storyList', $this->app->getURI(true), 'my');
  850. $this->app->loadClass('pager', true);
  851. $pager = pager::init($recTotal, $recPerPage, $pageID);
  852. $typeList = array();
  853. if($this->app->rawMethod == 'contribute')
  854. {
  855. $reviewList = $this->my->getReviewedList($browseType, $orderBy, $pager);
  856. }
  857. else
  858. {
  859. $typeList = $this->my->getReviewingTypeList();
  860. if(!isset($typeList->$browseType)) $browseType = 'all';
  861. $this->lang->my->featureBar['audit'] = (array)$typeList;
  862. $reviewList = $this->my->getReviewingList($browseType, $orderBy, $pager);
  863. }
  864. $flows = array();
  865. if(in_array($this->config->edition, array('max', 'ipd')))
  866. {
  867. $this->app->loadLang('approval');
  868. $flows = $this->my->getFlowPairs();
  869. }
  870. $this->view->title = $this->lang->review->common;
  871. $this->view->users = $this->user->getPairs('noclosed|noletter');
  872. $this->view->reviewList = $reviewList;
  873. $this->view->recTotal = $recTotal;
  874. $this->view->recPerPage = $recPerPage;
  875. $this->view->pageID = $pageID;
  876. $this->view->browseType = $browseType;
  877. $this->view->orderBy = $orderBy;
  878. $this->view->pager = $pager;
  879. $this->view->param = $param;
  880. $this->view->mode = 'audit';
  881. $this->view->flows = $flows;
  882. $this->view->products = $this->loadModel('product')->getPairs('', 0, '', 'all');;
  883. $this->view->projects = $this->loadModel('project')->getPairs();
  884. $this->display();
  885. }
  886. /**
  887. * 质量保证计划列表。
  888. * My auditplans.
  889. *
  890. * @param string $browseType
  891. * @param int $param
  892. * @param string $orderBy
  893. * @param int $recTotal
  894. * @param int $recPerPage
  895. * @param int $pageID
  896. * @access public
  897. * @return void
  898. */
  899. public function auditplan($browseType = 'myChecking', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  900. {
  901. if(!$browseType) $browseType = 'myChecking';
  902. /* Set session. */
  903. $this->session->set('auditplanList', $this->app->getURI(true));
  904. /* Set the pager. */
  905. $this->app->loadClass('pager', true);
  906. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  907. $pager = pager::init($recTotal, $recPerPage, $pageID);
  908. $auditplans = $this->loadModel('auditplan')->getList(0, $browseType, $param, $orderBy, $pager);
  909. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  910. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->auditplan;
  911. $this->view->browseType = $browseType;
  912. $this->view->param = $param;
  913. $this->view->orderBy = $orderBy;
  914. $this->view->pager = $pager;
  915. $this->view->mode = 'auditplan';
  916. $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed');
  917. $this->view->executions = $this->loadModel('execution')->getPairs();
  918. $this->view->processList = $this->loadModel('pssp')->getProcessPairs();
  919. $this->view->activityList = $this->pssp->getActivityPairs();
  920. $this->view->outputList = $this->pssp->getOutputPairs();
  921. $this->view->auditplans = $auditplans;
  922. $this->view->projects = $this->loadModel('project')->getPairs();
  923. $this->display();
  924. }
  925. /**
  926. * 不符合项列表。
  927. * My ncs.
  928. *
  929. * @param string $browseType
  930. * @param int $param
  931. * @param string $orderBy
  932. * @param int $recTotal
  933. * @param int $recPerPage
  934. * @param int $pageID
  935. * @access public
  936. * @return void
  937. */
  938. public function nc($browseType = 'assignedToMe', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  939. {
  940. if(!$browseType) $browseType = 'assignedToMe';
  941. /* Set session. */
  942. $this->session->set('ncList', $this->app->getURI(true));
  943. $this->loadModel('nc');
  944. /* Set the pager. */
  945. $this->app->loadClass('pager', true);
  946. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  947. $pager = pager::init($recTotal, $recPerPage, $pageID);
  948. $status = $this->app->rawMethod == 'contribute' ? '' : 'active';
  949. $ncList = $browseType == 'assignedBy' ? $this->my->getAssignedByMe($this->app->user->account, $pager, $orderBy, 'nc') : $this->my->getNcList($browseType, $orderBy, $pager, $status);
  950. foreach($ncList as $nc) $ncIdList[] = $nc->id;
  951. $this->session->set('ncIdList', isset($ncIdList) ? $ncIdList : '');
  952. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  953. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->nc;
  954. $this->view->browseType = $browseType;
  955. $this->view->ncs = $ncList;
  956. $this->view->users = $this->user->getPairs('noclosed|noletter');
  957. $this->view->projects = $this->loadModel('project')->getPairsByProgram();
  958. $this->view->pager = $pager;
  959. $this->view->orderBy = $orderBy;
  960. $this->view->param = $param;
  961. $this->view->mode = 'nc';
  962. $this->display();
  963. }
  964. /**
  965. * 会议列表。
  966. * My meeting list.
  967. *
  968. * @param string $browseType
  969. * @param int $param
  970. * @param string $orderBy
  971. * @param int $recTotal
  972. * @param int $recPerPage
  973. * @param int $pageID
  974. * @access public
  975. * @return void
  976. */
  977. public function myMeeting($browseType = 'futureMeeting', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  978. {
  979. $this->session->set('meetingList', $this->app->getURI(true), 'my');
  980. /* Load pager. */
  981. $this->app->loadClass('pager', $static = true);
  982. if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
  983. $pager = pager::init($recTotal, $recPerPage, $pageID);
  984. /* Build the search form. */
  985. $queryID = $browseType == 'bysearch' ? (int)$param : 0;
  986. $actionURL = $this->createLink('my', 'work', "mode=mymeeting&browseType=bysearch&param=myQueryID");
  987. $this->loadModel('meeting')->buildSearchForm($queryID, $actionURL);
  988. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  989. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->myMeeting;
  990. $this->view->browseType = $browseType;
  991. $this->view->meetings = $this->meeting->getListByUser($browseType, $orderBy, $queryID, $pager);
  992. $this->view->orderBy = $orderBy;
  993. $this->view->pager = $pager;
  994. $this->view->depts = $this->dept->getOptionMenu();
  995. $this->view->users = $this->user->getPairs('all,noletter');
  996. $this->view->queryID = $queryID;
  997. $this->view->param = $param;
  998. $this->view->mode = 'myMeeting';
  999. $this->view->projects = array(0 => '') + $this->loadModel('project')->getPairsByProgram(0, 'all', true);
  1000. $this->view->executions = array(0 => '') + $this->loadModel('execution')->getPairs(0, 'all', 'nocode');
  1001. $this->view->rooms = $this->loadModel('meetingroom')->getPairs();
  1002. $this->display();
  1003. }
  1004. /**
  1005. * 反馈列表。
  1006. * Feedback list.
  1007. *
  1008. * @param string $browseType
  1009. * @param int $param
  1010. * @param string $orderBy
  1011. * @param int $recTotal
  1012. * @param int $recPerPage
  1013. * @param int $pageID
  1014. * @access public
  1015. * @return void
  1016. */
  1017. public function feedback($browseType = 'assigntome', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  1018. {
  1019. $this->session->set('feedbackList', $this->app->getURI(true), 'feedback');
  1020. $queryID = $browseType == 'bysearch' ? (int)$param : 0;
  1021. $this->app->loadClass('pager', true);
  1022. $pager = pager::init($recTotal, $recPerPage, $pageID);
  1023. $this->loadModel('feedback');
  1024. if($browseType == 'assignedby')
  1025. {
  1026. $feedbacks = $this->my->getAssignedByMe($this->app->user->account, $pager, $orderBy, 'feedback');
  1027. }
  1028. elseif($browseType == 'bysearch')
  1029. {
  1030. $feedbacks = $this->my->getFeedbacksBySearch($queryID, $orderBy, $pager);
  1031. }
  1032. else
  1033. {
  1034. $feedbacks = $this->feedback->getList($browseType, $orderBy, $pager);
  1035. }
  1036. $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'feedback', false);
  1037. $this->loadModel('datatable');
  1038. $this->lang->datatable->moduleSetting = str_replace($this->lang->module, $this->lang->feedback->moduleAB, $this->lang->datatable->moduleSetting);
  1039. $this->lang->datatable->showModule = str_replace($this->lang->module, $this->lang->feedback->moduleAB, $this->lang->datatable->showModule);
  1040. $this->lang->datatable->showModuleList = str_replace($this->lang->module, $this->lang->feedback->moduleAB, $this->lang->datatable->showModuleList);
  1041. $this->myZen->assignRelatedData($feedbacks);
  1042. $this->myZen->buildSearchFormForFeedback($queryID, $orderBy);
  1043. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  1044. $this->view->title = $this->lang->my->feedback;
  1045. $this->view->mode = 'feedback';
  1046. $this->view->type = $browseType;
  1047. $this->view->feedbacks = $feedbacks;
  1048. $this->view->orderBy = $orderBy;
  1049. $this->view->pager = $pager;
  1050. $this->view->param = $param;
  1051. $this->view->depts = $this->dept->getOptionMenu();
  1052. $this->view->users = $this->user->getPairs('noletter|nodeleted|noclosed');
  1053. $this->view->projects = $this->loadModel('project')->getPairsByProgram(0, 'noclosed');
  1054. $this->view->allProducts = $this->dao->select('id, name')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->fetchPairs();
  1055. $this->view->modulePairs = $this->loadModel('tree')->getModulePairs(0, 'feedback');
  1056. $this->view->modules = $this->tree->getOptionMenu(0, 'feedback', 0);
  1057. $this->view->demands = ($feedbacks and $this->config->vision == 'or') ? $this->loadModel('demand')->getByList(array_keys($feedbacks)) : array();
  1058. $this->display();
  1059. }
  1060. /**
  1061. * 工单列表。
  1062. * My ticket.
  1063. *
  1064. * @param string $browseType
  1065. * @param int $param
  1066. * @param string $orderBy
  1067. * @param int $recTotal
  1068. * @param int $recPerPage
  1069. * @param int $pageID
  1070. * @access public
  1071. * @return void
  1072. */
  1073. public function ticket($browseType = 'assignedtome', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
  1074. {
  1075. $this->session->set('ticketList', $this->app->getURI(true), 'ticket');
  1076. $this->session->set('ticketBrowseType', $browseType);
  1077. $this->app->loadClass('pager', $static = true);
  1078. $pager = pager::init($recTotal, $recPerPage, $pageID);
  1079. $queryID = $browseType == 'bysearch' ? (int)$param : 0;
  1080. if($browseType != 'bysearch')
  1081. {
  1082. $tickets = $this->loadModel('ticket')->getList($browseType, $orderBy, $pager);
  1083. }
  1084. else
  1085. {
  1086. $tickets = $this->loadModel('ticket')->getBySearch($queryID, $orderBy, $pager);
  1087. }
  1088. foreach($tickets as $ticket) $ticket->feedbackTip = $ticket->feedback != 0 ? '#' . $ticket->feedback : '';
  1089. $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=ticket&type=bysearch&param=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
  1090. $this->my->buildTicketSearchForm($queryID, $actionURL);
  1091. $this->myZen->showWorkCount($recTotal, $recPerPage, $pageID);
  1092. $this->view->title = $this->lang->ticket->browse;
  1093. $this->view->products = $this->loadModel('feedback')->getGrantProducts();
  1094. $this->view->users = $this->user->getPairs('noclosed|nodeleted|noletter');
  1095. $this->view->tickets = $tickets;
  1096. $this->view->orderBy = $orderBy;
  1097. $this->view->pager = $pager;
  1098. $this->view->param = $param;
  1099. $this->view->browseType = $browseType;
  1100. $this->view->mode = 'ticket';
  1101. $this->display();
  1102. }
  1103. /**
  1104. * 团队列表。
  1105. * My team.
  1106. *
  1107. * @param string $orderBy
  1108. * @param int $recTotal
  1109. * @param int $recPerPage
  1110. * @param int $pageID
  1111. * @access public
  1112. * @return void
  1113. */
  1114. public function team($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
  1115. {
  1116. $this->lang->navGroup->my = 'system';
  1117. /* Set the pager. */
  1118. $this->app->loadClass('pager', true);
  1119. $pager = new pager($recTotal, $recPerPage, $pageID);
  1120. /* Append id for second sort. */
  1121. $sort = common::appendOrder($orderBy);
  1122. /* Get users by dept. */
  1123. $deptID = $this->app->user->admin ? 0 : $this->app->user->dept;
  1124. $users = $this->loadModel('company')->getUsers('inside', 'bydept', 0, $deptID, $sort, $pager);
  1125. foreach($users as $user) unset($user->password); // Remove passwd.
  1126. $this->view->title = $this->lang->my->team;
  1127. $this->view->users = $users;
  1128. $this->view->userPairs = $this->loadModel('user')->getPairs('noletter|noclosed');
  1129. $this->view->deptID = $deptID;
  1130. $this->view->orderBy = $orderBy;
  1131. $this->view->pager = $pager;
  1132. $this->display();
  1133. }
  1134. /**
  1135. * 编辑个人信息。
  1136. * Edit profile
  1137. *
  1138. * @access public
  1139. * @return void
  1140. */
  1141. public function editProfile()
  1142. {
  1143. if($this->app->user->account == 'guest') return print(js::alert('guest') . js::locate('back'));
  1144. if(!empty($_POST))
  1145. {
  1146. /* 设置语言项以便 form 类检查必填项时输出正确的字段名。*/
  1147. /* Set language item for form class to check required fields. */
  1148. $this->lang->my->realname = $this->lang->user->realname;
  1149. $this->lang->my->verifyPassword = $this->lang->user->verifyPassword;
  1150. $user = form::data($this->config->my->form->editProfile)
  1151. ->setIF($this->post->password1 != false, 'password', substr($this->post->password1, 0, 32))
  1152. ->add('group', $this->app->user->groups)
  1153. ->add('id', $this->app->user->id)
  1154. ->get();
  1155. $this->user->update($user);
  1156. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  1157. if(isInModal()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true));
  1158. return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->createLink('my', 'profile')));
  1159. }
  1160. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->editProfile;
  1161. $this->view->user = $this->user->getById($this->app->user->account);
  1162. $this->view->rand = updateSessionRandom();
  1163. $this->display();
  1164. }
  1165. /**
  1166. * 修改密码。
  1167. * Change password.
  1168. *
  1169. * @access public
  1170. * @return void
  1171. */
  1172. public function changePassword()
  1173. {
  1174. if($this->app->user->account == 'guest') return print(js::alert('guest') . js::locate('back'));
  1175. $this->app->loadLang('admin');
  1176. $isonlybody = isInModal();
  1177. if(!$isonlybody) unset($this->lang->my->menu);
  1178. if(!empty($_POST))
  1179. {
  1180. /* 确保必填项提示信息能显示正确的字段名。*/
  1181. $this->lang->my->originalPassword = $this->lang->user->originalPassword;
  1182. $this->lang->my->password1 = $this->lang->user->password1;
  1183. $this->lang->my->password2 = $this->lang->user->password2;
  1184. $user = form::data($this->config->my->form->changePassword)
  1185. ->setIF($this->post->password1 != false, 'password', substr($this->post->password1, 0, 32))
  1186. ->get();
  1187. $this->user->updatePassword($user);
  1188. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  1189. if($isonlybody) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true));
  1190. return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->createLink('index', 'index')));
  1191. }
  1192. $this->view->isonlybody = $isonlybody;
  1193. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->changePassword;
  1194. $this->view->user = $this->user->getById($this->app->user->account);
  1195. $this->view->rand = updateSessionRandom();
  1196. $this->display();
  1197. }
  1198. /**
  1199. * 管理联系人。
  1200. * Manage contacts.
  1201. *
  1202. * @param int $listID
  1203. * @access public
  1204. * @return void
  1205. */
  1206. public function manageContacts($listID = 0)
  1207. {
  1208. if($_POST)
  1209. {
  1210. $this->lang->my->listName = $this->lang->user->contacts->listName;
  1211. $this->lang->my->userList = $this->lang->user->contacts->selectedUsers;
  1212. if($listID)
  1213. {
  1214. $userContact = form::data($this->config->my->form->manageContacts)->add('account', $this->app->user->account)->add('id', $listID)->get();
  1215. $this->user->updateContactList($userContact);
  1216. }
  1217. else
  1218. {
  1219. $userContact = form::data($this->config->my->form->manageContacts)->add('account', $this->app->user->account)->get();
  1220. $this->user->createContactList($userContact);
  1221. }
  1222. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  1223. if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true));
  1224. if(isInModal()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "renderContactList"));
  1225. if($this->app->tab == 'project') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true));
  1226. return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => inlink('manageContacts', "listID={$listID}")));
  1227. }
  1228. $list = $listID ? $this->user->getContactListByID($listID) : null;
  1229. $userList = !empty($list->userList) ? $list->userList : '';
  1230. if($list)
  1231. {
  1232. $mode = $list->account == $this->app->user->account ? 'edit' : ($this->app->user->admin ? 'adminView' : 'view');
  1233. $label = $mode == 'edit' ? $this->lang->my->manageContacts : $this->lang->my->viewContacts;
  1234. $tip = $mode == 'edit' ? $this->lang->my->manageSelf : $this->lang->my->adminView;
  1235. }
  1236. else
  1237. {
  1238. $mode = 'create';
  1239. $label = $this->lang->my->createContacts;
  1240. $tip = '';
  1241. }
  1242. $userParams = empty($this->config->user->showDeleted) ? 'noletter|noempty|noclosed|noclosed|nodeleted' : 'noletter|noempty|noclosed|noclosed';
  1243. $users = $this->user->getPairs($userParams, $mode == 'new' ? '' : $userList);
  1244. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $label;
  1245. $this->view->lists = $this->user->getContactLists($this->app->user->account, 'list');
  1246. $this->view->users = $users;
  1247. $this->view->mode = $mode;
  1248. $this->view->label = $label;
  1249. $this->view->tip = $tip;
  1250. $this->view->list = $list;
  1251. $this->display();
  1252. }
  1253. /**
  1254. * 删除一个联系人列表。
  1255. * Delete a contact list.
  1256. *
  1257. * @param int $listID
  1258. * @access public
  1259. * @return void
  1260. */
  1261. public function deleteContacts($listID)
  1262. {
  1263. $this->user->deleteContactList($listID);
  1264. return $this->send(array('result' => 'success', 'load' => true));
  1265. }
  1266. /**
  1267. * 构建联系人列表。
  1268. * Build contact lists.
  1269. *
  1270. * @param string $dropdownName
  1271. * @param string $attr
  1272. * @access public
  1273. * @return void
  1274. * @param string $showManage
  1275. */
  1276. public function buildContactLists($dropdownName = 'mailto', $attr = '', $showManage = 'yes')
  1277. {
  1278. $this->view->contactLists = $this->user->getContactLists();
  1279. $this->view->dropdownName = $dropdownName;
  1280. $this->view->attr = $attr;
  1281. $this->view->showManage = $showManage;
  1282. $this->display();
  1283. }
  1284. /**
  1285. * 查看我的个人档案。
  1286. * View my profile.
  1287. *
  1288. * @access public
  1289. * @return void
  1290. */
  1291. public function profile()
  1292. {
  1293. if($this->app->user->account == 'guest') return print(js::alert('guest') . js::locate('back'));
  1294. $user = $this->user->getById($this->app->user->account);
  1295. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->profile;
  1296. $this->view->user = $user;
  1297. $this->view->groups = $this->loadModel('group')->getByAccount($this->app->user->account);
  1298. $this->view->deptPath = $this->dept->getParents($user->dept);
  1299. $this->display();
  1300. }
  1301. /**
  1302. * 查看个性化设置。
  1303. * User preference setting.
  1304. *
  1305. * @access public
  1306. * @return void
  1307. * @param string $showTip
  1308. */
  1309. public function preference($showTip = 'true')
  1310. {
  1311. $this->loadModel('setting');
  1312. if($_POST)
  1313. {
  1314. $keyList = array('URSR', 'programLink', 'productLink', 'projectLink', 'executionLink', 'docLink');
  1315. foreach($_POST as $key => $value)
  1316. {
  1317. if(!in_array($key, $keyList)) continue;
  1318. if($key != 'URSR' && !isset($this->lang->my->{$key . 'List'}[$value])) continue;
  1319. if($key == 'URSR') $value = (int)$value;
  1320. $this->setting->setItem("{$this->app->user->account}.common.$key", $value);
  1321. }
  1322. $this->setting->setItem("{$this->app->user->account}.common.preferenceSetted", 1);
  1323. return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => '$.apps.updateAppsMenu'));
  1324. }
  1325. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->preference;
  1326. $this->view->showTip = $showTip;
  1327. $this->view->URSRList = $this->loadModel('custom')->getURSRPairs();
  1328. $this->view->URSR = $this->setting->getURSR();
  1329. $this->view->programLink = isset($this->config->programLink) ? $this->config->programLink : 'program-browse';
  1330. $this->view->productLink = isset($this->config->productLink) ? $this->config->productLink : 'product-all';
  1331. $this->view->projectLink = isset($this->config->projectLink) ? $this->config->projectLink : 'project-browse';
  1332. $this->view->executionLink = isset($this->config->executionLink) ? $this->config->executionLink : 'execution-task';
  1333. $this->view->docLink = isset($this->config->docLink) ? $this->config->docLink : 'doc-lastViewedSpace';
  1334. $this->view->preferenceSetted = isset($this->config->preferenceSetted) ? true : false;
  1335. $this->display();
  1336. }
  1337. /**
  1338. * 我的动态列表。
  1339. * My dynamic.
  1340. *
  1341. * @param string $type
  1342. * @param int $recTotal
  1343. * @param string $date
  1344. * @param string $direction
  1345. * @access public
  1346. * @return void
  1347. */
  1348. public function dynamic($type = 'today', $recTotal = 0, $date = '', $direction = 'next')
  1349. {
  1350. /* Append id for second sort. */
  1351. $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc';
  1352. $date = empty($date) ? '' : date('Y-m-d', (int)$date);
  1353. $actions = $this->loadModel('action')->getDynamicByAccount($this->app->user->account, $type, $orderBy, 50, $date, $direction);
  1354. $dateGroups = $this->action->buildDateGroup($actions, $direction);
  1355. if(empty($recTotal) && $dateGroups) $recTotal = $this->action->getDynamicCount($type);
  1356. /* Assign. */
  1357. $this->view->title = $this->lang->my->common . $this->lang->hyphen . $this->lang->my->dynamic;
  1358. $this->view->type = $type;
  1359. $this->view->orderBy = $orderBy;
  1360. $this->view->dateGroups = $dateGroups;
  1361. $this->view->direction = $direction;
  1362. $this->view->recTotal = $recTotal;
  1363. $this->view->users = $this->user->getPairs('noletter|nodeleted');
  1364. $this->display();
  1365. }
  1366. /**
  1367. * 上传头像。
  1368. * Upload avatar.
  1369. *
  1370. * @access public
  1371. * @return void
  1372. */
  1373. public function uploadAvatar()
  1374. {
  1375. if($_SERVER['REQUEST_METHOD'] == 'POST')
  1376. {
  1377. $result = $this->user->uploadAvatar();
  1378. if($result['result'] == 'fail') $this->send($result);
  1379. return $this->send(array('result' => 'success', 'callback' => "loadModal('" . $this->createLink('user', 'cropavatar', "imageID={$result['fileID']}") . "', 'profile');"));
  1380. }
  1381. }
  1382. /**
  1383. * 取消与然之的绑定。
  1384. * Unbind ranzhi.
  1385. *
  1386. * @param string $confirm
  1387. * @access public
  1388. * @return void
  1389. */
  1390. public function unbind($confirm = 'no')
  1391. {
  1392. if($confirm == 'no')
  1393. {
  1394. return print(js::confirm($this->lang->user->confirmUnbind, $this->createLink('my', 'unbind', "confirm=yes")));
  1395. }
  1396. else
  1397. {
  1398. $this->user->unbind($this->app->user->account);
  1399. return print(js::locate($this->createLink('my', 'profile'), 'parent'));
  1400. }
  1401. }
  1402. /**
  1403. * Ajax: 切换界面.
  1404. * Switch vision by ajax.
  1405. *
  1406. * @param string $vision
  1407. * @access public
  1408. * @return void
  1409. */
  1410. public function ajaxSwitchVision($vision)
  1411. {
  1412. $_SESSION['vision'] = $vision;
  1413. $this->loadModel('setting')->setItem("{$this->app->user->account}.common.global.vision", $vision);
  1414. if(empty($this->config->hideVisionTips)) $this->setting->setItem("{$this->app->user->account}.common.global.hideVisionTips", 1);
  1415. $this->config->vision = $vision;
  1416. $_SESSION['user']->rights = $this->user->authorize($this->app->user->account);
  1417. setcookie('vision', $vision, $this->config->cookieLife, $this->config->webRoot, '', false, false);
  1418. return $this->send(array('result' => 'success', 'load' => helper::createLink('index', 'index')));
  1419. }
  1420. /**
  1421. * Ajax: 保存界面切换引导.
  1422. * Save hideVisionTips by ajax.
  1423. *
  1424. * @param string $vision
  1425. * @access public
  1426. * @return void
  1427. */
  1428. public function ajaxSaveVisionTips()
  1429. {
  1430. $this->loadModel('setting')->setItem("{$this->app->user->account}.common.global.hideVisionTips", 1);
  1431. return $this->send(array('result' => 'success', 'load' => helper::createLink('index', 'index')));
  1432. }
  1433. }