Index: openacs-4/packages/contacts/lib/label.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/label.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/contacts/lib/label.adp 16 Feb 2006 14:07:36 -0000 1.1
+++ openacs-4/packages/contacts/lib/label.adp 20 Feb 2006 09:11:10 -0000 1.2
@@ -1 +1 @@
-
+
Index: openacs-4/packages/contacts/lib/label.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/label.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/contacts/lib/label.tcl 16 Feb 2006 14:07:36 -0000 1.1
+++ openacs-4/packages/contacts/lib/label.tcl 20 Feb 2006 09:11:10 -0000 1.2
@@ -15,190 +15,82 @@
set $optional_param {}
}
}
+
set message_type "label"
+set label_options [callback contact::label -request "ad_form_option"]
ad_form -action message \
- -name letter \
+ -name label \
-cancel_label "[_ contacts.Cancel]" \
-cancel_url $return_url \
- -edit_buttons [list [list "[_ contacts.create_label] (this make take a bit, please be patient)" print]] \
+ -edit_buttons [list [list "[_ contacts.create_label] [_ contacts.lt_this_may_take_a_bit]" print]] \
-export {party_ids return_url title message_type} \
-form {
message_id:key
- {recipients:text(inform) {label "Contacts to Export"}}
+ {recipients:text(inform) {label "[_ contacts.Contacts_to_Export]"}}
{label_type:text(select),optional
- {label "[_ contacts.Label_Type]"}
- {options {{"Avery 5160 (1in x 2.5in, 30 per sheet)" avery5160}}}
+ {label "[_ contacts.Type]"}
+ {options $label_options}
}
} -on_request {
} -on_submit {
- # display the progress bar
+ }
- ad_progress_bar_begin \
- -title "Generating PDF" \
- -message_1 "Generating mailing labels for the contacts you selected, please wait..." \
- -message_2 "You will be automatically redirected once the file is complete."
+if { [template::form::is_valid label] || [llength $label_options] == "1" } {
+ if { [llength $label_options] == "1" } {
+ # we only have one envelope time to the user has to select it
+ set label_type [lindex [lindex $label_options 0] 1]
+ }
- set labels [list]
- foreach party_id $party_ids {
- set name [contact::name -party_id $party_id]
- set mailing_address [contact::message::mailing_address -party_id $party_id -format "text/plain"]
- if {[empty_string_p $mailing_address]} {
- ad_return_error [_ contacts.Error] [_ contacts.lt_there_was_an_error_processing_this_request]
- break
- }
-
- set name [openreport::clean_string_for_rml -string ${name}]
- set mailing_address [openreport::clean_string_for_rml -string ${mailing_address}]
-
- set one "
+ # display the progress bar
+
+ ad_progress_bar_begin \
+ -title [_ contacts.Generating_PDF] \
+ -message_1 [_ contacts.lt_Generating_the_labels_] \
+ -message_2 [_ contacts.lt_Once_finished_you_get]
+
+ set labels [list]
+ foreach party_id $party_ids {
+ set name [contact::name -party_id $party_id]
+ set mailing_address [contact::message::mailing_address -party_id $party_id -format "text/plain"]
+ if {[empty_string_p $mailing_address]} {
+ ad_return_error [_ contacts.Error] [_ contacts.lt_there_was_an_error_processing_this_request]
+ break
+ }
+
+ set name [openreport::clean_string_for_rml -string ${name}]
+ set mailing_address [openreport::clean_string_for_rml -string ${mailing_address}]
+
+ set one "
${name}
${mailing_address}
"
- lappend labels [string trim $one]
-
-
- }
-
-
- if { $label_type == "avery5160" } {
-
- # onLoad=\"window.print()\"
- set rml {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
-
+ lappend labels [string trim $one]
}
- set rml [string trim $rml]
- append rml "\n[join $labels "\n\n\n"]"
- append rml "\n\n"
-
- # Gerneate the pdf
- set filename "contacts_labels_[ad_conn user_id]_[dt_systime -format {%Y%m%d-%H%M%S}]_[ad_generate_random_string].pdf"
- set pdf_filename [openreport::trml2pdf -rml $rml -filename $filename]
- util_user_message -html -message "The pdf you requested is available. You may download it now."
- ad_progress_bar_end -url "[ad_conn package_url]pdfs/"
-
-# ad_returnredirect
- ad_script_abort
-
+
+ set rml ""
+ append rml [lindex [callback contact::label -request "template" -for $label_type] 0]
+ append rml ""
+ append rml [join $labels ""]
+ append rml ""
+
+ # Gerneate the pdf
+ set filename "contacts_labels_[ad_conn user_id]_[dt_systime -format {%Y%m%d-%H%M%S}]_[ad_generate_random_string].pdf"
+ set pdf_filename [openreport::trml2pdf -rml $rml -filename $filename]
+ set pdf_url "[ad_conn package_url]pdfs/${filename}"
+ util_user_message -html -message [_ contacts.lt_The_pdf_you_requested_-pdf_url-]
+
+ if { [exists_and_not_null return_url] } {
+ ad_progress_bar_end -url ${return_url}
+ ad_script_abort
+ } else {
+ ad_progress_bar_end -url [ad_conn package_url]
+ ad_script_abort
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+}