resolve conflict
This commit is contained in:
+2
-1
@@ -1 +1,2 @@
|
||||
ALTER TABLE `zt_task` add `order` mediumint(8) NOT NULL AFTER `activatedDate`;
|
||||
ALTER TABLE `zt_task` ADD `order` mediumint(8) NOT NULL DEFAULT '0' AFTER `activatedDate`;
|
||||
ALTER TABLE `zt_task` ADD INDEX `order` (`order`);
|
||||
|
||||
@@ -1537,6 +1537,7 @@ CREATE TABLE IF NOT EXISTS `zt_task` (
|
||||
KEY `story` (`story`),
|
||||
KEY `parent` (`parent`),
|
||||
KEY `assignedTo` (`assignedTo`)
|
||||
KEY `order` (`order`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
-- DROP TABLE IF EXISTS `zt_taskestimate`;
|
||||
CREATE TABLE IF NOT EXISTS `zt_taskestimate` (
|
||||
|
||||
@@ -273,21 +273,19 @@ class programplan extends control
|
||||
/**
|
||||
* Save task drag action.
|
||||
*
|
||||
* @param int $productID
|
||||
*
|
||||
* @access public
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxSaveGanttMove()
|
||||
public function ajaxSaveGanttMove($productID = 0)
|
||||
{
|
||||
if($_POST)
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
$IdList = explode('-', $data->id);
|
||||
$executionID = $IdList[0];
|
||||
$taskID = $IdList[1];
|
||||
|
||||
return 1231231;
|
||||
$this->loadModel('task')->saveTaskMove($productID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success'));
|
||||
}
|
||||
|
||||
return $this->send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ class programplanModel extends model
|
||||
|
||||
if(empty($selectCustom)) $selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
|
||||
$tasks = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)->andWhere('execution')->in($planIdList)->fetchAll('id');
|
||||
$tasks = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)->andWhere('execution')->in($planIdList)->orderBy('execution_asc, order_asc, id_desc')->fetchAll('id');
|
||||
$taskTeams = $this->dao->select('root,account')->from(TABLE_TEAM)->where('type')->eq('task')->andWhere('root')->in(array_keys($tasks))->fetchGroup('root', 'account');
|
||||
$users = $this->loadModel('user')->getPairs('noletter');
|
||||
|
||||
|
||||
@@ -479,7 +479,6 @@ $(function()
|
||||
gantt.config.order_branch = ganttType == 'assignedTo' ? false : 'marker';
|
||||
gantt.config.drag_progress = false;
|
||||
gantt.config.drag_links = false;
|
||||
gantt.config.drag_resize = false;
|
||||
gantt.config.smart_rendering = true;
|
||||
gantt.config.smart_scales = true;
|
||||
gantt.config.static_background = true;
|
||||
@@ -643,18 +642,20 @@ $(function()
|
||||
var link = createLink('programplan', 'ajaxSaveGanttMove');
|
||||
|
||||
//prevent moving to another position.
|
||||
if(task.parent != parent || id.indexOf('-') == -1) return false;
|
||||
|
||||
$.ajax({
|
||||
if(task.parent != parent || id.indexOf('-') == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$.ajax({
|
||||
url: link,
|
||||
dataType: "json",
|
||||
data: {id: id, type: task.type, order: tindex},
|
||||
type: "post",
|
||||
success: function(result)
|
||||
{
|
||||
var target = result;
|
||||
}
|
||||
});
|
||||
dataType: "json",
|
||||
data: {id: id, type: task.type, index: tindex},
|
||||
type: "post",
|
||||
success: function(result){}
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -3988,4 +3988,74 @@ class taskModel extends model
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save task order.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function saveTaskMove($productID = 0)
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
$targetTaskID = explode('-', $data->dropTarget)[1];
|
||||
$IdList = explode('-', $data->id);
|
||||
$executionID = $IdList[0];
|
||||
$taskID = $IdList[1];
|
||||
$index = (int)$data->index;
|
||||
|
||||
$oldTask = $this->loadModel('task')->getByID($taskID);
|
||||
$targetTask = $this->loadModel('task')->getByID($targetTaskID);
|
||||
$execution = $this->loadModel('execution')->getByID($executionID);
|
||||
$tasks = $this->dao->select('id')->from(TABLE_TASK)
|
||||
->where('execution')->eq($executionID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->beginIF($oldTask->parent <= 0)->andWhere('parent')->le(0)
|
||||
->beginIF($oldTask->parent > 0)->andWhere('parent')->eq($oldTask->parent)
|
||||
->fetchPairs('id');
|
||||
$taskOrderSum = $this->dao->select('SUM(`order`) as sum')->from(TABLE_TASK)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('execution')->eq($executionID)
|
||||
->beginIF($oldTask->parent <= 0)->andWhere('parent')->le(0)
|
||||
->beginIF($oldTask->parent > 0)->andWhere('parent')->eq($oldTask->parent)
|
||||
->fetch('sum');
|
||||
|
||||
if(!$taskOrderSum)
|
||||
{
|
||||
$order = 1;
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
$this->dao->update(TABLE_TASK)->set('`order`')->eq($order)->where('id')->eq($task)->exec();
|
||||
$order ++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$order = ++ $index;
|
||||
$oldOrder = (int)$oldTask->order;
|
||||
if($order > $oldOrder)
|
||||
{
|
||||
$this->dao->update(TABLE_TASK)->set('`order`')->eq('`order`-1')
|
||||
->where('execution')->eq($executionID)
|
||||
->andWhere('`order`')->le($order)
|
||||
->andWhere('`order`')->gt($oldOrder)
|
||||
->beginIF($oldTask->parent <= 0)->andWhere('parent')->le(0)
|
||||
->beginIF($oldTask->parent > 0)->andWhere('parent')->eq($oldTask->parent)
|
||||
->exec();
|
||||
}
|
||||
else if($order < $oldOrder)
|
||||
{
|
||||
$this->dao->update(TABLE_TASK)->set('`order`=`order`+1')
|
||||
->where('execution')->eq($executionID)
|
||||
->andWhere('`order`')->lt($oldOrder)
|
||||
->andWhere('`order`')->ge($order)
|
||||
->beginIF($oldTask->parent <= 0)->andWhere('parent')->le(0)
|
||||
->beginIF($oldTask->parent > 0)->andWhere('parent')->eq($oldTask->parent)
|
||||
->exec();
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_TASK)->set('`order`')->eq($order)->where('id')->eq($taskID)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user