Merge branch 'bug_8200' into 3.12-master
[koha.git] / acqui / newordersuggestion.pl
blobefc634bf2c514dd9c439c814b8725612e258912d
1 #!/usr/bin/perl
3 # Copyright 2006 Biblibre
4 # Parts Copyright 2011 PTFS Europe
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 =head1 NAME
23 newordersuggestion.pl
25 =head1 DESCRIPTION
27 this script allow to add an order from a existing suggestion.
28 The suggestion must have 'ACCEPTED' as status.
30 =head1 CGI PARAMETERS
32 =over 4
34 =item basketno
36 the number of this basket.
38 =item booksellerid
40 the bookseller who sells this record.
42 =item title
44 to filter on title when searching among ACCEPTED suggestion.
46 =item author
48 to filter on author when searching among ACCEPTED suggestion.
50 =item note
52 to filter on note when searching among ACCEPTED suggestion.
54 =item copyrightdate
56 =item publishercode
58 =item volumedesc
60 =item publicationyear
62 the publication year of this record.
64 =item place
66 =item isbn
68 the isbn of this suggestion.
70 =item duplicateNumber
72 is the biblionumber to put to the new suggestion.
74 =item suggestionid
76 the id of the suggestion to select.
78 =item op
80 can be equal to
81 * connectDuplicate :
82 then call to the function : ConnectSuggestionAndBiblio.
83 i.e set the biblionumber of this suggestion.
84 * else :
85 is the default value.
87 =back
89 =cut
91 use strict;
92 #use warnings; FIXME - Bug 2505
94 use CGI;
95 use C4::Auth; # get_template_and_user
96 use C4::Output;
97 use C4::Suggestions;
98 use C4::Bookseller qw/ GetBookSellerFromId /;
99 use C4::Biblio;
101 my $input = new CGI;
103 # getting the CGI params
104 my $basketno = $input->param('basketno');
105 my $booksellerid = $input->param('booksellerid');
106 my $author = $input->param('author');
107 my $title = $input->param('title');
108 my $publishercode = $input->param('publishercode');
109 my $op = $input->param('op');
110 my $suggestionid = $input->param('suggestionid');
111 my $duplicateNumber = $input->param('duplicateNumber');
112 my $uncertainprice = $input->param('uncertainprice');
114 $op = 'else' unless $op;
116 my $dbh = C4::Context->dbh;
117 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
119 template_name => "acqui/newordersuggestion.tmpl",
120 type => "intranet",
121 query => $input,
122 authnotrequired => 1,
123 flagsrequired => { acquisition => 'order_manage' },
127 if ( $op eq 'connectDuplicate' ) {
128 ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
131 # getting all suggestions.
132 my $suggestions_loop =
133 &SearchSuggestion(
134 { managedby => $borrowernumber,
135 author => $author,
136 title => $title,
137 publishercode => $publishercode,
138 STATUS => 'ACCEPTED'});
139 my $vendor = GetBookSellerFromId($booksellerid);
140 $template->param(
141 suggestions_loop => $suggestions_loop,
142 basketno => $basketno,
143 booksellerid => $booksellerid,
144 name => $vendor->{'name'},
145 "op_$op" => 1,
148 output_html_with_http_headers $input, $cookie, $template->output;