* finish task #2278.
This commit is contained in:
@@ -120,6 +120,18 @@ class productModel extends model
|
||||
return $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by idList.
|
||||
*
|
||||
* @param array $productIDList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByIdList($productIDList)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in($productIDList)->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get products.
|
||||
*
|
||||
@@ -217,7 +229,7 @@ class productModel extends model
|
||||
->exec();
|
||||
|
||||
$productID = $this->dao->lastInsertID();
|
||||
$this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($productID)->where('id')->eq($productID)->exec();
|
||||
$this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($productID * 5)->where('id')->eq($productID)->exec();
|
||||
return $productID;
|
||||
}
|
||||
|
||||
@@ -256,8 +268,9 @@ class productModel extends model
|
||||
*/
|
||||
public function batchUpdate()
|
||||
{
|
||||
$products = array();
|
||||
$allChanges = array();
|
||||
$products = array();
|
||||
$allChanges = array();
|
||||
$oldProducts = $this->getByIdList($this->post->productIDList);
|
||||
foreach($this->post->productIDList as $productID)
|
||||
{
|
||||
$products[$productID] = new stdClass();
|
||||
@@ -267,11 +280,12 @@ class productModel extends model
|
||||
$products[$productID]->QD = $this->post->QDs[$productID];
|
||||
$products[$productID]->RD = $this->post->RDs[$productID];
|
||||
$products[$productID]->status = $this->post->statuses[$productID];
|
||||
$products[$productID]->order = $this->post->orders[$productID];
|
||||
}
|
||||
|
||||
foreach($products as $productID => $product)
|
||||
{
|
||||
$oldProduct = $this->getById($productID);
|
||||
$oldProduct = $oldProducts[$productID];
|
||||
$this->dao->update(TABLE_PRODUCT)
|
||||
->data($product)
|
||||
->autoCheck()
|
||||
@@ -283,6 +297,7 @@ class productModel extends model
|
||||
if(dao::isError()) die(js::error('product#' . $productID . dao::getError(true)));
|
||||
$allChanges[$productID] = common::createChanges($oldProduct, $product);
|
||||
}
|
||||
$this->fixOrder();
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
@@ -679,4 +694,24 @@ class productModel extends model
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix order.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function fixOrder()
|
||||
{
|
||||
$products = $this->dao->select('id,`order`')->from(TABLE_PRODUCT)->orderBy('order')->fetchPairs('id', 'order');
|
||||
|
||||
$i = 0;
|
||||
foreach($products as $id => $order)
|
||||
{
|
||||
$i++;
|
||||
$newOrder = $i * 5;
|
||||
if($order == $newOrder) continue;
|
||||
$this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($newOrder)->where('id')->eq($id)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<th class='w-150px'><?php echo $lang->product->QD;?></th>
|
||||
<th class='w-150px'><?php echo $lang->product->RD;?></th>
|
||||
<th class='w-100px'><?php echo $lang->product->status;?></th>
|
||||
<th class='w-80px'><?php echo $lang->product->order;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach($productIDList as $productID):?>
|
||||
@@ -38,9 +39,10 @@
|
||||
<td class='text-left' style='overflow:visible'><?php echo html::select("QDs[$productID]", $qdUsers, $products[$productID]->QD, "class='form-control chosen'");?></td>
|
||||
<td class='text-left' style='overflow:visible'><?php echo html::select("RDs[$productID]", $rdUsers, $products[$productID]->RD, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select("statuses[$productID]", $lang->product->statusList, $products[$productID]->status, "class='form-control'");?></td>
|
||||
<td><?php echo html::input("orders[$productID]", $products[$productID]->order, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr><td colspan='7' class='text-center'><?php echo html::submitButton();?></td></tr>
|
||||
<tr><td colspan='8' class='text-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -239,7 +239,7 @@ class projectModel extends model
|
||||
$creatorExists = false;
|
||||
|
||||
/* Save order. */
|
||||
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($projectID)->where('id')->eq($projectID)->exec();
|
||||
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($projectID * 5)->where('id')->eq($projectID)->exec();
|
||||
|
||||
/* Copy team of project. */
|
||||
if($copyProjectID != '')
|
||||
@@ -332,8 +332,9 @@ class projectModel extends model
|
||||
*/
|
||||
public function batchUpdate()
|
||||
{
|
||||
$projects = array();
|
||||
$allChanges = array();
|
||||
$projects = array();
|
||||
$allChanges = array();
|
||||
$oldProjects = $this->getByIdList($this->post->projectIDList);
|
||||
foreach($this->post->projectIDList as $projectID)
|
||||
{
|
||||
$projects[$projectID] = new stdClass();
|
||||
@@ -344,11 +345,12 @@ class projectModel extends model
|
||||
$projects[$projectID]->begin = $this->post->begins[$projectID];
|
||||
$projects[$projectID]->end = $this->post->ends[$projectID];
|
||||
$projects[$projectID]->days = $this->post->dayses[$projectID];
|
||||
$projects[$projectID]->order = $this->post->orders[$projectID];
|
||||
}
|
||||
|
||||
foreach($projects as $projectID => $project)
|
||||
{
|
||||
$oldProject = $this->getById($projectID);
|
||||
$oldProject = $oldProjects[$projectID];
|
||||
$team = $this->getTeamMemberPairs($projectID);
|
||||
|
||||
$this->dao->update(TABLE_PROJECT)->data($project)
|
||||
@@ -378,6 +380,7 @@ class projectModel extends model
|
||||
if(dao::isError()) die(js::error('project#' . $projectID . dao::getError(true)));
|
||||
$allChanges[$projectID] = common::createChanges($oldProject, $project);
|
||||
}
|
||||
$this->fixOrder();
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
@@ -527,6 +530,18 @@ class projectModel extends model
|
||||
return $pairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by idList.
|
||||
*
|
||||
* @param array $projectIDList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByIdList($projectIDList)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($projectIDList)->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project lists.
|
||||
*
|
||||
@@ -1618,4 +1633,24 @@ class projectModel extends model
|
||||
$estimate = $this->dao->select('SUM(estimate) as estimate')->from(TABLE_TASK)->where('deleted')->eq('0')->andWhere('project')->eq($projectID)->fetch('estimate');
|
||||
return round($estimate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix order.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function fixOrder()
|
||||
{
|
||||
$projects = $this->dao->select('id,`order`')->from(TABLE_PROJECT)->orderBy('order')->fetchPairs('id', 'order');
|
||||
|
||||
$i = 0;
|
||||
foreach($projects as $id => $order)
|
||||
{
|
||||
$i++;
|
||||
$newOrder = $i * 5;
|
||||
if($order == $newOrder) continue;
|
||||
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($newOrder)->where('id')->eq($id)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<th class='w-110px'><?php echo $lang->project->begin;?> <span class='required'></span></th>
|
||||
<th class='w-110px'><?php echo $lang->project->end;?> <span class='required'></span></th>
|
||||
<th class='w-150px'><?php echo $lang->project->days;?></th>
|
||||
<th class='w-80px'><?php echo $lang->project->order;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach($projectIDList as $projectID):?>
|
||||
@@ -46,9 +47,10 @@
|
||||
<span class='input-group-addon'><?php echo $lang->project->day;?></span>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php echo html::input("orders[$projectID]", $projects[$projectID]->order, "class='form-control' autocomplete='off'")?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr><td colspan='8' class='text-center'><?php echo html::submitButton();?></td></tr>
|
||||
<tr><td colspan='9' class='text-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -123,6 +123,8 @@ class upgradeModel extends model
|
||||
case '7_2':
|
||||
case '7_2_4':
|
||||
$this->execSQL($this->getUpgradeFile('7.2.4'));
|
||||
case '7_2_5':
|
||||
$this->adjustOrder7_3();
|
||||
|
||||
default: if(!$this->isError()) $this->setting->updateVersion($this->config->version);
|
||||
}
|
||||
@@ -942,6 +944,23 @@ class upgradeModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust order for 7.3
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function adjustOrder7_3()
|
||||
{
|
||||
$products = $this->dao->select('`order`')->from(TABLE_PRODUCT)->orderBy('order desc')->limit(2)->fetchAll();
|
||||
if(count($products) == 2 and ($products[0]->order - $products[1]->order) != 5) $this->dao->update(TABLE_PRODUCT)->set('`order`=`order` * 5')->exec();
|
||||
|
||||
$projects = $this->dao->select('`order`')->from(TABLE_PROJECT)->orderBy('order desc')->limit(2)->fetchAll();
|
||||
if(count($projects) == 2 and ($projects[0]->order - $projects[1]->order) != 5) $this->dao->update(TABLE_PROJECT)->set('`order`=`order` * 5')->exec();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Judge any error occers.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user