Index: openacs-4/packages/ecommerce/www/admin/products/edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/edit-2.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/ecommerce/www/admin/products/edit-2.tcl 27 Apr 2008 01:38:24 -0000 1.10 +++ openacs-4/packages/ecommerce/www/admin/products/edit-2.tcl 13 Aug 2008 21:22:03 -0000 1.11 @@ -34,7 +34,7 @@ upload_file:optional upload_file.tmpfile:optional template_id - ec_custom_fields:array,optional + ec_custom_fields:array,html,optional } -validate { @@ -55,23 +55,23 @@ where column_type in ('date','integer') and active_p='t' } { - switch $column_type { + switch $column_type { - date { - if { [catch { set ec_custom_fields($field_identifier) [validate_ad_dateentrywidget $field_name ec_custom_fields.$field_identifier [ns_getform] 1]} errmsg] } { - ad_complain "$errmsg" - } - } - integer { - if { ![empty_string_p $ec_custom_fields($field_identifier)] } { - if { [catch {validate_integer $field_name $ec_custom_fields($field_identifier)} errmsg] } { - ad_complain "$errmsg" - } - } - } - } + date { + if { [catch { set ec_custom_fields($field_identifier) [validate_ad_dateentrywidget $field_name ec_custom_fields.$field_identifier [ns_getform] 1]} errmsg] } { + ad_complain "$errmsg" + } + } + integer { + if { ![empty_string_p $ec_custom_fields($field_identifier)] } { + if { [catch {validate_integer $field_name $ec_custom_fields($field_identifier)} errmsg] } { + ad_complain "$errmsg" + } + } + } + } } - } + } } ad_require_permission [ad_conn package_id] admin @@ -108,10 +108,10 @@ } if {$llength > 2} { set subsubcategory_id [lindex $categorization 2] - if {[lsearch -exact $subsubcategory_id_list $subsubcategory_id] == -1 && ![empty_string_p $subsubcategory_id] } { - lappend subsubcategory_id_list $subsubcategory_id + if {[lsearch -exact $subsubcategory_id_list $subsubcategory_id] == -1 && ![empty_string_p $subsubcategory_id] } { + lappend subsubcategory_id_list $subsubcategory_id # ns_log debug edit-2 lappending subsubcategory_id $subsubcategory_id - } + } } } @@ -152,291 +152,94 @@ set dirname [ecommerce::resource::dirname -product_id $product_id -product_name $product_name] set linked_thumbnail [ec_linked_thumbnail_if_it_exists $dirname] -doc_body_append "[ad_admin_header "Confirm Product Changes"] +set title "Confirm Product Changes" +set context [list $title] -

Confirm Product Changes

+set currency [parameter::get -package_id [ec_id] -parameter Currency] +set multiple_retailers_p [ad_parameter -package_id [ec_id] MultipleRetailersPerProductP ecommerce] -[ad_context_bar [list "../" "Ecommerce([ec_system_name])"] [list "index" "Products"] [list "one?[export_url_vars product_id]" $product_name] "Edit Product"] -
-

Please confirm that the information below is correct:

-" +set categorization_html [ec_category_subcategory_and_subsubcategory_display $category_id_list $subcategory_id_list $subsubcategory_id_list] -set currency [ad_parameter -package_id [ec_id] Currency ecommerce] -set multiple_retailers_p [ad_parameter -package_id [ec_id] MultipleRetailersPerProductP ecommerce] +if { $multiple_retailers_p } { + [ec_message_if_null $stock_status] -doc_body_append "
-
- -
-
-$linked_thumbnail - - - - - - - - - - - - - -" -if { !$multiple_retailers_p } { - doc_body_append " - - - - " -} -doc_body_append " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" -if { !$multiple_retailers_p } { - doc_body_append " - - - - " -} -doc_body_append " - - - - - - - -" -if { !$multiple_retailers_p } { - doc_body_append " - - - - - - - - " -} -doc_body_append " - - - -" -if { !$multiple_retailers_p } { + set user_classes_select_html "" db_foreach user_classes_select "select user_class_id, user_class_name from ec_user_classes order by user_class_name" { - if { [info exists user_class_prices($user_class_id)] } { - doc_body_append " - - - - - " - } + " + } } } +set regular_price [ec_message_if_null [ec_pretty_price $price $currency]] +set shipping_price [ec_message_if_null [ec_pretty_price $shipping $currency]] +set shipping_additional_price [ec_message_if_null [ec_pretty_price $shipping_additional $currency]] +set one_line_description_html [ec_message_if_null $one_line_description] +set detailed_description_html [ec_display_as_html [ec_message_if_null $detailed_description]] +set search_keywords_html [ec_message_if_null $search_keywords] +set color_list_html [ec_message_if_null $color_list] +set size_list_html [ec_message_if_null $size_list] +set style_list_html [ec_message_if_null $style_list] +set email_on_purchase_list_html [ec_message_if_null $email_on_purchase_list] +set url_html [ec_message_if_null $url] +set no_shipping_avail_p_html [ec_message_if_null [ec_PrettyBoolean [ec_decode $no_shipping_avail_p "t" "f" "f" "t"]]] +set present_p_html [ec_message_if_null [ec_PrettyBoolean $present_p]] +set weight_html "[ec_message_if_null $weight] [ec_decode $weight "" "" [parameter::get -package_id [ec_id] -parameter WeightUnits -default lbs]]" +set template_name_select_html [ec_message_if_null [db_string template_name_select "select template_name from ec_templates where template_id=:template_id" -default ""]] +set available_date_html [ec_message_if_null [util_AnsiDatetoPrettyDate [ec_date_text available_date]]] + +set custom_fields_select_html "" db_foreach custom_fields_select { select field_identifier, field_name, column_type from ec_custom_product_fields where active_p = 't' } { if { [string equal $column_type "date"] || [string equal $column_type "timestamp"] } { - - #CM This is a mess but it seems to work. Basically need to put together the date from the pieces - - #set up a date array to work with. - array set date "year $ec_custom_fields($field_identifier.year) month $ec_custom_fields($field_identifier.month) day $ec_custom_fields($field_identifier.day)" - - #Validate the date - This really should get caught somewhere or put up in the validate section of page contract. - - ec_date_widget_validate date - - #Run the proc that usually runs as part of page contract - ad_page_contract_filter_proc_date name date - - #Now set the custom field to the ansi date that is set by the above. - set ec_custom_fields($field_identifier) $date(date) - + #CM This is a mess but it seems to work. Basically need to put together the date from the pieces + #set up a date array to work with. + array set date "year $ec_custom_fields($field_identifier.year) month $ec_custom_fields($field_identifier.month) day $ec_custom_fields($field_identifier.day)" + + #Validate the date - This really should get caught somewhere or put up in the validate section of page contract. + ec_date_widget_validate date + #Run the proc that usually runs as part of page contract + ad_page_contract_filter_proc_date name date + #Now set the custom field to the ansi date that is set by the above. + set ec_custom_fields($field_identifier) $date(date) } if { [info exists ec_custom_fields($field_identifier)] } { - doc_body_append " - - - - - " + append custom_fields_select_html "" } } -doc_body_append " - - - - - - - -
-Product Name: - -$product_name -
-SKU - -$sku -
-Categorization: - -[ec_category_subcategory_and_subsubcategory_display $category_id_list $subcategory_id_list $subsubcategory_id_list] -
- Stock Status: - - " +} else { if { ![empty_string_p $stock_status] } { - doc_body_append [util_memoize "ad_parameter -package_id [ec_id] \"StockMessage[string toupper $stock_status]\"" [ec_cache_refresh]] - } else { - doc_body_append [ec_message_if_null $stock_status] + set stock_status_html [util_memoize "ad_parameter -package_id [ec_id] \"StockMessage[string toupper $stock_status]\"" [ec_cache_refresh]] } - - doc_body_append "
-One-Line Description: - -[ec_message_if_null $one_line_description] -
-Additional Descriptive Text: - -[ec_display_as_html [ec_message_if_null $detailed_description]] -
-Search Keywords: - -[ec_message_if_null $search_keywords] -
-Color Choices: - -[ec_message_if_null $color_list] -
-Size Choices: - -[ec_message_if_null $size_list] -
-Style Choices: - -[ec_message_if_null $style_list] -
-Email on Purchase: - -[ec_message_if_null $email_on_purchase_list] -
-URL: - -[ec_message_if_null $url] -
- Regular Price: - - [ec_message_if_null [ec_pretty_price $price $currency]] -
-Is this product shippable? - -[ec_message_if_null [ec_PrettyBoolean [ec_decode $no_shipping_avail_p "t" "f" "f" "t"]]] -
-Display this product when user does a search? - -[ec_message_if_null [ec_PrettyBoolean $present_p]] -
- Shipping Price - - [ec_message_if_null [ec_pretty_price $shipping $currency]] -
- Shipping - Additional - - [ec_message_if_null [ec_pretty_price $shipping_additional $currency]] -
-Weight - -[ec_message_if_null $weight] [ec_decode $weight "" "" [ad_parameter -package_id [ec_id] WeightUnits ecommerce]] -
+ if { [info exists user_class_prices($user_class_id)] } { + append user_classes_select_html "
$user_class_name Price: - + [ec_message_if_null [ec_pretty_price [set user_class_prices($user_class_id)] $currency]] -
- $field_name - - " + append custom_fields_select_html "
$field_name" if { $column_type == "char(1)" } { - doc_body_append "[ec_message_if_null [ec_PrettyBoolean "$ec_custom_fields($field_identifier)"]]\n" + append custom_fields_select_html "[ec_message_if_null [ec_PrettyBoolean "$ec_custom_fields($field_identifier)"]]\n" } elseif { $column_type == "date" || $column_type == "timestamp" } { - doc_body_append "$ec_custom_fields($field_identifier) to [ec_message_if_null [util_AnsiDatetoPrettyDate "$ec_custom_fields($field_identifier)"]]\n" + append custom_fields_select_html "$ec_custom_fields($field_identifier) to [ec_message_if_null [util_AnsiDatetoPrettyDate "$ec_custom_fields($field_identifier)"]]\n" } else { - doc_body_append "[ec_display_as_html [ec_message_if_null "$ec_custom_fields($field_identifier)"]]\n" + append custom_fields_select_html "[ec_display_as_html [ec_message_if_null "$ec_custom_fields($field_identifier)"]]\n" } - doc_body_append "
-Template - -[ec_message_if_null [db_string template_name_select "select template_name from ec_templates where template_id=:template_id" -default ""]] -
-Available Date - -[ec_message_if_null [util_AnsiDatetoPrettyDate [ec_date_text available_date]]] -
-
-

+set export_form_vars_html "[export_form_vars product_name sku category_id_list subcategory_id_list subsubcategory_id_list one_line_description detailed_description color_list size_list style_list email_on_purchase_list search_keywords url price no_shipping_avail_p present_p shipping shipping_additional weight template_id product_id stock_status] +" -[export_form_vars product_name sku category_id_list subcategory_id_list subsubcategory_id_list one_line_description detailed_description color_list size_list style_list email_on_purchase_list search_keywords url price no_shipping_avail_p present_p shipping shipping_additional weight template_id product_id stock_status] - -" - # also need to export custom field values db_foreach custom_fields_export "select field_identifier from ec_custom_product_fields where active_p='t'" { - if { [info exists ec_custom_fields($field_identifier)] } { - doc_body_append "\n" - } + if { [info exists ec_custom_fields($field_identifier)] } { + append export_form_vars_html "\n" + } } foreach user_class_id [db_list user_class_select "select user_class_id from ec_user_classes"] { - if { [info exists user_class_prices($user_class_id)] } { - doc_body_append "\n" - } + if { [info exists user_class_prices($user_class_id)] } { + append export_form_vars_html "\n" + } } - -doc_body_append "

- -
-
- -[ad_admin_footer] -"