* Modify the logic of project editing.

This commit is contained in:
tianshujie98
2021-02-20 15:57:10 +08:00
parent 8203c0df12
commit 8212de6cc3
25 changed files with 363 additions and 133 deletions
+71 -5
View File
@@ -951,17 +951,19 @@ class program extends control
* Edit a project.
*
* @param int $projectID
* @param int $programID
* @param string $from PRJ|pgmbrowse|pgmproject
* @access public
* @return void
*/
public function PRJEdit($projectID = 0, $programID = 0, $from = 'PRJ')
public function PRJEdit($projectID = 0, $from = 'PRJ')
{
$this->app->loadLang('custom');
$this->app->loadLang('project');
$this->loadModel('productplan');
$project = $this->program->getPRJByID($projectID);
$programID = $project->parent;
/* Navigation stay in program when enter from program list. */
if($from == 'PRJ')
{
@@ -998,12 +1000,11 @@ class program extends control
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locateLink));
}
$project = $this->program->getPRJByID($projectID);
$linkedBranches = array();
$productPlans = array(0 => '');
$allProducts = $programID != $project->parent ? $this->program->getPGMProductPairs($programID) : $this->program->getPGMProductPairs($project->parent, 'assign', 'noclosed');
$linkedProducts = $programID != $project->parent ? array() : $this->project->getProducts($projectID);
$allProducts = $this->program->getPGMProductPairs($project->parent, 'assign', 'noclosed');
$linkedProducts = $this->project->getProducts($projectID);
$parentProgram = $this->program->getPGMByID($programID);
/* If the story of the product which linked the project, you don't allow to remove the product. */
@@ -1047,6 +1048,33 @@ class program extends control
$this->display();
}
/**
* Batch edit projects.
*
* @param string $from
* @param int $programID
* @access public
* @return void
*/
public function PRJBatchEdit($from = 'prjbrowse', $programID = 0)
{
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;
}
$projectIdList = $this->post->projectIdList;
$this->display();
}
/**
* View a project.
*
@@ -1780,4 +1808,42 @@ class program extends control
echo $this->fetch('program', 'PGMProduct', "programID=$programID");
}
/**
* AJAX: Check products.
*
* @param int $programID
* @param int $projectID
* @access public
* @return array
*/
public function ajaxCheckProduct($programID, $projectID)
{
$project = $this->program->getPRJByID($projectID);
$oldTopPGM = $this->program->getTopPGMByID($project->parent);
$newTopPGM = $this->program->getTopPGMByID($programID);
if($oldTopPGM == $newTopPGM) die();
$response = array();
$response['result'] = true;
$multiLinkedProducts = $this->program->getMultiLinkedProducts($projectID);
if($multiLinkedProducts)
{
$multiLinkedProjects = array();
foreach($multiLinkedProducts as $productID => $product)
{
$multiLinkedProjects[$productID] = $this->loadModel('product')->getProjectPairsByProduct($productID);
}
$response['result'] = false;
$response['message'] = $multiLinkedProducts;
$response['multiLinkedProjects'] = $multiLinkedProjects;
}
else
{
$response['message'] = $this->lang->program->changeProgramTip;
}
die(json_encode($response));
}
}