Merge branch 'master' of github.com:easysoft/zentaopms

This commit is contained in:
wangyidong
2015-11-13 09:02:41 +08:00
6 changed files with 87 additions and 37 deletions

View File

@@ -32,7 +32,7 @@
<th> <?php common::printOrderLink('build', $orderBy, $vars, $lang->testtask->build);?></th>
<th class='w-80px'><?php common::printOrderLink('begin', $orderBy, $vars, $lang->testtask->begin);?></th>
<th class='w-80px'><?php common::printOrderLink('end', $orderBy, $vars, $lang->testtask->end);?></th>
<th class='w-50px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->statusAB);?></th>
<th class='w-80px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->statusAB);?></th>
<th class='w-100px'><?php echo $lang->actions;?></th>
</tr>
</thead>

View File

@@ -29,10 +29,9 @@
<tr class='colhead'>
<th class='w-id'> <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
<th> <?php common::printOrderLink('title', $orderBy, $vars, $lang->productplan->title);?></th>
<th class='w-p50'> <?php common::printOrderLink('desc', $orderBy, $vars, $lang->productplan->desc);?></th>
<th class='w-100px'> <?php common::printOrderLink('begin', $orderBy, $vars, $lang->productplan->begin);?></th>
<th class='w-100px'> <?php common::printOrderLink('end', $orderBy, $vars, $lang->productplan->end);?></th>
<th class="w-110px {sorter: false}"><?php echo $lang->actions;?></th>
<th class='w-120px'> <?php common::printOrderLink('begin', $orderBy, $vars, $lang->productplan->begin);?></th>
<th class='w-120px'> <?php common::printOrderLink('end', $orderBy, $vars, $lang->productplan->end);?></th>
<th class="w-120px {sorter: false}"><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
@@ -43,7 +42,6 @@
<?php echo $plan->id;?>
</td>
<td class='text-left' title="<?php echo $plan->title?>"><?php echo html::a(inlink('view', "id=$plan->id"), $plan->title);?></td>
<td class='text-left content'><div class='article-content'><?php echo $plan->desc;?></div></td>
<td><?php echo $plan->begin;?></td>
<td><?php echo $plan->end;?></td>
<td class='text-center'>
@@ -64,7 +62,7 @@
</tbody>
<tfoot>
<tr>
<td colspan='6'>
<td colspan='5'>
<?php echo html::selectButton();?>
<?php if(common::hasPriv('productplan', 'batchEdit')) echo html::submitButton($lang->edit);?>
<?php $pager->show();?>

View File

@@ -351,21 +351,24 @@ class project extends control
die(js::locate(inlink('importTask', "toProject=$toProject&fromProject=$fromProject"), 'parent'));
}
$project = $this->commonAction($toProject);
$projects = $this->project->getProjectsToImport();
$project = $this->commonAction($toProject);
$branches = $this->project->getProjectBranches($toProject);
$tasks = $this->project->getTasks2Imported($branches);
$projects = $this->project->getProjectsToImport(array_keys($tasks));
unset($projects[$toProject]);
unset($tasks[$toProject]);
if($fromProject == 0)
{
$tasks2Imported = array();
foreach($projects as $id => $projectName)
{
$tasks2Imported = array_merge($tasks2Imported, $this->project->getTasks2Imported($id));
$tasks2Imported = array_merge($tasks2Imported, $tasks[$id]);
}
}
else
{
$tasks2Imported = $this->project->getTasks2Imported($fromProject);
$tasks2Imported = $tasks[$fromProject];
}
/* Save session. */

View File

@@ -31,3 +31,17 @@ $(function()
$('#importTeams a').click(function(){importTeam($(this).data('id')); $('#importTeamModal').modal('hide')});
});
function addItem()
{
var item = $('#addItem').html().replace(/%i%/g, i).replace(/%memberCount%/g, memberCount);
$('#submit').before('<tr class="addedItem">' + item + '</tr>');
$('#accounts' + memberCount).trigger('liszt:updated');
$('#accounts' + memberCount).chosen(defaultChosenOptions);
i ++;
memberCount ++;
}
function deleteItem(obj)
{
$(obj).closest('.addedItem').remove();
}

View File

@@ -800,17 +800,16 @@ class projectModel extends model
/**
* Get projects to import
*
*
* @param array $projectIds
* @access public
* @return void
* @return array
*/
public function getProjectsToImport()
public function getProjectsToImport($projectIds)
{
$projects = $this->dao->select('distinct t1.*')->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_TASK)->alias('t2')->on('t1.id=t2.project')
->where('t2.status')->notIN('done,closed')
->andWhere('t2.deleted')->eq(0)
->andWhere('t1.deleted')->eq(0)
$projects = $this->dao->select('*')->from(TABLE_PROJECT)
->where('id')->in($projectIds)
->andWhere('deleted')->eq(0)
->orderBy('id desc')
->fetchAll('id');
@@ -876,18 +875,22 @@ class projectModel extends model
}
/**
* Get rasks can be imported.
* Get tasks can be imported.
*
* @param int $projectID
* @param array $branches
* @access public
* @return array
*/
public function getTasks2Imported($fromProject)
public function getTasks2Imported($branches)
{
$this->loadModel('task');
$tasks = array();
$projectTasks = $this->task->getProjectTasks($fromProject, 'wait,doing,pause,cancel');
$tasks = array_merge($tasks, $projectTasks);
$tasks = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName')->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account')
->where('t1.status')->in('wait, doing, pause, cancel')
->andWhere('t1.deleted')->eq(0)
->andWhere("(t1.story = 0 OR t2.branch in ('0','" . join("','", $branches) . "'))")
->fetchGroup('project', 'id');
return $tasks;
}
@@ -1662,4 +1665,18 @@ class projectModel extends model
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($newOrder)->where('id')->eq($id)->exec();
}
}
/**
* Get branches of project.
*
* @param int $projectID
* @access public
* @return array
*/
public function getProjectBranches($projectID)
{
return $this->dao->select('product, branch')->from(TABLE_PROJECTPRODUCT)
->where('project')->eq($projectID)
->fetchPairs();
}
}

