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 236-241 Link Here
236
                            [% FOR m IN messages %]
239
                            [% FOR m IN messages %]
237
                                <div class="alert alert-[% m.type | html %]">
240
                                <div class="alert alert-[% m.type | html %]">
238
                                    [% SWITCH m.code %]
241
                                    [% SWITCH m.code %]
242
                                    [% CASE 'total_suggestions' %]
243
                                        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).
239
                                    [% CASE 'too_many' %]
244
                                    [% CASE 'too_many' %]
240
                                        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.
245
                                        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.
241
                                    [% CASE 'already_exists' %]
246
                                    [% CASE 'already_exists' %]
Lines 278-284 Link Here
278
                                    <input type="hidden" name="op" value="delete_confirm" />
283
                                    <input type="hidden" name="op" value="delete_confirm" />
279
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
284
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
280
                                        <div id="toolbar" class="toolbar clearfix">
285
                                        <div id="toolbar" class="toolbar clearfix">
281
                                        [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
286
                                        [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
287
                                                <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p>
288
                                        [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
282
                                                <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>
289
                                                <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>
283
                                        [% ELSE %]
290
                                        [% ELSE %]
284
                                                <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
291
                                                <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
Lines 384-390 Link Here
384
                                    <p>There are no pending purchase suggestions.</p>
391
                                    <p>There are no pending purchase suggestions.</p>
385
                                [% END %]
392
                                [% END %]
386
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
393
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
387
                                    [% IF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
394
                                    [% IF ( Koha.Preference('MaxTotalSuggestions') != ''  && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
395
                                        <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p>
396
                                    [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
388
                                        <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>
397
                                        <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>
389
                                    [% ELSE %]
398
                                    [% ELSE %]
390
                                        <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
399
                                        <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 128-140 if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the sug Link Here
128
}
128
}
129
129
130
my $patrons_pending_suggestions_count = 0;
130
my $patrons_pending_suggestions_count = 0;
131
if ( $borrowernumber && C4::Context->preference("MaxOpenSuggestions") ne '' ) {
131
my $patrons_total_suggestions_count = 0;
132
    $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
132
if ( $borrowernumber ){
133
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && C4::Context->preference("NumberOfSuggestionDays") ne '' ) {
134
        my $suggesteddate_from = dt_from_string()->subtract(days=>C4::Context->preference("NumberOfSuggestionDays"));
135
        $patrons_total_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, suggesteddate_from => $suggesteddate_from } ) } ;
136
    }
137
    if ( C4::Context->preference("MaxOpenSuggestions") ne '' ) {
138
        $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
139
    }
133
}
140
}
134
141
135
if ( $op eq "add_confirm" ) {
142
if ( $op eq "add_confirm" ) {
136
    my $suggestions_loop = &SearchSuggestion($suggestion);
143
    my $suggestions_loop = &SearchSuggestion($suggestion);
137
    if ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
144
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
145
    {
146
        push @messages, { type => 'error', code => 'total_suggestions' };
147
    }
148
    elsif ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
138
    {
149
    {
139
        push @messages, { type => 'error', code => 'too_many' };
150
        push @messages, { type => 'error', code => 'too_many' };
140
    }
151
    }
Lines 164-169 if ( $op eq "add_confirm" ) { Link Here
164
175
165
        &NewSuggestion($suggestion);
176
        &NewSuggestion($suggestion);
166
        $patrons_pending_suggestions_count++;
177
        $patrons_pending_suggestions_count++;
178
        $patrons_total_suggestions_count++;
167
179
168
        # delete empty fields, to avoid filter in "SearchSuggestion"
180
        # delete empty fields, to avoid filter in "SearchSuggestion"
169
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
181
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
Lines 256-261 $template->param( Link Here
256
    suggested_by_anyone   => $suggested_by_anyone,
268
    suggested_by_anyone   => $suggested_by_anyone,
257
    patrons_pending_suggestions_count => $patrons_pending_suggestions_count,
269
    patrons_pending_suggestions_count => $patrons_pending_suggestions_count,
258
    need_confirm => $need_confirm,
270
    need_confirm => $need_confirm,
271
    patrons_total_suggestions_count => $patrons_total_suggestions_count,
259
);
272
);
260
273
261
output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 };
274
output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 };
262
- 

Return to bug 22774