Index: openacs-4/packages/contacts/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/contacts/www/search.tcl 18 Nov 2005 17:48:27 -0000 1.22 +++ openacs-4/packages/contacts/www/search.tcl 23 Nov 2005 17:29:47 -0000 1.23 @@ -78,7 +78,7 @@ # set query_pretty [list] if { [exists_and_not_null search_id] } { if { [contact::search::exists_p -search_id $search_id] } { - db_1row get_em { select title, owner_id, all_or_any, object_type from contact_searches where search_id = :search_id } + db_1row get_em { } set search_exists_p 1 } } @@ -274,15 +274,14 @@ } - if { $search_exists_p } { set conditions [list] db_foreach selectqueries { select condition_id, type as query_type, var_list as query_var_list from contact_search_conditions where search_id = :search_id } { set condition_name [contacts::search::condition_type -type $query_type -request pretty -var_list $query_var_list] if { [empty_string_p $condition_name] } { - set condition_name "[_ contacts.Employee]" + set condition_name "[_ contacts.Employees]" } lappend conditions "$condition_name " } @@ -295,31 +294,43 @@ lappend form_elements [list query_pretty:text(inform),optional [list label {}] [list value $query_pretty]] } - +# The employee search only works without other attribute so +# we are going to remove the option "Employee" where is already +# a condition_name and we are going to remove the attributes +# where the condition_name equals employee +set employee_p 0 if { [exists_and_not_null object_type] } { - # QUERY TYPE set type_options [contacts::search::condition_types] # We are going to add one extra element to show all employees # and its organization - if {[string equal $object_type "party"] } { + if { [string equal $object_type "party"] && ![exists_and_not_null condition_name] } { lappend type_options [list "[_ contacts.Employees]" employees] } - append form_elements { - {type:text(select),optional {label {}} {options $type_options} {html {onChange "javascript:acs_FormRefresh('advanced_search')"}}} + if { [exists_and_not_null condition_name] && [string equal $condition_name [_ contacts.Employees]] } { + set employee_p 1 } + if { !$employee_p } { + # Show the attribute options of the search + append form_elements { + {type:text(select),optional {label {}} {options $type_options} {html {onChange "javascript:acs_FormRefresh('advanced_search')"}}} + } + } } -# get condition types widgets +#get condition types widgets set form_elements [concat \ - $form_elements \ - [contacts::search::condition_type -type $type -request ad_form_widgets -form_name advanced_search -object_type $object_type] \ - ] + $form_elements \ + [contacts::search::condition_type -type $type -request ad_form_widgets -form_name advanced_search -object_type $object_type] \ + ] +if { !$employee_p } { + # Show the Ok button + lappend form_elements [list next:text(submit) [list label [_ acs-kernel.common_OK]] [list value "ok"]] +} -lappend form_elements [list next:text(submit) [list label [_ acs-kernel.common_OK]] [list value "ok"]] if { $search_exists_p } {