* Finish task #68999.

This commit is contained in:
liugang
2022-09-14 14:07:00 +08:00
parent 4a7986fa00
commit b45b3e3661
5 changed files with 32 additions and 15 deletions
+2
View File
@@ -267,6 +267,7 @@ class productModel extends model
return $this->dao->select('t1.id as id,t1.*')->from(TABLE_PRODUCT)->alias('t1')
->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
->where('t1.deleted')->eq(0)
->andWhere('t1.shadow')->eq(0)
->beginIF($programID)->andWhere('t1.program')->eq($programID)->fi()
->beginIF($line > 0)->andWhere('t1.line')->eq($line)->fi()
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
@@ -323,6 +324,7 @@ class productModel extends model
->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
->where($productQuery)
->andWhere('t1.deleted')->eq(0)
->andWhere('t1.shadow')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
->andWhere('t1.vision')->eq($this->config->vision)->fi()
->orderBy('t1.order_asc')
+1 -1
View File
@@ -447,7 +447,7 @@ class project extends control
$this->loadModel('action')->create('project', $projectID, 'opened');
/* Link the plan stories. */
if(!empty($_POST['plans']))
if(!empty($_POST['hasProduct']) && !empty($_POST['plans']))
{
$planIdList = array();
foreach($_POST['plans'] as $plans)
+7
View File
@@ -1,5 +1,12 @@
$(function()
{
$('[name=hasProduct]').change(function()
{
const hasProduct = $('[name=hasProduct]:checked').val();
$('#productTitle, #linkPlan').closest('tr').toggle(hasProduct == 1);
});
$('#copyProjects a').click(function()
{
setCopyProject($(this).data('id'));
+18 -14
View File
@@ -1112,7 +1112,7 @@ class projectModel extends model
if(isset($this->config->setCode) and $this->config->setCode == 0) unset($project->code);
$linkedProductsCount = 0;
if(isset($_POST['products']))
if($project->hasProduct && isset($_POST['products']))
{
foreach($_POST['products'] as $product)
{
@@ -1126,7 +1126,7 @@ class projectModel extends model
$program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($project->parent)->fetch();
/* Judge products not empty. */
if(empty($linkedProductsCount) and !isset($_POST['newProduct']))
if($project->hasProduct && empty($linkedProductsCount) and !isset($_POST['newProduct']))
{
dao::$errors['products0'] = $this->lang->project->productNotEmpty;
return false;
@@ -1160,7 +1160,7 @@ class projectModel extends model
}
/* When select create new product, product name cannot be empty and duplicate. */
if(isset($_POST['newProduct']))
if($project->hasProduct && isset($_POST['newProduct']))
{
if(empty($_POST['productName']))
{
@@ -1265,11 +1265,12 @@ class projectModel extends model
$this->updateProducts($projectID);
if(isset($_POST['newProduct']) or (!$project->parent and empty($linkedProductsCount)))
if(!$project->hasProduct or isset($_POST['newProduct']) or (!$project->parent and empty($linkedProductsCount)))
{
/* If parent not empty, link products or create products. */
$product = new stdclass();
$product->name = $this->post->productName ? $this->post->productName : $project->name;
$product->name = !$project->hasProduct ? "{$project->name}_{$projectID}" : ($this->post->productName ? $this->post->productName : $project->name);
$product->shadow = (int)empty($project->hasProduct);
$product->bind = $this->post->parent ? 0 : 1;
$product->program = $project->parent ? current(array_filter(explode(',', $program->path))) : 0;
$product->acl = $project->acl == 'open' ? 'open' : 'private';
@@ -1292,15 +1293,18 @@ class projectModel extends model
$this->dao->insert(TABLE_PROJECTPRODUCT)->data($projectProduct)->exec();
/* Create doc lib. */
$this->app->loadLang('doc');
$lib = new stdclass();
$lib->product = $productID;
$lib->name = $this->lang->doclib->main['product'];
$lib->type = 'product';
$lib->main = '1';
$lib->acl = 'default';
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
if($project->hasProduct)
{
/* Create doc lib. */
$this->app->loadLang('doc');
$lib = new stdclass();
$lib->product = $productID;
$lib->name = $this->lang->doclib->main['product'];
$lib->type = 'product';
$lib->main = '1';
$lib->acl = 'default';
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
}
}
/* Save order. */
+4
View File
@@ -72,6 +72,10 @@
<td><?php echo html::input('code', $code, "class='form-control' required");?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->project->type;?></th>
<td><?php echo html::radio('hasProduct', $lang->project->projectTypeList, 1);?></td>
</tr>
<tr>
<th><?php echo $lang->project->PM;?></th>
<td><?php echo html::select('PM', $pmUsers, '', "class='form-control chosen'" . (strpos($requiredFields, 'PM') !== false ? ' required' : ''));?></td>