Hi,
Thanks you for you reply.
I use the 2.0.0 version.
I can send you a partial bug fix (see below).
The problem is on the copyProjectTo.php, currently the activities are iterated on id field.
Parent activity should not be migrated to the new project when the current activity is saved. A validation error is done in save method and the current activity isn't moved to the new project.
To fix the problem, activities must be ordered by wbsSortable field and not by id field. Navigation tree was done from parent activities to sons activities . The parent activities are moved and saved; then sons activities aremoved and saved. No validation errors occured.
Below the svn patch.
The last problem to resolve: sons activities order in the final project are not saved in the same order as parent. The activiy copy (in foreach statement, line 46) is the problem. It was done on an array sorted by id but not by wbs.
Index: copyProjectTo.php
===================================================================
--- copyProjectTo.php (revision 450)
+++ copyProjectTo.php (working copy)
@@ -41,12 +41,17 @@
// Copy activities
$activity=New Activity();
$activities=$activity->getSqlElementsFromCriteria($crit, false, null, null, true);
+
foreach ($activities as $activity) {
$act=new Activity($activity->id);
$new=$act->copy();
$actArrayObj[$new->id]=$new;
$actArray[$activity->id]=$new->id;
}
+
+ // Sort by wbsSortable
+ usort($actArrayObj, "customSortByWbsSortable");
+
foreach ($actArrayObj as $new) {
//$new=new Activity($new->id);
//$new->name='Copied ' . $new->name;
@@ -139,4 +144,12 @@
} else {
echo '<span class="messageWARNING" >' . $result . '</span>';
}
+
+function customSortByWbsSortable($a,$b) {
+ if (strlen($a->ActivityPlanningElement->wbsSortable) == strlen($b->ActivityPlanningElement->wbsSortable) ){
+ return $a->ActivityPlanningElement->wbsSortable > $b->ActivityPlanningElement->wbsSortable;
+ }else {
+ return $a->ActivityPlanningElement->wbsSortable < $b->ActivityPlanningElement->wbsSortable;
+ }
+}
?>
\ No newline at end of file
Best regards