View | Details | Raw Unified | Return to bug 22774
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-3 / +12 lines)
Lines 31-37 Link Here
31
                <div class="span10">
31
                <div class="span10">
32
                    <div id="usersuggestions" class="maincontent">
32
                    <div id="usersuggestions" class="maincontent">
33
                        [% IF ( op_add ) %]
33
                        [% IF ( op_add ) %]
34
                            [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
34
                            [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
35
                                    <h1 class="TooManySuggestions">You cannot place any more suggestions</h1>
36
                                    <h2 class="TooManySuggestionsText">You may have only [% Koha.Preference('MaxTotalSuggestions') | html %] suggestions in last [% Koha.Preference('NumberOfSuggestionDays') | html %] days.</h2>
37
                            [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
35
                                    <h1 class="TooManySuggestions">You cannot place any more suggestions</h1>
38
                                    <h1 class="TooManySuggestions">You cannot place any more suggestions</h1>
36
                                    <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>
39
                                    <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>
37
                            [% ELSE %]
40
                            [% ELSE %]
Lines 215-220 Link Here
215
                            [% FOR m IN messages %]
218
                            [% FOR m IN messages %]
216
                                <div class="alert alert-[% m.type | html %]">
219
                                <div class="alert alert-[% m.type | html %]">
217
                                    [% SWITCH m.code %]
220
                                    [% SWITCH m.code %]
221
                                    [% CASE 'total_suggestions' %]
222
                                        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).
218
                                    [% CASE 'too_many' %]
223
                                    [% CASE 'too_many' %]
219
                                        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.
224
                                        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.
220
                                    [% CASE 'already_exists' %]
225
                                    [% CASE 'already_exists' %]
Lines 257-263 Link Here
257
                                    <input type="hidden" name="op" value="delete_confirm" />
262
                                    <input type="hidden" name="op" value="delete_confirm" />
258
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
263
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
259
                                        <div id="toolbar" class="toolbar clearfix">
264
                                        <div id="toolbar" class="toolbar clearfix">
260
                                        [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
265
                                        [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
266
                                                <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p>
267
                                        [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
261
                                                <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>
268
                                                <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>
262
                                        [% ELSE %]
269
                                        [% ELSE %]
263
                                                <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
270
                                                <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
Lines 363-369 Link Here
363
                                    <p>There are no pending purchase suggestions.</p>
370
                                    <p>There are no pending purchase suggestions.</p>
364
                                [% END %]
371
                                [% END %]
365
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
372
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
366
                                    [% IF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
373
                                    [% IF ( Koha.Preference('MaxTotalSuggestions') != ''  && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
374
                                        <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p>
375
                                    [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
367
                                        <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>
376
                                        <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>
368
                                    [% ELSE %]
377
                                    [% ELSE %]
369
                                        <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
378
                                        <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
(-)a/opac/opac-suggestions.pl (-4 / +16 lines)
Lines 115-127 if ( $op eq 'else' ) { Link Here
115
}
115
}
116
116
117
my $patrons_pending_suggestions_count = 0;
117
my $patrons_pending_suggestions_count = 0;
118
if ( $borrowernumber && C4::Context->preference("MaxOpenSuggestions") ne '' ) {
118
my $patrons_total_suggestions_count = 0;
119
    $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
119
if ( $borrowernumber ){
120
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && C4::Context->preference("NumberOfSuggestionDays") ne '' ) {
121
        my $suggesteddate_from = dt_from_string()->subtract(days=>C4::Context->preference("NumberOfSuggestionDays"));
122
        $patrons_total_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, suggesteddate_from => $suggesteddate_from } ) } ;
123
    }
124
    if ( C4::Context->preference("MaxOpenSuggestions") ne '' ) {
125
        $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
126
    }
120
}
127
}
121
128
122
my $suggestions_loop = &SearchSuggestion($suggestion);
129
my $suggestions_loop = &SearchSuggestion($suggestion);
123
if ( $op eq "add_confirm" ) {
130
if ( $op eq "add_confirm" ) {
124
    if ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
131
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
132
    {
133
        push @messages, { type => 'error', code => 'total_suggestions' };
134
    }
135
    elsif ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
125
    {
136
    {
126
        push @messages, { type => 'error', code => 'too_many' };
137
        push @messages, { type => 'error', code => 'too_many' };
127
    }
138
    }
Lines 151-156 if ( $op eq "add_confirm" ) { Link Here
151
162
152
        &NewSuggestion($suggestion);
163
        &NewSuggestion($suggestion);
153
        $patrons_pending_suggestions_count++;
164
        $patrons_pending_suggestions_count++;
165
        $patrons_total_suggestions_count++;
154
166
155
        # delete empty fields, to avoid filter in "SearchSuggestion"
167
        # delete empty fields, to avoid filter in "SearchSuggestion"
156
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
168
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
Lines 228-233 $template->param( Link Here
228
    suggestionsview       => 1,
240
    suggestionsview       => 1,
229
    suggested_by_anyone   => $suggested_by_anyone,
241
    suggested_by_anyone   => $suggested_by_anyone,
230
    patrons_pending_suggestions_count => $patrons_pending_suggestions_count,
242
    patrons_pending_suggestions_count => $patrons_pending_suggestions_count,
243
    patrons_total_suggestions_count => $patrons_total_suggestions_count,
231
);
244
);
232
245
233
output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 };
246
output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 };
234
- 

Return to bug 22774