diff --git a/module/kanban/model.php b/module/kanban/model.php index fa626fcf8f..18345be3b0 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -3007,7 +3007,32 @@ class kanbanModel extends model if($column->parent) { $parent = $this->getColumnByID($column->parent); - if($parent->parent != -1) $this->dao->update(TABLE_KANBANCOLUMN)->set('parent')->eq(-1)->where('id')->eq($column->parent)->exec(); + + /* If the parent column is normal now, put its card into child column. */ + if($parent->parent != -1) + { + $parentCells = $this->dao->select('*')->from(TABLE_KANBANCELL) + ->where('`column`')->eq($column->parent) + ->andWhere('type')->eq('common') + ->fetchAll('id'); + + foreach($parentCells as $cell) + { + $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq($cell->cards) + ->where('lane')->eq($cell->lane) + ->andWhere('`column`')->eq($columnID) + ->andWhere('type')->eq('common') + ->exec(); + + $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq('') + ->where('lane')->eq($cell->lane) + ->andWhere('`column`')->eq($cell->column) + ->andWhere('type')->eq('common') + ->exec(); + } + + $this->dao->update(TABLE_KANBANCOLUMN)->set('parent')->eq(-1)->where('id')->eq($column->parent)->exec(); + } } $this->dao->update(TABLE_KANBANCOLUMN)