Bug 19503: Duplicating a dropdown menu subfield yields an empty subfield tag
[koha.git] / circ / request-article.pl
blobea33b3ee5a3ba4483bae9f81acc87751afdf0e56
1 #!/usr/bin/perl
3 # Copyright 2015 ByWater Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
22 use C4::Output;
23 use C4::Auth;
24 use C4::Utils::DataTables::Members;
25 use Koha::Biblios;
26 use Koha::Patrons;
27 use Koha::ArticleRequests;
29 my $cgi = new CGI;
31 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
33 template_name => "circ/request-article.tt",
34 query => $cgi,
35 type => "intranet",
36 authnotrequired => 0,
37 flagsrequired => { circulate => 'circulate_remaining_permissions' },
41 my $action = $cgi->param('action') || q{};
42 my $biblionumber = $cgi->param('biblionumber');
43 my $patron_cardnumber = $cgi->param('patron_cardnumber');
44 my $patron_id = $cgi->param('patron_id');
46 my $biblio = Koha::Biblios->find($biblionumber);
47 my $patron =
48 $patron_id ? Koha::Patrons->find($patron_id)
49 : $patron_cardnumber ? Koha::Patrons->find( { cardnumber => $patron_cardnumber } )
50 : undef;
52 if ( $action eq 'create' ) {
53 my $borrowernumber = $cgi->param('borrowernumber');
54 my $branchcode = $cgi->param('branchcode');
56 my $itemnumber = $cgi->param('itemnumber') || undef;
57 my $title = $cgi->param('title') || undef;
58 my $author = $cgi->param('author') || undef;
59 my $volume = $cgi->param('volume') || undef;
60 my $issue = $cgi->param('issue') || undef;
61 my $date = $cgi->param('date') || undef;
62 my $pages = $cgi->param('pages') || undef;
63 my $chapters = $cgi->param('chapters') || undef;
64 my $patron_notes = $cgi->param('patron_notes') || undef;
66 my $ar = Koha::ArticleRequest->new(
68 borrowernumber => $borrowernumber,
69 biblionumber => $biblionumber,
70 branchcode => $branchcode,
71 itemnumber => $itemnumber,
72 title => $title,
73 author => $author,
74 volume => $volume,
75 issue => $issue,
76 date => $date,
77 pages => $pages,
78 chapters => $chapters,
79 patron_notes => $patron_notes,
81 )->store();
85 if ( !$patron && $patron_cardnumber ) {
86 my $results = C4::Utils::DataTables::Members::search(
88 searchmember => $patron_cardnumber,
89 dt_params => { iDisplayLength => -1 },
93 my $patrons = $results->{patrons};
95 if ( scalar @$patrons == 1 ) {
96 $patron = Koha::Patrons->find( $patrons->[0]->{borrowernumber} );
98 elsif (@$patrons) {
99 $template->param( patrons => $patrons );
101 else {
102 $template->param( no_patrons_found => $patron_cardnumber );
106 $template->param(
107 biblio => $biblio,
108 patron => $patron,
111 output_html_with_http_headers $cgi, $cookie, $template->output;