Index: openacs-4/contrib/packages/project-manager/www/add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/add-edit.tcl,v diff -u -r1.12.2.7 -r1.12.2.8 --- openacs-4/contrib/packages/project-manager/www/add-edit.tcl 5 Feb 2004 23:57:49 -0000 1.12.2.7 +++ openacs-4/contrib/packages/project-manager/www/add-edit.tcl 27 Feb 2004 22:46:13 -0000 1.12.2.8 @@ -45,13 +45,21 @@ set use_project_customizations_p [parameter::get -parameter "UseProjectCustomizationsP" -default "0"] +set ongoing_by_default_p [parameter::get -parameter "OngoingByDefaultP" -default "f"] + +if {[exists_and_not_null project_item_id] && ![exists_and_not_null project_id]} { + set project_id [pm::project::get_project_id -project_item_id $project_item_id] +} + + if {[exists_and_not_null project_id]} { set title "Edit a $project_term_lower" set context_bar [ad_context_bar "Edit $project_term"] # permissions permission::require_permission -party_id $user_id -object_id $package_id -privilege write + } else { set title "Add a $project_term_lower" set context_bar [ad_context_bar "New $project_term"] @@ -91,23 +99,22 @@ {planned_start_date:date,to_sql(linear_date) {label "Starts"} - {format "MONTH DD YYYY"} - {value {[util::date acquire clock [clock scan $planned_start_date]]}} + {value $planned_start_date} {today} {help} } {planned_end_date:date,to_sql(linear_date) {label "Deadline"} - {format "MONTH DD YYYY"} - {value {[util::date acquire clock [clock scan $planned_end_date]]}} + {value $planned_end_date} {today} {help} } {ongoing_p:text(select) {label "Project is ongoing?"} - {options {{"No" "f"} {"Yes" "t"}} {value $ongoing_p}} + {options {{"No" f} {"Yes" t}}} + {value $ongoing_p} {help_text "If yes, then this project has no deadline"} } @@ -116,9 +123,21 @@ {options {[db_list_of_lists get_status_codes { }]}} } - } + } \ + -new_request { + + if {[string equal $ongoing_by_default_p t]} { + set ongoing_p t + } + set planned_end_date [util::date acquire clock [clock scan $planned_end_date]] + set planned_start_date [util::date acquire clock [clock scan $planned_start_date]] + + } + + + if {[exists_and_not_null project_id]} { if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} { ad_form -extend -name add_edit -form { @@ -171,28 +190,27 @@ } -new_data { + set project_id [pm::project::new \ + -project_name $project_name \ + -project_code $project_code \ + -parent_id $parent_id \ + -goal $goal \ + -description $description \ + -planned_start_date $planned_start_date \ + -planned_end_date $planned_end_date \ + -actual_start_date "" \ + -actual_end_date "" \ + -ongoing_p $ongoing_p \ + -status_id $status_id \ + -organization_id $customer_id \ + -creation_date "" \ + -creation_user $user_id \ + -creation_ip $peeraddr \ + -package_id $package_id + ] - set project_id [project_manager::project::new \ - -project_name $project_name \ - -project_code $project_code \ - -parent_id $parent_id \ - -goal $goal \ - -description $description \ - -planned_start_date $planned_start_date \ - -planned_end_date $planned_end_date \ - -actual_start_date "" \ - -actual_end_date "" \ - -ongoing_p $ongoing_p \ - -status_id $status_id \ - -organization_id $customer_id \ - -creation_date "" \ - -creation_user $user_id \ - -creation_ip $peeraddr \ - -package_id $package_id - ] + set project_item_id [pm::project::get_project_item_id -project_id $project_id] - set project_item_id [db_string get_item_id { }] - if {[exists_and_not_null category_ids]} { category::map_object -remove_old -object_id $project_item_id $category_ids } @@ -206,18 +224,21 @@ } } -edit_data { + + # we need to pass the old_project_id to add-edit-2.tcl because + # the new revision will not have any of the custom values in + # it until it is edited. So we need to pull in these values + set old_project_id $project_id -ns_log Notice "edit" set project_id [db_exec_plsql new_project_revision { *SQL* }] - project_manager::project::compute_parent_status $project_item_id + pm::project::compute_parent_status $project_item_id category::map_object -remove_old -object_id $project_item_id $category_ids } -after_submit { -ns_log Notice "after_submit" if {$use_project_customizations_p} { - ad_returnredirect "add-edit-2?[export_url_vars project_id]" + ad_returnredirect "add-edit-2?[export_url_vars project_id old_project_id]" ad_script_abort } else { ad_returnredirect "one?[export_url_vars project_id]"