Index: openacs-4/packages/invoices/www/invoice-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-ae.tcl,v
diff -u -r1.23 -r1.24
--- openacs-4/packages/invoices/www/invoice-ae.tcl 29 Jan 2006 14:29:41 -0000 1.23
+++ openacs-4/packages/invoices/www/invoice-ae.tcl 29 Jan 2006 15:43:16 -0000 1.24
@@ -165,7 +165,7 @@
}
ad_form -extend -name iv_invoice_form -form {
- {invoice_nr:text {label "[_ invoices.iv_invoice_invoice_nr]"} {html {size 80 maxlength 200}} {help_text "[_ invoices.iv_invoice_invoice_nr_help]"}}
+ {invoice_nr:text(inform) {label "[_ invoices.iv_invoice_invoice_nr]"} {help_text "[_ invoices.iv_invoice_invoice_nr_help]"}}
}
if {$has_submit} {
@@ -325,7 +325,6 @@
set description [lang::util::localize [join [db_list project_titles {}] ",\n"]]
set due_date [db_string today {}]
set title "[_ invoices.iv_invoice_1] $organization_name $due_date"
- set invoice_nr [db_nextval iv_invoice_seq]
db_1row offer_data {}
set vat_percent [format "%.1f" $vat_percent]
Index: openacs-4/packages/invoices/www/invoice-send.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-send.tcl,v
diff -u -r1.13 -r1.14
--- openacs-4/packages/invoices/www/invoice-send.tcl 4 Jan 2006 08:06:48 -0000 1.13
+++ openacs-4/packages/invoices/www/invoice-send.tcl 29 Jan 2006 15:43:16 -0000 1.14
@@ -18,6 +18,12 @@
set page_title "[_ invoices.iv_invoice_send]"
db_1row invoice_data {}
+
+# We are only getting the invoice_nr here.
+if {[string eq $invoice_nr ""]} {
+ set invoice_nr [db_nextval iv_invoice_seq]
+}
+
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]"] $page_title]
@@ -99,14 +105,42 @@
# content::item::set_live_revision -revision_id $file_id
lappend file_ids $file_id
- db_dml set_publish_status {}
+# db_dml set_publish_status {}
}
}
if {[llength $file_ids] > 0} {
- set return_url [export_vars -base invoice-pdf {invoice_id {file_id:multiple $file_ids}}]
-} else {
- set return_url [export_vars -base invoice-list {organization_id}]
+
+ # an invoice has been generated.
+ # Store this fact as "Billed" in the system.
+
+ set project_id [lindex [application_data_link::get_linked -from_object_id $invoice_id -to_object_type content_item] 0]
+ if {![empty_string_p $project_id]} {
+ acs_object::get -object_id $project_id -array project
+ set pm_url [lindex [site_node::get_url_from_object_id -object_id $project(package_id)] 0]
+ set return_url [export_vars -base "${pm_url}one" {{project_item_id $project_id}}]
+ } else {
+ set return_url [export_vars -base invoice-list {organization_id}]
+ }
+
+ set root_folder_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type content_folder] 0]
+ set invoice_folder_id [fs::get_folder -name "invoices_${root_folder_id}" -parent_id $root_folder_id]
+ db_transaction {
+ # move files to invoice_folder
+ foreach one_file $file_id {
+ content::item::move -item_id $one_file -target_folder_id $invoice_folder_id
+ application_data_link::new -this_object_id $invoice_id -target_object_id $one_file
+ db_dml set_publish_status {}
+ db_dml set_context_id {}
+ }
+ db_dml set_invoice_nr {}
+ if {$status != "paid"} {
+ iv::invoice::set_status -invoice_id $invoice_id -status "billed"
+ }
+ }
+
}
+
+set return_url [export_vars -base invoice-list {organization_id}]
ad_return_template
Index: openacs-4/packages/invoices/www/invoice-send.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-send.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/invoices/www/invoice-send.xql 31 Dec 2005 07:36:24 -0000 1.5
+++ openacs-4/packages/invoices/www/invoice-send.xql 29 Jan 2006 15:43:16 -0000 1.6
@@ -5,22 +5,42 @@
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
+ i.total_amount, i.recipient_id, i.contact_id, i.organization_id, i.status
from iv_invoices i, cr_items ii
where ii.latest_revision = i.invoice_id
and ii.item_id = :invoice_id
+
+
+
+ update iv_invoices
+ set invoice_nr = :invoice_nr
+ where invoice_id = (select latest_revision from cr_items where item_id = :invoice_id)
+
+
+
+
update cr_items
- set publish_status = 'expired'
- where item_id = :file_id
+ set publish_status = 'live'
+ where item_id = :one_file
+
+
+
+ update acs_objects
+ set context_id = :invoice_folder_id
+ where object_id = :one_file
+
+
+
+