Index: openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql	3 May 2006 18:02:11 -0000	1.11
+++ openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql	26 May 2006 15:52:15 -0000	1.12
@@ -169,6 +169,20 @@
     </querytext>
   </fullquery>
 
+
+   <fullquery name="pm::project::parent_project_id.project_parent">
+         <querytext>
+
+	select i.parent_id
+	from cr_items i, cr_items ip, pm_projects p, pm_projects pp
+	where i.item_id = :project_id
+	and ip.item_id = i.parent_id
+	and p.project_id = i.latest_revision
+	and pp.project_id = ip.latest_revision
+
+         </querytext>
+   </fullquery>
+
   <fullquery name="pm::project::compute_parent_status.get_parent_id">
     <querytext>
         select
Index: openacs-4/packages/project-manager/tcl/project-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs.tcl,v
diff -u -r1.32 -r1.33
--- openacs-4/packages/project-manager/tcl/project-procs.tcl	3 May 2006 18:02:11 -0000	1.32
+++ openacs-4/packages/project-manager/tcl/project-procs.tcl	26 May 2006 15:52:15 -0000	1.33
@@ -1515,10 +1515,44 @@
     return $task_list
 
 }
+    
+    
+ad_proc -public pm::project::parent_project_id {
+    {-project_id:required}
+    {-respect_subproject:boolean}
+} {
+    get the project_id of the parent project
+} {
+    if {![db_0or1row project_parent {}] || ($respect_subproject_p && $subproject_p == "t")} {
+	return ""
+    } else {
+	return $parent_id
+    }
+}
 
+ad_proc -public pm::project::root_project {
 
+    {-project_item_id:required}
+    {-package_id ""}
+} {
+    
+    Return the root project of a given subproject.
+    
+    @param project_item_id Project who's root we are looking for
+    
+    @return project_item_id of the root project
+} {
 
+    # get main project_id
+    set next_parent_id $project_item_id
+    while {![empty_string_p $next_parent_id]} {
+	set project_parent_id $next_parent_id
+	set next_parent_id [pm::project::parent_project_id -project_id $project_parent_id]
+    }
 
+    return $project_parent_id
+}
+
 ad_proc -public pm::project::compute_parent_status {project_item_id} {
 
     When a project is updated, or a task updated within a project, we need to 
@@ -1545,7 +1579,7 @@
         set my_item_id $parent_id
     }
 
-    # ns_log Notice "root: $root_folder , last_item_id $last_item_id"
+    ns_log Debug "root: $root_folder , last_item_id $last_item_id"
 
     set return_code [pm::project::compute_status $last_item_id]
 
@@ -2270,7 +2304,13 @@
 	    
 	    set date [lindex [split $task_deadline " "] 0]
 	    set hours [lindex [split [lindex [split $task_deadline " "] 1] :] 0]
+	    if {[string length $hours] > 1} {
+		set hours [string trimleft $hours]
+	    }
 	    set mins  [lindex [split [lindex [split $task_deadline " "] 1] :] 1]
+	    if {[string length $mins] > 1} {
+		set mins [string trimleft $mins]
+	    }
 	    set mins [expr ($hours*60) + $mins]
 	    
 	    set date_j [dt_ansi_to_julian_single_arg $date]
@@ -2374,7 +2414,13 @@
 	    
 	    set date [lindex [split $earliest_start($task_item) " "] 0]
 	    set hours [lindex [split [lindex [split $earliest_start($task_item) " "] 1] :] 0]
+	    if {[string length $hours] > 1} {
+		set hours [string trimleft $hours]
+	    }
 	    set mins  [lindex [split [lindex [split $earliest_start($task_item) " "] 1] :] 1]
+	    if {[string length $mins] > 1} {
+		set mins [string trimleft $mins]
+	    }
 	    set mins [expr ($hours*60) + $mins]
 	    
 	    set date_j [dt_ansi_to_julian_single_arg $date]
@@ -2650,7 +2696,13 @@
 		
 		set date [lindex [split $latest_finish($task_item) " "] 0]
 		set hours [lindex [split [lindex [split $latest_finish($task_item) " "] 1] :] 0]
+		if {[string length $hours] > 1} {
+		    set hours [string trimleft $hours]
+		}
 		set mins  [lindex [split [lindex [split $latest_finish($task_item) " "] 1] :] 1]
+		if {[string length $mins] > 1} {
+		    set mins [string trimleft $mins]
+		}
 		set mins [expr ($hours*60) + $mins]
 		
 		set date_j [dt_ansi_to_julian_single_arg $date]
@@ -2706,8 +2758,14 @@
                     
                     set date [lindex [split $latest_finish($task_item) " "] 0]
                     set hours [lindex [split [lindex [split $latest_finish($task_item) " "] 1] :] 0]
+		    if {[string length $hours] > 1} {
+			set hours [string trimleft $hours]
+		    }
                     set hours [lc_parse_number $hours en_US]
                     set mins  [lindex [split [lindex [split $latest_finish($task_item) " "] 1] :] 1]
+		    if {[string length $mins] > 1} {
+			set mins [string trimleft $mins]
+		    }
                     set mins [expr ($hours*60) + $mins]
                     set date_j [dt_ansi_to_julian_single_arg $date]
                     set today_j $date_j