+ add dailyreminder to zentao.
This commit is contained in:
3
Makefile
3
Makefile
@@ -52,9 +52,6 @@ tgz:
|
||||
mv zentaotest.zip zentaopms/tmp/extension
|
||||
mv zentaostory.zip zentaopms/tmp/extension
|
||||
mv zentaotask.zip zentaopms/tmp/extension
|
||||
# copy dailyreminder to zentaopms.
|
||||
svn export https://svn.cnezsoft.com/easysoft/trunk/zentaoext/dailyreminder
|
||||
cp -rf dailyreminder/module zentaopms
|
||||
# notify.zip.
|
||||
mkdir zentaopms/www/data/notify/
|
||||
wget http://192.168.1.99/release/notify.zip -O zentaopms/www/data/notify/notify.zip
|
||||
|
||||
@@ -541,7 +541,13 @@ function isLocalIP()
|
||||
*/
|
||||
function getWebRoot()
|
||||
{
|
||||
return substr($_SERVER['SCRIPT_NAME'], 0, (strrpos($_SERVER['SCRIPT_NAME'], '/') + 1));
|
||||
$path = $_SERVER['SCRIPT_NAME'];
|
||||
if(defined('IN_SHELL'))
|
||||
{
|
||||
$url = parse_url($_SERVER['argv'][1]);
|
||||
$path = $url['path'];
|
||||
}
|
||||
return substr($path, 0, (strrpos($path, '/') + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
5
module/report/config.php
Normal file
5
module/report/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/* Open daily reminder.*/
|
||||
$config->report->dailyreminder->bug = true;
|
||||
$config->report->dailyreminder->task = true;
|
||||
$config->report->dailyreminder->todo = true;
|
||||
@@ -119,4 +119,46 @@ class report extends control
|
||||
$this->view->submenu = 'staff';
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send daily reminder mail.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function remind()
|
||||
{
|
||||
if($this->config->report->dailyreminder->bug) $bugs = $this->report->getUserBugs();
|
||||
if($this->config->report->dailyreminder->task) $tasks = $this->report->getUserTasks();
|
||||
if($this->config->report->dailyreminder->todo) $todos = $this->report->getUserTodos();
|
||||
|
||||
$reminder = array();
|
||||
if(!empty($bugs)) foreach($bugs as $user => $bug) $reminder[$user]->bugs = $bug;
|
||||
if(!empty($tasks)) foreach($tasks as $user => $task) $reminder[$user]->tasks = $task;
|
||||
if(!empty($todos)) foreach($todos as $user => $todo) $reminder[$user]->todos = $todo;
|
||||
|
||||
$this->loadModel('mail');
|
||||
foreach($reminder as $user => $mail)
|
||||
{
|
||||
/* Get email content and title.*/
|
||||
$this->view->mail = $mail;
|
||||
$mailContent = $this->parse('report', 'dailyreminder');
|
||||
$mailTitle = $this->lang->report->mailtitle->begin;
|
||||
$mailTitle .= isset($mail->bugs) ? sprintf($this->lang->report->mailtitle->bug, count($mail->bugs)) : '';
|
||||
$mailTitle .= isset($mail->tasks) ? sprintf($this->lang->report->mailtitle->task, count($mail->tasks)) : '';
|
||||
$mailTitle .= isset($mail->todos) ? sprintf($this->lang->report->mailtitle->todo, count($mail->todos)) : '';
|
||||
$mailTitle = rtrim($mailTitle, ',');
|
||||
$this->clear();
|
||||
|
||||
/* Send email.*/
|
||||
echo date('Y-m-d H:i:s') . " sending to $user, ";
|
||||
$this->mail->send($user, $mailTitle, $mailContent, '', true);
|
||||
if($this->mail->isError())
|
||||
{
|
||||
echo "fail: \n" ;
|
||||
a($this->mail->getError());
|
||||
}
|
||||
echo "ok\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,4 +70,15 @@ $lang->report->manhourTotal = "Manhour Total";
|
||||
$lang->report->bugTotal = "%s Bugs";
|
||||
$lang->report->unplanned = 'unplanned';
|
||||
|
||||
/* daily reminder. */
|
||||
$lang->report->idAB = 'ID';
|
||||
$lang->report->bugTitle = 'Bug Title';
|
||||
$lang->report->taskName = 'Task Name';
|
||||
$lang->report->todoName = 'Todo Name';
|
||||
|
||||
$lang->report->mailtitle->begin = 'Notice : Your';
|
||||
$lang->report->mailtitle->bug = " Bugs(%s),";
|
||||
$lang->report->mailtitle->task = " Tasks(%s),";
|
||||
$lang->report->mailtitle->todo = " Todos(%s),";
|
||||
|
||||
$lang->report->proVersion = '<a href="http://www.zentao.net/goto.php?item=proversion&from=reportpage" target="_blank">Try pro version for more!</a>';
|
||||
|
||||
@@ -70,4 +70,15 @@ $lang->report->manhourTotal = "总工时";
|
||||
$lang->report->bugTotal = "共%s个Bug";
|
||||
$lang->report->unplanned = '未计划';
|
||||
|
||||
/* daily reminder. */
|
||||
$lang->report->idAB = 'ID';
|
||||
$lang->report->bugTitle = 'Bug标题';
|
||||
$lang->report->taskName = '任务名称';
|
||||
$lang->report->todoName = 'Todo名称';
|
||||
|
||||
$lang->report->mailtitle->begin = '提醒:您有';
|
||||
$lang->report->mailtitle->bug = " Bugs(%s),";
|
||||
$lang->report->mailtitle->task = " 任务(%s),";
|
||||
$lang->report->mailtitle->todo = " Todos(%s),";
|
||||
|
||||
$lang->report->proVersion = '<a href="http://www.zentao.net/goto.php?item=proversion&from=reportpage" target="_blank">更多精彩,尽在专业版!</a>';
|
||||
|
||||
@@ -470,4 +470,93 @@ EOT;
|
||||
unset($assign['closed']);
|
||||
return $assign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get System URL.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getSysURL()
|
||||
{
|
||||
/* Ger URL when run in shell. */
|
||||
if(defined('IN_SHELL'))
|
||||
{
|
||||
$url = parse_url(trim($this->server->argv[1]));
|
||||
$port = (empty($url['port']) or $url['port'] == 80) ? '' : $url['port'];
|
||||
$host = empty($port) ? $url['host'] : $url['host'] . ':' . $port;
|
||||
return $url['scheme'] . '://' . $host;
|
||||
}
|
||||
else
|
||||
{
|
||||
return common::getSysURL();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user bugs.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getUserBugs()
|
||||
{
|
||||
$bugs = $this->dao->select('t1.id, t1.title, t2.account as user')
|
||||
->from(TABLE_BUG)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')
|
||||
->on('t1.assignedTo = t2.account')
|
||||
->where('t1.assignedTo')->ne('')
|
||||
->andWhere('t1.assignedTo')->ne('closed')
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetchGroup('user');
|
||||
return $bugs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user tasks.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getUserTasks()
|
||||
{
|
||||
$tasks = $this->dao->select('t1.id, t1.name, t2.account as user')
|
||||
->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')
|
||||
->on('t1.assignedTo = t2.account')
|
||||
->where('t1.assignedTo')->ne('')
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.status')->in('wait, doing')
|
||||
->fetchGroup('user');
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user todos.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getUserTodos()
|
||||
{
|
||||
$stmt = $this->dao->select('t1.*, t2.account as user')
|
||||
->from(TABLE_TODO)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')
|
||||
->on('t1.account = t2.account')
|
||||
->where('t1.status')->eq('wait')
|
||||
->orWhere('t1.status')->eq('doing')
|
||||
->query();
|
||||
|
||||
$todos = array();
|
||||
while($todo = $stmt->fetch())
|
||||
{
|
||||
if($todo->type == 'task') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name');
|
||||
if($todo->type == 'bug') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_BUG)->fetch('title');
|
||||
$todos[$todo->user][] = $todo;
|
||||
}
|
||||
return $todos;
|
||||
}
|
||||
}
|
||||
|
||||
71
module/report/view/dailyreminder.html.php
Executable file
71
module/report/view/dailyreminder.html.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php $url = $this->report->getSysURL();?>
|
||||
<style>
|
||||
del {background:#fcc}
|
||||
ins {background:#cfc; text-decoration:none}
|
||||
table, tr, th, td {border:1px solid gray; font-size:12px; border-collapse:collapse}
|
||||
tr, th, td {padding:5px}
|
||||
.w-id {width:45px}
|
||||
.header {background:#efefef}
|
||||
</style>
|
||||
<?php if(isset($mail->bugs)):?>
|
||||
<table width='66%' align='center'>
|
||||
<tr class='header'>
|
||||
<th class='w-id'><?php echo $lang->report->idAB;?></th>
|
||||
<th><?php echo $lang->report->bugTitle;?></th>
|
||||
</tr>
|
||||
<?php foreach($mail->bugs as $bug):?>
|
||||
<tr>
|
||||
<td><?php echo $bug->id;?></td>
|
||||
<td>
|
||||
<?php
|
||||
$link = $this->createLink('bug', 'view', "bugID=$bug->id");
|
||||
if($config->requestType == 'GET' and strpos($link, 'ztcli') !== false) $link = str_replace($this->server->php_self, $config->webRoot, $link);
|
||||
echo html::a($url . $link, $bug->title);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if(isset($mail->tasks)):?>
|
||||
<table width='66%' align='center'>
|
||||
<tr class='header'>
|
||||
<th class='w-id'><?php echo $lang->report->idAB;?></th>
|
||||
<th><?php echo $lang->report->taskName;?></th>
|
||||
</tr>
|
||||
<?php foreach($mail->tasks as $task):?>
|
||||
<tr>
|
||||
<td><?php echo $task->id;?></td>
|
||||
<td>
|
||||
<?php
|
||||
$link = $this->createLink('task', 'view', "taskID=$task->id");
|
||||
if($config->requestType == 'GET' and strpos($link, 'ztcli') !== false) $link = str_replace($this->server->php_self, $config->webRoot, $link);
|
||||
echo html::a($url . $link, $task->name);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if(isset($mail->todos)):?>
|
||||
<table width='66%' align='center'>
|
||||
<tr class='header'>
|
||||
<th class='w-id'><?php echo $lang->report->idAB;?></th>
|
||||
<th><?php echo $lang->report->todoName;?></th>
|
||||
</tr>
|
||||
<?php foreach($mail->todos as $todo):?>
|
||||
<tr>
|
||||
<td><?php echo $todo->id;?></td>
|
||||
<td>
|
||||
<?php
|
||||
$link = $this->createLink('todo', 'view', "todoID=$todo->id");
|
||||
if($config->requestType == 'GET' and strpos($link, 'ztcli') !== false) $link = str_replace($this->server->php_self, $config->webRoot, $link);
|
||||
echo html::a($url . $link, $todo->name);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
Reference in New Issue
Block a user