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.4 -r1.5 --- openacs-4/packages/invoices/tcl/price-list-procs.tcl 29 Jun 2006 14:46:45 -0000 1.4 +++ openacs-4/packages/invoices/tcl/price-list-procs.tcl 4 Aug 2006 15:43:42 -0000 1.5 @@ -90,11 +90,13 @@ } } +# modified 2006/08/04 by cognovis/nfl: new logic related to the default price list id ad_proc -public iv::price_list::get_list_id { -organization_id:required {-package_id ""} } { @author Timo Hentschel (timo@timohentschel.de) + @author Nils Lohse (nils.lohse@cognovis.de) @creation-date 2005-07-01 Get id of customer price list (or default) @@ -103,13 +105,52 @@ set package_id [ad_conn package_id] } - if {[db_0or1row check_customer_price_list {}] || [db_0or1row check_default_price_list {}]} { - return $list_id - } else { - return "" + # --- 1) look, if there is a customer price list + if {[db_0or1row check_customer_price_list {}]} { + return $list_id + } else { + # --- 2) deliver default price list + set dpl_id [iv::price_list::get_default_list_id -package_id $package_id] + return $dpl_id } + +# old code - used until 2006/08/04: +# if {[db_0or1row check_customer_price_list {}] || [db_0or1row check_default_price_list {}]} { +# return $list_id +# } else { +# return "" +# } } +# created 2006/08/04 by cognovis/nfl +ad_proc -public iv::price_list::get_default_list_id { + {-package_id ""} +} { + @author Nils Lohse (nils.lohse@cognovis.de) + @creation-date 2006-08-04 + + Get id of default price list +} { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + + # --- 1) try to get the parameter DefaultPriceListID out of the .info file + set dpl_id [parameter::get -package_id $package_id -parameter DefaultPriceListID] + if {$dpl_id != ""} { + return $dpl_id + } else { + # --- 2) get lowest (= oldest) item_id of the pricelists + if {[db_0or1row get_oldest_price_list {}]} { + parameter::set_value -package_id $package_id -parameter DefaultPriceListID -value $list_id + return $list_id + } else { + return "" + } + } +} + + ad_proc -public iv::price_list::get_price { -organization_id:required -category_id:required @@ -131,3 +172,16 @@ 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 ""] } } + +# created 2006/08/04 by cognovis/nfl +ad_proc -public iv::price_list::get_name_of_list { + -item_id:required +} { + @author Nils Lohse (nils.lohse@cognovis.de) + @creation-date 2006-08-04 + + Get name of given price list +} { + set pricelist_name [content::item::get_title -item_id $item_id] + return $pricelist_name +} \ No newline at end of file