select oi.offer_item_id, oi.title as item_title, o.title as offer_title, oi.price_per_unit, oi.rebate, oi.item_units, com.category_id as cat_id, o.organization_id, org.name as org_name, to_char(oi.creation_date,'yy-mm-dd') as creation_date, to_char(oi.creation_date,'mm') as month, o.item_id, ob.title as cat_name from iv_offer_itemsx oi, iv_offersx o, organizations org, category_object_map com, cr_items i, acs_objects ob where i.item_id = o.item_id and o.offer_id = i.latest_revision and o.offer_id = oi.offer_id and com.object_id = oi.offer_item_id and org.organization_id = o.organization_id and com.category_id = ob.object_id $category_filter_clause and [template::list::page_where_clause -name "offer_items"] [template::list::filter_where_clauses -and -name "offer_items"] [template::list::orderby_clause -orderby -name "offer_items"] select oi.offer_item_id from iv_offer_itemsx oi, iv_offersx o, organizations org, category_object_map com, cr_items i, acs_objects ob where i.item_id = o.item_id and o.offer_id = i.latest_revision and o.offer_id = oi.offer_id and com.object_id = oi.offer_item_id and org.organization_id = o.organization_id and com.category_id = ob.object_id $category_filter_clause [template::list::filter_where_clauses -and -name "offer_items"] [template::list::orderby_clause -orderby -name "offer_items"] select distinct o.title, c.tree_id from category_object_map com, iv_offer_items io, acs_objects o, categories c where com.object_id = io.offer_item_id and com.category_id = c.category_id and c.tree_id = o.object_id order by o.title asc select o.title, c.category_id from categories c, acs_objects o where o.object_id = c.category_id and c.tree_id in ([template::util::tcl_to_sql_list $tree_ids]) select price_per_unit, item_units, rebate from iv_offer_itemsx oi, category_object_map com, iv_offersx o, cr_items i where i.item_id = o.item_id and o.offer_id = i.latest_revision and o.offer_id = oi.offer_id and com.object_id = oi.offer_item_id and com.category_id = :c_id