Merge branch 'origin/new/bug3756_reenable_local_sysprefs' of git://git.tamil.fr/git...
[koha.git] / acqui / neworderbiblio.pl
blob2333f89d071fba546e0c41184af41a1768286832
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
7 # Copyright 2008-2009 BibLibre SARL
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 =head1 NAME
26 neworderbiblio.pl
28 =head1 DESCRIPTION
30 this script allows to perform a new order from an existing record.
32 =head1 CGI PARAMETERS
34 =over 4
36 =item search
37 the title the librarian has typed to search an existing record.
39 =item q
40 the keyword the librarian has typed to search an existing record.
42 =item author
43 the author of the new record.
45 =item num
46 the number of result per page to display
48 =item booksellerid
49 the id of the bookseller this script has to add an order.
51 =item basketno
52 the basket number to know on which basket this script have to add a new order.
54 =back
56 =cut
58 use strict;
59 #use warnings; FIXME - Bug 2505
61 use C4::Search;
62 use CGI;
63 use C4::Bookseller;
64 use C4::Biblio;
65 use C4::Auth;
66 use C4::Output;
67 use C4::Koha;
69 my $input = new CGI;
71 #getting all CGI params into a hash.
72 my $params = $input->Vars;
74 my $page = $params->{'page'} || 1;
75 my $query = $params->{'q'};
76 my $results_per_page = $params->{'num'} || 20;
77 my $booksellerid = $params->{'booksellerid'};
78 my $basketno = $params->{'basketno'};
79 my $sub = $params->{'sub'};
80 my $bookseller = GetBookSellerFromId($booksellerid);
82 # getting the template
83 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
85 template_name => "acqui/neworderbiblio.tmpl",
86 query => $input,
87 type => "intranet",
88 authnotrequired => 0,
89 flagsrequired => { acquisition => 'order_manage' },
93 # Searching the catalog.
94 my @operands = $query;
95 my ( @operators, @indexes, @sort_by, @limits ) = ();
96 my ( $builterror, $builtquery, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, $stopwords_removed, $query_type ) =
97 buildQuery( \@operators, \@operands, \@indexes, @limits, \@sort_by, undef, undef );
99 # find results
100 my ( $error, $marcresults, $total_hits ) = SimpleSearch( $builtquery, $results_per_page * ( $page - 1 ), $results_per_page );
102 if (defined $error) {
103 $template->param(
104 query_error => $error,
105 basketno => $basketno,
106 booksellerid => $bookseller->{'id'},
107 name => $bookseller->{'name'},
109 output_html_with_http_headers $input, $cookie, $template->output;
110 exit;
113 my @results;
115 if ($marcresults) {
116 foreach my $result ( @{$marcresults} ) {
117 my $marcrecord = MARC::File::USMARC::decode( $result );
118 my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
120 $biblio->{booksellerid} = $booksellerid;
121 push @results, $biblio;
125 $template->param(
126 basketno => $basketno,
127 booksellerid => $bookseller->{'id'},
128 name => $bookseller->{'name'},
129 resultsloop => \@results,
130 total => $total_hits,
131 query => $query,
132 pagination_bar => pagination_bar( "$ENV{'SCRIPT_NAME'}?q=$query&booksellerid=$booksellerid&basketno=$basketno&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ),
135 # BUILD THE TEMPLATE
136 output_html_with_http_headers $input, $cookie, $template->output;