* adjust code for task#757 which batch create todo.
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
$config->todo->batchCreate = 10;
|
||||
$config->todo->batchCreate = 8;
|
||||
|
||||
$config->todo->create->requiredFields = 'name';
|
||||
$config->todo->edit->requiredFields = 'name';
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 = '今天';
|
||||
|
||||
+27
-23
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,28 +11,27 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<form method='post'>
|
||||
<table class='table-1 fixed'>
|
||||
<caption><?php echo $lang->todo->batchCreate;?></caption>
|
||||
<caption><?php echo $lang->todo->batchCreate . $lang->colon . $date;?></caption>
|
||||
<tr>
|
||||
<th class='w-20px'><?php echo $lang->idAB;?></th>
|
||||
<th class='w-150px'><?php echo $lang->todo->date;?></th>
|
||||
<th class='w-100px'><?php echo $lang->todo->type;?></th>
|
||||
<th class='w-100px'><?php echo $lang->todo->pri;?></th>
|
||||
<th class='w-400px'><?php echo $lang->todo->name;?></th>
|
||||
<th class='w-300px'><?php echo $lang->todo->desc;?></th>
|
||||
<th class='w-70px'><?php echo $lang->todo->pri;?></th>
|
||||
<th class='w-p40'><?php echo $lang->todo->name;?></th>
|
||||
<th class='w-p30'><?php echo $lang->todo->desc;?></th>
|
||||
<th class='w-150px'><?php echo $lang->todo->beginAndEnd;?></th>
|
||||
</tr>
|
||||
|
||||
<?php $pri = 3;?>
|
||||
<?php for($i = 0; $i < $config->todo->batchCreate; $i++):?>
|
||||
<tr class='a-center'>
|
||||
<td><?php echo $i+1;?></td>
|
||||
<td><?php echo html::input("date[$i]", $date, "class='select-2 date'"); echo "<span class='star'>*</span>";?></td>
|
||||
<td><?php echo html::select("type[$i]", $lang->todo->typeList, '', "onchange=loadList(this.value,$i+1) class='select-1'");?></td>
|
||||
<td><?php echo html::select("pri[$i]", $lang->todo->priList, $pri, 'class=select-1');?></td>
|
||||
<td><div id='<?php echo "nameBox" . ($i+1);?>'><?php echo html::input("name[$i]", '', 'class=text-1'); echo "<span class='star'>*</span>";?></div></td>
|
||||
<td><?php echo html::textarea("desc[$i]", '', "rows='1' class='text-1'");?></td>
|
||||
<td><?php echo html::select("types[$i]", $lang->todo->typeList, '', "onchange=loadList(this.value,$i+1) class='select-1'");?></td>
|
||||
<td><?php echo html::select("pris[$i]", $lang->todo->priList, $pri, 'class=select-1');?></td>
|
||||
<td><div id='<?php echo "nameBox" . ($i+1);?>' class='nameBox'><?php echo html::input("names[$i]", '', 'class="f-left text-1"'); echo "<span class='star'>*</span>";?></div></td>
|
||||
<td><?php echo html::textarea("descs[$i]", '', "rows='2' class=text-1");?></td>
|
||||
<td><?php echo html::select('begins[]', $times, '') . html::select('ends[]', $times, '');?><td>
|
||||
</tr>
|
||||
<?php endfor;?>
|
||||
<tr>
|
||||
@@ -45,4 +44,3 @@
|
||||
</form>
|
||||
<?php include './footer.html.php';?>
|
||||
<script language='Javascript'>selectNext();</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->todo->name;?></th>
|
||||
<td><div id='nameBox'><?php echo html::input('name', '', 'class=text-1');?></div></td>
|
||||
<td><div id='nameBox' class='nameBox'><?php echo html::input('name', '', 'class=text-1');?></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->todo->desc;?></th>
|
||||
|
||||
@@ -1,31 +1,46 @@
|
||||
<script language='Javascript'>
|
||||
account='<?php echo $app->user->account;?>';
|
||||
function loadList(type)
|
||||
customHtml = $('.nameBox').html();
|
||||
function loadList(type, id)
|
||||
{
|
||||
if(arguments[1])
|
||||
if(id)
|
||||
{
|
||||
divID = '#nameBox' + arguments[1];
|
||||
customHtml = $('#nameBox' + arguments[1]).html();
|
||||
divID = '#nameBox' + id;
|
||||
customHtml = customHtml.replace('nameBox', 'nameBox' + id);
|
||||
}
|
||||
else
|
||||
{
|
||||
divID = '#nameBox';
|
||||
customHtml = $('#nameBox').html();
|
||||
}
|
||||
|
||||
if(type == 'bug')
|
||||
{
|
||||
link = createLink('bug', 'ajaxGetUserBugs', 'account=' + account);
|
||||
if(id)
|
||||
{
|
||||
link = createLink('bug', 'ajaxGetUserBugs', 'account=' + account + '&id=' + id);
|
||||
}
|
||||
else
|
||||
{
|
||||
link = createLink('bug', 'ajaxGetUserBugs', 'account=' + account);
|
||||
}
|
||||
}
|
||||
else if(type == 'task')
|
||||
{
|
||||
link = createLink('task', 'ajaxGetUserTasks', 'account=' + account);
|
||||
if(id)
|
||||
{
|
||||
link = createLink('task', 'ajaxGetUserTasks', 'account=' + account + '&id=' + id);
|
||||
}
|
||||
else
|
||||
{
|
||||
link = createLink('task', 'ajaxGetUserTasks', 'account=' + account);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(type == 'bug' || type == 'task')
|
||||
{
|
||||
$(divID).load(link);
|
||||
}
|
||||
else if(type == 'custom')
|
||||
else if(type == 'custom')
|
||||
{
|
||||
$(divID).html(customHtml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user