control.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * The control file of report 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 report
  9. * @version $Id: control.php 4622 2013-03-28 01:09:02Z chencongzhi520@gmail.com $
  10. * @link https://www.zentao.net
  11. */
  12. class report extends control
  13. {
  14. /**
  15. * 项目ID。
  16. * The projectID.
  17. *
  18. * @var float
  19. * @access public
  20. */
  21. public $projectID = 0;
  22. /**
  23. * 构造函数。
  24. * Construct.
  25. *
  26. * @access public
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * 报告主页,跳转到年度数据。
  35. * The index of report, goto aunnual data.
  36. *
  37. * @access public
  38. * @return void
  39. */
  40. public function index()
  41. {
  42. $this->locate(inlink('annualData'));
  43. }
  44. /**
  45. * 发送每日提醒邮件。
  46. * Send daily reminder mail.
  47. *
  48. * @access public
  49. * @return void
  50. */
  51. public function remind()
  52. {
  53. /* Get reminder, and send email. */
  54. $reminder = $this->reportZen->getReminder();
  55. /* Check mail turnon, if the system doesn't turn on the e-mail function, return the tip. */
  56. $this->loadModel('mail');
  57. if(!$this->config->mail->turnon)
  58. {
  59. echo "You should turn on the Email feature first.\n";
  60. return false;
  61. }
  62. foreach($reminder as $user => $mail)
  63. {
  64. /* Reset $this->output. */
  65. $this->clear();
  66. $mailTitle = $this->lang->report->mailTitle->begin;
  67. $mailTitle .= isset($mail->bugs) ? sprintf($this->lang->report->mailTitle->bug, count($mail->bugs)) : '';
  68. $mailTitle .= isset($mail->tasks) ? sprintf($this->lang->report->mailTitle->task, count($mail->tasks)) : '';
  69. $mailTitle .= isset($mail->todos) ? sprintf($this->lang->report->mailTitle->todo, count($mail->todos)) : '';
  70. $mailTitle .= isset($mail->testTasks) ? sprintf($this->lang->report->mailTitle->testTask, count($mail->testTasks)) : '';
  71. $mailTitle .= isset($mail->cards) ? sprintf($this->lang->report->mailTitle->card, count($mail->cards)) : '';
  72. $mailTitle = rtrim($mailTitle, ',');
  73. /* Get email content and title.*/
  74. $this->view->mail = $mail;
  75. $this->view->mailTitle = $mailTitle;
  76. $oldViewType = $this->viewType;
  77. if($oldViewType == 'json') $this->viewType = 'html';
  78. $mailContent = $this->parse('report', 'dailyreminder');
  79. $this->viewType = $oldViewType;
  80. /* Send email.*/
  81. echo date('Y-m-d H:i:s') . " sending to {$user}, ";
  82. $this->mail->send($user, $mailTitle, $mailContent, '', true);
  83. if($this->mail->isError())
  84. {
  85. echo "fail: \n" ;
  86. a($this->mail->getError());
  87. }
  88. echo "ok\n";
  89. }
  90. }
  91. /**
  92. * 展示年度数据。
  93. * Show annual data.
  94. *
  95. * @param string $year
  96. * @param string $dept
  97. * @param string $account
  98. * @access public
  99. * @return void
  100. */
  101. public function annualData($year = '', $dept = '', $account = '')
  102. {
  103. $this->app->loadLang('story');
  104. $this->app->loadLang('task');
  105. $this->app->loadLang('bug');
  106. $this->app->loadLang('testcase');
  107. /* Assign annual data. */
  108. $this->reportZen->assignAnnualReport($year, $dept, $account);
  109. $mode = 'company';
  110. if((int)$dept && empty($account)) $mode = 'dept';
  111. if($account) $mode = 'user';
  112. $this->view->contributionCountTips = $this->report->getContributionCountTips($mode);
  113. $this->view->mode = $mode;
  114. $this->view->account = $account;
  115. $this->display();
  116. }
  117. }