Index: openacs-4/packages/logger/www/admin/project.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/project.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/logger/www/admin/project.tcl 1 May 2003 21:18:08 -0000 1.5 +++ openacs-4/packages/logger/www/admin/project.tcl 1 May 2003 21:50:38 -0000 1.6 @@ -51,37 +51,59 @@ {description:text(textarea),optional {html {cols 60 rows 13}} } +} -select_query { + select name, + description + from logger_projects + where project_id = :project_id +} -validate { + { + name + { ![empty_string_p [string trim $name]] } + { A name with only spaces is not allowed } + } + +} -new_data { + + logger::project::new -project_id $project_id \ + -name $name \ + -description $description \ +} -edit_data { + + # The edit proc requires all attributes to be provided + # so use the old values for project_lead and active_p + logger::project::get -project_id $project_id -array old_project + logger::project::edit -project_id $project_id \ + -name $name \ + -description $description \ + -project_lead $old_project(project_lead) \ + -active_p $old_project(active_p) +} -after_submit { + + ad_returnredirect "[ad_conn url]?project_id=$project_id" + + ad_script_abort } if { $project_exists_p } { # We are in edit or display mode - # Display the variables linked to this project - set variables_list [list] - set variables_text "" - db_foreach variables_in_project { + + ########### + # + # Variables + # + ########### + + db_multirow variables variables_in_project { select lv.variable_id, lv.name, lpvm.primary_p from logger_project_var_map lpvm, logger_variables lv where lpvm.variable_id = lv.variable_id and lpvm.project_id = :project_id - } { - set variable_link "$name" - if { [string equal $primary_p "f"] } { - append variable_link "   \[ unmap | make primary \]" - } else { - append variable_link " (primary)" - } - - lappend variables_list $variable_link } - if { [llength $variables_list] != 0 } { - set variables_text "" - } else { - set variables_text "no variables" - } set n_can_be_mapped [db_string n_can_be_mapped { select count(*) from logger_variables lv @@ -102,51 +124,28 @@ and acs_permission.permission_p(lv.variable_id, :user_id, 'read') = 't' }] - if { $n_can_be_mapped > 0 } { - append variables_text "

\[add variable\]

" - } + ########### + # + # Projections + # + ########### + db_multirow projections select_projections { + select lpe.projection_id, + lpe.name, + lpe.description, + lpe.value, + lpo.name as project_name, + lv.name as variable_name, + to_char(lpe.start_time, 'YYYY-MM-DD') start_day, + to_char(lpe.end_time, 'YYYY-MM-DD') end_day, + acs_permission.permission_p(lpo.project_id, :user_id, 'admin') as admin_p + from logger_projections lpe, + logger_projects lpo, + logger_variables lv + where lpe.project_id = :project_id + and lpe.project_id = lpo.project_id + and lpe.variable_id = lv.variable_id + } - ad_form -extend -name project_form -form { - {variables:text(inform) - {label Variables} - {value $variables_text} - } - } - } - -# Finalize the form with the execution blocks -ad_form -extend -name project_form -select_query { - select name, - description - from logger_projects - where project_id = :project_id -} -validate { - { - name - { ![empty_string_p [string trim $name]] } - { A name with only spaces is not allowed } - } - -} -new_data { - - logger::project::new -project_id $project_id \ - -name $name \ - -description $description \ -} -edit_data { - - # The edit proc requires all attributes to be provided - # so use the old values for project_lead and active_p - logger::project::get -project_id $project_id -array old_project - logger::project::edit -project_id $project_id \ - -name $name \ - -description $description \ - -project_lead $old_project(project_lead) \ - -active_p $old_project(active_p) -} -after_submit { - - ad_returnredirect "[ad_conn url]?project_id=$project_id" - - ad_script_abort -}