Index: openacs-4/packages/invoices/lib/report-invoice-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/report-invoice-items.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/report-invoice-items.tcl 9 Nov 2005 19:29:27 -0000 1.1 +++ openacs-4/packages/invoices/lib/report-invoice-items.tcl 9 Nov 2005 21:30:12 -0000 1.2 @@ -49,13 +49,43 @@ append extra_query " and to_char(ii.creation_date, 'DD') = :day" } + +set category_where_clause "" +if { [exists_and_not_null category_f] } { + set category_where_clause "com.category_id in ([template::util::tcl_to_sql_list $category_f])" +} + +set categories_trees [db_list_of_lists get_category_trees { }] + +set categories_filter [list] +set tree_ids [list] + +foreach tree $categories_trees { + set tree_name [lindex $tree 0] + set tree_id [lindex $tree 1] + lappend tree_ids $tree_id + + set categories [db_list_of_lists get_categories " "] + + foreach cat $categories { + lappend categories_filter [list [lang::util::localize [lindex $cat 0]] [lindex $cat 1]] + } +} + template::list::create \ -name reports \ -multirow reports \ -filters { + category_f { + label "Categories" + type multival + values $categories_filter + where_clause $category_where_clause + } year {} month {} day {} + show_p {} } -elements { title { label "[_ invoices.iv_invoice_item_Title]:" @@ -89,7 +119,7 @@ -template::multirow create reports iv_items title creation_date amount_total +template::multirow create reports iv_items title creation_date amount_total offer_item_id category_id set iv_items [db_list_of_lists get_iv_items { }] @@ -100,9 +130,13 @@ set title [lindex $item 1] set creation_date [lindex $item 2] set iv_item_total [lindex $item 3] + set offer_item_id [lindex $item 4] + set category_id [lindex $item 5] + set final_amount [db_string get_final_amount {} -default 0] - template::multirow append reports $iv_item_id $title $creation_date $iv_item_total + template::multirow append reports $iv_item_id $title $creation_date $iv_item_total $offer_item_id $category_id + } } else { # We accumulate the amount_total and the number of iv_invoice_items Index: openacs-4/packages/invoices/lib/report-invoice-items.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/report-invoice-items.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/report-invoice-items.xql 9 Nov 2005 19:29:27 -0000 1.1 +++ openacs-4/packages/invoices/lib/report-invoice-items.xql 9 Nov 2005 21:30:12 -0000 1.2 @@ -7,15 +7,19 @@ ii.iv_item_id, ii.title as item_title, to_char(ii.creation_date, 'YYYY-MM-DD') as creation_date, - ii.amount_total + ii.amount_total, + ii.offer_item_id, + com.category_id from iv_invoice_itemsx ii, iv_invoicesx iv, + category_object_map com, cr_items i where iv.item_id = i.item_id and ii.invoice_id = iv.invoice_id and ii.invoice_id = i.latest_revision + and ii.offer_item_id = com.object_id $extra_query [template::list::filter_where_clauses -and -name "reports"] @@ -28,13 +32,50 @@ from iv_invoice_itemsx ii, iv_invoicesx iv, + category_object_map com, cr_items i where iv.item_id = i.item_id and ii.invoice_id = iv.invoice_id and ii.invoice_id = i.latest_revision + and ii.offer_item_id = com.object_id $extra_query + [template::list::filter_where_clauses -and -name "reports"] + + + 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]) + + + \ No newline at end of file