Index: openacs-4/packages/invoices/lib/projects-billable.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/projects-billable.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/invoices/lib/projects-billable.tcl 20 Oct 2006 10:19:26 -0000 1.20 +++ openacs-4/packages/invoices/lib/projects-billable.tcl 25 Oct 2006 21:21:23 -0000 1.21 @@ -101,6 +101,12 @@ set normal_actions [list "[_ invoices.iv_invoice_url]" $base_url "[_ invoices.iv_invoice_url2]"] +# Organization filter +if {[exists_and_not_null organization_id]} { + set organization_where_clause "and p.customer_id = :organization_id" +} else { + set organization_where_clause "" +} template::list::create \ -name projects \ @@ -173,21 +179,13 @@ orderby_asc {lower(r.description) asc, r.item_id} default_direction asc } - creation_date { - label {[_ invoices.iv_invoice_closed_date]} - orderby {sub.creation_date} - default_direction desc - } } -orderby_name orderby -html {width 100%} \ -page_size_variable_p 1 \ -page_size 1000 \ -page_flush_p 1 \ -page_query_name projects_to_bill_paginated \ -filters { page_num {} - organization_id { - where_clause {sub.customer_id = :organization_id} - } } \ -formats { normal { Index: openacs-4/packages/invoices/lib/projects-billable.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/projects-billable.xql,v diff -u -r1.12 -r1.13 --- openacs-4/packages/invoices/lib/projects-billable.xql 20 Oct 2006 10:19:26 -0000 1.12 +++ openacs-4/packages/invoices/lib/projects-billable.xql 25 Oct 2006 21:21:23 -0000 1.13 @@ -150,45 +150,38 @@ select sub.project_id - from ( - select - pi.item_id as project_id, - pr.title, - pr.description, - o.creation_date, - p.customer_id, - p.recipient_id, - oz.name - from - cr_items pi, - cr_revisions pr, - pm_projects p, - acs_objects o, + from ( select pi.item_id as project_id, + pr.title, + pr.description, + p.customer_id, + p.recipient_id + from + cr_items pi, + cr_revisions pr, + pm_projects p + where + pi.latest_revision = pr.revision_id + $organization_where_clause + and p.project_id = pr.revision_id + and p.status_id = :p_closed_id + and p.invoice_p = true) sub, acs_data_links r, cr_items oi, - iv_offer_items ofi, - organizations oz + iv_offer_items ofi where - pi.latest_revision = pr.revision_id - and p.project_id = pr.revision_id - and o.object_id = p.project_id - and r.object_id_one = pi.item_id + r.object_id_one = sub.project_id and r.object_id_two = oi.item_id - and p.status_id = :p_closed_id - and p.invoice_p = true and ofi.offer_id = oi.latest_revision - and p.customer_id = oz.organization_id and ofi.offer_item_id not in (select ii.offer_item_id from iv_invoice_items ii, iv_invoices i, cr_items ci where i.invoice_id = ii.invoice_id and ci.latest_revision = i.invoice_id and i.cancelled_p = 'f') - group by - pi.item_id, pr.title, pr.description, o.creation_date, p.customer_id, oz.name, p.recipient_id - ) sub - where 1=1 [template::list::filter_where_clauses -and -name projects] + group by + sub.project_id, sub.title, sub.description, sub.customer_id, sub.recipient_id, oi.name [template::list::orderby_clause -name projects -orderby] +