diff --git a/module/todo/config.php b/module/todo/config.php index 65c2d5fc4c..4adebcf501 100644 --- a/module/todo/config.php +++ b/module/todo/config.php @@ -1,4 +1,6 @@ todo->batchCreate = 10; + $config->todo->create->requiredFields = 'name'; $config->todo->edit->requiredFields = 'name'; $config->todo->dates->end = 15; diff --git a/module/todo/control.php b/module/todo/control.php index d590df5ac3..ce6304b7e8 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -57,6 +57,37 @@ class todo extends control $this->display(); } + /** + * Batch create todo + * + * @param string $date + * @param string $account + * @access public + * @return void + */ + public function batchCreate($date = 'today', $account = '') + { + if($date == 'today') $this->view->date = helper::today(); + $todoLink = $this->createLink('my', 'todo', "date=all"); + + if(!empty($_POST)) + { + $this->todo->batchCreate(); + if(dao::isError()) die(js::error(dao::getError())); + + /* Locate the browser. */ + die(js::locate($todoLink, 'parent')); + } + + $header['title'] = $this->lang->my->common . $this->lang->colon . $this->lang->todo->create; + $position[] = $this->lang->todo->create; + + $this->view->header = $header; + $this->view->position = $position; + + $this->display(); + } + /** * Edit a todo. * diff --git a/module/todo/css/batchcreate.css b/module/todo/css/batchcreate.css new file mode 100755 index 0000000000..01f65fd4a0 --- /dev/null +++ b/module/todo/css/batchcreate.css @@ -0,0 +1,4 @@ +.w-400px {width:400px} +.w-300px {width:300px} +.half-left{text-align:right} +.half-right{text-align:left} diff --git a/module/todo/lang/en.php b/module/todo/lang/en.php index 0cdb768143..cdb001e330 100644 --- a/module/todo/lang/en.php +++ b/module/todo/lang/en.php @@ -42,6 +42,8 @@ $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->week = '(l)'; // date function's param. $lang->todo->today = 'Today'; $lang->todo->weekDateList = ''; diff --git a/module/todo/lang/zh-cn.php b/module/todo/lang/zh-cn.php index 0f6fd2f435..c7d6babdd5 100644 --- a/module/todo/lang/zh-cn.php +++ b/module/todo/lang/zh-cn.php @@ -42,6 +42,8 @@ $lang->todo->desc = '描述'; $lang->todo->private = '私人事务'; $lang->todo->idvalue = '任务或Bug'; +$lang->todo->notes = '(注:“日期”、“名称”必需填写,否则此行无效)'; + $lang->todo->week = '星期'; $lang->todo->today = '今天'; $lang->todo->weekDateList = '一,二,三,四,五,六,天'; diff --git a/module/todo/model.php b/module/todo/model.php index 44635c7bda..6fb0ad8cb6 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -47,6 +47,56 @@ class todoModel extends model return $this->dao->lastInsertID(); } + /** + * Create batch todo + * + * @access public + * @return void + */ + public function batchCreate() + { + $now = helper::now(); + $todos = fixer::input('post') ->get(); + + for($i = 0; $i < $this->config->todo->batchCreate; $i++) + { + if($todos->date[$i] != '' and $todos->name[$i] != '') + { + $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(); + + if(dao::isError()) + { + echo js::error(dao::getError()); + die(js::reload('parent')); + } + } + else + { + unset($todos->date[$i]); + unset($todos->type[$i]); + unset($todos->pri[$i]); + unset($todos->name[$i]); + unset($todos->desc[$i]); + } + } + } + /** * update a todo. * diff --git a/module/todo/view/batchcreate.html.php b/module/todo/view/batchcreate.html.php new file mode 100755 index 0000000000..3cce7d78df --- /dev/null +++ b/module/todo/view/batchcreate.html.php @@ -0,0 +1,48 @@ + + * @package todo + * @version $Id: create.html.php 2741 2012-04-07 07:24:21Z areyou123456 $ + * @link http://www.zentao.net + */ +?> + + +
+ + + + + + + + + + + + + todo->batchCreate; $i++):?> + + + + + + + + + + + + +
todo->batchCreate;?>
idAB;?>todo->date;?>todo->type;?>todo->pri;?>todo->name;?>todo->desc;?>
*";?>todo->typeList, '', "onchange=loadList(this.value,$i+1) class='select-1'");?>todo->priList, $pri, 'class=select-1');?>
*";?>
+
todo->notes;?>
+
+
+
+ + + diff --git a/module/todo/view/footer.html.php b/module/todo/view/footer.html.php index 58b83e9ac7..654e79fa4d 100644 --- a/module/todo/view/footer.html.php +++ b/module/todo/view/footer.html.php @@ -1,8 +1,17 @@