Index: openacs-4/packages/invoices/www/price-list-choose.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/price-list-choose.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/invoices/www/price-list-choose.adp 4 Aug 2006 15:25:02 -0000 1.1
@@ -0,0 +1,19 @@
+
+
+ @organization_id@
+
+
+
+
+@page_title;noquote@
+@context;noquote@
+
+#invoices.Change_pricelist_of_customer#: @organization_name@ (@current_pricelist_name@)
+
+
+
+
+
+#invoices.Delete#
+
+
\ No newline at end of file
Index: openacs-4/packages/invoices/www/price-list-choose.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/price-list-choose.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/invoices/www/price-list-choose.tcl 4 Aug 2006 15:25:02 -0000 1.1
@@ -0,0 +1,83 @@
+ad_page_contract {
+ List of Pricelists to choose/change the one of the customer.
+
+ @author Nils Lohse (nils.lohse@cognovis.de)
+ @creation-date 2006-07-31
+} {
+ {price_list_id:integer,optional ""}
+ {organization_id:integer}
+ {delete_only:integer,optional ""}
+} -properties {
+ context:onevalue
+ page_title:onevalue
+}
+
+set package_id [ad_conn package_id]
+set contact_package_id [apm_package_id_from_key contacts]
+set contact_master [parameter::get -parameter ContactMaster -package_id $contact_package_id]
+
+set user_id [auth::require_login]
+
+# set title of the page
+set organization_name [contact::name -party_id $organization_id]
+set page_title "$organization_name: "
+append page_title [_ invoices.iv_price_list]
+
+# set addition to the context (URL line) of the page: price-lists with link and this page without link
+set context [list [list "price-list-list" "[_ invoices.iv_price_list_2]"] $page_title]
+
+set current_pricelist_name [content::item::get_title -item_id [iv::price_list::get_list_id -organization_id $organization_id -package_id $package_id]]
+
+if {($price_list_id == "") && ($delete_only != 1)} {
+ # - - - - - - - - - -
+ # no price_list_id is provided, so let the user choose a new one
+ # - - - - - - - - - -
+
+ template::list::create \
+ -name iv_pricelist_list \
+ -key list_id \
+ -no_data "[_ invoices.None]" \
+ -elements {
+ title {
+ label {[_ invoices.iv_price_list_1]}
+ display_template {@iv_pricelist_list.title@}
+ }
+ action {
+ display_template {\#invoices.ok\#}
+ }
+ }
+
+ # the old one with del links here: display_template {\#invoices.ok\# \#invoices.Delete\#}
+
+ db_multirow -extend {list_url} iv_pricelist_list iv_pricelist_list {} {
+ set list_url [export_vars -base "price-list" {list_id organization_id}]
+ }
+
+
+
+} else {
+ # - - - - - - - - - -
+ # a price_list_id was provided, so make this the new price list for the customer and remove the old one
+ # - - - - - - - - - -
+ set new_list_id $price_list_id
+
+ # Get id of customer price list (or default)
+ set old_list_id [iv::price_list::get_list_id -organization_id $organization_id -package_id $package_id]
+
+ if {($new_list_id != $old_list_id) || ($delete_only == 1)} {
+ if {[application_data_link::exist_link -object_id $organization_id -target_object_id $old_list_id]} {
+ # delete the link between the customer and the old price list
+ set object_id1 $organization_id
+ set object_id2 $old_list_id
+ db_dml iv_delete_application_data_link {}
+ }
+
+ if {($delete_only != 1) && ($new_list_id != "")} {
+ # insert the link between the customer and the new price list
+ application_data_link::new -this_object_id $organization_id -target_object_id $new_list_id
+ }
+ }
+ ad_returnredirect "/invoices/price-list?organization_id=$organization_id"
+}
+
+ad_return_template
Index: openacs-4/packages/invoices/www/price-list-choose.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/price-list-choose.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/invoices/www/price-list-choose.xql 4 Aug 2006 15:25:02 -0000 1.1
@@ -0,0 +1,30 @@
+!
+
+
+
+
+
+ select cr.item_id as list_id, cr.title
+ from cr_folders cf, cr_items ci, cr_revisions cr, iv_price_lists t
+ where cr.revision_id = ci.latest_revision
+ and t.list_id = cr.revision_id
+ and ci.parent_id = cf.folder_id
+ and cf.package_id = :package_id
+ order by cr.title
+
+
+
+
+
+
+ delete from acs_data_links
+ where (
+ (object_id_one = :object_id1
+ and object_id_two = :object_id2)
+ or (object_id_one = :object_id2
+ and object_id_two = :object_id1)
+ )
+
+
+
+
Index: openacs-4/packages/invoices/www/price-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/price-list.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/invoices/www/price-list.adp 9 Dec 2005 18:25:01 -0000 1.6
+++ openacs-4/packages/invoices/www/price-list.adp 4 Aug 2006 15:25:02 -0000 1.7
@@ -21,4 +21,10 @@
#invoices.Create_new_pricelist_for_customer#
+#invoices.Change_pricelist_of_customer#
+
+
+
+#invoices.Customers_using_pricelist#: @page_title@
+
\ No newline at end of file
Index: openacs-4/packages/invoices/www/price-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/price-list.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/invoices/www/price-list.tcl 12 Oct 2005 13:25:34 -0000 1.3
+++ openacs-4/packages/invoices/www/price-list.tcl 4 Aug 2006 15:25:02 -0000 1.4
@@ -24,4 +24,34 @@
set page_title $list_title
set context [list [list "price-list-list" "[_ invoices.iv_price_list_2]"] $page_title]
+# ---
+# show the organizations that uses this price list
+# added 2006/07/31 by nfl
+set organization_values ""
+set organization_values [application_data_link::get_linked -from_object_id $list_id -to_object_type organization]
+# the standard price list isn't linked, so the result will be empty (nfl 31.07.2006)
+
+template::list::create \
+ -name iv_customer_using_pricelist \
+ -key customer_id \
+ -elements {
+ customer_no {
+ label {}
+ }
+ customer_name {
+ label {}
+ display_template {@iv_customer_using_pricelist.customer_name@}
+ }
+ }
+
+multirow create iv_customer_using_pricelist customer_id customer_no customer_name
+
+foreach organization_id_new $organization_values {
+ set organization_name [contact::name -party_id $organization_id_new]
+ set organization_no [ams::value -object_id [content::item::get_best_revision -item_id $organization_id_new] -attribute_name client_id]
+ multirow append iv_customer_using_pricelist $organization_id_new $organization_no $organization_name
+}
+
+# ---
+
ad_return_template