From 7ca9093f03bc56bc18c060fb617c0761d85945d9 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Tue, 6 Nov 2012 09:50:48 +0100 Subject: [PATCH] Bug 8443: Suggestions publication year and copyright date Main patch correcting suggestions search : - allow filtering on copyrightdate, manageddate and accepteddate - entered dates remains in filter during search - empty and null values are in the same tab - null/empty values are not present in filers comboboxes Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- C4/Suggestions.pm | 6 +++--- .../prog/en/modules/suggestion/suggestion.tt | 20 +++++++++---------- suggestion/suggestion.pl | 19 ++++++++++++++++-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 0cb484a883..3489105b3e 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -121,7 +121,7 @@ sub SearchSuggestion { push @sql_params,'%'.$s.'%'; " and suggestions.$_ like ? "; } else { () } - } qw( title author isbn publishercode collectiontitle ) + } qw( title author isbn publishercode copyrightdate collectiontitle ) ); my $userenv = C4::Context->userenv; @@ -137,7 +137,7 @@ sub SearchSuggestion { foreach my $field (grep { my $fieldname=$_; any {$fieldname eq $_ } qw< STATUS branchcode itemtype suggestedby managedby acceptedby - bookfundid biblionumber + budgetid biblionumber >} keys %$suggestion ) { if ($$suggestion{$field}){ @@ -155,7 +155,7 @@ sub SearchSuggestion { my $from = $_ . "_from"; my $to = $_ . "_to"; if ($$suggestion{$from} || $$suggestion{$to}) { - push @query, " AND suggestions.suggesteddate BETWEEN '" + push @query, " AND suggestions.$_ BETWEEN '" . (format_date_in_iso($$suggestion{$from}) || 0000-00-00) . "' AND '" . (format_date_in_iso($$suggestion{$to}) || $today) . "'"; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index fb73fd15ea..d1b38ec3bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -493,7 +493,7 @@ $(document).ready(function() { calcNewsuggTotal(); });
  • -
  • +
  • Suggestion information

    @@ -511,39 +511,39 @@ $(document).ready(function() { calcNewsuggTotal(); });
  • -
  • [% suggesteddate %] +
  • - + - +
  • -
  • [% manageddate %] +
  • - + - +
  • -
  • [% accepteddate %] +
  • - + - +
  • diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 99f38eb04e..717d5dfd6b 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -190,10 +190,22 @@ if ($op=~/else/) { $displayby||="STATUS"; delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); + # distinct values of display by my $criteria_list=GetDistinctValues("suggestions.".$displayby); + my (@criteria_dv, $criteria_has_empty); + foreach (@$criteria_list) { + if ($_->{value}) { + push @criteria_dv, $_->{value}; + } else { + $criteria_has_empty = 1; + } + } + # agregate null and empty values under empty value + push @criteria_dv, '' if $criteria_has_empty; + my @allsuggestions; my $reasonsloop = GetAuthorisedValues("SUGGEST"); - foreach my $criteriumvalue ( map { $$_{'value'} } @$criteria_list ) { + foreach my $criteriumvalue ( @criteria_dv ) { # By default, display suggestions from current working branch if(not defined $branchfilter) { $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; @@ -356,15 +368,18 @@ $template->param( total => sprintf("%.2f", $$suggestion_ref{'total'}||0), ); +# lists of distinct values (without empty) for filters my %hashlists; foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) { my $values_list; $values_list = GetDistinctValues( "suggestions." . $field ); my @codes_list = map { { 'code' => $$_{'value'}, - 'desc' => GetCriteriumDesc( $$_{'value'}, $field ), + 'desc' => GetCriteriumDesc( $$_{'value'}, $field ) || $$_{'value'}, 'selected' => ($$suggestion_ref{$field}) ? $$_{'value'} eq $$suggestion_ref{$field} : 0, } + } grep { + $$_{'value'} } @$values_list; $hashlists{ lc($field) . "_loop" } = \@codes_list; } -- 2.39.5