View File

@@ -32,6 +32,8 @@
<th><?php echo $lang->team->role;?></th>
<th class='w-100px'><?php echo $lang->team->days;?></th>
<th class='w-100px'><?php echo $lang->team->hours;?></th>
<th class="w-40px"> <?php echo $lang->actions;?></th>
<th class="w-40px"> <?php echo $lang->delete;?></th>
</tr>
</thead>
<?php $i = 1; $memberCount = 0;?>
@@ -47,12 +49,14 @@
<input type='hidden' name='modes[]' value='update' />
<input type='hidden' name='accounts[]' value='<?php echo $member->account;?>' />
</td>
<td><a href='javascript:;' onclick='addItem()' class='btn btn-block'><i class='icon-plus'></i></a></td>
<td><a href='javascript:;' onclick='deleteItem()' class='disabled btn btn-block'><i class='icon icon-remove'></i></a></td>
</tr>
<?php $i ++; $memberCount ++;?>
<?php endforeach;?>
<?php foreach($members2Import as $member2Import):?>
<tr>
<tr class='addedItem'>
<td><?php echo html::select("accounts[$memberCount]", $users, $member2Import->account, "class='select-2 chosen' onchange='setRole(this.value, $i)'");?></td>
<td><input type='text' name='roles[]' id='role<?php echo $i;?>' class='form-control' value='<?php echo $member2Import->role;?>' /></td>
<td><input type='text' name='days[]' id='days<?php echo $i;?>' class='form-control' value='<?php echo $project->days?>'/></td>
@@ -60,29 +64,43 @@
<input type='text' name='hours[]' id='hours<?php echo $i;?>' class='form-control' value='<?php echo $member2Import->hours;?>' />
<input type='hidden' name='modes[]' value='create' />
</td>
<td><a href='javascript:;' onclick='addItem()' class='btn btn-block'><i class='icon-plus'></i></a></td>
<td><a href='javascript:;' onclick='deleteItem(this)' class='btn btn-block'><i class='icon icon-remove'></i></a></td>
</tr>
<?php $i ++; $memberCount ++;?>
<?php endforeach;?>
<?php
$count = count($users) - 1;
if($count > PROJECTMODEL::LINK_MEMBERS_ONE_TIME) $count = PROJECTMODEL::LINK_MEMBERS_ONE_TIME;
?>
<?php for($j = 0; $j < $count; $j ++):?>
<tr>
<?php for($j = 0; $j < 5; $j ++):?>
<tr class='addedItem'>
<td><?php echo html::select("accounts[$memberCount]", $users, '', "class='select-2 chosen' onchange='setRole(this.value, $i)'");?></td>
<td><input type='text' name='roles[]' id='role<?php echo ($i);?>' class='form-control' /></td>
<td><input type='text' name='days[]' id='days<?php echo ($i);?>' class='form-control' value='<?php echo $project->days?>'/></td>
<td><input type='text' name='roles[]' id='role<?php echo ($i);?>' class='form-control' /></td>
<td><input type='text' name='days[]' id='days<?php echo ($i);?>' class='form-control' value='<?php echo $project->days?>'/></td>
<td>
<input type='text' name='hours[]' id='hours<?php echo ($i);?>' class='form-control' value='7' />
<input type='hidden' name='modes[]' value='create' />
</td>
<td><a href='javascript:;' onclick='addItem()' class='btn btn-block'><i class='icon-plus'></i></a></td>
<td><a href='javascript:;' onclick='deleteItem(this)' class='btn btn-block'><i class='icon icon-remove'></i></a></td>
</tr>
<?php $i ++; $memberCount ++;?>
<?php endfor;?>
<tr>
<td colspan='4' class='text-center'>
<?php js::set('i', $i);?>
<?php js::set('memberCount', $memberCount);?>
<?php $i = '%i%'; $memberCount = '%memberCount%';?>
<tr id='addItem' class='hidden'>
<td><?php echo html::select("accounts[$memberCount]", $users, '', "class='select-2' onchange='setRole(this.value, $i)'");?></td>
<td><input type='text' name='roles[]' id='role<?php echo ($i);?>' class='form-control' /></td>
<td><input type='text' name='days[]' id='days<?php echo ($i);?>' class='form-control' value='<?php echo $project->days?>'/></td>
<td>
<input type='text' name='hours[]' id='hours<?php echo ($i);?>' class='form-control' value='7' />
<input type='hidden' name='modes[]' value='create' />
</td>
<td><a href='javascript:;' onclick='addItem()' class='btn btn-block'><i class='icon-plus'></i></a></td>
<td><a href='javascript:;' onclick='deleteItem(this)' class='btn btn-block'><i class='icon icon-remove'></i></a></td>
</tr>
<tr id='submit'>
<td colspan='6' class='text-center'>
<?php echo html::submitButton() ?>
</td>
</tr>