Index: openacs-4/packages/ecommerce/www/admin/products/upload-vendor-imports-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/upload-vendor-imports-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ecommerce/www/admin/products/upload-vendor-imports-2.tcl 14 Aug 2008 11:05:42 -0000 1.1 +++ openacs-4/packages/ecommerce/www/admin/products/upload-vendor-imports-2.tcl 16 Aug 2008 12:46:49 -0000 1.2 @@ -12,55 +12,44 @@ } # We need them to be logged in - ad_require_permission [ad_conn package_id] admin set user_id [ad_get_user_id] set peeraddr [ns_conn peeraddr] - +set serious_errors 0 # Grab package_id as context_id - set context_id [ad_conn package_id] + set title "Import Vendors Products" -doc_body_append "[ad_admin_header $title] -

$title

+set context [list [list index Products] $title] -[ad_context_bar [list "../" "Ecommerce([ec_system_name])"] [list "index.tcl" "Products"] $title] -
-
-" - # Get the name of the transfered data file - set unix_file_name ${csv_file.tmpfile} # Check that the file is readable. - if { ![file readable $unix_file_name] } { - doc_body_append "Cannot read file $unix_file_name" - return + append doc_body "Cannot read file $unix_file_name" + set serious_errors 1 } # Check that vendor abbrev length is > 0 if { [string length $abbrev] == 0 } { - doc_body_append "Vendor abbreviation does not exist." - return + append doc_body "Vendor abbreviation does not exist." + set serious_errors 1 } # Start reading. # use file_type to determine which proc to delimit data set datafilefp [open $unix_file_name] set count 0 -set errors 0 +set errors $serious_errors set success_count 0 # Continue reading the file till the end but stop when an error # occured. - set line_status [ns_getcsv $datafilefp elements] while { $line_status != -1 && !$errors } { - # Create or update the product if all the required fields were # given values. foreach vendor_code $elements { @@ -71,7 +60,6 @@ } else { incr success_count } - } # read next line of data file, depending on file type, or end read loop if error. set line_status [ns_getcsv $datafilefp elements] @@ -83,9 +71,4 @@ set product_string "products" } -doc_body_append "
- -

Successfully imported $success_count $product_string out of [ec_decode $count "0" "0" [expr $count -1]]. -See server log for details. -[ad_admin_footer] -" +set line_count [ec_decode $count "0" "0" [expr $count -1]]