Index: openacs.org-dev/packages/ecommerce/tcl/ecommerce-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/ecommerce/tcl/ecommerce-procs-postgresql.xql,v diff -u -r1.1.1.1 -r1.1.1.2 --- openacs.org-dev/packages/ecommerce/tcl/ecommerce-procs-postgresql.xql 9 Jul 2002 17:35:05 -0000 1.1.1.1 +++ openacs.org-dev/packages/ecommerce/tcl/ecommerce-procs-postgresql.xql 8 Oct 2002 15:47:05 -0000 1.1.1.2 @@ -57,7 +57,7 @@ - + insert into ec_user_sessions (user_session_id, ip_address, start_time, http_user_agent) @@ -66,4 +66,43 @@ + + + select min(case when ucp.price is null then p.price + when p.price < ucp.price then p.price + else ucp.price end) as regular_price, ucp.user_class_name + from ec_products p left join (select uc.product_id, uc.price, c.user_class_name + from ec_product_user_class_prices uc, ec_user_classes c, ec_user_class_user_map m + where uc.user_class_id = c.user_class_id + and uc.product_id = :product_id + and uc.user_class_id = m.user_class_id + and m.user_id = :user_id + and m.user_class_approved_p = 't' + order by uc.price + limit 1) as ucp using (product_id) + where p.product_id = :product_id + group by p.product_id, ucp.user_class_name + + + + + + select min(case when ucp.price is null then p.price + when p.price < ucp.price then p.price + else ucp.price end) as regular_price, ucp.user_class_name + from ec_products p left join (select uc.product_id, uc.price, c.user_class_name + from ec_product_user_class_prices uc, ec_user_classes c, ec_user_class_user_map m + where uc.user_class_id = c.user_class_id + and uc.product_id = :product_id + and uc.user_class_id = m.user_class_id + and m.user_id = :user_id + and (m.user_class_approved_p is null + or m.user_class_approved_p = 't') + order by uc.price + limit 1) as ucp using (product_id) + where p.product_id = :product_id + group by p.product_id, ucp.user_class_name + + +