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

(-)a/circ/request-article.pl (-5 / +16 lines)
Lines 25-32 use C4::Utils::DataTables::Members; Link Here
25
use C4::Search qw( enabled_staff_search_views );
25
use C4::Search qw( enabled_staff_search_views );
26
use C4::Serials qw( CountSubscriptionFromBiblionumber );
26
use C4::Serials qw( CountSubscriptionFromBiblionumber );
27
use Koha::Biblios;
27
use Koha::Biblios;
28
use Koha::Logger;
28
use Koha::Patrons;
29
use Koha::Patrons;
29
use Koha::ArticleRequests;
30
use Koha::ArticleRequests;
31
32
use Scalar::Util qw( blessed );
30
use Try::Tiny;
33
use Try::Tiny;
31
34
32
my $cgi = CGI->new;
35
my $cgi = CGI->new;
Lines 86-96 if ( $action eq 'create' ) { Link Here
86
                patron_notes   => $patron_notes,
89
                patron_notes   => $patron_notes,
87
                format         => $format,
90
                format         => $format,
88
            }
91
            }
89
        )->store();
92
        )->request;
90
    } catch {
93
    } catch {
91
        $template->param(
94
        if ( blessed $_ and $_->isa('Koha::Exceptions::ArticleRequest::LimitReached') ) {
92
            error_message => $_->{message}
95
            $template->param(
93
        );
96
                error_message => 'article_request_limit_reached'
97
            );
98
        }
99
        else {
100
            Koha::Logger->get->debug("Unhandled exception when placing an article request ($_)");
101
            $template->param(
102
                error_message => 'article_request_unhandled_exception'
103
            );
104
        }
94
    };
105
    };
95
106
96
}
107
}
Lines 119-125 if ( !$patron && $patron_cardnumber ) { Link Here
119
if( $patron && !$patron->can_request_article) {
130
if( $patron && !$patron->can_request_article) {
120
    $patron = undef;
131
    $patron = undef;
121
    $template->param(
132
    $template->param(
122
        error_message => 'Patron cannot request more articles for today'
133
        error_message => 'article_request_limit_reached'
123
    );
134
    );
124
}
135
}
125
136
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (-1 / +4 lines)
Lines 48-54 Link Here
48
                    <h1>Request article from [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
48
                    <h1>Request article from [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
49
                    [% IF error_message %]
49
                    [% IF error_message %]
50
                        <div class="dialog alert">
50
                        <div class="dialog alert">
51
                            <p>[% error_message | html %]</p>
51
                        [% SWITCH error_message %]
52
                            [% CASE 'article_request_limit_reached'       %]<p>Patron reached daily limit.</p>
53
                            [% CASE 'article_request_unhandled_exception' %]<p>An error has occurred. Check the logs.</p>
54
                        [% END %]
52
                        </div>
55
                        </div>
53
                    [% END %]
56
                    [% END %]
54
                    [% IF no_patrons_found %]
57
                    [% IF no_patrons_found %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt (-1 / +4 lines)
Lines 219-225 Link Here
219
                [% ELSIF error_message %]
219
                [% ELSIF error_message %]
220
                    <h1 class="title">[% biblio.title | html %]</h1>
220
                    <h1 class="title">[% biblio.title | html %]</h1>
221
                    <div class="alert alert-info">
221
                    <div class="alert alert-info">
222
                        [% error_message | html %]
222
                        [% SWITCH error_message %]
223
                            [% CASE 'article_request_limit_reached'       %]You reached your article requests daily limit.
224
                            [% CASE 'article_request_unhandled_exception' %]An error has occurred.
225
                        [% END %]
223
                    </div>
226
                    </div>
224
                [% ELSE %]
227
                [% ELSE %]
225
                    <h1 class="title">[% biblio.title | html %]</h1>
228
                    <h1 class="title">[% biblio.title | html %]</h1>
(-)a/opac/opac-request-article.pl (-9 / +24 lines)
Lines 25-31 use C4::Auth qw( get_template_and_user ); Link Here
25
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
26
26
27
use Koha::Biblios;
27
use Koha::Biblios;
28
use Koha::Logger;
28
use Koha::Patrons;
29
use Koha::Patrons;
30
31
use Scalar::Util qw( blessed );
29
use Try::Tiny;
32
use Try::Tiny;
30
33
31
my $cgi = CGI->new;
34
my $cgi = CGI->new;
Lines 60-65 if ( $action eq 'create' ) { Link Here
60
    my $patron_notes = $cgi->param('patron_notes') || undef;
63
    my $patron_notes = $cgi->param('patron_notes') || undef;
61
    my $format       = $cgi->param('format')       || undef;
64
    my $format       = $cgi->param('format')       || undef;
62
65
66
67
    my $success;
68
63
    try {
69
    try {
64
        my $ar = Koha::ArticleRequest->new(
70
        my $ar = Koha::ArticleRequest->new(
65
            {
71
            {
Lines 77-92 if ( $action eq 'create' ) { Link Here
77
                patron_notes   => $patron_notes,
83
                patron_notes   => $patron_notes,
78
                format         => $format,
84
                format         => $format,
79
            }
85
            }
80
        )->store();
86
        )->request;
87
        $success = 1;
88
    } catch {
89
        if ( blessed $_ and $_->isa('Koha::Exceptions::ArticleRequest::LimitReached') ) {
90
            $template->param(
91
                error_message => 'article_request_limit_reached'
92
            );
93
        }
94
        else {
95
            Koha::Logger->get->debug("Unhandled exception when placing an article request ($_)");
96
            $template->param(
97
                error_message => 'article_request_unhandled_exception'
98
            );
99
        }
100
    };
81
101
102
    if ( $success ) {
82
        print $cgi->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests");
103
        print $cgi->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests");
83
        exit;
104
        exit;
84
    } catch {
105
    }
85
        exit unless $_->[0] && $_->[0] eq 'EXIT';
86
        $template->param(
87
            error_message => $_->{message}
88
        );
89
    };
90
# Should we redirect?
106
# Should we redirect?
91
}
107
}
92
elsif ( !$action && C4::Context->preference('ArticleRequestsOpacHostRedirection') ) {
108
elsif ( !$action && C4::Context->preference('ArticleRequestsOpacHostRedirection') ) {
Lines 106-112 my $patron = Koha::Patrons->find($borrowernumber); Link Here
106
122
107
if(!$patron->can_request_article) {
123
if(!$patron->can_request_article) {
108
    $template->param(
124
    $template->param(
109
        error_message => 'You cannot request more articles for today'
125
        error_message => 'article_request_limit_reached'
110
    );
126
    );
111
}
127
}
112
128
113
- 

Return to bug 27945