--- /dev/null
+INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once, unlimited if blank','Integer')
('MaxItemsToDisplayForBatchDel','1000',NULL,'Display up to a given number of items in a single item deletionbatch.','Integer'),
('MaxItemsToProcessForBatchMod','1000',NULL,'Process up to a given number of items in a single item modification batch.','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'),
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
<div class="span10">
<div id="usersuggestions" class="maincontent">
[% IF ( op_add ) %]
+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_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') %]). Once the library has processed those suggestions you will be able to place more.</h2>
+ [% ELSE %]
<h1>Enter a new purchase suggestion</h1>
<p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
<input type="submit" onclick="Check(this.form); return false;" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
</fieldset>
</form>
+ [% END %]
[% END # IF op_add %]
[% IF ( op_else ) %]
[% FOR m IN messages %]
<div class="alert alert-[% m.type %]">
[% SWITCH m.code %]
+ [% 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') %]). Once the library has processed those suggestions you will be able to place more.
[% CASE 'already_exists' %]
The suggestion has not been added. A suggestion with this title already exists.
[% CASE 'success_on_inserted' %]
<input type="hidden" name="op" value="delete_confirm" />
[% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
<div id="toolbar" class="toolbar clearfix">
- <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
+ <p class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') %]).</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>
+ [% END %]
</div>
[% END %]
<p>There are no pending purchase suggestions.</p>
[% END %]
[% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
- <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_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>
+ [% END %]
[% END %]
[% END # / IF suggestions_loop %]
my $suggestions_loop =
&SearchSuggestion( $suggestion);
if ( $op eq "add_confirm" ) {
- if (@$suggestions_loop>=1){
+ my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber}) : 0;
+ if( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ){
+ push @messages, { type => 'error', code => 'too_many'};
+ }
+ elsif (@$suggestions_loop>=1){
#some suggestion are answering the request Donot Add
for my $suggestion ( @$suggestions_loop ) {
push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
$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;
}
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;