* adjust the tdo feature.
This commit is contained in:
@@ -40,6 +40,12 @@ class my extends control
|
||||
/* 用户的todo列表。*/
|
||||
public function todo($type = 'today', $account = '', $status = 'all')
|
||||
{
|
||||
/* 登记session。*/
|
||||
$uri = $this->app->getURI(true);
|
||||
$this->session->set('todoList', $uri);
|
||||
$this->session->set('bugList', $uri);
|
||||
$this->session->set('taskList', $uri);
|
||||
|
||||
$this->view->header->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->todo;
|
||||
$this->view->position[] = $this->lang->my->todo;
|
||||
|
||||
|
||||
@@ -76,20 +76,14 @@ function changeDate(date)
|
||||
<td><?php echo $todo->date;?></td>
|
||||
<td><?php echo $lang->todo->typeList->{$todo->type};?></td>
|
||||
<td><?php echo $todo->pri;?></td>
|
||||
<td class='a-left'>
|
||||
<?php
|
||||
if($todo->type == 'bug') $link = $this->createLink('bug', 'view', "id={$todo->idvalue}");
|
||||
if($todo->type == 'task') $link = $this->createLink('task', 'edit', "id={$todo->idvalue}");
|
||||
if($todo->type == 'custom') $link = $this->createLink('todo', 'edit', "id={$todo->id}");
|
||||
echo html::a($link, $todo->name);
|
||||
?>
|
||||
</td>
|
||||
<td class='a-left'><?php echo html::a($this->createLink('todo', 'view', "id={$todo->id}"), $todo->name);?></td>
|
||||
<td><?php echo $todo->begin;?></td>
|
||||
<td><?php echo $todo->end;?></td>
|
||||
<td class='<?php echo $todo->status;?>'><?php echo $lang->todo->statusList[$todo->status];?></td>
|
||||
<td>
|
||||
<?php
|
||||
echo html::a($this->createLink('todo', 'mark', "id=$todo->id&status=$todo->status"), $lang->todo->{'mark'.ucfirst($todo->status)}, 'hiddenwin');
|
||||
echo html::a($this->createLink('todo', 'view', "id=$todo->id&from=my"), $lang->todo->viewAB);
|
||||
echo html::a($this->createLink('todo', 'edit', "id=$todo->id"), $lang->edit);
|
||||
echo html::a($this->createLink('todo', 'delete', "id=$todo->id"), $lang->delete, 'hiddenwin');
|
||||
?>
|
||||
|
||||
+22
-9
@@ -39,8 +39,9 @@ class todo extends control
|
||||
if($account == '') $account = $this->app->user->account;
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->todo->create($date, $account);
|
||||
$todoID = $this->todo->create($date, $account);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
$this->loadModel('action')->create('todo', $todoID, 'opened');
|
||||
die(js::locate($this->createLink('my', 'todo', "date=$_POST[date]"), 'parent'));
|
||||
}
|
||||
|
||||
@@ -61,9 +62,14 @@ class todo extends control
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->todo->update($todoID);
|
||||
$changes = $this->todo->update($todoID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
die(js::locate($this->createLink('my', 'todo', "date=$_POST[date]"), 'parent'));
|
||||
if($changes)
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('todo', $todoID, 'edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
die(js::locate(inlink('view', "todoID=$todoID"), 'parent'));
|
||||
}
|
||||
|
||||
/* 获取todo信息,判断是否是私人事务。*/
|
||||
@@ -82,17 +88,25 @@ class todo extends control
|
||||
}
|
||||
|
||||
/* 查看todo。*/
|
||||
public function view($todoID)
|
||||
public function view($todoID, $from = 'company')
|
||||
{
|
||||
$todo = $this->todo->getById($todoID);
|
||||
if(!$todo) die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
|
||||
/* 登记session。*/
|
||||
$this->session->set('taskList', $this->app->getURI(true));
|
||||
$this->session->set('bugList', $this->app->getURI(true));
|
||||
|
||||
$this->lang->todo->menu = $this->lang->user->menu;
|
||||
$this->loadModel('user')->setMenu($this->user->getPairs(), $todo->account);
|
||||
$this->lang->set('menugroup.todo', 'company');
|
||||
$this->lang->set('menugroup.todo', $from);
|
||||
|
||||
$this->view->header->title = $this->lang->todo->view;
|
||||
$this->view->position[] = $this->lang->todo->view;
|
||||
$this->view->todo = $todo;
|
||||
$this->view->times = $this->todo->buildTimeList();
|
||||
$this->view->actions = $this->loadModel('action')->getList('todo', $todoID);
|
||||
$this->view->from = $from;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -107,10 +121,9 @@ class todo extends control
|
||||
}
|
||||
else
|
||||
{
|
||||
$todo = $this->todo->getById($todoID);
|
||||
$this->todo->delete($todoID);
|
||||
echo js::locate($this->createLink('my', 'todo', "date={$todo->date}"), 'parent');
|
||||
exit;
|
||||
$this->dao->delete()->from(TABLE_TODO)->where('id')->eq($todoID)->exec();
|
||||
$this->loadModel('action')->create('todo', $todoID, 'erased');
|
||||
die(js::locate($this->session->todoList, 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ $lang->todo->index = "todo一览";
|
||||
$lang->todo->create = "新增TODO";
|
||||
$lang->todo->edit = "更新TODO";
|
||||
$lang->todo->view = "TODO详情";
|
||||
$lang->todo->viewAB = "详情";
|
||||
$lang->todo->markDone = "未完成";
|
||||
$lang->todo->markWait = "已完成";
|
||||
$lang->todo->markDoing = "已完成";
|
||||
@@ -79,3 +80,5 @@ $lang->todo->lastWeekTodos = '上周总结';
|
||||
$lang->todo->allDaysTodos = '所有TODO';
|
||||
$lang->todo->allUndone = '之前未完';
|
||||
$lang->todo->todayTodos = '今日安排';
|
||||
|
||||
$lang->todo->action->marked = array('main' => '$date, 由 <strong>$actor</strong> 标记为<strong>$extra</strong>。', 'extra' => $lang->todo->statusList);
|
||||
|
||||
@@ -46,11 +46,14 @@ class todoModel extends model
|
||||
->autoCheck()
|
||||
->checkIF($todo->type == 'custom', $this->config->todo->create->requiredFields, 'notempty')
|
||||
->exec();
|
||||
return $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* 更新一个todo。*/
|
||||
public function update($todoID)
|
||||
{
|
||||
$oldTodo = $this->getById($todoID);
|
||||
if($oldTodo->type != 'custom') $oldTodo->name = '';
|
||||
$todo = fixer::input('post')
|
||||
->cleanInt('date, pri, begin, end, private')
|
||||
->specialChars('type,name,desc')
|
||||
@@ -62,25 +65,23 @@ class todoModel extends model
|
||||
->autoCheck()
|
||||
->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')->where('id')->eq($todoID)
|
||||
->exec();
|
||||
if(!dao::isError()) return common::createChanges($oldTodo, $todo);
|
||||
}
|
||||
|
||||
/* 删除一个todo。*/
|
||||
public function delete($todoID)
|
||||
{
|
||||
return $this->dao->delete()->from(TABLE_TODO)->where('id')->eq((int)$todoID)->exec();
|
||||
}
|
||||
|
||||
/* 更改状态。*/
|
||||
public function mark($todoID, $status)
|
||||
{
|
||||
$status = ($status == 'done') ? 'wait' : 'done';
|
||||
return $this->dao->update(TABLE_TODO)->set('status')->eq($status)->where('id')->eq((int)$todoID)->exec();
|
||||
$this->dao->update(TABLE_TODO)->set('status')->eq($status)->where('id')->eq((int)$todoID)->exec();
|
||||
$this->loadModel('action')->create('todo', $todoID, 'marked', '', $status);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 获得一条todo信息。*/
|
||||
public function getById($todoID)
|
||||
{
|
||||
$todo = $this->dao->findById((int)$todoID)->from(TABLE_TODO)->fetch();
|
||||
if(!$todo) return false;
|
||||
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');
|
||||
$todo->date = str_replace('-', '', $todo->date);
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
<div class='yui-d0'>
|
||||
<?php if(!$todo->private or ($todo->private and $todo->account == $app->user->account)):?>
|
||||
<table class='table-1 a-left'>
|
||||
<caption><?php echo $lang->todo->view;?></caption>
|
||||
<caption>
|
||||
<div class='f-left'><?php echo $lang->todo->view;?></div>
|
||||
<div class='f-right'><?php echo html::a($this->session->todoList, $lang->goback);?></div>
|
||||
</caption>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->todo->date;?></th>
|
||||
<td><?php echo date(DT_DATE1, strtotime($todo->date));?></td>
|
||||
@@ -41,7 +44,13 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->todo->name;?></th>
|
||||
<td><?php echo $todo->name;?></td>
|
||||
<td>
|
||||
<?php
|
||||
if($todo->type == 'bug') echo html::a($this->createLink('bug', 'view', "id={$todo->idvalue}"), $todo->name);
|
||||
if($todo->type == 'task') echo html::a($this->createLink('task', 'view', "id={$todo->idvalue}"), $todo->name);
|
||||
if($todo->type == 'custom') echo $todo->name;
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->todo->desc;?></th>
|
||||
@@ -60,9 +69,32 @@
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php else:?>
|
||||
<?php echo $lang->todo->thisIsPrivate;?>
|
||||
<?php endif;?>
|
||||
</table>
|
||||
<div class='a-center f-16px strong'>
|
||||
<?php
|
||||
if($this->session->todoList)
|
||||
{
|
||||
$browseLink = $this->session->todoList;
|
||||
}
|
||||
elseif($todo->account == $app->user->account)
|
||||
{
|
||||
$browseLink = $this->createLink('my', 'todo');
|
||||
}
|
||||
else
|
||||
{
|
||||
$browseLink = $this->createLink('user', 'todo', "account=$todo->account");
|
||||
}
|
||||
if($todo->account == $app->user->account)
|
||||
{
|
||||
common::printLink('todo', 'edit', "todoID=$todo->id", $lang->edit);
|
||||
common::printLink('todo', 'delete', "todoID=$todo->id", $lang->delete, 'hiddenwin');
|
||||
}
|
||||
echo html::a($browseLink, $lang->goback);
|
||||
?>
|
||||
</div>
|
||||
<?php include '../../common/view/action.html.php';?>
|
||||
<?php else:?>
|
||||
<?php echo $lang->todo->thisIsPrivate;?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -41,6 +41,8 @@ class user extends control
|
||||
/* 用户的todo列表。*/
|
||||
public function todo($account, $type = 'today', $status = 'all')
|
||||
{
|
||||
$this->session->set('todoList', $this->app->getURI(true));
|
||||
|
||||
/* 加载todo model。*/
|
||||
$this->loadModel('todo');
|
||||
$this->lang->set('menugroup.user', 'company');
|
||||
|
||||
Reference in New Issue
Block a user