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 |
- |
|
|