3 # This file is part of Koha.
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
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.
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
24 this script allow to add an order from a existing suggestion.
31 the number of this basket.
34 the bookseller who sells this record.
37 the title of this record suggested.
40 the author of this suggestion.
43 this param allow to enter a note with this suggestion.
46 the copyright date for this suggestion.
53 the publication year of this record.
58 the isbn of this suggestion.
61 is the biblionumber to put to the new suggestion.
64 the id of the suggestion to select.
69 then call to the function : ConnectSuggestionAndBiblio.
70 i.e set the biblionumber of this suggestion.
81 use C4::Auth; # get_template_and_user
82 use C4::Interface::CGI::Output;
89 my $basketno = $input->param('basketno');
90 my $supplierid = $input->param('booksellerid');
91 my $title = $input->param('title');
92 my $author = $input->param('author');
93 my $note = $input->param('note');
94 my $copyrightdate =$input->param('copyrightdate');
95 my $publishercode = $input->param('publishercode');
96 my $volumedesc = $input->param('volumedesc');
97 my $publicationyear = $input->param('publicationyear');
98 my $place = $input->param('place');
99 my $isbn = $input->param('isbn');
100 my $duplicateNumber = $input->param('duplicateNumber');
101 my $suggestionid = $input->param('suggestionid');
103 my $status = 'ACCEPTED';
104 my $suggestedbyme = -1; # search ALL suggestors
105 my $op = $input->param('op');
106 $op = 'else' unless $op;
108 my $dbh = C4::Context->dbh;
109 my ($template, $borrowernumber, $cookie)
110 = get_template_and_user({template_name => "acqui/suggestion-select.tmpl",
113 authnotrequired => 1,
114 flagsrequired => {acquisition => 1},
117 if ($op eq 'connectDuplicate') {
118 ConnectSuggestionAndBiblio($suggestionid,$duplicateNumber);
120 my $suggestions_loop= &SearchSuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
121 foreach (@$suggestions_loop) {
122 unless ($_->{biblionumber}) {
123 my (@tags, @and_or, @excluding, @operator, @value, $offset,$length);
124 # search on biblio.title
126 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.title","");
127 push @tags, "'".$tag.$subfield."'";
130 push @operator, "contains";
131 push @value, $_->{title};
134 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.author","");
135 push @tags, "'".$tag.$subfield."'";
138 push @operator, "contains";
139 push @value, $_->{author};
141 # ... and on publicationyear.
142 if ($_->{publicationyear}) {
143 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publicationyear","");
144 push @tags, "'".$tag.$subfield."'";
148 push @value, $_->{publicationyear};
150 # ... and on publisher.
151 if ($_->{publishercode}) {
152 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publishercode","");
153 push @tags, "'".$tag.$subfield."'";
157 push @value, $_->{publishercode};
160 my ($finalresult,$nbresult) = C4::SearchMarc::catalogsearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10);
161 # there is at least 1 result => return the 1st one
163 # warn "$nbresult => ".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title};
164 # warn "DUPLICATE ==>".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title};
165 $_->{duplicateBiblionumber} = @$finalresult[0]->{biblionumber};
169 $template->param(suggestions_loop => $suggestions_loop,
172 publishercode => $publishercode,
174 suggestedbyme => $suggestedbyme,
175 basketno => $basketno,
176 supplierid => $supplierid,
178 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
179 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
180 IntranetNav => C4::Context->preference("IntranetNav"),
182 output_html_with_http_headers $input, $cookie, $template->output;