added 440* and 490* 'series' indexes
[koha.git] / acqui / neworderbiblio.pl
blob6fb6f7c53f4291bfb7d3b2f13721fbdf8796a0ff
1 #!/usr/bin/perl
3 #origninally script to provide intranet (librarian) advanced search facility
4 #now script to do searching for acquisitions
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
23 =head1 NAME
25 neworderbiblio.pl
27 =head1 DESCRIPTION
29 this script allows to perform a new order from an existing record.
31 =head1 CGI PARAMETERS
33 =over 4
35 =item search
36 the title the librarian has typed to search an existing record.
38 =item q
39 the keyword the librarian has typed to search an existing record.
41 =item author
42 the author of the new record.
44 =item num
45 the number of result per page to display
47 =item booksellerid
48 the id of the bookseller this script has to add an order.
50 =item basketno
51 the basket number to know on which basket this script have to add a new order.
53 =back
55 =cut
57 use strict;
58 use C4::Search;
59 use CGI;
60 use C4::Bookseller;
61 use C4::Biblio;
63 use C4::Auth;
64 use C4::Output;
65 use C4::Koha;
67 my $input = new CGI;
69 #getting all CGI params into a hash.
70 my $params = $input->Vars;
72 my $offset = $params->{'offset'} || 0;
73 my $query = $params->{'q'};
74 my $num = $params->{'num'};
75 $num = 20 unless $num;
77 my $booksellerid = $params->{'booksellerid'};
78 my $basketno = $params->{'basketno'};
79 my $sub = $params->{'sub'};
81 # getting the template
82 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
84 template_name => "acqui/neworderbiblio.tmpl",
85 query => $input,
86 type => "intranet",
87 authnotrequired => 0,
88 flagsrequired => { acquisition => 1 },
92 # Searching the catalog.
93 my ($error, $marcresults) = SimpleSearch($query);
95 if (defined $error) {
96 $template->param(query_error => $error);
97 warn "error: ".$error;
98 output_html_with_http_headers $input, $cookie, $template->output;
99 exit;
102 my $hits = scalar @$marcresults;
103 my @results;
105 for(my $i=0;$i<$hits;$i++) {
106 my %resultsloop;
107 my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
108 my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
110 #build the hash for the template.
111 %resultsloop=%$biblio;
112 $resultsloop{highlight} = ($i % 2)?(1):(0);
113 $resultsloop{booksellerid} = $booksellerid;
114 push @results, \%resultsloop;
117 $template->param(
118 basketno => $basketno,
119 booksellerid => $booksellerid,
120 resultsloop => \@results,
121 total => $hits,
122 query => $query,
123 virtualshelves => C4::Context->preference("virtualshelves"),
124 LibraryName => C4::Context->preference("LibraryName"),
125 OpacNav => C4::Context->preference("OpacNav"),
126 opaccredits => C4::Context->preference("opaccredits"),
127 AmazonContent => C4::Context->preference("AmazonContent"),
128 opacsmallimage => C4::Context->preference("opacsmallimage"),
129 opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
130 opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
131 "BiblioDefaultView".C4::Context->preference("IntranetBiblioDefaultView") => 1,
134 # BUILD THE TEMPLATE
135 output_html_with_http_headers $input, $cookie, $template->output;