From 70ea3e39a883a4feb85f894e4fb25b59d21d5688 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nazl=C4=B1=20=C3=87etin?= Date: Mon, 23 Mar 2020 13:30:48 +0000 Subject: [PATCH] Bug 22774: (follow-up) Limit purchase suggestion in a specified time period Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- opac/opac-suggestions.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index b506a1537a..74e3079dfe 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -33,7 +33,7 @@ use Koha::AuthorisedValues; use Koha::Libraries; use Koha::Patrons; -use Koha::DateUtils qw( dt_from_string ); +use Koha::DateUtils; my $input = new CGI; my $op = $input->param('op') || 'else'; @@ -130,10 +130,12 @@ my $patrons_total_suggestions_count = 0; if ( $borrowernumber ){ if ( C4::Context->preference("MaxTotalSuggestions") ne '' && C4::Context->preference("NumberOfSuggestionDays") ne '' ) { my $suggesteddate_from = dt_from_string()->subtract(days=>C4::Context->preference("NumberOfSuggestionDays")); - $patrons_total_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, suggesteddate_from => $suggesteddate_from } ) } ; + $suggesteddate_from = output_pref({ dt => $suggesteddate_from, dateformat => 'iso', dateonly => 1 }); + $patrons_total_suggestions_count = Koha::Suggestions->search({ suggestedby => $borrowernumber, suggesteddate => { '>=' => $suggesteddate_from } })->count; + } if ( C4::Context->preference("MaxOpenSuggestions") ne '' ) { - $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ; + $patrons_pending_suggestions_count = Koha::Suggestions->search({ suggestedby => $borrowernumber, STATUS => 'ASKED' } )->count ; } } -- 2.39.5