* fix Bug 2654
This commit is contained in:
@@ -978,6 +978,12 @@ class actionModel extends model
|
||||
{
|
||||
$this->dao->update(TABLE_DOCLIB)->set('deleted')->eq(0)->where($action->objectType)->eq($action->objectID)->exec();
|
||||
}
|
||||
/* Revert productplan project status */
|
||||
if($action->objectType == 'productplan')
|
||||
{
|
||||
$plan = $this->loadModel('productplan')->getById($action->objectID);
|
||||
$this->loadModel('productplan')->updatePlanParentStatus($plan->parent);
|
||||
}
|
||||
|
||||
/* Update action record in action table. */
|
||||
$this->dao->update(TABLE_ACTION)->set('extra')->eq(ACTIONMODEL::BE_UNDELETED)->where('id')->eq($actionID)->exec();
|
||||
|
||||
@@ -165,7 +165,7 @@ class productplan extends control
|
||||
{
|
||||
$plan = $this->productplan->getById($planID);
|
||||
$this->productplan->delete(TABLE_PRODUCTPLAN, $planID);
|
||||
|
||||
$this->productplan->updatePlanParentStatus($plan->parent);
|
||||
$this->executeHooks($planID);
|
||||
|
||||
/* if ajax request, send result. */
|
||||
@@ -277,7 +277,6 @@ class productplan extends control
|
||||
}
|
||||
|
||||
$this->executeHooks($planID);
|
||||
|
||||
if($plan->parent > 0) $this->view->parentPlan = $this->productplan->getById($plan->parent);
|
||||
if($plan->parent == '-1') $this->view->childrenPlans = $this->productplan->getChildren($plan->id);
|
||||
|
||||
|
||||
@@ -296,6 +296,22 @@ class productplanModel extends model
|
||||
return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq((int)$planID)->andWhere('deleted')->eq('0')->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* updatePlanParentStatus,hasChild set parent = -1;noChild set parent = 0;
|
||||
*
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updatePlanParentStatus($planID)
|
||||
{
|
||||
if($planID <= 0) return;
|
||||
$childCount = count($this->getChildren($planID));
|
||||
if($childCount == 0) $status = 0;
|
||||
if($childCount > 0) $status = -1;
|
||||
return $this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq($status)->where('id')->eq((int)$planID)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plan.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user