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="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus"></i> New purchase suggestion</a>
291
                                                <a class="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus"></i> New purchase suggestion</a>
Lines 392-398 Link Here
392
                                    <p>There are no pending purchase suggestions.</p>
399
                                    <p>There are no pending purchase suggestions.</p>
393
                                [% END %]
400
                                [% END %]
394
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
401
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
395
                                    [% IF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
402
                                    [% IF ( Koha.Preference('MaxTotalSuggestions') != ''  && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
403
                                        <p class="TooManySuggestionsText">You may have only <b>[% Koha.Preference('MaxTotalSuggestions') | html %]</b> suggestions in last <b>[% Koha.Preference('NumberOfSuggestionDays') | html %]</b> days.</p>
404
                                    [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
396
                                        <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>
405
                                        <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
                                    [% ELSE %]
406
                                    [% ELSE %]
398
                                        <p><a class="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus"></i> New purchase suggestion</a></p>
407
                                        <p><a class="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus"></i> New purchase suggestion</a></p>
(-)a/opac/opac-suggestions.pl (-4 / +16 lines)
Lines 126-138 if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the sug Link Here
126
}
126
}
127
127
128
my $patrons_pending_suggestions_count = 0;
128
my $patrons_pending_suggestions_count = 0;
129
if ( $borrowernumber && C4::Context->preference("MaxOpenSuggestions") ne '' ) {
129
my $patrons_total_suggestions_count = 0;
130
    $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
130
if ( $borrowernumber ){
131
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && C4::Context->preference("NumberOfSuggestionDays") ne '' ) {
132
        my $suggesteddate_from = dt_from_string()->subtract(days=>C4::Context->preference("NumberOfSuggestionDays"));
133
        $patrons_total_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, suggesteddate_from => $suggesteddate_from } ) } ;
134
    }
135
    if ( C4::Context->preference("MaxOpenSuggestions") ne '' ) {
136
        $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
137
    }
131
}
138
}
132
139
133
if ( $op eq "add_confirm" ) {
140
if ( $op eq "add_confirm" ) {
134
    my $suggestions_loop = &SearchSuggestion($suggestion);
141
    my $suggestions_loop = &SearchSuggestion($suggestion);
135
    if ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
142
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
143
    {
144
        push @messages, { type => 'error', code => 'total_suggestions' };
145
    }
146
    elsif ( C4::Context->preference("MaxOpenSuggestions") ne '' && $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
136
    {
147
    {
137
        push @messages, { type => 'error', code => 'too_many' };
148
        push @messages, { type => 'error', code => 'too_many' };
138
    }
149
    }
Lines 162-167 if ( $op eq "add_confirm" ) { Link Here
162
173
163
        &NewSuggestion($suggestion);
174
        &NewSuggestion($suggestion);
164
        $patrons_pending_suggestions_count++;
175
        $patrons_pending_suggestions_count++;
176
        $patrons_total_suggestions_count++;
165
177
166
        # delete empty fields, to avoid filter in "SearchSuggestion"
178
        # delete empty fields, to avoid filter in "SearchSuggestion"
167
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
179
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
Lines 254-259 $template->param( Link Here
254
    suggested_by_anyone   => $suggested_by_anyone,
266
    suggested_by_anyone   => $suggested_by_anyone,
255
    patrons_pending_suggestions_count => $patrons_pending_suggestions_count,
267
    patrons_pending_suggestions_count => $patrons_pending_suggestions_count,
256
    need_confirm => $need_confirm,
268
    need_confirm => $need_confirm,
269
    patrons_total_suggestions_count => $patrons_total_suggestions_count,
257
);
270
);
258
271
259
output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 };
272
output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 };
260
- 

Return to bug 22774