* change for merge program.
This commit is contained in:
@@ -157,6 +157,11 @@ class upgrade extends control
|
||||
$now = helper::now();
|
||||
if($type == 'productline')
|
||||
{
|
||||
foreach($this->post->newPrograms as $lineID => $programName)
|
||||
{
|
||||
if(empty($programName)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->program)));
|
||||
}
|
||||
|
||||
foreach($this->post->newPrograms as $lineID => $programName)
|
||||
{
|
||||
if(empty($_POST['products'][$lineID])) continue;
|
||||
@@ -168,8 +173,8 @@ class upgrade extends control
|
||||
$programID = $this->upgrade->createProgram($programName, $linkedProducts, $linkedProjects);
|
||||
|
||||
/* Change program field for product and project. */
|
||||
$this->upgrade->setProductProgram($programID, $linkedProducts);
|
||||
if($linkedProjects) $this->upgrade->setProjectProgram($programID, $linkedProjects);
|
||||
$this->upgrade->setProgram4Product($programID, $linkedProducts);
|
||||
if($linkedProjects) $this->upgrade->setProgram4Project($programID, $linkedProjects);
|
||||
|
||||
/* Set program team. */
|
||||
|
||||
@@ -212,11 +217,12 @@ class upgrade extends control
|
||||
else
|
||||
{
|
||||
$programID = $this->post->programs[$i];
|
||||
$this->dao->update(TABLE_PROJECT)->set('category')->eq('multiple')->where('id')->eq($programID)->andWhere('category')->eq('single')->exec();
|
||||
}
|
||||
|
||||
/* Change program field for product and project. */
|
||||
$this->upgrade->setProductProgram($programID, $linkedProducts);
|
||||
if($linkedProjects) $this->upgrade->setProjectProgram($programID, $linkedProjects);
|
||||
$this->upgrade->setProgram4Product($programID, $linkedProducts);
|
||||
if($linkedProjects) $this->upgrade->setProgram4Project($programID, $linkedProjects);
|
||||
|
||||
/* Set program team. */
|
||||
|
||||
@@ -255,14 +261,18 @@ class upgrade extends control
|
||||
else
|
||||
{
|
||||
$programID = $this->post->programs[$i];
|
||||
$this->dao->update(TABLE_PROJECT)->set('category')->eq('multiple')->where('id')->eq($programID)->andWhere('category')->eq('single')->exec();
|
||||
}
|
||||
|
||||
$this->upgrade->createProduct4Program($programID);
|
||||
$productID = $this->upgrade->createProduct4Program($programID);
|
||||
|
||||
/* Change program field for product and project. */
|
||||
$this->upgrade->setProjectProgram($programID, $linkedProjects);
|
||||
$this->upgrade->setProgram4Project($programID, $linkedProjects);
|
||||
|
||||
/* Set program team. */
|
||||
|
||||
/* Link product. */
|
||||
foreach($linkedProjects as $projectID) $this->dao->replace(TABLE_PROJECTPRODUCT)->set('project')->eq($projectID)->set('product')->eq($productID)->exec();
|
||||
}
|
||||
elseif($type == 'moreLink')
|
||||
{
|
||||
@@ -271,7 +281,7 @@ class upgrade extends control
|
||||
$projectID = $this->post->projects[$i];
|
||||
|
||||
/* Change program field for product and project. */
|
||||
$this->upgrade->setProjectProgram($programID, array($projectID));
|
||||
$this->upgrade->setProgram4Project($programID, array($projectID));
|
||||
|
||||
/* Set program team. */
|
||||
}
|
||||
|
||||
@@ -3751,6 +3751,15 @@ class upgradeModel extends model
|
||||
fwrite($fh, $log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create program.
|
||||
*
|
||||
* @param string $programName
|
||||
* @param array $productIdList
|
||||
* @param array $projectIdList
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function createProgram($programName, $productIdList = array(), $projectIdList = array())
|
||||
{
|
||||
$program = new stdclass();
|
||||
@@ -3795,10 +3804,20 @@ class upgradeModel extends model
|
||||
return $programID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create product for program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createProduct4Program($programID)
|
||||
{
|
||||
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
|
||||
|
||||
$product = $this->dao->select('*')->from(TABLE_PRODUCT)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('code')->eq($program->code)->fetch();
|
||||
if($product) return $product->id;
|
||||
|
||||
$product = new stdclass();
|
||||
$product->name = $program->name;
|
||||
$product->code = $program->code;
|
||||
@@ -3824,9 +3843,19 @@ class upgradeModel extends model
|
||||
$lib->acl = 'default';
|
||||
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
|
||||
if($product->acl != 'open') $this->loadModel('user')->updateUserView($productID, 'product');
|
||||
|
||||
return $productID;
|
||||
}
|
||||
|
||||
public function setProductProgram($programID, $productIdList = array())
|
||||
/**
|
||||
* Set program for product
|
||||
*
|
||||
* @param int $programID
|
||||
* @param array $productIdList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setProgram4Product($programID, $productIdList = array())
|
||||
{
|
||||
$this->dao->update(TABLE_PRODUCT)->set('program')->eq($programID)->where('id')->in($productIdList)->exec();
|
||||
$this->dao->update(TABLE_STORY)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
|
||||
@@ -3839,7 +3868,15 @@ class upgradeModel extends model
|
||||
$this->dao->update(TABLE_DOC)->set('program')->eq($programID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'product' and product " . helper::dbIN($productIdList) . ')')->exec();
|
||||
}
|
||||
|
||||
public function setProjectProgram($programID, $projectIdList = array())
|
||||
/**
|
||||
* Set program for project
|
||||
*
|
||||
* @param int $programID
|
||||
* @param array $projectIdList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setProgram4Project($programID, $projectIdList = array())
|
||||
{
|
||||
$this->dao->update(TABLE_PROJECT)->set('program')->eq($programID)->where('id')->in($projectIdList)->exec();
|
||||
$this->dao->update(TABLE_TASK)->set('program')->eq($programID)->where('project')->in($projectIdList)->exec();
|
||||
|
||||
@@ -14,14 +14,16 @@
|
||||
<?php if($i == 0):?>
|
||||
<td class='text-top' rowspan='<?php echo count($noMergedProducts);?>'>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select("programs", $programs, '', "class='form-control chosen'");?>
|
||||
<?php if($programs) echo html::select("programs", $programs, '', "class='form-control chosen'");?>
|
||||
<?php echo html::input("programName", '', "class='form-control'");?>
|
||||
<?php if($programs):?>
|
||||
<span class='input-group-addon'>
|
||||
<div class="checkbox-primary">
|
||||
<input type="checkbox" name="newProgram" value="0" checked onchange="toggleProgram(this)" id="newProgram0" />
|
||||
<label for="newProgram0"><?php echo $lang->upgrade->newProgram;?></label>
|
||||
</div>
|
||||
</span>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</td>
|
||||
<td class='text-top' rowspan='<?php echo count($noMergedProducts);?>'><?php echo html::select("account", $users, '', "class='form-control chosen'");?></td>
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
<?php if($i == 0):?>
|
||||
<td class='text-top' rowspan='<?php echo count($noMergedProjects);?>'>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select("programs", $programs, '', "class='form-control chosen'");?>
|
||||
<?php if($programs) echo html::select("programs", $programs, '', "class='form-control chosen'");?>
|
||||
<?php echo html::input("programName", '', "class='form-control'");?>
|
||||
<?php if($programs):?>
|
||||
<span class='input-group-addon'>
|
||||
<div class="checkbox-primary">
|
||||
<input type="checkbox" name="newProgram" value="0" checked onchange="toggleProgram(this)" id="newProgram0" />
|
||||
<label for="newProgram0"><?php echo $lang->upgrade->newProgram;?></label>
|
||||
</div>
|
||||
</span>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</td>
|
||||
<td class='text-top' rowspan='<?php echo count($noMergedProjects);?>'><?php echo html::select("account", $users, '', "class='form-control chosen'");?></td>
|
||||
|
||||
Reference in New Issue
Block a user