Index: openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 10 Apr 2006 14:14:20 -0000 1.16 +++ openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 5 Jun 2006 11:34:17 -0000 1.17 @@ -160,6 +160,16 @@ } { } +ad_proc -public -callback iv::offer_create_items { + {-project_item_id:required} + {-organization_id:required} + {-offer_id:required} +} { + Callback to be executed for actually filling the offer items to the offer. + As this is usually very custom specific we need a callback here + This callback is hooked into /www/offer-create +} - + ad_proc -public -callback contacts::populate::organization::customer_attributes -impl invoices { {-list_id:required} } { Index: openacs-4/packages/invoices/tcl/price-list-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/price-list-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/invoices/tcl/price-list-procs.tcl 11 Oct 2005 15:23:28 -0000 1.2 +++ openacs-4/packages/invoices/tcl/price-list-procs.tcl 5 Jun 2006 11:34:17 -0000 1.3 @@ -109,3 +109,25 @@ return "" } } + +ad_proc -public iv::price_list::get_price { + -organization_id:required + -category_id:required + {-package_id ""} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-07-01 + + Get id of customer price for a certain category +} { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + + set list_id [iv::price_list::get_list_id -organization_id $organization_id -package_id $package_id] + if {$list_id eq ""} { + return "" + } else { + return [db_string get_price "select amount from iv_prices p, cr_items i where i.latest_revision = p.price_id and p.list_id = :list_id and category_id = :category_id" -default ""] + } +} Index: openacs-4/packages/invoices/www/offer-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-create.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices/www/offer-create.tcl 5 Jun 2006 11:34:17 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + Page to automatically create an offer from a given project. + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-06-06 +} { + organization_id:integer + project_item_id:integer + return_url +} + +set package_id [ad_conn package_id] +# First get the basic organization date +set list_id [iv::price_list::get_list_id -organization_id $organization_id] +if {[empty_string_p $list_id]} { + set currency [parameter::get -parameter "DefaultCurrency" -default "EUR" -package_id $package_id] + set credit_percent 0 +} else { + db_1row get_currency_and_credit_percent {} +} + +set payment_days "0" +set vat_percent "0.0" +set contacts_package_id [lindex [application_link::get_linked -from_package_id $package_id -to_package_key contacts] 0] +array set org_data [contacts::get_values \ + -group_name "Customers" \ + -object_type "organization" \ + -party_id $organization_id \ + -contacts_package_id $contacts_package_id] +if {[info exists org_data(payment_days)]} { + set payment_days $org_data(payment_days) +} +if {[info exists org_data(vat_percent)]} { + set vat_percent [format "%.1f" $org_data(vat_percent)] +} + +# Get the information from the project + +db_1row get_project {} + +# The PA name should be the same as the project +set title "PA $project_name" + +# Create the new offer +set new_offer_rev_id [iv::offer::new \ + -title $title \ + -comment $comment \ + -organization_id $organization_id \ + -amount_total 0 \ + -amount_sum 0 \ + -currency $currency \ + -payment_days $payment_days \ + -vat_percent $vat_percent \ + -vat 0 \ + -credit_percent $credit_percent] + +set offer_id [content::revision::item_id -revision_id $new_offer_rev_id] + +application_data_link::new -this_object_id $offer_id -target_object_id $project_item_id + + + +# now it is time to create the offer-items. +# This is basically a copy of the project_new callback and should be kept in sync. +# Byte the way: Everything below this line is most likely custom code + +callback iv::offer_create_items -offer_id $new_offer_rev_id -project_item_id $project_item_id -organization_id $organization_id + +ad_returnredirect $return_url \ No newline at end of file Index: openacs-4/packages/invoices/www/offer-create.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-create.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/invoices/www/offer-create.xql 5 Jun 2006 11:34:17 -0000 1.1 @@ -0,0 +1,28 @@ + + + + + + + select l.currency, l.credit_percent as credit_percent + from iv_price_lists l, cr_items li + where l.list_id = li.latest_revision + and li.item_id = :list_id + + + + + + + + select r.title as project_name, r.item_id, p.project_code, r.description as comment, + to_char(p.planned_end_date,'YYYY-MM-DD HH24:MI:SS') as project_date_ansi + from cr_revisions r, cr_items i, pm_projects p + where i.item_id = :project_item_id + and i.latest_revision = r.revision_id + and p.project_id = r.revision_id + + + + +