| |
103 |
103 |
# we must use the operand in the var prefix because |
| |
104 |
104 |
# this will rest the vars if somebody changes the operand |
| |
105 |
105 |
set var1 "${attrprefix}${operand}__var1" |
| |
106 |
106 |
set var2 "${attrprefix}${operand}__var2" |
| |
107 |
107 |
set ${var1} [ns_queryget ${var1}] |
| |
108 |
108 |
if { [template::element::exists $form_name $var1] } { |
| |
109 |
109 |
if { [template::element::get_property $form_name $var1 widget] == "date" } { |
| |
110 |
110 |
set ${var1} [join \ |
| |
111 |
111 |
[template::util::date::get_property linear_date_no_time \ |
| |
112 |
112 |
[template::element::get_value $form_name $var1] \ |
| |
113 |
113 |
] \ |
| |
114 |
114 |
"-"] |
| |
115 |
115 |
} |
| |
116 |
116 |
} |
| |
117 |
117 |
set ${var2} [ns_queryget ${var2}] |
| |
118 |
118 |
set var_elements [list] |
| |
119 |
119 |
|
| |
120 |
120 |
switch $value_method { |
| |
121 |
121 |
ams_value__options { |
| |
122 |
122 |
set operand_options [list \ |
| |
|
123 |
[list "- - - - - -" ""] \ |
| |
123 |
124 |
[list "[_ contacts.is_-]" "selected"] \ |
| |
124 |
125 |
[list "[_ contacts.is_not_-]" "not_selected"] \ |
| |
125 |
126 |
] |
| |
126 |
127 |
|
| |
127 |
128 |
if { $operand == "selected" || $operand == "not_selected" } { |
| |
128 |
129 |
set option_options [ams::widget_options -attribute_id $attribute_id] |
| |
129 |
130 |
lappend var_elements [list ${var1}:text(select) [list label {}] [list options $option_options]] |
| |
130 |
131 |
} |
| |
131 |
132 |
} |
| |
132 |
133 |
ams_value__telecom_number { |
| |
133 |
134 |
set operand_options [list \ |
| |
|
135 |
[list "- - - - - -" ""] \ |
| |
134 |
136 |
[list "[_ contacts.area_code_is_-]" "area_code_equals"] \ |
| |
135 |
137 |
[list "[_ contacts.area_code_is_not_-]" "not_area_code_equals"] \ |
| |
136 |
138 |
[list "[_ contacts.country_code_is_-]" "country_code_equals"] \ |
| |
137 |
139 |
[list "[_ contacts.lt_country_code_is_not_-]" "not_country_code_equals"] \ |
| |
138 |
140 |
] |
| |
139 |
141 |
if { [exists_and_not_null operand] } { |
| |
140 |
142 |
lappend var_elements [list ${var1}:integer(text) [list label {}] [list html [list size 3 maxlength 3]]] |
| |
141 |
143 |
} |
| |
142 |
144 |
} |
| |
143 |
145 |
ams_value__text { |
| |
144 |
146 |
set operand_options [list \ |
| |
|
147 |
[list "- - - - - -" ""] \ |
| |
145 |
148 |
[list "[_ contacts.contains_-]" "contains"] \ |
| |
146 |
149 |
[list "[_ contacts.does_not_contain_-]" "not_contains"] \ |
| |
147 |
150 |
] |
| |
148 |
151 |
if { [exists_and_not_null operand] } { |
| |
149 |
152 |
lappend var_elements [list ${var1}:text(text) [list label {}]] |
| |
150 |
153 |
} |
| |
151 |
154 |
} |
| |
152 |
155 |
ams_value__postal_address { |
| |
153 |
156 |
set operand_options [list \ |
| |
|
157 |
[list "- - - - - -" ""] \ |
| |
154 |
158 |
[list "[_ contacts.country_is_-]" "country_is"] \ |
| |
155 |
159 |
[list "[_ contacts.country_is_not_-]" "country_is_not"] \ |
| |
156 |
160 |
[list "[_ contacts.stateprovince_is_-]" "state_is"] \ |
| |
157 |
161 |
[list "[_ contacts.lt_stateprovince_is_not_]" "state_is_not"] \ |
| |
158 |
162 |
[list "[_ contacts.lt_zippostal_starts_with]" "zip_is"] \ |
| |
159 |
163 |
[list "[_ contacts.lt_zippostal_does_not_st]" "zip_is_not"] \ |
| |
160 |
164 |
] |
| |
161 |
165 |
|
| |
162 |
166 |
if { $operand == "state_is" || $operand == "state_is_not" } { |
| |
163 |
167 |
lappend var_elements [list ${var1}:text(text) [list label {}] [list html [list size 2 maxlength 2]]] |
| |
164 |
168 |
} elseif { $operand == "country_is" || $operand == "country_is_not" } { |
| |
165 |
169 |
set country_options [template::util::address::country_options] |
| |
166 |
170 |
lappend var_elements [list ${var1}:text(select) [list label {}] [list options $country_options]] |
| |
167 |
171 |
} elseif { $operand == "zip_is" || $operand == "zip_is_not" } { |
| |
168 |
172 |
lappend var_elements [list ${var1}:text(text) [list label {}] [list html [list size 7 maxlength 7]]] |
| |
169 |
173 |
} |
| |
170 |
174 |
} |
| |
171 |
175 |
ams_value__number { |
| |
172 |
176 |
set operand_options [list \ |
| |
173 |
177 |
[list "[_ contacts.is_-]" "is"] \ |
| |
174 |
178 |
[list "[_ contacts.is_greater_than_-]" "greater_than"] \ |
| |
175 |
179 |
[list "[_ contacts.is_less_than_-]" "less_than"] \ |
| |
176 |
180 |
] |
| |
177 |
181 |
if { [exists_and_not_null operand] } { |
| |
178 |
182 |
lappend var_elements [list ${var1}:integer(text) [list label {}] [list html [list size 4 maxlength 20]]] |
| |
179 |
183 |
} |
| |
180 |
184 |
} |
| |
181 |
185 |
ams_value__time { |
| |
182 |
186 |
set operand_options [list \ |
| |
|
187 |
[list "- - - - - -" ""] \ |
| |
183 |
188 |
[list "[_ contacts.is_less_than_-]" "less_than"] \ |
| |
184 |
189 |
[list "[_ contacts.is_more_than_-]" "more_than"] \ |
| |
185 |
190 |
[list "[_ contacts.is_after_-]" "after"] \ |
| |
186 |
191 |
[list "[_ contacts.is_before_-]" "before"] \ |
| |
187 |
192 |
] |
| |
188 |
193 |
if { $operand == "more_than" || $operand == "less_than" } { |
| |
189 |
194 |
set interval_options [list \ |
| |
190 |
195 |
[list years years] \ |
| |
191 |
196 |
[list months months] \ |
| |
192 |
197 |
[list days days] \ |
| |
193 |
198 |
] |
| |
194 |
199 |
lappend var_elements [list \ |
| |
195 |
200 |
${var1}:integer(text) \ |
| |
196 |
201 |
[list label {}] \ |
| |
197 |
202 |
[list html [list size 2 maxlength 3]] \ |
| |
198 |
203 |
] |
| |
199 |
204 |
lappend var_elements [list \ |
| |
200 |
205 |
${var2}:text(select) \ |
| |
201 |
206 |
[list label {}] \ |
| |
202 |
207 |
[list options $interval_options] \ |
| |
203 |
208 |
[list after_html [list ago]] \ |
| |
204 |
209 |
] |
| |
205 |
210 |
} elseif { [exists_and_not_null operand] } { |
| |
206 |
211 |
lappend var_elements [list ${var1}:date(date) [list label {}]] |
| |
207 |
212 |
} |
| |
208 |
213 |
} |
| |
209 |
214 |
} |
| |
210 |
215 |
} |
| |
211 |
216 |
|
| |
212 |
217 |
set form_elements [list] |
| |
213 |
218 |
|
| |
214 |
219 |
|
| |
215 |
220 |
set attribute_options [db_list_of_lists get_attributes { |
| |
216 |
221 |
select pretty_name, attribute_id |
| |
217 |
222 |
from ams_attributes |
| |
218 |
223 |
where object_type in ('organization','party','person','user') |
| |
219 |
224 |
and ams_attribute_id is not null |
| |
220 |
225 |
}] |
| |
221 |
226 |
set sorted_options [ams::util::localize_and_sort_list_of_lists -list $attribute_options] |
| |
222 |
|
set attribute_options [list [list "" ""]] |
| |
|
227 |
set attribute_options [list [list "- - - -" ""]] |
| |
223 |
228 |
foreach op $sorted_options { |
| |
224 |
229 |
if { $without_arrow_p } { |
| |
225 |
230 |
lappend attribute_options [list "[lindex $op 0]" "[lindex $op 1]"] |
| |
226 |
231 |
} else { |
| |
227 |
232 |
lappend attribute_options [list "[lindex $op 0] ->" "[lindex $op 1]"] |
| |
228 |
233 |
} |
| |
229 |
234 |
} |
| |
230 |
235 |
lappend form_elements [list \ |
| |
231 |
236 |
${prefix}attribute_id:text(select),optional \ |
| |
232 |
237 |
[list label {}] \ |
| |
233 |
238 |
[list options $attribute_options] \ |
| |
234 |
239 |
[list html [list onChange "javascript:acs_FormRefresh('$form_name')"]] \ |
| |
235 |
240 |
[list value $attribute_id] \ |
| |
236 |
241 |
] |
| |
237 |
242 |
|
| |
238 |
243 |
if { [exists_and_not_null attribute_id] } { |
| |
239 |
244 |
# now we add operand options that are available to anybody |
| |
240 |
245 |
lappend operand_options [list "[_ contacts.is_set]" "set"] [list "[_ contacts.is_not_set]" "not_set"] |
| |
241 |
246 |
|
| |
242 |
247 |
lappend form_elements [list \ |