Merge branch 'sprint/gantt_upgrade' of https://gitlab.zcorp.cc/easycorp/zentaopms into sprint/max40_gantt_upgrade
This commit is contained in:
@@ -86,6 +86,18 @@ class programplan extends control
|
||||
$plans = $this->programplan->getDataForGantt($projectID, $this->productID, $baselineID, $selectCustom, false);
|
||||
}
|
||||
|
||||
if($type == 'assignedTo')
|
||||
{
|
||||
$owner = $this->app->user->account;
|
||||
$module = 'programplan';
|
||||
$section = 'browse';
|
||||
$object = 'stageCustom';
|
||||
$selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
if(strpos($selectCustom, 'date') !== false) $dateDetails = 0;
|
||||
|
||||
$plans = $this->programplan->getDataForGanttGroupByAssignedTo($projectID, $this->productID, $baselineID, $selectCustom, false);
|
||||
}
|
||||
|
||||
if($type == 'lists')
|
||||
{
|
||||
$sort = common::appendOrder($orderBy);
|
||||
@@ -103,6 +115,7 @@ class programplan extends control
|
||||
$this->view->selectCustom = $selectCustom;
|
||||
$this->view->dateDetails = $dateDetails;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->ganttType = $type;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -248,14 +261,8 @@ class programplan extends control
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
if($_POST['type'] == 'task')
|
||||
{
|
||||
$objectID = explode('-', $_POST['id'])[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$objectID = $_POST['id'];
|
||||
}
|
||||
if(!isset($_POST['id']) or empty($_POST['id'])) return $this->send(array('result' => 'fail', 'message' => ''));
|
||||
$objectID = $_POST['id'];
|
||||
|
||||
$this->loadModel('task')->saveTaskDrag($objectID, $_POST['type']);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
@@ -86,3 +86,7 @@ $lang->programplan->error->parentWorkload = '子阶段的工作量之和不能
|
||||
$lang->programplan->error->parentDuration = '子阶段计划开始、计划完成不能超过父阶段';
|
||||
$lang->programplan->error->sameName = '阶段名称不能相同!';
|
||||
$lang->programplan->error->taskDrag = '%s的任务不可以拖动';
|
||||
|
||||
|
||||
$lang->programplan->ganttBrowseType['gantt'] = '按阶段分组';
|
||||
$lang->programplan->ganttBrowseType['assignedTo'] = '按指派给分组';
|
||||
|
||||
@@ -144,6 +144,7 @@ class programplanModel extends model
|
||||
* @param int $baselineID
|
||||
* @param string $selectCustom
|
||||
* @param bool $returnJson
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
@@ -329,6 +330,193 @@ class programplanModel extends model
|
||||
}
|
||||
|
||||
$datas['data'] = isset($datas['data']) ? array_values($datas['data']) : array();
|
||||
// a($datas['data']);exit;
|
||||
return $returnJson ? json_encode($datas) : $datas;
|
||||
}
|
||||
|
||||
public function getDataForGanttGroupByAssignedTo($executionID, $productID, $baselineID = 0, $selectCustom = '', $returnJson = true)
|
||||
{
|
||||
$plans = $this->getStage($executionID, $productID);
|
||||
|
||||
$datas = array();
|
||||
$planIdList = array();
|
||||
$isMilestone = "<icon class='icon icon-flag icon-sm red'></icon> ";
|
||||
$stageIndex = array();
|
||||
|
||||
foreach($plans as $plan)
|
||||
{
|
||||
$planIdList[$plan->id] = $plan->id;
|
||||
}
|
||||
|
||||
$taskSign = "<span class='task-label'>[ T ] </span>";
|
||||
$taskPri = "<span class='label-pri label-pri-%s' title='%s'>%s</span> ";
|
||||
|
||||
/* Judge whether to display tasks under the stage. */
|
||||
$owner = $this->app->user->account;
|
||||
$module = 'programplan';
|
||||
$section = 'browse';
|
||||
$object = 'stageCustom';
|
||||
if(empty($selectCustom)) $selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
|
||||
$tasksGroup = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)->andWhere('execution')->in($planIdList)->fetchGroup('assignedTo','id');
|
||||
$users = $this->loadModel('user')->getPairs('noletter');
|
||||
|
||||
foreach($tasksGroup as $group => $tasks)
|
||||
{
|
||||
foreach($tasks as $id => $task)
|
||||
{
|
||||
if($task->mode == 'multi')
|
||||
{
|
||||
$team = $this->dao->select('t1.*,t2.realname')->from(TABLE_TEAM)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account')
|
||||
->where('t1.root')->eq($id)->andWhere('t1.type')->eq('task')->orderBy('t1.order')->fetchAll('account');
|
||||
foreach($team as $account => $member)
|
||||
{
|
||||
if($account == $group) continue;
|
||||
if(!isset($taskGroups[$account])) $taskGroups[$account] = array();
|
||||
|
||||
$taskGroups[$account][$id] = clone $task;
|
||||
$taskGroups[$account][$id]->id = $id . '_' . $account;
|
||||
$taskGroups[$account][$id]->realID = $id;
|
||||
$taskGroups[$account][$id]->assignedTo = $account;
|
||||
$taskGroups[$account][$id]->realname = $member->realname;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$groupID = 0;
|
||||
foreach($tasksGroup as $group => $tasks)
|
||||
{
|
||||
$groupID --;
|
||||
$groupName = $group;
|
||||
$groupName = zget($users, $group);
|
||||
$dataGroup = new stdclass();
|
||||
$dataGroup->id = $groupID;
|
||||
$dataGroup->type = 'group';
|
||||
$dataGroup->text = $groupName;
|
||||
$dataGroup->percent = '';
|
||||
$dataGroup->attribute = '';
|
||||
$dataGroup->milestone = '';
|
||||
$dataGroup->owner_id = $group;
|
||||
$dataGroup->status = '';
|
||||
$dataGroup->begin = '';
|
||||
$dataGroup->deadline = '';
|
||||
$dataGroup->realBegan = '';
|
||||
$dataGroup->realEnd = '';
|
||||
$dataGroup->parent = 0;
|
||||
$dataGroup->open = true;
|
||||
$dataGroup->progress = '';
|
||||
$dataGroup->start_date = '';
|
||||
$dataGroup->endDate = '';
|
||||
$dataGroup->duration = 0;
|
||||
|
||||
$groupKey = $groupID . $group;
|
||||
$datas['data'][$groupKey] = $dataGroup;
|
||||
|
||||
foreach($tasks as $taskID => $task)
|
||||
{
|
||||
// if($task->parent > 0 and $task->assignedTo)
|
||||
// {
|
||||
// $a = $task->parent;
|
||||
// a($tasksGroup[$task->assignedTo]);
|
||||
// a($task->parent);exit;
|
||||
// }
|
||||
$execution = zget($plans, $task->execution, array());
|
||||
|
||||
$priIcon = sprintf($taskPri, $task->pri, $task->pri, $task->pri);
|
||||
|
||||
$estStart = helper::isZeroDate($task->estStarted) ? '' : $task->estStarted;
|
||||
$estEnd = helper::isZeroDate($task->deadline) ? '' : $task->deadline;
|
||||
$realBegan = helper::isZeroDate($task->realStarted) ? '' : $task->realStarted;
|
||||
$realEnd = (in_array($task->status, array('done', 'closed')) and !helper::isZeroDate($task->finishedDate)) ? $task->finishedDate : '';
|
||||
|
||||
$start = $realBegan ? $realBegan : $estStart;
|
||||
$end = $realEnd ? $realEnd : $estEnd;
|
||||
if(empty($start) and $execution) $start = $execution->begin;
|
||||
if(empty($end) and $execution) $end = $execution->end;
|
||||
if($start > $end) $end = $start;
|
||||
|
||||
$data = new stdclass();
|
||||
$data->id = $task->id;
|
||||
$data->type = 'task';
|
||||
$data->text = $taskSign . $priIcon . $task->name;
|
||||
$data->percent = '';
|
||||
$data->status = $this->processStatus('task', $task);
|
||||
$data->owner_id = $task->assignedTo;
|
||||
$data->attribute = '';
|
||||
$data->milestone = '';
|
||||
$data->begin = $start;
|
||||
$data->deadline = $end;
|
||||
$data->realBegan = $realBegan;
|
||||
$data->realEnd = $realEnd;
|
||||
$data->pri = $task->pri;
|
||||
$data->parent = ($task->parent > 0 and $task->assignedTo != '') ? $task->parent : $groupID;
|
||||
$data->open = true;
|
||||
$progress = $task->consumed ? round($task->consumed / ($task->left + $task->consumed), 3) : 0;
|
||||
$data->progress = $progress;
|
||||
$data->taskProgress = ($progress * 100) . '%';
|
||||
$data->start_date = $start;
|
||||
$data->endDate = $end;
|
||||
$data->duration = 0;
|
||||
|
||||
/* If multi task then show the teams. */
|
||||
// if($task->mode == 'multi' and !empty($taskTeams[$task->id]))
|
||||
// {
|
||||
// $teams = array_keys($taskTeams[$task->id]);
|
||||
// $assigneds = array();
|
||||
// foreach($teams as $assignedTo) $assigneds[] = zget($users, $assignedTo);
|
||||
// $data->owner_id = join(',', $assigneds);
|
||||
// }
|
||||
|
||||
if($data->endDate > $data->start_date) $data->duration = helper::diffDate($data->endDate, $data->start_date) + 1;
|
||||
if($data->start_date) $data->start_date = date('d-m-Y', strtotime($data->start_date));
|
||||
if($data->start_date == '' or $data->endDate == '') $data->duration = 0;
|
||||
|
||||
if(strpos($selectCustom, 'task') !== false) $datas['data'][$data->id] = $data;
|
||||
|
||||
foreach($stageIndex as $index => $stage)
|
||||
{
|
||||
if($stage['planID'] == $task->execution)
|
||||
{
|
||||
$stageIndex[$index]['progress']['totalConsumed'] += $task->consumed;
|
||||
$stageIndex[$index]['progress']['totalReal'] += ($task->left + $task->consumed);
|
||||
|
||||
$parent = $stage['parent'];
|
||||
if(isset($stageIndex[$parent]))
|
||||
{
|
||||
$stageIndex[$parent]['progress']['totalConsumed'] += $task->consumed;
|
||||
$stageIndex[$parent]['progress']['totalReal'] += ($task->left + $task->consumed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate the progress of the phase. */
|
||||
foreach($stageIndex as $index => $stage)
|
||||
{
|
||||
$progress = empty($stage['progress']['totalConsumed']) ? 0 : round($stage['progress']['totalConsumed'] / $stage['progress']['totalReal'], 3);
|
||||
$datas['data'][$index]->progress = $progress;
|
||||
|
||||
$progress = ($progress * 100) . '%';
|
||||
$datas['data'][$index]->taskProgress = $progress;
|
||||
}
|
||||
|
||||
$datas['links'] = array();
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
$relations = $this->dao->select('*')->from(TABLE_RELATIONOFTASKS)->where('execution')->in($planIdList)->orderBy('task,pretask')->fetchAll();
|
||||
foreach($relations as $relation)
|
||||
{
|
||||
$link['source'] = $relation->execution . '-' . $relation->pretask;
|
||||
$link['target'] = $relation->execution . '-' . $relation->task;
|
||||
$link['type'] = $this->config->execution->gantt->linkType[$relation->condition][$relation->action];
|
||||
$datas['links'][] = $link;
|
||||
}
|
||||
}
|
||||
|
||||
$datas['data'] = isset($datas['data']) ? array_values($datas['data']) : array();
|
||||
|
||||
return $returnJson ? json_encode($datas) : $datas;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<?php if($type == 'gantt') include './gantt.html.php';?>
|
||||
<?php if($type == 'gantt' or $type == 'assignedTo') include './gantt.html.php';?>
|
||||
<?php if($type == 'lists') include './list.html.php';?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* @version $Id: gantt.html.php 4903 2013-06-26 05:32:59Z wyd621@gmail.com $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php chdir(__DIR__);?>
|
||||
<?php include '../../common/view/gantt.html.php';?>
|
||||
@@ -64,6 +65,8 @@ form {display: block; margin-top: 0em; margin-block-end: 1em;}
|
||||
.gantt-fullscreen #mainMenu,
|
||||
.gantt-fullscreen #footer {display: none!important;}
|
||||
.gantt-fullscreen #mainContent {position: fixed; top: 0; right: 0; bottom: 0; left: 0}
|
||||
.gantt_grid_head_cell.gantt_grid_head_text{overflow:visible;}
|
||||
|
||||
</style>
|
||||
<?php js::set('customUrl', $this->createLink('programplan', 'ajaxCustom'));?>
|
||||
<?php js::set('dateDetails', $dateDetails);?>
|
||||
@@ -93,6 +96,16 @@ form {display: block; margin-top: 0em; margin-block-end: 1em;}
|
||||
</div>
|
||||
<?php $fileName = "gantt-export-{$projectID}";?>
|
||||
<a id='ganttDownload' target='hiddenwin' download='<?php echo "{$fileName}.png";?>'></a>
|
||||
<?php
|
||||
$typeHtml = '<div class="btn-group">';
|
||||
$typeHtml .= '<button class="btn btn-link" data-toggle="dropdown"><span class="text">' . $lang->programplan->ganttBrowseType[$ganttType] . '</span> <span class="caret"></span></button>';
|
||||
$typeHtml .= '<ul class="dropdown-menu">';
|
||||
foreach($lang->programplan->ganttBrowseType as $browseType => $typeName)
|
||||
{
|
||||
$typeHtml .= '<li ' . ($ganttType == $browseType ? "class='active'" : '') . '>' . html::a($this->createLink('programplan', 'browse', "projectID=$projectID&productID=$productID&type=$browseType"), $typeName) . '</li>';
|
||||
}
|
||||
$typeHtml .= '</ul></div>';
|
||||
?>
|
||||
</div>
|
||||
<script>
|
||||
var scriptLoadedMap = {};
|
||||
@@ -403,7 +416,7 @@ function validateResources(id)
|
||||
|
||||
/* Check data. */
|
||||
var postData = {
|
||||
'id' : task.id,
|
||||
'id' : type == 'task' ? task.id.split("-")[1] : task.id,
|
||||
'start_date': from.toLocaleDateString('en-CA'),
|
||||
'end_date' : to.toLocaleDateString('en-CA'),
|
||||
'type' : type
|
||||
@@ -489,7 +502,7 @@ $(function()
|
||||
{name: 'realEnd', align: 'center', width: 80}
|
||||
];
|
||||
|
||||
gantt.locale.labels.column_text = "<?php echo $lang->programplan->name;?>";
|
||||
gantt.locale.labels.column_text = <?php echo json_encode($typeHtml);?>;
|
||||
gantt.locale.labels.column_status = "<?php echo $lang->statusAB;?>";
|
||||
gantt.locale.labels.column_percent = "<?php echo $lang->programplan->percentAB;?>";
|
||||
gantt.locale.labels.column_taskProgress = "<?php echo $lang->programplan->taskProgress;?>";
|
||||
|
||||
Reference in New Issue
Block a user