Index: openacs-4/contrib/packages/project-manager/tcl/project-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/tcl/Attic/project-procs.tcl,v diff -u -r1.6.2.1 -r1.6.2.2 --- openacs-4/contrib/packages/project-manager/tcl/project-procs.tcl 25 Mar 2004 18:36:05 -0000 1.6.2.1 +++ openacs-4/contrib/packages/project-manager/tcl/project-procs.tcl 20 May 2004 17:30:04 -0000 1.6.2.2 @@ -86,13 +86,17 @@ {-task_item_id ""} {-project_item_id ""} {-update_status_p "t"} + {-party_id ""} } { Adds a logger entry to a project. If task_item_id is passed in, also links it up with that task, and updates the task hours. - + @author Jade Rubick (jader@bread.com) @creation-date 2004-03-05 + + @see logger::entry::new + @see pm::project::compute_status @param entry_id If passed in, determines the entry_id for the newly logged entry @@ -117,6 +121,9 @@ This can be set to f when editing a task, because these things are done later anyway. + @param party_id If set, the party that creates the new logger + entry. If not set, defaults to ad_conn user_id + @return 0 if there no task it is logged against, otherwise returns the total number of hours logged to that task @@ -132,13 +139,20 @@ set entry_id [db_nextval acs_object_id_seq] } + if {[exists_and_not_null party_id]} { + set creation_user $party_id + } else { + set creation_user [ad_conn user_id] + } + # add in the new entry logger::entry::new -entry_id $entry_id \ -project_id $logger_project_id \ -variable_id $variable_id \ -value $value \ -time_stamp $timestamp_ansi \ - -description $description + -description $description \ + -party_id $creation_user # if we have a pm_task_id, then we need to note that this # entry is logged to a particular task. @@ -173,6 +187,7 @@ {-parent_id ""} {-goal ""} {-description ""} + {-mime_type "text/plain"} {-planned_start_date ""} {-planned_end_date ""} {-actual_start_date ""} @@ -206,7 +221,6 @@ # create a logger project set logger_project [logger::project::new \ -name $project_name \ - -description $description \ -project_lead $creation_user \ ] @@ -265,8 +279,19 @@ } { Stub for project edit - - + @author Jade Rubick (jader@bread.com) + @creation-date 2004-03-03 + + @param project_item_id + + @param project_name + + @return + + @error +} { + + set returnval [db_exec_plsql update_project " select pm_project__new_project_revision ( :project_item_id, :project_name, @@ -278,29 +303,18 @@ to_timestamp(:planned_end_date,'YYYY MM DD HH24 MI SS'), null, null, + :logger_project, :ongoing_p, :status_id, - :customer_id, + :organization_id, now(), - :user_id, - :peeraddr, + :creation_user, + :creation_ip, :package_id ); - - + "] - @author Jade Rubick (jader@bread.com) - @creation-date 2004-03-03 - - @param project_item_id - - @param project_name - - @return - - @error -} { - + return $returnval } @@ -552,7 +566,8 @@ latest_finish(i) = latest_start(i) + activity_time(i) - Tasks in ongoing projects are given null completion dates. + Tasks in ongoing projects are given null completion dates, + unless they already have deadlines.

@@ -575,6 +590,9 @@ For a project with subprojects, the statistics are based on the tasks of both of those projects. +

