From ab2b2dcf22870178c6635f06da2378d5f6d63025 Mon Sep 17 00:00:00 2001 From: "chencongzhi520@gmail.com" Date: Tue, 1 May 2012 00:54:21 +0000 Subject: [PATCH] * adjust code for task#757 which batch create todo. --- module/bug/control.php | 4 ++- module/task/control.php | 4 ++- module/todo/config.php | 2 +- module/todo/control.php | 4 ++- module/todo/css/batchcreate.css | 3 +- module/todo/lang/en.php | 2 +- module/todo/lang/zh-cn.php | 2 +- module/todo/model.php | 50 +++++++++++++++------------ module/todo/view/batchcreate.html.php | 22 ++++++------ module/todo/view/create.html.php | 2 +- module/todo/view/footer.html.php | 33 +++++++++++++----- 11 files changed, 75 insertions(+), 53 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index f238ff8918..5bd7b5fc2d 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -699,10 +699,12 @@ class bug extends control * @access public * @return string */ - public function ajaxGetUserBugs($account = '') + public function ajaxGetUserBugs($account = '', $id = '') { if($account == '') $account = $this->app->user->account; $bugs = $this->bug->getUserBugPairs($account); + + if($id) die(html::select("bugs[$id]", $bugs, '', 'class="select-1 f-left"')); die(html::select('bug', $bugs, '', 'class=select-1')); } diff --git a/module/task/control.php b/module/task/control.php index 1f7fec5688..669190f1aa 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -576,10 +576,12 @@ class task extends control * @access public * @return string */ - public function ajaxGetUserTasks($account = '', $status = 'wait,doing') + public function ajaxGetUserTasks($account = '', $id = '', $status = 'wait,doing') { if($account == '') $account = $this->app->user->account; $tasks = $this->task->getUserTaskPairs($account, $status); + + if($id) die(html::select("tasks[$id]", $tasks, '', 'class="select-1 f-left"')); die(html::select('task', $tasks, '', 'class=select-1')); } diff --git a/module/todo/config.php b/module/todo/config.php index 4adebcf501..09bc320557 100644 --- a/module/todo/config.php +++ b/module/todo/config.php @@ -1,5 +1,5 @@ todo->batchCreate = 10; +$config->todo->batchCreate = 8; $config->todo->create->requiredFields = 'name'; $config->todo->edit->requiredFields = 'name'; diff --git a/module/todo/control.php b/module/todo/control.php index cdaa01f004..f18367f1ce 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -67,7 +67,7 @@ class todo extends control public function batchCreate($date = 'today', $account = '') { if($date == 'today') $this->view->date = helper::today(); - $todoLink = $this->createLink('my', 'todo', "date=all"); + $todoLink = $this->createLink('my', 'todo', "date=today"); if(!empty($_POST)) { @@ -83,6 +83,8 @@ class todo extends control $this->view->header = $header; $this->view->position = $position; + $this->view->times = $this->todo->buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta); + $this->view->time = $this->todo->now(); $this->display(); } diff --git a/module/todo/css/batchcreate.css b/module/todo/css/batchcreate.css index 01f65fd4a0..a5255f7774 100755 --- a/module/todo/css/batchcreate.css +++ b/module/todo/css/batchcreate.css @@ -1,4 +1,3 @@ -.w-400px {width:400px} -.w-300px {width:300px} .half-left{text-align:right} .half-right{text-align:left} +.f-left {margin-left:20px} diff --git a/module/todo/lang/en.php b/module/todo/lang/en.php index cdb001e330..b4c42cc5c8 100644 --- a/module/todo/lang/en.php +++ b/module/todo/lang/en.php @@ -42,7 +42,7 @@ $lang->todo->desc = 'Desc'; $lang->todo->private = 'Private'; $lang->todo->idvalue = 'Task or bug'; -$lang->todo->notes = '(Notes: the date, name must be written, otherwise it is no use)'; +$lang->todo->notes = '(Notes: the name must be written, otherwise it is no use)'; $lang->todo->week = '(l)'; // date function's param. $lang->todo->today = 'Today'; diff --git a/module/todo/lang/zh-cn.php b/module/todo/lang/zh-cn.php index c7d6babdd5..5ae06a3fa6 100644 --- a/module/todo/lang/zh-cn.php +++ b/module/todo/lang/zh-cn.php @@ -42,7 +42,7 @@ $lang->todo->desc = '描述'; $lang->todo->private = '私人事务'; $lang->todo->idvalue = '任务或Bug'; -$lang->todo->notes = '(注:“日期”、“名称”必需填写,否则此行无效)'; +$lang->todo->notes = '(注:“名称”必需填写,否则此行无效)'; $lang->todo->week = '星期'; $lang->todo->today = '今天'; diff --git a/module/todo/model.php b/module/todo/model.php index 0c874d9010..f03c0e038f 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -60,26 +60,29 @@ class todoModel extends model for($i = 0; $i < $this->config->todo->batchCreate; $i++) { - if($todos->date[$i] != '' and $todos->name[$i] != '') + if((isset($todos->names[$i]) && $todos->names[$i] != '') || (!isset($todos->names[$i]) && (isset($todos->bugs[$i+1]) || isset($todos->tasks[$i+1])))) { - $data[$i]->account = $this->app->user->account; - $data[$i]->date = $todos->date[$i]; - $data[$i]->begin = $todos->begin[$i]; - $data[$i]->end = $todos->end[$i]; - $data[$i]->type = $todos->type[$i]; - $data[$i]->idvalue = 0; - $data[$i]->name = $todos->name[$i]; - $data[$i]->desc = $todos->desc[$i]; - $data[$i]->status = "wait"; - $data[$i]->private = 0; - - $this->dao->insert(TABLE_TODO)->data($data[$i]) - ->autoCheck() - ->checkIF($data->type == 'custom', $this->config->todo->create->requiredFields, 'notempty') - ->checkIF($data->type == 'bug' and $data->idvalue == 0, 'idvalue', 'notempty') - ->checkIF($data->type == 'task' and $data->idvalue == 0, 'idvalue', 'notempty') - ->exec(); + $data->account = $this->app->user->account; + $data->date = helper::today(); + $data->type = $todos->types[$i]; + $data->pri = $todos->pris[$i]; + $data->name = isset($todos->names[$i]) ? $todos->names[$i] : ''; + $data->desc = $todos->descs[$i]; + $data->begin = $todos->begins[$i]; + $data->end = $todos->ends[$i]; + $data->status = "wait"; + $data->private = 0; + $data->idvalue = 0; + if(isset($todos->bugs[$i+1])) + { + $data->idvalue = $todos->bugs[$i+1]; + } + elseif(isset($todos->tasks[$i+1])) + { + $data->idvalue = $todos->tasks[$i+1]; + } + $this->dao->insert(TABLE_TODO)->data($data) ->exec(); if(dao::isError()) { echo js::error(dao::getError()); @@ -88,11 +91,12 @@ class todoModel extends model } else { - unset($todos->date[$i]); - unset($todos->type[$i]); - unset($todos->pri[$i]); - unset($todos->name[$i]); - unset($todos->desc[$i]); + unset($todos->types[$i]); + unset($todos->pris[$i]); + unset($todos->names[$i]); + unset($todos->descs[$i]); + unset($todos->begins[$i]); + unset($todos->ends[$i]); } } } diff --git a/module/todo/view/batchcreate.html.php b/module/todo/view/batchcreate.html.php index 3cce7d78df..1cf6071003 100755 --- a/module/todo/view/batchcreate.html.php +++ b/module/todo/view/batchcreate.html.php @@ -11,28 +11,27 @@ */ ?> -
- + - - - - + + + + todo->batchCreate; $i++):?> - - - - - + + + + + @@ -45,4 +44,3 @@ - diff --git a/module/todo/view/create.html.php b/module/todo/view/create.html.php index 9e6007895e..da317d3bf2 100644 --- a/module/todo/view/create.html.php +++ b/module/todo/view/create.html.php @@ -30,7 +30,7 @@ - + diff --git a/module/todo/view/footer.html.php b/module/todo/view/footer.html.php index 654e79fa4d..a5390075cc 100644 --- a/module/todo/view/footer.html.php +++ b/module/todo/view/footer.html.php @@ -1,31 +1,46 @@
todo->batchCreate;?>todo->batchCreate . $lang->colon . $date;?>
idAB;?>todo->date;?> todo->type;?>todo->pri;?>todo->name;?>todo->desc;?>todo->pri;?>todo->name;?>todo->desc;?>todo->beginAndEnd;?>
*";?>todo->typeList, '', "onchange=loadList(this.value,$i+1) class='select-1'");?>todo->priList, $pri, 'class=select-1');?>
*";?>
todo->typeList, '', "onchange=loadList(this.value,$i+1) class='select-1'");?>todo->priList, $pri, 'class=select-1');?>
*";?>
todo->name;?>
todo->desc;?>