* code for task#933.
* move todoBatchEdit for open source version to pro version.
This commit is contained in:
@@ -13,5 +13,9 @@ INSERT INTO `zt_groupPriv` (`company`, `group`, `module`, `method`) VALUES
|
||||
(1, 2, 'story', 'batchEdit'),
|
||||
(1, 3, 'story', 'batchEdit'),
|
||||
(1, 4, 'story', 'batchEdit'),
|
||||
(1, 5, 'story', 'batchEdit');
|
||||
|
||||
(1, 5, 'story', 'batchEdit'),
|
||||
(1, 1, 'todo', 'batchEdit'),
|
||||
(1, 2, 'todo', 'batchEdit'),
|
||||
(1, 3, 'todo', 'batchEdit'),
|
||||
(1, 4, 'todo', 'batchEdit'),
|
||||
(1, 5, 'todo', 'batchEdit');
|
||||
|
||||
@@ -88,6 +88,7 @@ $lang->my->methodOrder[55] = 'changePassword';
|
||||
$lang->resource->todo->create = 'create';
|
||||
$lang->resource->todo->batchCreate = 'batchCreate';
|
||||
$lang->resource->todo->edit = 'edit';
|
||||
$lang->resource->todo->batchEdit = 'batchEdit';
|
||||
$lang->resource->todo->view = 'view';
|
||||
$lang->resource->todo->delete = 'delete';
|
||||
$lang->resource->todo->export = 'export';
|
||||
|
||||
@@ -17,20 +17,19 @@
|
||||
<div id='featurebar'>
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
echo '<span id="today">' . html::a(inlink('todo', "date=today"), $lang->todo->todayTodos) . '</span>';
|
||||
echo '<span id="yesterday">' . html::a(inlink('todo', "date=yesterday"), $lang->todo->yesterdayTodos). '</span>';
|
||||
echo '<span id="thisweek">' . html::a(inlink('todo', "date=thisweek"), $lang->todo->thisWeekTodos) . '</span>';
|
||||
echo '<span id="lastweek">' . html::a(inlink('todo', "date=lastweek"), $lang->todo->lastWeekTodos) . '</span>';
|
||||
echo '<span id="thismonth">' . html::a(inlink('todo', "date=thismonth"), $lang->todo->thismonthTodos). '</span>';
|
||||
echo '<span id="lastmonth">' . html::a(inlink('todo', "date=lastmonth"), $lang->todo->lastmonthTodos). '</span>';
|
||||
echo '<span id="thisseason">' . html::a(inlink('todo', "date=thisseason"),$lang->todo->thisseasonTodos).'</span>';
|
||||
echo '<span id="thisyear">' . html::a(inlink('todo', "date=thisyear"), $lang->todo->thisyearTodos) . '</span>';
|
||||
echo '<span id="future">' . html::a(inlink('todo', "date=future"), $lang->todo->futureTodos) . '</span>';
|
||||
echo '<span id="all">' . html::a(inlink('todo', "date=all"), $lang->todo->allDaysTodos) . '</span>';
|
||||
echo '<span id="before">' . html::a(inlink('todo', "date=before&account={$app->user->account}&status=undone"), $lang->todo->allUndone) . '</span>';
|
||||
echo "<span id='bydate'>" . html::input('date', $date, "class='w-date date' onchange=changeDate(this.value)") . '</span>';
|
||||
?>
|
||||
<?php
|
||||
echo '<span id="today">' . html::a(inlink('todo', "date=today"), $lang->todo->todayTodos) . '</span>';
|
||||
echo '<span id="yesterday">'. html::a(inlink('todo', "date=yesterday"), $lang->todo->yesterdayTodos). '</span>';
|
||||
echo '<span id="thisweek">' . html::a(inlink('todo', "date=thisweek"), $lang->todo->thisWeekTodos) . '</span>';
|
||||
echo '<span id="lastweek">' . html::a(inlink('todo', "date=lastweek"), $lang->todo->lastWeekTodos) . '</span>';
|
||||
echo '<span id="thismonth">'. html::a(inlink('todo', "date=thismonth"), $lang->todo->thismonthTodos). '</span>';
|
||||
echo '<span id="lastmonth">' . html::a(inlink('todo', "date=lastmonth"), $lang->todo->lastmonthTodos). '</span>';
|
||||
echo '<span id="thisseason">'. html::a(inlink('todo', "date=thisseason"),$lang->todo->thisseasonTodos).'</span>';
|
||||
echo '<span id="thisyear">' . html::a(inlink('todo', "date=thisyear"), $lang->todo->thisyearTodos) . '</span>';
|
||||
echo '<span id="future">' . html::a(inlink('todo', "date=future"), $lang->todo->futureTodos) . '</span>';
|
||||
echo '<span id="all">' . html::a(inlink('todo', "date=all"), $lang->todo->allDaysTodos) . '</span>';
|
||||
echo '<span id="before">' . html::a(inlink('todo', "date=before&account={$app->user->account}&status=undone"), $lang->todo->allUndone) . '</span>';
|
||||
echo "<span id='$date'>" . html::input('date', $date,"class='w-date date'") . '</span>';
|
||||
|
||||
if($type == 'bydate')
|
||||
{
|
||||
if($date == date('Y-m-d'))
|
||||
@@ -64,16 +63,16 @@
|
||||
<th class='w-hour'><?php echo $lang->todo->beginAB;?></th>
|
||||
<th class='w-hour'><?php echo $lang->todo->endAB;?></th>
|
||||
<th class='w-status'><?php echo $lang->todo->status;?></th>
|
||||
<th class='w-100px {sorter:false}'><?php echo $lang->actions;?></th>
|
||||
<th class='w-140px {sorter:false}'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($todos as $todo):?>
|
||||
<tr class='a-center'>
|
||||
<td class='a-center'>
|
||||
<?php if(common::hasPriv('todo', 'import2Today') and $importFuture): ?>
|
||||
<?php if(common::hasPriv('todo', 'batchEdit') or (common::hasPriv('todo', 'import2Today') and $importFuture)):?>
|
||||
<input type='checkbox' name='todoIDList[<?php echo $todo->id;?>]' value='<?php echo $todo->id;?>' />
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
<?php echo $todo->id; ?>
|
||||
</td>
|
||||
<td><?php echo $todo->date == '2030-01-01' ? $lang->todo->dayInFuture : $todo->date;?></td>
|
||||
@@ -83,7 +82,7 @@
|
||||
<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 class='f-right'>
|
||||
<td>
|
||||
<?php
|
||||
echo html::a($this->createLink('todo', 'mark', "id=$todo->id&status=$todo->status"), $lang->todo->{'mark'.ucfirst($todo->status)}, 'hiddenwin');
|
||||
common::printIcon('todo', 'edit', "id=$todo->id", '', 'list');
|
||||
@@ -93,15 +92,24 @@
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
<?php if(count($todos) and ((common::hasPriv('todo', 'import2Today') and $importFuture) or $type == 'all')):?>
|
||||
<?php if(count($todos)):?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan='9'>
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
if(common::hasPriv('todo', 'import2Today') and $importFuture)
|
||||
if(common::hasPriv('todo', 'batchEdit') or (common::hasPriv('todo', 'import2Today') and $importFuture))
|
||||
{
|
||||
echo html::selectAll() . html::selectReverse();
|
||||
}
|
||||
if(common::hasPriv('todo', 'batchEdit'))
|
||||
{
|
||||
$actionLink = $this->createLink('todo', 'batchEdit', "from=myTodo&type=$type&account=$account&status=$status");
|
||||
echo html::commonButton($lang->todo->batchEdit, "onclick=\"changeAction('todoform', 'batchEdit', '$actionLink')\"");
|
||||
|
||||
}
|
||||
if(common::hasPriv('todo', 'import2Today') and $importFuture)
|
||||
{
|
||||
$actionLink = $this->createLink('todo', 'import2Today');
|
||||
echo html::commonButton($lang->todo->import2Today, "onclick=\"changeAction('todoform', 'import2Today', '$actionLink')\"");
|
||||
}
|
||||
|
||||
@@ -125,6 +125,89 @@ class todo extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch edit todo.
|
||||
*
|
||||
* @param string $from example:myTodo, todoBatchEdit.
|
||||
* @param string $type
|
||||
* @param string $account
|
||||
* @param string $status
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function batchEdit($from = '', $type = 'today', $account = '', $status = 'all')
|
||||
{
|
||||
/* Get form data for my-todo. */
|
||||
if($from == 'myTodo')
|
||||
{
|
||||
/* Initialize vars. */
|
||||
$editedTodos = array();
|
||||
$todoIDList = array();
|
||||
$columns = 7;
|
||||
$showSuhosinInfo = false;
|
||||
|
||||
if($account == '') $account = $this->app->user->account;
|
||||
$bugs = $this->bug->getUserBugPairs($account);
|
||||
$tasks = $this->task->getUserTaskPairs($account, $status);
|
||||
$allTodos = $this->todo->getList($type, $account, $status);
|
||||
if($this->post->todoIDList) $todoIDList = $this->post->todoIDList;
|
||||
|
||||
/* Initialize todos whose need to edited. */
|
||||
foreach($allTodos as $todo)
|
||||
{
|
||||
if(in_array($todo->id, $todoIDList))
|
||||
{
|
||||
$editedTodos[$todo->id] = $todo;
|
||||
}
|
||||
}
|
||||
foreach($editedTodos as $todo)
|
||||
{
|
||||
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);
|
||||
$todo->begin = str_replace(':', '', $todo->begin);
|
||||
$todo->end = str_replace(':', '', $todo->end);
|
||||
}
|
||||
|
||||
/* Judge whether the edited todos is too large. */
|
||||
$showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($editedTodos), $columns);
|
||||
|
||||
/* Set the sessions. */
|
||||
$this->app->session->set('showSuhosinInfo', $showSuhosinInfo);
|
||||
|
||||
/* Assign. */
|
||||
$header['title'] = $this->lang->my->common . $this->lang->colon . $this->lang->todo->batchEdit;
|
||||
$position[] = $this->lang->todo->common;
|
||||
$position[] = $this->lang->todo->batchEdit;
|
||||
|
||||
if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo;
|
||||
$this->view->bugs = $bugs;
|
||||
$this->view->tasks = $tasks;
|
||||
$this->view->editedTodos = $editedTodos;
|
||||
$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->view->header = $header;
|
||||
$this->view->position = $position;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
/* Get form data from todo-batchEdit. */
|
||||
elseif($from == 'todoBatchEdit')
|
||||
{
|
||||
$allChanges = $this->todo->batchUpdate();
|
||||
foreach($allChanges as $todoID => $changes)
|
||||
{
|
||||
if(!empty($changes))
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('todo', $todoID, 'edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
|
||||
die(js::locate($this->session->todoList, 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View a todo.
|
||||
*
|
||||
|
||||
@@ -14,6 +14,7 @@ $lang->todo->index = "Index";
|
||||
$lang->todo->create = "Create";
|
||||
$lang->todo->batchCreate = "Batch create";
|
||||
$lang->todo->edit = "Edit";
|
||||
$lang->todo->batchEdit = "Batch edit";
|
||||
$lang->todo->view = "Info";
|
||||
$lang->todo->viewAB = "Info";
|
||||
$lang->todo->markDone = "Undone";
|
||||
|
||||
@@ -14,6 +14,7 @@ $lang->todo->index = "todo一览";
|
||||
$lang->todo->create = "新增";
|
||||
$lang->todo->batchCreate = "批量添加";
|
||||
$lang->todo->edit = "更新TODO";
|
||||
$lang->todo->batchEdit = "批量编辑";
|
||||
$lang->todo->view = "TODO详情";
|
||||
$lang->todo->viewAB = "详情";
|
||||
$lang->todo->markDone = "未完成";
|
||||
|
||||
@@ -127,6 +127,65 @@ class todoModel extends model
|
||||
if(!dao::isError()) return common::createChanges($oldTodo, $todo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch update todos.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchUpdate()
|
||||
{
|
||||
$todos = array();
|
||||
$allChanges = array();
|
||||
$todoIDList = $this->post->todoIDList ? $this->post->todoIDList : array();
|
||||
|
||||
/* Adjust whether the post data is complete, if not, remove the last element of $todoIDList. */
|
||||
if($this->session->showSuhosinInfo) array_pop($taskIDList);
|
||||
|
||||
if(!empty($todoIDList))
|
||||
{
|
||||
/* Initialize todos from the post data. */
|
||||
foreach($todoIDList as $todoID)
|
||||
{
|
||||
$todo->date = $this->post->dates[$todoID];
|
||||
$todo->type = $this->post->types[$todoID];
|
||||
$todo->pri = $this->post->pris[$todoID];
|
||||
$todo->name = $todo->type == 'custom' ? htmlspecialchars($this->post->names[$todoID]) : '';
|
||||
$todo->begin = $this->post->begins[$todoID];
|
||||
$todo->end = $this->post->ends[$todoID];
|
||||
if($todo->type == 'task') $todo->idvalue = isset($this->post->tasks[$todoID]) ? $this->post->tasks[$todoID] : 0;
|
||||
if($todo->type == 'bug') $todo->idvalue = isset($this->post->bugs[$todoID]) ? $this->post->bugs[$todoID] : 0;
|
||||
|
||||
$todos[$todoID] = $todo;
|
||||
unset($todo);
|
||||
}
|
||||
|
||||
foreach($todos as $todoID => $todo)
|
||||
{
|
||||
$oldTodo = $this->getById($todoID);
|
||||
if($oldTodo->type != 'custom') $oldTodo->name = '';
|
||||
$this->dao->update(TABLE_TODO)->data($todo)
|
||||
->autoCheck()
|
||||
->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)
|
||||
->exec();
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
$allChanges[$todoID] = common::createChanges($oldTodo, $todo);
|
||||
}
|
||||
else
|
||||
{
|
||||
die(js::error('todo#' . $todoID . dao::getError(true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of a todo.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* The batch edit view of todo module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Congzhi Chen <congzhi@cnezsoft.com>
|
||||
* @package todo
|
||||
* @version $Id: create.html.php 2741 2012-04-07 07:24:21Z areyou123456 $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<form method='post' target='hiddenwin' action='<?php echo $this->inlink('batchEdit', "from=todoBatchEdit");?>'>
|
||||
<table class='table-1 fixed'>
|
||||
<caption><?php echo $lang->todo->batchEdit . $lang->colon;?></caption>
|
||||
<tr>
|
||||
<th class='w-20px'><?php echo $lang->idAB;?></th>
|
||||
<th class='w-200px'><?php echo $lang->todo->date;?></th>
|
||||
<th class='w-100px'><?php echo $lang->todo->type;?></th>
|
||||
<th class='w-70px'><?php echo $lang->todo->pri;?></th>
|
||||
<th class='w-p65'><?php echo $lang->todo->name;?></th>
|
||||
<th class='w-120px'><?php echo $lang->todo->beginAndEnd;?></th>
|
||||
</tr>
|
||||
|
||||
<?php foreach($editedTodos as $todo):?>
|
||||
<tr class='a-center'>
|
||||
<td><?php echo $todo->id . html::hidden("todoIDList[$todo->id]", $todo->id);?></td>
|
||||
<td><?php echo html::input("dates[$todo->id]", $todo->date, "class='text-1 date'");?></td>
|
||||
<td><?php echo html::select("types[$todo->id]", $lang->todo->typeList, $todo->type, "onchange=loadList(this.value,$todo->id) class='select-1'");?></td>
|
||||
<td><?php echo html::select("pris[$todo->id]", $lang->todo->priList, $todo->pri, 'class=select-1');?></td>
|
||||
<td>
|
||||
<div id='<?php echo "nameBox" . $todo->id;?>' class='hidden'><? echo html::input("names[$todo->id]", '', "class='f-left text-1 hiddenwin'"); echo "<span class='star'>*</span>";?></div>
|
||||
<div class='<?php echo "nameBox" . $todo->id;?>'>
|
||||
<?php
|
||||
if($todo->type == 'custom')
|
||||
{
|
||||
echo html::input("names[$todo->id]", $todo->name, "class='f-left text-1'"); echo "<span class='star'>*</span>";
|
||||
}
|
||||
elseif($todo->type == 'task')
|
||||
{
|
||||
echo html::select("tasks[$todo->id]", $tasks, $todo->idvalue, 'class="select-1 f-left"');
|
||||
}
|
||||
elseif($todo->type == 'bug')
|
||||
{
|
||||
echo html::select("bugs[$todo->id]", $bugs, $todo->idvalue, 'class="select-1 f-left"');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php echo html::select("begins[$todo->id]", $times, $todo->begin) . html::select("ends[$todo->id]", $times, $todo->end);?><td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php if(isset($suhosinInfo)):?>
|
||||
<tr><td colspan='6'><div class='f-left blue'><?php echo $suhosinInfo;?></div></td></tr>
|
||||
<?php endif;?>
|
||||
<tr><td colspan='6' class='a-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include './footer.html.php';?>
|
||||
<script language='Javascript'>selectNext();</script>
|
||||
Reference in New Issue
Block a user