From 20ef3dcca2a6a827ba3c96fc9241479e3efdd49d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 14 Jun 2016 16:47:43 -0400 Subject: [PATCH] Bug 15128 - Add ability to limit patrons open purchase suggestions To test: 1 - Define a number of MaxOpenSuggestions 2 - Add some suggestions for a patron 3 - Note they cannot add any more suggestions if limit is reached 4 - Delete a suggestion and note you can add another 5 - Add them to limit again 6 - Accept a suggestion in the staff client and note user can add more 7 - Repeat above with rejecting or deleting 8 - Sign off. Sponsored by: North Central Regional Library (http://ncrl.org/) --- installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 6 +++++- .../opac-tmpl/bootstrap/en/modules/opac-suggestions.tt | 17 +++++++++++++++-- opac/opac-suggestions.pl | 5 +++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 2b95c99..260bc1f 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -233,6 +233,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('MaxFine',NULL,'','Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','Integer'), ('MaxItemsForBatch','1000',NULL,'Max number of items record to process in a batch (modification or deletion)','Integer'), ('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'), +('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once','Integer') ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index e1c72f0..b3e43bd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -566,7 +566,11 @@ OPAC: yes: "Block" no: "Don't block" - expired patrons from OPAC actions such as placing a hold or renewing. Note that the setting for a patron category takes priority over this system preference. - + - + - Limit patrons to + - pref: MaxOpenSuggestions + class: integer + - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions" Privacy: - - pref: StoreLastBorrower 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 45b5e59..f71b8e8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -28,6 +28,10 @@
[% IF ( op_add ) %] + [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] +

You cannot place any more suggestions

+

You have reached your limit of suggestions you can place at this time. Once the library has processed those suggestions you will be able to place more

+ [% ELSE %]

Enter a new purchase suggestion

Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion

@@ -88,6 +92,7 @@ Cancel + [% END %] [% END # IF op_add %] [% IF ( op_else ) %] @@ -145,7 +150,11 @@ [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
- New purchase suggestion + [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] +

You have reached your limit of suggestions you can place at this time.
Once the library has processed those suggestions you will be able to place more

+ [% ELSE %] + New purchase suggestion + [% END %]
[% END %] @@ -245,7 +254,11 @@

There are no pending purchase suggestions.

[% END %] [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %] -

New purchase suggestion

+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] +

You have reached your limit of suggestions you can place at this time.
Once the library has processed those suggestions you will be able to place more

+ [% ELSE %] +

New purchase suggestion

+ [% END %] [% END %] [% END # / IF suggestions_loop %] diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index aad0e85..d9501ee 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -157,9 +157,13 @@ map{ $library ? $s->{branchcodesuggestedby} = $library->branchname : () } @$suggestions_loop; +my $own_suggestions_count = 0; foreach my $suggestion(@$suggestions_loop) { if($suggestion->{'suggestedby'} == $borrowernumber) { $suggestion->{'showcheckbox'} = $borrowernumber; + if ( $suggestion->{'STATUS'} eq 'ASKED' ) { + $own_suggestions_count++; + } } else { $suggestion->{'showcheckbox'} = 0; } @@ -195,6 +199,7 @@ $template->param( messages => \@messages, suggestionsview => 1, suggested_by_anyone => $suggested_by_anyone, + own_suggestions_count => $own_suggestions_count, ); output_html_with_http_headers $input, $cookie, $template->output; -- 2.1.4