-
+
diff --git a/module/todo/control.php b/module/todo/control.php
index 65b888a473..cbcf79e152 100644
--- a/module/todo/control.php
+++ b/module/todo/control.php
@@ -13,7 +13,7 @@ class todo extends control
{
/**
* Construct function, load model of task, bug, my.
- *
+ *
* @access public
* @return void
*/
@@ -28,9 +28,9 @@ class todo extends control
/**
* Create a todo.
- *
- * @param string|date $date
- * @param string $account
+ *
+ * @param string|date $date
+ * @param string $account
* @access public
* @return void
*/
@@ -46,11 +46,11 @@ class todo extends control
$date = str_replace('-', '', $this->post->date);
if($date == '')
{
- $date = 'future';
+ $date = 'future';
}
elseif($date == date('Ymd'))
{
- $date = 'today';
+ $date = 'today';
}
if(!empty($_POST['idvalue'])) $this->send(array('result' => 'success'));
@@ -64,14 +64,14 @@ class todo extends control
$this->view->date = date("Y-m-d", strtotime($date));
$this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
$this->view->time = date::now();
- $this->display();
+ $this->display();
}
/**
* Batch create todo
- *
- * @param string $date
- * @param string $account
+ *
+ * @param string $date
+ * @param string $account
* @access public
* @return void
*/
@@ -87,11 +87,11 @@ class todo extends control
$date = str_replace('-', '', $this->post->date);
if($date == '')
{
- $date = 'future';
+ $date = 'future';
}
else if($date == date('Ymd'))
{
- $date= 'today';
+ $date= 'today';
}
die(js::locate($this->createLink('my', 'todo', "type=$date"), 'parent'));
}
@@ -114,8 +114,8 @@ class todo extends control
/**
* Edit a todo.
- *
- * @param int $todoID
+ *
+ * @param int $todoID
* @access public
* @return void
*/
@@ -137,7 +137,7 @@ class todo extends control
/* Judge a private todo or not, If private, die. */
$todo = $this->todo->getById($todoID);
if($todo->private and $this->app->user->account != $todo->account) die('private');
-
+
$todo->date = date("Y-m-d", strtotime($todo->date));
$this->view->title = $this->lang->todo->common . $this->lang->colon . $this->lang->todo->edit;
$this->view->position[] = $this->lang->todo->common;
@@ -149,11 +149,11 @@ class todo extends control
/**
* Batch edit todo.
- *
+ *
* @param string $from example:myTodo, todoBatchEdit.
- * @param string $type
- * @param string $account
- * @param string $status
+ * @param string $type
+ * @param string $account
+ * @param string $status
* @access public
* @return void
*/
@@ -174,14 +174,14 @@ class todo extends control
if($this->post->todoIDList) $todoIDList = $this->post->todoIDList;
/* Initialize todos whose need to edited. */
- foreach($allTodos as $todo)
+ foreach($allTodos as $todo)
{
if(in_array($todo->id, $todoIDList))
{
$editedTodos[$todo->id] = $todo;
}
}
- foreach($editedTodos as $todo)
+ foreach($editedTodos as $todo)
{
if($todo->type == 'story') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_STORY)->fetch('title');
if($todo->type == 'task') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name');
@@ -233,10 +233,61 @@ class todo extends control
}
/**
- * View a todo.
- *
- * @param int $todoID
- * @param string $from my|company
+ * Activated todo.
+ *
+ * @param $todoID
+ * @access public
+ * @return void
+ */
+ public function activate($todoID)
+ {
+ $todo = $this->todo->getById($todoID);
+ if($todo->status == 'done') $this->todo->activate($todoID);
+ if(isonlybody()) die(js::reload('parent.parent'));
+ die(js::reload('parent'));
+ }
+
+ /**
+ * Closed todo.
+ *
+ * @param $todoID
+ *
+ * @access public
+ * @return void
+ */
+ public function close($todoID)
+ {
+ $todo = $this->todo->getById($todoID);
+ if($todo->status == 'done') $this->todo->close($todoID);
+ if(isonlybody()) die(js::reload('parent.parent'));
+ die(js::reload('parent'));
+ }
+
+ /**
+ * Assign.
+ *
+ * @param $todoID
+ *
+ * @access public
+ * @return void
+ */
+ public function assignTo($todoID)
+ {
+ if(!empty($_POST))
+ {
+ if(empty($_POST['assignedTo'])) die(js::error($this->lang->todo->noAssignedTo));
+ $this->todo->assignTo($todoID);
+ if(dao::isError()) die(js::error(dao::getError()));
+ die(js::reload('parent'));
+ }
+ }
+
+ /**
+ * View a todo.
+ *
+ * @param int $todoID
+ * @param string $from my|company
+ *
* @access public
* @return void
*/
@@ -288,8 +339,8 @@ class todo extends control
/**
* Delete a todo.
- *
- * @param int $todoID
+ *
+ * @param int $todoID
* @param string $confirm yes|no
* @access public
* @return void
@@ -327,8 +378,8 @@ class todo extends control
/**
* Finish a todo.
- *
- * @param int $todoID
+ *
+ * @param int $todoID
* @access public
* @return void
*/
@@ -349,7 +400,7 @@ class todo extends control
/**
* Batch finish todos.
- *
+ *
* @access public
* @return void
*/
@@ -357,7 +408,7 @@ class todo extends control
{
if(!empty($_POST['todoIDList']))
{
- foreach($_POST['todoIDList'] as $todoID)
+ foreach($_POST['todoIDList'] as $todoID)
{
$todo = $this->todo->getById($todoID);
if($todo->status != 'done') $this->todo->finish($todoID);
@@ -368,7 +419,7 @@ class todo extends control
/**
* Import selected todoes to today.
- *
+ *
* @access public
* @return void
*/
@@ -381,10 +432,10 @@ class todo extends control
}
/**
- * Get data to export
- *
- * @param string $productID
- * @param string $orderBy
+ * Get data to export
+ *
+ * @param string $productID
+ * @param string $orderBy
* @access public
* @return void
*/
@@ -446,8 +497,8 @@ class todo extends control
/**
* AJAX: get actions of a todo. for web app.
- *
- * @param int $todoID
+ *
+ * @param int $todoID
* @access public
* @return void
*/
@@ -459,7 +510,7 @@ class todo extends control
/**
* Create cycle.
- *
+ *
* @access public
* @return void
*/
diff --git a/module/todo/lang/en.php b/module/todo/lang/en.php
index ba73c3c830..9fd8bfcfdd 100644
--- a/module/todo/lang/en.php
+++ b/module/todo/lang/en.php
@@ -12,8 +12,11 @@
$lang->todo->common = 'Todo';
$lang->todo->index = "Home";
$lang->todo->create = "Create Todo";
+$lang->todo->assignTo = "Assign";
+$lang->todo->activate = "Activate";
$lang->todo->batchCreate = "Batch Create";
$lang->todo->edit = "Edit";
+$lang->todo->close = "Close";
$lang->todo->batchEdit = "Batch Edit";
$lang->todo->view = "Overview";
$lang->todo->finish = "Finish";
@@ -59,9 +62,10 @@ $lang->todo->confirmBug = 'This Todo is related to Bug #%s. Do you want to edi
$lang->todo->confirmTask = 'This Todo is related to Task #%s,Do you want to edit it?';
$lang->todo->confirmStory = 'This Todo is related to Story #%s,Do you want to edit it?';
-$lang->todo->statusList['wait'] = 'Wait';
-$lang->todo->statusList['doing'] = 'Doing';
-$lang->todo->statusList['done'] = 'Done';
+$lang->todo->statusList['wait'] = 'Wait';
+$lang->todo->statusList['doing'] = 'Doing';
+$lang->todo->statusList['done'] = 'Done';
+$lang->todo->statusList['closed'] = 'Closed';
//$lang->todo->statusList['cancel'] = 'Cancelled';
//$lang->todo->statusList['postpone'] = 'Delayed';
@@ -86,6 +90,7 @@ $lang->todo->thisIsPrivate = 'This is a private Todo';
$lang->todo->lblDisableDate = 'Set later.';
$lang->todo->lblBeforeDays = "%s early in advance to be done";
$lang->todo->noTodo = 'No this type of Todo.';
+$lang->todo->noAssignedTo = "The AssignedTo user can't be empty.";
$lang->todo->periods['today'] = 'Today';
$lang->todo->periods['yesterday'] = 'Yesterday';
diff --git a/module/todo/lang/zh-cn.php b/module/todo/lang/zh-cn.php
index 5202990c6c..0fbda0b2a2 100644
--- a/module/todo/lang/zh-cn.php
+++ b/module/todo/lang/zh-cn.php
@@ -12,14 +12,17 @@
$lang->todo->common = '待办';
$lang->todo->index = "待办一览";
$lang->todo->create = "新增";
+$lang->todo->assignTo = "指派";
+$lang->todo->activate = "激活";
$lang->todo->batchCreate = "批量添加";
-$lang->todo->edit = "更新待办";
+$lang->todo->edit = "编辑";
+$lang->todo->close = "关闭";
$lang->todo->batchEdit = "批量编辑";
$lang->todo->view = "待办详情";
$lang->todo->finish = "完成";
$lang->todo->batchFinish = "批量完成";
$lang->todo->export = "导出";
-$lang->todo->delete = "删除待办";
+$lang->todo->delete = "删除";
$lang->todo->import2Today = "导入到今天";
$lang->todo->import = "导入";
$lang->todo->legendBasic = "基本信息";
@@ -59,9 +62,10 @@ $lang->todo->confirmBug = '该Todo关联的是Bug #%s,需要修改它吗?'
$lang->todo->confirmTask = '该Todo关联的是Task #%s,需要修改它吗?';
$lang->todo->confirmStory = '该Todo关联的是Story #%s,需要修改它吗?';
-$lang->todo->statusList['wait'] = '未开始';
-$lang->todo->statusList['doing'] = '进行中';
-$lang->todo->statusList['done'] = '已完成';
+$lang->todo->statusList['wait'] = '未开始';
+$lang->todo->statusList['doing'] = '进行中';
+$lang->todo->statusList['done'] = '已完成';
+$lang->todo->statusList['closed'] = '已关闭';
//$lang->todo->statusList['cancel'] = '已取消';
//$lang->todo->statusList['postpone'] = '已延期';
@@ -86,6 +90,7 @@ $lang->todo->thisIsPrivate = '这是一条私人事务。:)';
$lang->todo->lblDisableDate = '暂时不设定时间';
$lang->todo->lblBeforeDays = "提前%s天生成待办";
$lang->todo->noTodo = '该类型没有待办事务';
+$lang->todo->noAssignedTo = '被指派人不能为空';
$lang->todo->periods['today'] = '今日';
$lang->todo->periods['yesterday'] = '昨日';
diff --git a/module/todo/model.php b/module/todo/model.php
index 080d476e36..96fb105c64 100644
--- a/module/todo/model.php
+++ b/module/todo/model.php
@@ -15,9 +15,9 @@ class todoModel extends model
{
/**
* Create a todo.
- *
- * @param date $date
- * @param string $account
+ *
+ * @param date $date
+ * @param string $account
* @access public
* @return void
*/
@@ -81,7 +81,7 @@ class todoModel extends model
/**
* Create batch todo
- *
+ *
* @access public
* @return void
*/
@@ -116,7 +116,7 @@ class todoModel extends model
if($todo->type == 'story') $todo->idvalue = isset($todos->storys[$i + 1]) ? $todos->storys[$i + 1] : 0;
$this->dao->insert(TABLE_TODO)->data($todo)->autoCheck()->exec();
- if(dao::isError())
+ if(dao::isError())
{
echo js::error(dao::getError());
die(js::reload('parent'));
@@ -139,8 +139,8 @@ class todoModel extends model
/**
* update a todo.
- *
- * @param int $todoID
+ *
+ * @param int $todoID
* @access public
* @return void
*/
@@ -198,7 +198,7 @@ class todoModel extends model
/**
* Batch update todos.
- *
+ *
* @access public
* @return array
*/
@@ -235,7 +235,7 @@ class todoModel extends model
if($oldTodo->type == 'bug' or $oldTodo->type == 'task') $oldTodo->name = '';
$this->dao->update(TABLE_TODO)->data($todo)
->autoCheck()
- ->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')
+ ->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')
->checkIF($todo->type == 'bug', 'idvalue', 'notempty')
->checkIF($todo->type == 'task', 'idvalue', 'notempty')
->where('id')->eq($todoID)
@@ -243,7 +243,7 @@ class todoModel extends model
if($oldTodo->status != 'done' and $todo->status == 'done') $this->loadModel('action')->create('todo', $todoID, 'finished', '', 'done');
- if(!dao::isError())
+ if(!dao::isError())
{
$allChanges[$todoID] = common::createChanges($oldTodo, $todo);
}
@@ -259,23 +259,28 @@ class todoModel extends model
/**
* Change the status of a todo.
- *
- * @param string $todoID
- * @param string $status
+ *
+ * @param string $todoID
+ * @param string $status
* @access public
* @return void
*/
public function finish($todoID)
{
- $this->dao->update(TABLE_TODO)->set('status')->eq('done')->where('id')->eq((int)$todoID)->exec();
+ $this->dao->update(TABLE_TODO)
+ ->set('status')->eq('done')
+ ->set('finishedBy')->eq($this->app->user->account)
+ ->set('finishedDate')->eq(helper::now())
+ ->where('id')->eq((int)$todoID)
+ ->exec();
$this->loadModel('action')->create('todo', $todoID, 'finished', '', 'done');
return;
}
/**
* Get info of a todo.
- *
- * @param int $todoID
+ *
+ * @param int $todoID
* @param bool $setImgSize
* @access public
* @return object|bool
@@ -295,11 +300,11 @@ class todoModel extends model
/**
* Get todo list of a user.
- *
- * @param date $date
- * @param string $account
+ *
+ * @param date $date
+ * @param string $account
* @param string $status all|today|thisweek|lastweek|before, or a date.
- * @param int $limit
+ * @param int $limit
* @access public
* @return void
*/
@@ -309,12 +314,12 @@ class todoModel extends model
$todos = array();
$date = strtolower($date);
- if($date == 'today')
+ if($date == 'today')
{
$begin = date::today();
$end = $begin;
}
- elseif($date == 'yesterday')
+ elseif($date == 'yesterday')
{
$begin = date::yesterday();
$end = $begin;
@@ -381,7 +386,7 @@ class todoModel extends model
->beginIF($limit > 0)->limit($limit)->fi()
->page($pager)
->query();
-
+
/* Set session. */
$sql = explode('WHERE', $this->dao->get());
$sql = explode('ORDER', $sql[1]);
@@ -409,9 +414,9 @@ class todoModel extends model
/**
* Judge an action is clickable or not.
- *
- * @param object $todo
- * @param string $action
+ *
+ * @param object $todo
+ * @param string $action
* @access public
* @return bool
*/
@@ -429,9 +434,9 @@ class todoModel extends model
}
/**
- * CreateByCycle
- *
- * @param int $todoList
+ * CreateByCycle
+ *
+ * @param int $todoList
* @access public
* @return void
*/
@@ -495,4 +500,55 @@ class todoModel extends model
}
}
}
+
+ /**
+ * Activate todo.
+ *
+ * @param $todoID
+ *
+ * @access public
+ * @return bool
+ */
+ public function activate($todoID)
+ {
+ $this->dao->update(TABLE_TODO)->set('status')->eq('wait')->where('id')->eq((int)$todoID)->exec();
+ $this->loadModel('action')->create('todo', $todoID, 'activated', '', 'wait');
+ return !dao::isError();
+ }
+
+ /**
+ * Closed todo.
+ *
+ * @param $todoID
+ *
+ * @access public
+ * @return bool
+ */
+ public function close($todoID)
+ {
+ $this->dao->update(TABLE_TODO)
+ ->set('status')->eq('closed')
+ ->set('closedBy')->eq($this->app->user->account)
+ ->set('closedDate')->eq(helper::now())
+ ->where('id')->eq((int)$todoID)
+ ->exec();
+ $this->loadModel('action')->create('todo', $todoID, 'closed', '', 'closed');
+ return !dao::isError();
+ }
+
+ public function assignTo($todoID)
+ {
+ $todo = fixer::input('post')
+ ->add('assignedBy', $this->app->user->account)
+ ->add('assignedDate', helper::now())
+ ->setIF(isset($_POST['future']), 'date', '2030-01-01')
+ ->setIF(isset($_POST['lblDisableDate']), 'begin', '2400')
+ ->setIF(isset($_POST['lblDisableDate']), 'end', '2400')
+ ->remove('future,lblDisableDate')
+ ->get();
+
+ $this->dao->update(TABLE_TODO)->data($todo)->where('id')->eq((int)$todoID)->exec();
+ $this->loadModel('action')->create('todo', $todoID, 'assigned', '', 'assigned');
+ return !dao::isError();
+ }
}
diff --git a/module/todo/view/assignto.html.php b/module/todo/view/assignto.html.php
new file mode 100755
index 0000000000..fa9710cfd4
--- /dev/null
+++ b/module/todo/view/assignto.html.php
@@ -0,0 +1,88 @@
+
+ * @package todo
+ * @version $Id: create.html.php 2741 2012-04-07 07:24:21 $
+ * @link http://www.zentao.net
+ */
+?>
+
+
+
+
+
+
todo->assignTo;?>
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/module/todo/view/view.html.php b/module/todo/view/view.html.php
index 8269a3486f..1b72750642 100644
--- a/module/todo/view/view.html.php
+++ b/module/todo/view/view.html.php
@@ -24,7 +24,7 @@