Index: openacs-4/packages/invoices/lib/invoice-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-list.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/invoices/lib/invoice-list.tcl 4 Jan 2006 08:06:45 -0000 1.10 +++ openacs-4/packages/invoices/lib/invoice-list.tcl 27 Jan 2006 16:22:47 -0000 1.11 @@ -95,7 +95,7 @@ display_template {[_ invoices.iv_invoice_status_@iv_invoice.status@]} } action { - display_template {#invoices.Edit# #invoices.Invoice_Cancel# #invoices.Delete#} + display_template {#invoices.Edit# #invoices.Invoice_Cancel# #invoices.Delete# #invoices.Preview#} } } -actions $actions -sub_class narrow \ -bulk_actions $bulk_actions \ @@ -153,7 +153,11 @@ -page_flush_p 1 \ -page_query_name iv_invoice_paginated \ -pass_properties {invoice_cancel_p} \ - -filters {organization_id {}} \ + -filters { + organization_id { + where_clause {t.organization_id = :organization_id} + } + } \ -formats { normal { label "[_ invoices.Table]" @@ -170,12 +174,13 @@ set contacts_p [apm_package_installed_p contacts] -db_multirow -extend {creator_link edit_link cancel_link delete_link recipient} iv_invoice iv_invoice {} { +db_multirow -extend {creator_link edit_link cancel_link delete_link preview_link recipient} iv_invoice iv_invoice {} { # Ugly hack. We should find out which contact package is linked set edit_link [export_vars -base "${base_url}invoice-ae" {invoice_id}] set cancel_link [export_vars -base "${base_url}invoice-cancellation" {organization_id {parent_id $invoice_rev_id}}] set delete_link [export_vars -base "${base_url}invoice-delete" {invoice_id}] + set preview_link [export_vars -base "${base_url}invoice-preview" {invoice_id}] if {[empty_string_p $total_amount]} { set total_amount 0 } Index: openacs-4/packages/invoices/www/invoice-preview.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-preview.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices/www/invoice-preview.tcl 27 Jan 2006 16:22:46 -0000 1.1 @@ -0,0 +1,64 @@ +ad_page_contract { + Preview of an invoice + + @author Malte Sussdorff (malte.sussdorff@cognovis.de) + @creation-date 2006-01-26 +} { + invoice_id:integer + {invoice_p 1} + {file_ids ""} +} -properties { + context:onevalue + page_title:onevalue +} + +db_1row invoice_data {} + +set locale [lang::user::site_wide_locale -user_id $contact_id] + +set context [list [list [export_vars -base invoice-list {organization_id}] "[_ invoices.iv_invoice_2]"] [list [export_vars -base invoice-ae {invoice_id}] "[_ invoices.iv_invoice_View]"] Preview] + +set document_types {} + +if {$total_amount > 0} { + # send invoice + set invoice_text "#invoices.iv_invoice_email#" + set subject [lang::util::localize "#invoices.iv_invoice_email_subject#" $locale] + set invoice_title [lang::util::localize "#invoices.file_invoice#_${invoice_nr}.pdf" $locale] + if {$invoice_p} { + set document_types invoice + } +} elseif {[empty_string_p $parent_invoice_id]} { + # send credit + set invoice_text "#invoices.iv_invoice_credit_email#" + set subject [lang::util::localize "#invoices.iv_invoice_credit_email_subject#" $locale] + set invoice_title [lang::util::localize "#invoices.file_invoice_credit#_${invoice_nr}.pdf" $locale] + if {$invoice_p} { + set document_types credit + } +} else { + # send cancellation + set invoice_text "#invoices.iv_invoice_cancel_email#" + set subject [lang::util::localize "#invoices.iv_invoice_cancel_email_subject#" $locale] + set invoice_title [lang::util::localize "#invoices.file_invoice_cancel#_${invoice_nr}.pdf" $locale] + if {$invoice_p} { + set document_types cancel + } +} + +# substitute variables in invoice text +# and return the content of all necessary document files +# (opening, invoice/credit/cancellation, copy) +set documents [iv::invoice::parse_data -invoice_id $invoice_id -types $document_types -email_text $invoice_text] + +set invoice_text [lindex $documents 0] + +set documents [lreplace $documents 0 0] + +set file_title $invoice_title + +if {![empty_string_p $documents]} { + set file_size [file size $documents] + set file [contact::oo::import_oo_pdf -oo_file $documents -printer_name "pdfconv" -title $file_title -parent_id $invoice_id -no_import] + ns_returnfile 200 [lindex $file 0] [lindex $file 1] +} Index: openacs-4/packages/invoices/www/invoice-preview.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-preview.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices/www/invoice-preview.xql 27 Jan 2006 16:22:46 -0000 1.1 @@ -0,0 +1,16 @@ + + + + + + + select i.invoice_nr, i.organization_id, i.parent_invoice_id, i.invoice_nr, + i.total_amount, i.recipient_id, i.contact_id, i.organization_id + from iv_invoices i, cr_items ii + where ii.latest_revision = i.invoice_id + and ii.item_id = :invoice_id + + + + +