Bugzilla – Attachment 34169 Details for
Bug 13378
There is no way to search suggestions not linked to a fund
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[Signed-off] Bug 13378: Add a filter to search suggestions not linked to a fund
Signed-off-Bug-13378-Add-a-filter-to-search-sugges.patch (text/plain), 8.38 KB, created by
Marc Véron
on 2014-12-08 11:31:55 UTC
(
hide
)
Description:
[Signed-off] Bug 13378: Add a filter to search suggestions not linked to a fund
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2014-12-08 11:31:55 UTC
Size:
8.38 KB
patch
obsolete
>From 3ff076ec717ed30c238160ab9d2b85e07c6aca2e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 3 Dec 2014 11:35:36 +0100 >Subject: [PATCH] [Signed-off] Bug 13378: Add a filter to search suggestions > not linked to a fund >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds a "None" option for the fund filter. > >Test plan: >1/ Go on the suggestion search page >2/ Search suggestions not linked to a fund using the "None" option. >3/ Search all suggestions (linked or not to a fund) using the "Any" option. > >Works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> >--- > C4/Suggestions.pm | 17 +++--- > .../prog/en/modules/suggestion/suggestion.tt | 9 +++- > t/db_dependent/Suggestions.t | 56 ++++++++++++++++++-- > 3 files changed, 68 insertions(+), 14 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 1d9edbb..35deb20 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -158,16 +158,17 @@ sub SearchSuggestion { > qw( STATUS itemtype suggestedby managedby acceptedby budgetid biblionumber ) > ) > { >- if ( exists $suggestion->{$field} ) { >- if ( defined $suggestion->{$field} and $suggestion->{$field} ne '' ) >- { >- push @sql_params, $suggestion->{$field}; >- push @query, qq{ AND suggestions.$field=? }; >+ if ( exists $suggestion->{$field} >+ and defined $suggestion->{$field} >+ and $suggestion->{$field} ne '__ANY__' >+ and $suggestion->{$field} ne q|| >+ ) { >+ if ( $suggestion->{$field} eq '__NONE__' ) { >+ push @query, qq{ AND (suggestions.$field = '' OR suggestions.$field IS NULL) }; > } > else { >- push @query, qq{ >- AND (suggestions.$field='' OR suggestions.$field IS NULL) >- }; >+ push @sql_params, $suggestion->{$field}; >+ push @query, qq{ AND suggestions.$field = ? }; > } > } > } >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 bfe0198..770e52e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -743,7 +743,14 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o > > <fieldset class="brief"><h4 class="local_collapse"><a href="#">Acquisition information</a></h4> > <ol><li><label for="budgetid"> Book fund:</label> >- <select name="budgetid" id="budgetid"><option value="">Any</option>[% FOREACH budgetid_loo IN budgetid_loop %] >+ <select name="budgetid" id="budgetid"> >+ <option value="__ANY__">Any</option> >+ [% IF budgetid == '__NONE__' %] >+ <option value="__NONE__" selected="selected">None</option> >+ [% ELSE %] >+ <option value="__NONE__">None</option> >+ [% END %] >+ [% FOREACH budgetid_loo IN budgetid_loop %] > [% IF ( budgetid_loo.selected ) %] <option value="[% budgetid_loo.code %]" selected="selected">[% budgetid_loo.desc %]</option>[% ELSE %]<option value="[% budgetid_loo.code %]">[% budgetid_loo.desc %]</option>[% END %] > [% END %] > </select></li> >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 1584301..927b6df 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -20,10 +20,11 @@ use Modern::Perl; > use C4::Context; > use C4::Members; > use C4::Letters; >+use C4::Budgets; > > use Koha::DateUtils qw( dt_from_string ); > >-use Test::More tests => 97; >+use Test::More tests => 101; > use Test::Warn; > > BEGIN { >@@ -65,6 +66,33 @@ my $my_suggestion = { > note => 'my note', > }; > >+my $budgetperiod_id = AddBudgetPeriod({ >+ budget_period_startdate => '2008-01-01', >+ budget_period_enddate => '2008-12-31', >+ budget_period_description => 'MAPERI', >+ budget_period_active => 1, >+}); >+ >+my $budget_id = AddBudget({ >+ budget_code => 'ABCD', >+ budget_amount => '123.132000', >+ budget_name => 'ABCD', >+ budget_notes => 'This is a note', >+ budget_period_id => $budgetperiod_id, >+}); >+my $my_suggestion_with_budget = { >+ title => 'my title 2', >+ author => 'my author 2', >+ publishercode => 'my publishercode 2', >+ suggestedby => $borrowernumber, >+ biblionumber => $biblionumber1, >+ managedby => '', >+ manageddate => '', >+ accepteddate => dt_from_string, >+ note => 'my note', >+ budgetid => $budget_id, >+}; >+ > > is( CountSuggestion(), 0, 'CountSuggestion without the status returns 0' ); > is( CountSuggestion('ASKED'), 0, 'CountSuggestion returns the correct number of suggestions' ); >@@ -74,6 +102,7 @@ is( CountSuggestion('REJECTED'), 0, 'CountSuggestion returns the correct number > > my $my_suggestionid = NewSuggestion($my_suggestion); > isnt( $my_suggestionid, 0, 'NewSuggestion returns an not null id' ); >+my $my_suggestionid_with_budget = NewSuggestion($my_suggestion_with_budget); > > is( GetSuggestion(), undef, 'GetSuggestion without the suggestion id returns undef' ); > my $suggestion = GetSuggestion($my_suggestionid); >@@ -85,7 +114,7 @@ is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion > is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' ); > is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' ); > is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' ); >-is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' ); >+is( CountSuggestion('ASKED'), 2, 'CountSuggestion returns the correct number of suggestions' ); > > > is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' ); >@@ -201,9 +230,8 @@ is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' > $suggestion = GetSuggestion($my_suggestionid); > is( $suggestion->{biblionumber}, $biblionumber2, 'ConnectSuggestionAndBiblio updates the biblio number correctly' ); > >- > my $search_suggestion = SearchSuggestion(); >-is( @$search_suggestion, 1, 'SearchSuggestion without arguments returns all suggestions' ); >+is( @$search_suggestion, 2, 'SearchSuggestion without arguments returns all suggestions' ); > > $search_suggestion = SearchSuggestion({ > title => $mod_suggestion1->{title}, >@@ -224,7 +252,7 @@ $search_suggestion = SearchSuggestion({ > is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' ); > > $search_suggestion = SearchSuggestion({ >- publishercode => $mod_suggestion3->{publishercode}, >+ publishercode => $mod_suggestion1->{publishercode}, > }); > is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' ); > $search_suggestion = SearchSuggestion({ >@@ -241,6 +269,22 @@ $search_suggestion = SearchSuggestion({ > }); > is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' ); > >+$search_suggestion = SearchSuggestion({ >+ budgetid => '', >+}); >+is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = "") returns the correct number of suggestions' ); >+$search_suggestion = SearchSuggestion({ >+ budgetid => $budget_id, >+}); >+is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = $budgetid) returns the correct number of suggestions' ); >+$search_suggestion = SearchSuggestion({ >+ budgetid => '__NONE__', >+}); >+is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = "__NONE__") returns the correct number of suggestions' ); >+$search_suggestion = SearchSuggestion({ >+ budgetid => '__ANY__', >+}); >+is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = "__ANY__") returns the correct number of suggestions' ); > > my $del_suggestion = { > title => 'my deleted title', >@@ -273,3 +317,5 @@ is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSe > is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved'); > > $dbh->rollback; >+ >+done_testing; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13378
:
34086
|
34168
|
34169
|
34367