Index: openacs-4/packages/invoices/www/invoice-send-1.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-send-1.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/invoices/www/invoice-send-1.tcl 4 Jan 2006 08:06:48 -0000 1.3 +++ openacs-4/packages/invoices/www/invoice-send-1.tcl 2 Apr 2006 22:08:02 -0000 1.4 @@ -5,6 +5,7 @@ @creation-date 2005-12-24 } { invoice_id:integer + {return_url:optional ""} } -properties { context:onevalue page_title:onevalue @@ -23,12 +24,18 @@ set rec_organization_id $recipient_id } +# warn if invoice already got sent +set sent_p 0 +if {![empty_string_p $invoice_nr]} { + set sent_p 1 +} + set rec_orga_revision_id [content::item::get_best_revision -item_id $rec_organization_id] set invoice_copy [ams::value -attribute_name "invoice_copy" -object_id $rec_orga_revision_id] set boolean_options [list [list "[_ invoices.yes]" 1] [list "[_ invoices.no]" 0]] -ad_form -name invoice_send -action invoice-send-1 -form { +ad_form -name invoice_send -action invoice-send-1 -export {return_url} -form { {invoice_id:key} } @@ -41,15 +48,26 @@ ad_form -extend -name invoice_send -form { {invoice_p:text(radio) {label "[_ invoices.iv_invoice_p]"} {options $boolean_options}} {copy_p:text(radio) {label "[_ invoices.iv_invoice_copy_p]"} {options $boolean_options}} + {email_p:text(radio) {label "[_ invoices.iv_invoice_email_p]"} {options $boolean_options}} } -edit_request { set opening_p 0 set invoice_p 1 + set email_p 0 set copy_p [ad_decode $invoice_copy t 1 0] if {[empty_string_p $copy_p]} { set copy_p 0 } + if {$sent_p} { + # if invoice is already sent, let user send copy by default + set invoice_p 0 + set copy_p 1 + } } -after_submit { - ad_returnredirect [export_vars -base "invoice-send" {invoice_id opening_p invoice_p copy_p}] + if {$email_p} { + ad_returnredirect [export_vars -base "invoice-send" {invoice_id opening_p invoice_p copy_p return_url}] + } else { + ad_returnredirect [export_vars -base "invoice-documents" {invoice_id opening_p invoice_p copy_p return_url}] + } ad_script_abort }