Index: openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl,v diff -u -r1.13.2.1 -r1.13.2.2 --- openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl 29 Oct 2004 04:45:45 -0000 1.13.2.1 +++ openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl 31 Oct 2004 10:14:22 -0000 1.13.2.2 @@ -141,13 +141,18 @@ } { Get Custom Form Element. } { - if { $column_type == "integer" || $column_type == "number"} { + if { [string equal $column_type "integer"] || [string equal $column_type "number"] } { return "" - } elseif { $column_type == "date" } { - return [ad_dateentrywidget ec_custom_fields.$field_identifier $default_value] - } elseif { $column_type == "varchar(200)" } { + } elseif { [string equal $column_type "date"] } { + return "[ad_dateentrywidget ec_custom_fields.$field_identifier $default_value]" + } elseif { [string equal $column_type "timestamp"] } { + # timestamp is in form yyyy-mm-dd hh:mm:ss + # so ec_timeentrywidget could be added here for lindex default_values 1 + set default_values [split $default_value " "] + return "[ad_dateentrywidget ec_custom_fields.$field_identifier [lindex $default_values 0]]" + } elseif { [string equal $column_type "varchar(200)"] } { return "" - } elseif { $column_type == "varchar(4000)" } { + } elseif { [string equal $column_type "varchar(4000)"] } { return "" } else { Index: openacs-4/packages/ecommerce/www/admin/products/custom-field-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/custom-field-add.tcl,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/ecommerce/www/admin/products/custom-field-add.tcl 9 Mar 2004 00:59:51 -0000 1.4 +++ openacs-4/packages/ecommerce/www/admin/products/custom-field-add.tcl 31 Oct 2004 10:12:59 -0000 1.4.2.1 @@ -38,15 +38,16 @@ the name you'll see when adding/updating products. - - Default Value (if any) - - What kind of information will this field hold? [ec_column_type_widget] + + Default Value (if any) + + For Date type, entering \"0\" here will set the default value to the current time of each new item. For other dates, use the format \"YYYY-MM-DD\" +
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.6 -r1.6.2.1 --- openacs-4/packages/ecommerce/www/admin/products/edit-2.tcl 9 Mar 2004 00:59:51 -0000 1.6 +++ openacs-4/packages/ecommerce/www/admin/products/edit-2.tcl 31 Oct 2004 10:12:59 -0000 1.6.2.1 @@ -126,10 +126,10 @@ #page_validation { #ec_date_widget_validate available_date #} { - #set date_field_identifiers [db_list custom_date_fields_select "select field_identifier from ec_custom_product_fields where column_type='date' and active_p='t'"] - #foreach field_identifier $date_field_identifiers { - #array set date {year ec_custom_fields($field_identifier.year) month ec_custom_fields($field_identifier.month) ec_custom_fields($field_identifier.day)} - # ec_date_widget_validate date +# set date_field_identifiers [db_list custom_date_fields_select "select field_identifier from ec_custom_product_fields where column_type='date' and active_p='t'"] + # foreach field_identifier $date_field_identifiers { + # array set date {year ec_custom_fields($field_identifier.year) month ec_custom_fields($field_identifier.month) ec_custom_fields($field_identifier.day)} + # ec_date_widget_validate date #} #} @@ -404,6 +404,24 @@ 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) + + } if { [info exists ec_custom_fields($field_identifier)] } { doc_body_append " @@ -414,8 +432,8 @@ " if { $column_type == "char(1)" } { doc_body_append "[ec_message_if_null [ec_PrettyBoolean "$ec_custom_fields($field_identifier)"]]\n" - } elseif { $column_type == "date" } { - doc_body_append "[ec_message_if_null [util_AnsiDatetoPrettyDate "$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" } else { doc_body_append "[ec_display_as_html [ec_message_if_null "$ec_custom_fields($field_identifier)"]]\n" }