using 'our' instead of 'use vars' which is deprecated.
[koha.git] / acqui / newordersuggestion.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18 # $Id$
19
20 =head1 NAME
21
22 newordersuggestion.pl
23
24 =head1 DESCRIPTION
25
26 this script allow to add an order from a existing suggestion.
27 The suggestion must have 'ACCEPTED' as status.
28
29 =head1 CGI PARAMETERS
30
31 =over 4
32
33 =item basketno
34
35     the number of this basket.
36
37 =item booksellerid
38
39     the bookseller who sells this record.
40
41 =item title
42
43     to filter on title when searching among ACCEPTED suggestion.
44
45 =item author
46
47     to filter on author when searching among ACCEPTED suggestion.
48
49 =item note
50
51     to filter on note when searching among ACCEPTED suggestion.
52
53 =item copyrightdate
54
55 =item publishercode
56
57 =item volumedesc
58
59 =item publicationyear
60
61 the publication year of this record.
62
63 =item place
64
65 =item isbn
66
67 the isbn of this suggestion.
68
69 =item duplicateNumber
70
71 is the biblionumber to put to the new suggestion.
72
73 =item suggestionid
74
75 the id of the suggestion to select.
76
77 =item op
78
79 can be equal to
80     * connectDuplicate :
81         then call to the function : ConnectSuggestionAndBiblio.
82         i.e set the biblionumber of this suggestion.
83     * else :
84         is the default value.
85
86 =back
87
88 =cut
89
90 use strict;
91 require Exporter;
92 use CGI;
93 use C4::Auth;    # get_template_and_user
94 use C4::Output;
95 use C4::Suggestions;
96 use C4::Biblio;
97
98 my $input = new CGI;
99
100 # getting the CGI params
101 my $basketno        = $input->param('basketno');
102 my $supplierid      = $input->param('booksellerid');
103 my $author          = $input->param('author');
104 my $title           = $input->param('title');
105 my $publishercode   = $input->param('publishercode');
106 my $op              = $input->param('op');
107 my $suggestionid    = $input->param('suggestionid');
108 my $duplicateNumber = $input->param('duplicateNumber');
109
110 $op = 'else' unless $op;
111
112 my $dbh = C4::Context->dbh;
113 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
114     {
115         template_name   => "acqui/newordersuggestion.tmpl",
116         type            => "intranet",
117         query           => $input,
118         authnotrequired => 1,
119         flagsrequired   => { acquisition => 1 },
120     }
121 );
122
123 if ( $op eq 'connectDuplicate' ) {
124     ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
125 }
126
127 # getting all suggestions.
128 my $suggestions_loop =
129   &SearchSuggestion( $borrowernumber, $author, $title, $publishercode,'ACCEPTED',
130     -1 );
131
132 $template->param(
133     suggestions_loop        => $suggestions_loop,
134     basketno                => $basketno,
135     supplierid              => $supplierid,
136     "op_$op"                => 1,
137     intranetcolorstylesheet =>
138       C4::Context->preference("intranetcolorstylesheet"),
139     intranetstylesheet => C4::Context->preference("intranetstylesheet"),
140     IntranetNav        => C4::Context->preference("IntranetNav"),
141 );
142
143 output_html_with_http_headers $input, $cookie, $template->output;