* Finish task #36019.
This commit is contained in:
@@ -55,6 +55,6 @@ $(document).on('click', 'td.content .more', function(e)
|
||||
*/
|
||||
function getPlanID(obj)
|
||||
{
|
||||
var planID = $(obj).attr("data-id")
|
||||
var planID = $(obj).attr("data-id");
|
||||
$('#planID').val(planID);
|
||||
}
|
||||
|
||||
@@ -1059,18 +1059,35 @@ class program extends control
|
||||
*/
|
||||
public function PRJBatchEdit($from = 'prjbrowse', $programID = 0)
|
||||
{
|
||||
/* Navigation stay in program when enter from program list. */
|
||||
if($from == 'pgmproject')
|
||||
{
|
||||
$this->app->rawMethod = 'pgmproject';
|
||||
$this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true);
|
||||
$this->program->setPGMViewMenu($programID);
|
||||
}
|
||||
|
||||
if($from == 'prjbrowse')
|
||||
{
|
||||
$this->lang->program->menu = $this->lang->PRJ->menu;
|
||||
}
|
||||
|
||||
if($this->post->names)
|
||||
{
|
||||
$allChanges = $this->program->PRJBatchUpdate();
|
||||
|
||||
if(!empty($allChanges))
|
||||
{
|
||||
foreach($allChanges as $projectID => $changes)
|
||||
{
|
||||
if(empty($changes)) continue;
|
||||
|
||||
$actionID = $this->loadModel('action')->create('project', $projectID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
die(js::locate($this->session->projectList, 'parent'));
|
||||
}
|
||||
|
||||
$projectIdList = $this->post->projectIdList ? $this->post->projectIdList : die(js::locate($this->session->projectList, 'parent'));
|
||||
$projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchAll('id');
|
||||
|
||||
@@ -1831,6 +1848,7 @@ class program extends control
|
||||
*/
|
||||
public function ajaxCheckProduct($programID, $projectID)
|
||||
{
|
||||
/* Set vars. */
|
||||
$project = $this->program->getPRJByID($projectID);
|
||||
$oldTopPGM = $this->program->getTopPGMByID($project->parent);
|
||||
$newTopPGM = $this->program->getTopPGMByID($programID);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
$(function()
|
||||
{
|
||||
$("select[name^='parents']").change(function()
|
||||
{
|
||||
var $this = $(this);
|
||||
var programID = $this.val();
|
||||
var projectID = $this.attr("data-id");
|
||||
var oldParent = $this.attr("data-parent");
|
||||
var title = changeProgram.replace('%s', $this.attr("data-name"));
|
||||
|
||||
/* Determine whether the project can change the program set. */
|
||||
link = createLink('program', 'ajaxCheckProduct', 'programID=' + programID + '&projectID=' + projectID);
|
||||
$.getJSON(link, function(data)
|
||||
{
|
||||
var changed = true;
|
||||
|
||||
if(data && data.result)
|
||||
{
|
||||
changed = confirm(data.message);
|
||||
}
|
||||
|
||||
if(data && !data.result)
|
||||
{
|
||||
$('#promptTable tbody tr').remove();
|
||||
$('.modal-title').text(title);
|
||||
for(var i in data.message)
|
||||
{
|
||||
var product = data.message[i];
|
||||
$('#promptTable').append("<tr><td><i class='icon icon-product'></i><strong>" + product +"</strong> " + linkedProjectsTip +"</td></tr>");
|
||||
for(var j in data.multiLinkedProjects)
|
||||
{
|
||||
if(i == j)
|
||||
{
|
||||
html = ''
|
||||
for(k in data.multiLinkedProjects[j])
|
||||
{
|
||||
var project = data.multiLinkedProjects[j][k];
|
||||
html += "<p><i class='icon icon-project'></i>" + project +"</p>";
|
||||
}
|
||||
$('#promptTable').append("<tr><td style='padding-left:40px'>" + html + "</td></tr>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changed = false;
|
||||
$('#promptBox').modal({show: true});
|
||||
}
|
||||
|
||||
if(!changed) $this.val(oldParent).trigger("chosen:updated");
|
||||
$this.attr('data-parent', $this.val());
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,7 @@ $(function()
|
||||
{
|
||||
var programID = $(this).val();
|
||||
|
||||
/* Determine whether the project can change the program set. */
|
||||
link = createLink('program', 'ajaxCheckProduct', 'programID=' + programID + '&projectID=' + projectID);
|
||||
$.getJSON(link, function(data)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ $lang->program->morePRJ = 'More Project';
|
||||
|
||||
$lang->program->productNotEmpty = 'Please link products or create products.';
|
||||
$lang->program->existProductName = 'Product name already exists.';
|
||||
$lang->program->changeProgram = 'Change program';
|
||||
$lang->program->changeProgram = '%s > Change program';
|
||||
$lang->program->changeProgramTip = 'After modifying the program set, the products linked with the project will also modify the program set to which it belongs. Please confirm whether to modify it.';
|
||||
$lang->program->linkedProjectsTip = 'Linked projects are as follows';
|
||||
$lang->program->multiLinkedProductsTip = 'The following products linked to this project are also linked to other projects, please unlink before proceeding.';
|
||||
|
||||
@@ -93,7 +93,7 @@ $lang->program->morePRJ = 'More Project';
|
||||
|
||||
$lang->program->productNotEmpty = 'Please link products or create products.';
|
||||
$lang->program->existProductName = 'Product name already exists.';
|
||||
$lang->program->changeProgram = 'Change program';
|
||||
$lang->program->changeProgram = '%s > Change program';
|
||||
$lang->program->changeProgramTip = 'After modifying the program set, the products linked with the project will also modify the program set to which it belongs. Please confirm whether to modify it.';
|
||||
$lang->program->linkedProjectsTip = 'Linked projects are as follows';
|
||||
$lang->program->multiLinkedProductsTip = 'The following products linked to this project are also linked to other projects, please unlink before proceeding.';
|
||||
|
||||
@@ -93,7 +93,7 @@ $lang->program->morePRJ = 'More Projects';
|
||||
|
||||
$lang->program->productNotEmpty = 'Please link products or create products.';
|
||||
$lang->program->existProductName = 'Product name already exists.';
|
||||
$lang->program->changeProgram = 'Change program';
|
||||
$lang->program->changeProgram = '%s > Change program';
|
||||
$lang->program->changeProgramTip = 'After modifying the program set, the products linked with the project will also modify the program set to which it belongs. Please confirm whether to modify it.';
|
||||
$lang->program->linkedProjectsTip = 'Linked projects are as follows';
|
||||
$lang->program->multiLinkedProductsTip = 'The following products linked to this project are also linked to other projects, please unlink before proceeding.';
|
||||
|
||||
@@ -93,7 +93,7 @@ $lang->program->morePRJ = 'More Projects';
|
||||
|
||||
$lang->program->productNotEmpty = 'Please link products or create products.';
|
||||
$lang->program->existProductName = 'Product name already exists.';
|
||||
$lang->program->changeProgram = 'Change program';
|
||||
$lang->program->changeProgram = '%s > Change program';
|
||||
$lang->program->changeProgramTip = 'After modifying the program set, the products linked with the project will also modify the program set to which it belongs. Please confirm whether to modify it.';
|
||||
$lang->program->linkedProjectsTip = 'Linked projects are as follows';
|
||||
$lang->program->multiLinkedProductsTip = 'The following products linked to this project are also linked to other projects, please unlink before proceeding.';
|
||||
|
||||
@@ -93,7 +93,7 @@ $lang->program->morePRJ = '更多项目';
|
||||
|
||||
$lang->program->productNotEmpty = '请关联产品或创建产品。';
|
||||
$lang->program->existProductName = '产品名称已存在。';
|
||||
$lang->program->changeProgram = '修改项目集';
|
||||
$lang->program->changeProgram = '%s > 修改项目集';
|
||||
$lang->program->changeProgramTip = '修改项目集后,该项目关联的产品也会同时修改所属项目集,请确认是否修改。';
|
||||
$lang->program->linkedProjectsTip = '关联的项目如下';
|
||||
$lang->program->multiLinkedProductsTip = '该项目关联的如下产品还关联了其他项目,请取消关联后再操作';
|
||||
|
||||
+31
-16
@@ -102,7 +102,7 @@ class programModel extends model
|
||||
*/
|
||||
public function getPGMByID($programID = 0)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->andWhere('`type`')->eq('program')->fetch();
|
||||
return $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq((int)$programID)->andWhere('`type`')->eq('program')->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,7 +469,7 @@ class programModel extends model
|
||||
if(empty($programID)) return $topPGM;
|
||||
|
||||
$program = $this->getPGMByID($programID);
|
||||
if(!empty($program))list($topPGM) = explode(',', trim($program->path, ','));
|
||||
if(!empty($program)) list($topPGM) = explode(',', trim($program->path, ','));
|
||||
return $topPGM;
|
||||
}
|
||||
|
||||
@@ -1657,8 +1657,8 @@ class programModel extends model
|
||||
*/
|
||||
public function PRJUpdate($projectID = 0)
|
||||
{
|
||||
$oldProject = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch();
|
||||
$linkedProducts = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs();
|
||||
$oldProject = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch();
|
||||
$linkedProducts = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs();
|
||||
$_POST['products'] = isset($_POST['products']) ? $_POST['products'] : $linkedProducts;
|
||||
|
||||
$project = fixer::input('post')
|
||||
@@ -1699,16 +1699,6 @@ class programModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
/* Product belonging program set processing. */
|
||||
$oldTopPGM = $this->getTopPGMByID($oldProject->parent);
|
||||
$newTopPGM = $this->getTopPGMByID($project->parent);
|
||||
if($oldTopPGM != $newTopPGM)
|
||||
{
|
||||
foreach($_POST['products'] as $productID => $product)
|
||||
{
|
||||
$this->dao->update(TABLE_PRODUCT)->set('program')->eq($newTopPGM)->where('id')->eq($productID)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
/* Judge products not empty. */
|
||||
$linkedProductsCount = 0;
|
||||
@@ -1746,6 +1736,17 @@ class programModel extends model
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
/* Product belonging program set processing. */
|
||||
$oldTopPGM = $this->getTopPGMByID($oldProject->parent);
|
||||
$newTopPGM = $this->getTopPGMByID($project->parent);
|
||||
if($oldTopPGM != $newTopPGM)
|
||||
{
|
||||
foreach($_POST['products'] as $productID => $product)
|
||||
{
|
||||
$this->dao->update(TABLE_PRODUCT)->set('program')->eq($newTopPGM)->where('id')->eq($productID)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
$this->loadModel('project')->updateProducts($projectID, $_POST['products']);
|
||||
$this->file->updateObjectID($this->post->uid, $projectID, 'project');
|
||||
|
||||
@@ -1760,7 +1761,7 @@ class programModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch update products.
|
||||
* Batch update projects.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
@@ -1801,7 +1802,21 @@ class programModel extends model
|
||||
->exec();
|
||||
|
||||
if(dao::isError()) die(js::error('project#' . $projectID . dao::getError(true)));
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
/* Product belonging program set processing. */
|
||||
$oldTopPGM = $this->getTopPGMByID($oldProject->parent);
|
||||
$newTopPGM = $this->getTopPGMByID($project->parent);
|
||||
$linkedProducts = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs();
|
||||
if($oldTopPGM != $newTopPGM)
|
||||
{
|
||||
foreach($linkedProducts as $productID => $product)
|
||||
{
|
||||
$this->dao->update(TABLE_PRODUCT)->set('program')->eq($newTopPGM)->where('id')->eq($productID)->exec();
|
||||
}
|
||||
}
|
||||
if($oldProject->parent != $project->parent) $this->processNode($projectID, $project->parent, $oldProject->path, $oldProject->grade);
|
||||
}
|
||||
$allChanges[$projectID] = common::createChanges($oldProject, $project);
|
||||
}
|
||||
return $allChanges;
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('linkedProjectsTip', $lang->program->linkedProjectsTip);?>
|
||||
<?php js::set('changeProgram', $lang->program->changeProgram);?>
|
||||
<?php $requiredFields = $config->program->PRJEdit->requiredFields;?>
|
||||
<div id="mainContent" class="main-content">
|
||||
<div class="main-header">
|
||||
<h2><?php echo $lang->product->batchEdit;?></h2>
|
||||
<h2><?php echo $lang->program->PRJBatchEdit;?></h2>
|
||||
</div>
|
||||
<form method='post' class='load-indicator main-form' enctype='multipart/form-data' target='hiddenwin' id="batchEditForm">
|
||||
<table class="table table-form">
|
||||
@@ -29,10 +31,10 @@
|
||||
<tbody>
|
||||
<?php foreach($projectIdList as $projectID):?>
|
||||
<tr>
|
||||
<td><?php echo sprintf('%03d', $projectID) . html::hidden("productIDList[$projectID]", $projectID);?></td>
|
||||
<td><?php echo html::select('parents', $programList, $projects[$projectID]->parent, "class='form-control chosen'");?></td>
|
||||
<td><?php echo sprintf('%03d', $projectID) . html::hidden("projectIdList[$projectID]", $projectID);?></td>
|
||||
<td><?php echo html::select("parents[$projectID]", $programList, $projects[$projectID]->parent, "class='form-control chosen' data-id='$projectID' data-name='{$projects[$projectID]->name}' data-parent='{$projects[$projectID]->parent}'");?></td>
|
||||
<td title='<?php echo $projects[$projectID]->name;?>'><?php echo html::input("names[$projectID]", $projects[$projectID]->name, "class='form-control'");?></td>
|
||||
<td><?php echo html::select('PMs[$projectID]', $PMUsers, $projects[$projectID]->PM, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select("PMs[$projectID]", $PMUsers, $projects[$projectID]->PM, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
@@ -46,4 +48,24 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal fade" id="promptBox">
|
||||
<div class="modal-dialog mw-600px">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon icon-close"></i></button>
|
||||
<h4 class="modal-title"></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class='table table-form' id='promptTable'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='text-left'><?php echo $lang->program->multiLinkedProductsTip;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -179,7 +179,7 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon icon-close"></i></button>
|
||||
<h4 class="modal-title"><?php echo $project->name . ' > ' . $lang->program->changeProgram;?></h4>
|
||||
<h4 class="modal-title"><?php printf($lang->program->changeProgram, $project->name);?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class='table table-form' id='promptTable'>
|
||||
|
||||
Reference in New Issue
Block a user