* Modify getPGMProduct to getPGMProductPairs.:
This commit is contained in:
+17
-19
@@ -740,7 +740,7 @@ class program extends control
|
||||
}
|
||||
}
|
||||
|
||||
$allProducts = $this->program->getPGMProduct($programID);
|
||||
$allProducts = empty($programID) ? array() : $this->program->getPGMProductPairs($programID);
|
||||
|
||||
$this->view->title = $this->lang->program->PRJCreate;
|
||||
$this->view->position[] = $this->lang->program->PRJCreate;
|
||||
@@ -772,11 +772,11 @@ class program extends control
|
||||
* Edit a project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $parentID
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function PRJEdit($projectID = 0, $parentID = 0)
|
||||
public function PRJEdit($projectID = 0, $programID = 0)
|
||||
{
|
||||
$this->lang->navGroup->program = 'project';
|
||||
$this->app->loadLang('project');
|
||||
@@ -798,12 +798,11 @@ class program extends control
|
||||
}
|
||||
|
||||
$project = $this->program->getPRJByID($projectID);
|
||||
$parents = $this->program->getParentPairs();
|
||||
|
||||
$linkedBranches = array();
|
||||
$productPlans = array(0 => '');
|
||||
$allProducts = $parentID ? $this->program->getPGMProduct($parentID) : $this->program->getPGMProduct($projectID);
|
||||
$linkedProducts = $parentID ? array() : $this->project->getProducts($projectID);
|
||||
$allProducts = $programID ? $this->program->getPGMProductPairs($programID) : $this->program->getPGMProductPairs($project->parent, 'assign', 'noclosed');
|
||||
$linkedProducts = $programID ? array() : $this->project->getProducts($projectID);
|
||||
|
||||
foreach($linkedProducts as $product)
|
||||
{
|
||||
@@ -813,17 +812,17 @@ class program extends control
|
||||
|
||||
foreach($linkedProducts as $product)
|
||||
{
|
||||
$productPlans[$product->id] = $this->loadModel('productplan')->getPairs($product->id);
|
||||
$productPlans[$product->id] = $this->productplan->getPairs($product->id);
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->program->PRJEdit;
|
||||
$this->view->position[] = $this->lang->program->PRJEdit;
|
||||
|
||||
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $project->PM);
|
||||
$this->view->PMUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $project->PM);
|
||||
$this->view->users = $this->user->getPairs('noclosed|nodeleted');
|
||||
$this->view->project = $project;
|
||||
$this->view->parents = $parents;
|
||||
$this->view->parentID = $parentID;
|
||||
$this->view->programList = $this->program->getParentPairs();
|
||||
$this->view->programID = $programID;
|
||||
$this->view->allProducts = array('0' => '') + $allProducts;
|
||||
$this->view->productPlans = $productPlans;
|
||||
$this->view->linkedProducts = $linkedProducts;
|
||||
@@ -1364,25 +1363,25 @@ class program extends control
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $programID
|
||||
* @param string $from
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function PRJManageProducts($projectID, $programID, $from = '')
|
||||
public function PRJManageProducts($projectID, $programID)
|
||||
{
|
||||
$this->lang->navGroup->program = 'project';
|
||||
$browseProjectLink = $this->createLink('program', 'PRJBrowse', "programID=$programID");
|
||||
$browseProjectLink = inLink('PRJBrowse', "programID=$programID");
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
if(!isset($_POST['products']))
|
||||
{
|
||||
die(js::alert($this->lang->program->errorNoProducts) . js::locate(inlink('PRJManageProducts', "projectID=$projectID&programID=$programID&from=$from")));
|
||||
dao::$errors['message'][] = $this->lang->program->errorNoProducts;
|
||||
$this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
}
|
||||
|
||||
$oldProducts = $this->project->getProducts($projectID);
|
||||
$this->project->updateProducts($projectID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$oldProducts = array_keys($oldProducts);
|
||||
$newProducts = $this->project->getProducts($projectID);
|
||||
@@ -1390,19 +1389,18 @@ class program extends control
|
||||
$diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts));
|
||||
if($diffProducts) $this->loadModel('action')->create('project', $projectID, 'Managed', '', !empty($_POST['products']) ? join(',', $_POST['products']) : '');
|
||||
|
||||
die(js::locate($browseProjectLink));
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $browseProjectLink));
|
||||
}
|
||||
|
||||
$this->loadModel('product');
|
||||
$project = $this->project->getById($projectID);
|
||||
$programID = $this->program->getTopProgramID($projectID);
|
||||
$project = $this->project->getById($projectID);
|
||||
|
||||
/* Title and position. */
|
||||
$title = $this->lang->project->manageProducts . $this->lang->colon . $project->name;
|
||||
$position[] = html::a($browseProjectLink, $project->name);
|
||||
$position[] = $this->lang->project->manageProducts;
|
||||
|
||||
$allProducts = $this->product->getPairs('noclosed|nocode', $programID);
|
||||
$allProducts = $this->program->getPGMProductPairs($project->parent, 'assign', 'noclosed');
|
||||
$linkedProducts = $this->project->getProducts($project->id);
|
||||
$linkedBranches = array();
|
||||
|
||||
|
||||
+22
-28
@@ -17,17 +17,33 @@ class programModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product associated with the project.
|
||||
* Get the product associated with the program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $programID
|
||||
* @param int $mode all|assign
|
||||
* @param string $status all|noclosed
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPGMProduct($programID = 0)
|
||||
public function getPGMProductPairs($programID = 0, $mode = 'assign', $status = 'all')
|
||||
{
|
||||
if(!$programID) return array();
|
||||
$programID = $this->getTopProgramID($programID);
|
||||
return $this->loadModel('product')->getPairs('noclosed', $programID);
|
||||
/* Get the top programID. */
|
||||
if($programID)
|
||||
{
|
||||
$program = $this->getPGMByID($programID);
|
||||
$path = explode(',', $program->path);
|
||||
$path = array_filter($path);
|
||||
$programID = current($path);
|
||||
}
|
||||
|
||||
/* When mode equals assign and programID equals 0, you can query the standalone product. */
|
||||
$products = $this->dao->select('*')->from(TABLE_PRODUCT)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF($mode == 'assign')->andWhere('program')->eq($programID)->fi()
|
||||
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
|
||||
->fetchPairs('id', 'name');
|
||||
return $products;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1034,28 +1050,6 @@ class programModel extends model
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top program which the project belongs to.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getTopProgramID($projectID)
|
||||
{
|
||||
if(empty($projectID)) return 0;
|
||||
$project = $this->getPRJByID($projectID);
|
||||
|
||||
if($project->parent == 0) return 0;
|
||||
|
||||
$programID = 0;
|
||||
$path = explode(',', $project->path);
|
||||
$path = array_filter($path);
|
||||
$programID = current($path);
|
||||
|
||||
return $programID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project pairs.
|
||||
*
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<?php js::import($jsRoot . 'misc/date.js');?>
|
||||
<?php js::set('weekend', $config->project->weekend);?>
|
||||
<?php js::set('errorSameProducts', $lang->program->errorSameProducts);?>
|
||||
<?php js::set('parentID', $parentID);?>
|
||||
<?php js::set('oldParent', $project->parent);?>
|
||||
<?php js::set('projectID', $project->id);?>
|
||||
<?php js::set('PGMChangeTips', $lang->program->PGMChangeTips);?>
|
||||
@@ -34,7 +33,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->PGMParent;?></th>
|
||||
<td><?php echo html::select('parent', $parents, $parentID ? $parentID : $project->parent, "class='form-control chosen' onchange='setParentProgram(this.value)'");?></td>
|
||||
<td><?php echo html::select('parent', $programList, $programID ? $programID : $project->parent, "class='form-control chosen' onchange='setParentProgram(this.value)'");?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@@ -68,7 +67,7 @@
|
||||
</div>
|
||||
<?php $i++;?>
|
||||
<?php endforeach;?>
|
||||
<div class='col-sm-4 <?php if($parentID) echo 'required';?>'>
|
||||
<div class='col-sm-4 <?php if($programID) echo 'required';?>'>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select("products[$i]", $allProducts, '', "class='form-control chosen' onchange='loadBranches(this)'");?>
|
||||
<span class='input-group-addon fix-border'></span>
|
||||
@@ -92,7 +91,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->PRJPM;?></th>
|
||||
<td><?php echo html::select('PM', $pmUsers, $project->PM, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('PM', $PMUsers, $project->PM, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->PRJBudget;?></th>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div id='mainContent'>
|
||||
<div class='cell'>
|
||||
<form id='productsBox' method='post'>
|
||||
<form class='main-form form-ajax' method='post' id='productsBox' enctype='multipart/form-data'>
|
||||
<div class='detail'>
|
||||
<div class='detail-title'><?php echo $lang->project->linkedProducts;?></div>
|
||||
<div class='detail-content row'>
|
||||
|
||||
Reference in New Issue
Block a user