Bugzilla – Attachment 97061 Details for
Bug 22774
Add ability to limit the number of purchase suggestions a patron may submit in a specified time period
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period
Bug-22774-follow-up-Limit-Purchase-Suggestion-in-a.patch (text/plain), 8.76 KB, created by
Devinim
on 2020-01-09 10:50:59 UTC
(
hide
)
Description:
Bug 22774: (follow-up) Limit Purchase Suggestion in a specified Time period
Filename:
MIME Type:
Creator:
Devinim
Created:
2020-01-09 10:50:59 UTC
Size:
8.76 KB
patch
obsolete
>From 81e855817fc7efe3fee1c4971bb40016dc544016 Mon Sep 17 00:00:00 2001 >From: Devinim <kohadevinim@devinim.com.tr> >Date: Thu, 9 Jan 2020 10:48:15 +0000 >Subject: [PATCH] Bug 22774: (follow-up) Limit Purchase Suggestion in a > specified Time period > >--- > .../bootstrap/en/modules/opac-suggestions.tt | 15 ++++++++++++--- > opac/opac-suggestions.pl | 19 ++++++++++++++++--- > 2 files changed, 28 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >index bc763386262..53270ac0288 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >@@ -31,7 +31,10 @@ > <div class="span10"> > <div id="usersuggestions" class="maincontent"> > [% IF ( op_add ) %] >- [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] >+ [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %] >+ <h1 class="TooManySuggestions">You cannot place any more suggestions</h1> >+ <h2 class="TooManySuggestionsText">You may have only [% Koha.Preference('MaxTotalSuggestions') | html %] suggestions in last [% Koha.Preference('NumberOfSuggestionDays') | html %] days.</h2> >+ [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] > <h1 class="TooManySuggestions">You cannot place any more suggestions</h1> > <h2 class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') | html %]). Once the library has processed those suggestions you will be able to place more.</h2> > [% ELSE %] >@@ -236,6 +239,8 @@ > [% FOR m IN messages %] > <div class="alert alert-[% m.type | html %]"> > [% SWITCH m.code %] >+ [% CASE 'total_suggestions' %] >+ The suggestion has not been added. You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxTotalSuggestions') | html %] last [% Koha.Preference('NumberOfSuggestionDays') | html %] days). > [% CASE 'too_many' %] > The suggestion has not been added. You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') | html %]). Once the library has processed those suggestions you will be able to place more. > [% CASE 'already_exists' %] >@@ -278,7 +283,9 @@ > <input type="hidden" name="op" value="delete_confirm" /> > [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %] > <div id="toolbar" class="toolbar clearfix"> >- [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] >+ [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %] >+ <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p> >+ [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] > <p class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') | html %]).</br>Once the library has processed those suggestions you will be able to place more.</p> > [% ELSE %] > <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a> >@@ -384,7 +391,9 @@ > <p>There are no pending purchase suggestions.</p> > [% END %] > [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %] >- [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] >+ [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %] >+ <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p> >+ [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] > <p class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time.</br>Once the library has processed those suggestions you will be able to place more.</p> > [% ELSE %] > <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p> >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index b502e927375..83803988fee 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -128,13 +128,24 @@ if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the sug > } > > my $patrons_pending_suggestions_count = 0; >-if ( $borrowernumber && C4::Context->preference("MaxOpenSuggestions") ne '' ) { >- $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ; >+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 } ) } ; >+ } >+ if ( C4::Context->preference("MaxOpenSuggestions") ne '' ) { >+ $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ; >+ } > } > > if ( $op eq "add_confirm" ) { > my $suggestions_loop = &SearchSuggestion($suggestion); >- if ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers >+ if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") ) >+ { >+ push @messages, { type => 'error', code => 'total_suggestions' }; >+ } >+ elsif ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers > { > push @messages, { type => 'error', code => 'too_many' }; > } >@@ -164,6 +175,7 @@ if ( $op eq "add_confirm" ) { > > &NewSuggestion($suggestion); > $patrons_pending_suggestions_count++; >+ $patrons_total_suggestions_count++; > > # delete empty fields, to avoid filter in "SearchSuggestion" > foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) { >@@ -256,6 +268,7 @@ $template->param( > suggested_by_anyone => $suggested_by_anyone, > patrons_pending_suggestions_count => $patrons_pending_suggestions_count, > need_confirm => $need_confirm, >+ patrons_total_suggestions_count => $patrons_total_suggestions_count, > ); > > output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 }; >-- >2.11.0
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 22774
:
95940
|
95941
|
97061
|
97070
|
97071
|
99045
|
99046
|
99380
|
99381
|
99382
|
100192
|
100193
|
100912
|
100913
|
101448
|
102882
|
102883
|
102884
|
102885
|
102886