+ Tasks which are closed are not updated + @author Jade Rubick (jader@bread.com) @creation-date 2004-02-19 @@ -595,6 +613,11 @@ # to improve this in the future, be more intelligent about what is updated. # i.e., this procedure updates everything, which is necessary sometimes, # but not if you only edit one task. + # + # I added in an optimization to only save when something has + # changed -- JR + # I added in another optimization that only saves tasks that are + # open -- JR # ------------------------------------------------------------------------- # Add in resource limits. (it's not realistic that 300 tasks can be done in # one day) @@ -667,16 +690,34 @@ db_foreach tasks_query { } { + # We now save information about all the tasks, so that we can + # save on database hits later. Specifically, what we'll do is + # we won't need to save changes if the earliest_start, + # earliest finish, latest_start and latest_finish all haven't + # changed at all. We also save whether the task is open (o) or + # closed(c). + + set old_ES_j($my_iid) $old_earliest_start_j + set old_EF_j($my_iid) $old_earliest_finish_j + set old_LS_j($my_iid) $old_latest_start_j + set old_LF_j($my_iid) $old_latest_finish_j + set old_task_status($my_iid) $status_type + + # ns_log Notice "old_task_status: $my_iid $status_type" + set activity_time($my_iid) [expr $to_work - $worked] if {[exists_and_not_null task_deadline_j]} { - # ns_log notice "$my_iid has a deadline $task_jdeadline_j" + # ns_log notice "$my_iid has a deadline $task_deadline_j" set latest_finish($my_iid) $task_deadline_j - set latest_start($my_iid) [latest_start $task_deadline_j $activity_time($my_iid) $hours_day] - + set latest_start($my_iid) [pm::project::latest_start \ + -end_date_j $task_deadline_j \ + -hours_to_complete $activity_time($my_iid) \ + -hours_day $hours_day] + } } @@ -709,7 +750,7 @@ db_1row project_info { } if {[string equal $ongoing_p t] && ![empty_string_p $end_date_j]} { - ns_log Error "Project cannot be ongoing and have a non-null end-date" + ns_log Error "Project cannot be ongoing and have a non-null end-date. Setting end date to blank" set end_date_j "" } @@ -797,6 +838,11 @@ set max_earliest_start 0 + # testing if this fixes the bug + if {![exists_and_not_null depends($task_item)]} { + set depends($task_item) [list] + } + foreach dependent_item $depends($task_item) { set my_earliest_start [my_earliest_start $earliest_start($dependent_item) $activity_time($dependent_item) $hours_day] @@ -807,7 +853,7 @@ } set earliest_start($task_item) $max_earliest_start - # set earliest_finish($task_item) [expr $max_earliest_start + [expr $activity_time($task_item) / double($hours_day)]] + set earliest_finish($task_item) [earliest_finish $max_earliest_start $activity_time($task_item) $hours_day] # ns_log Notice \ @@ -851,7 +897,7 @@ # Note the latest_finish dates may be set to an arbitrary deadline. # Also note that it is possible for a project to be ongoing. # In that case, the latest_start and latest_finish dates should - # be set to null. + # be set to null, unless there is a hard deadline (end_date). # ----------------------------------------------------------------- # If these represent the dependency hierarchy: # 2155 @@ -1209,7 +1255,23 @@ set lf "" } - db_dml update_task { } + # Only update the task if something has actually + # changed. Hopefully this should help speed things up. + + if { \ + [string equal $es $old_ES_j($task_item)] && \ + [string equal $ef $old_EF_j($task_item)] && \ + [string equal $ls $old_LS_j($task_item)] && \ + [string equal $lf $old_LF_j($task_item)]} { + # do nothing + } else { + # if the task is open... + if {[string equal "o" $old_task_status($task_item)]} { + db_dml update_task { } + } + } + + } @@ -1278,3 +1340,37 @@ (select live_revision from cr_items where item_id = :project_item_id) " -default "no_project"] } + + +ad_proc -public pm::project::get_list_of_open { +} { + Returns a list of lists, of all open project ids and their names + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-05-13 + + @return list of lists, with project id and name + + @error +} { + + set return_val [db_list_of_lists get_vals " + SELECT + case when o.name is null then p.title else o.name || ' - ' || p.title end, + p.item_id + FROM pm_projectsx p + LEFT JOIN + organizations o + ON p.customer_id = o.organization_id, + cr_items i, + pm_project_status s + WHERE + p.project_id = i.live_revision and + s.status_id = p.status_id and + s.status_type = 'o' + ORDER BY + lower(o.name), lower(p.title) + "] + + return $return_val +}