From 9ef1ce883fe727c30a1c48fc7e0854cbd42bc1b2 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 1 Dec 2005 22:53:35 +0000 Subject: [PATCH] clark knows how to use custom widget filter code now git-svn-id: svn://svn.open-ils.org/ILS/trunk@2152 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/reporter/clark-kent.pl | 11 ++++++- Open-ILS/src/reporter/widgets.example.xml | 38 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index 10af011a6f..5a1ba2c62e 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -771,7 +771,16 @@ sub generate_query { my ($w) = keys %{ $$p{filter}{$t}{$c}{$fam} }; my $val = $$p{filter}{$t}{$c}{$fam}{$w}; - if (ref $val) { + my $filter_code_xpath = "/reporter/widgets/widget-family[\@name='$fam']/widget[\@name='$w']/filter-code[\@type='perl']"; + if (my $widget_code = $doc->findvalue($filter_code_xpath)) # widget supplys it's own filter code + my ($where_clause, $bind_list) = ('',[]); + + eval $widget_code; + + push @where, $where_clause; + push @bind, @$bind_list; + + } elsif (ref $val) { push @where, "$full_col IN (".join(",",map {'?'}@$val).")"; push @bind, @$val; } else { diff --git a/Open-ILS/src/reporter/widgets.example.xml b/Open-ILS/src/reporter/widgets.example.xml index ba1fe897a7..fe46568a15 100644 --- a/Open-ILS/src/reporter/widgets.example.xml +++ b/Open-ILS/src/reporter/widgets.example.xml @@ -68,6 +68,11 @@ This widget allows the user to pick a specific date on which to report. + + $full_col = "DATE_TRUNC($full_col, 'day')"; + $where_clause = "$full_col = CAST(? AS DATE)" + push @$bind_list, sprintf('%d/%02d/%02d', @$val{qw/year month day/}); + @@ -76,6 +81,11 @@ This widget allows the user to pick a specific week of the year on which to report. + + $full_col = "EXTRACT('week' FROM $full_col)"; + $where_clause = "$full_col = ?" + push @$bind_list, $val; + @@ -84,6 +94,13 @@ This widget allows the user to pick a range of weeks of the year on which to report. + + $where_clause = + "EXTRACT('year' FROM $full_col) = ? ". + "AND EXTRACT('week' FROM $full_col) ". + "BETWEEN ? AND ?"; + push @$bind_list, $$val{year}, $$val{start}, $$val{end}; + @@ -92,6 +109,11 @@ This widget allows the user to pick a specific year and month on which to report. + + $full_col = "EXTRACT('week' FROM $full_col)"; + $where_clause = "$full_col = ?" + push @$bind_list, $val; + @@ -100,6 +122,14 @@ This widget allows the user to pick a range of month on which to report. + + $where_clause = + "DATE_TRUNC($full_col, 'month') ". + "BETWEEN CAST(? AS DATE) AND CAST(? AS DATE)"; + push @$bind_list, + sprintf('%d/%02d/01', @$val{qw/start-year start-month/}), + sprintf('%d/%02d/01', @$val{qw/end-year end-month/}); + @@ -124,6 +154,10 @@ This widget allows the user to pick a specific year on which to report. + + $where_clause = "EXTRACT('year' FROM $full_col) = ?"; + push @$bind_list, $val; + @@ -132,6 +166,10 @@ This widget allows the user to pick a range of years on which to report. + + $where_clause = "EXTRACT('year' FROM $full_col) BETWEEN ? AND ?"; + push @$bind_list, $$val{year}, $$val{year} + $$val{year-count}; + -- 2.43.2