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
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # Koha is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with Koha; if not, see <http://www.gnu.org/licenses>.
30 this script allows to perform a new order from an existing record.
37 the title the librarian has typed to search an existing record.
40 the keyword the librarian has typed to search an existing record.
43 the author of the new record.
46 the number of result per page to display
49 the id of the bookseller this script has to add an order.
52 the basket number to know on which basket this script have to add a new order.
59 #use warnings; FIXME - Bug 2505
63 use C4
::Bookseller qw
/ GetBookSellerFromId /;
68 use C4
::Members qw
/ GetMember /;
69 use C4
::Budgets qw
/ GetBudgetHierarchy /;
73 #getting all CGI params into a hash.
74 my $params = $input->Vars;
76 my $page = $params->{'page'} || 1;
77 my $query = $params->{'q'};
78 my $results_per_page = $params->{'num'} || 20;
79 my $booksellerid = $params->{'booksellerid'};
80 my $basketno = $params->{'basketno'};
81 my $sub = $params->{'sub'};
82 my $bookseller = GetBookSellerFromId
($booksellerid);
84 # getting the template
85 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
87 template_name
=> "acqui/neworderbiblio.tt",
91 flagsrequired
=> { acquisition
=> 'order_manage' },
95 # Searching the catalog.
97 my @operands = $query;
99 $QParser = C4
::Context
->queryparser if (C4
::Context
->preference('UseQueryParser'));
102 $builtquery = $query;
104 my ( $builterror,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
105 ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery
(undef,\
@operands);
107 my ( $error, $marcresults, $total_hits ) = SimpleSearch
( $builtquery, $results_per_page * ( $page - 1 ), $results_per_page );
109 if (defined $error) {
111 query_error
=> $error,
112 basketno
=> $basketno,
113 booksellerid
=> $bookseller->{'id'},
114 name
=> $bookseller->{'name'},
116 output_html_with_http_headers
$input, $cookie, $template->output;
122 foreach my $result ( @
{$marcresults} ) {
123 my $marcrecord = C4
::Search
::new_record_from_zebra
( 'biblioserver', $result );
124 my $biblio = TransformMarcToKoha
( C4
::Context
->dbh, $marcrecord, '' );
126 $biblio->{booksellerid
} = $booksellerid;
127 push @results, $biblio;
131 my $borrower= GetMember
('borrowernumber' => $loggedinuser);
132 my $budgets = GetBudgetHierarchy
(q{},$borrower->{branchcode
},$borrower->{borrowernumber
});
134 foreach my $r (@
{$budgets}) {
135 if (!defined $r->{budget_amount
} || $r->{budget_amount
} == 0) {
143 has_budgets
=> $has_budgets,
144 basketno
=> $basketno,
145 booksellerid
=> $bookseller->{'id'},
146 name
=> $bookseller->{'name'},
147 resultsloop
=> \
@results,
148 total
=> $total_hits,
150 pagination_bar
=> pagination_bar
( "$ENV{'SCRIPT_NAME'}?q=$query&booksellerid=$booksellerid&basketno=$basketno&", getnbpages
( $total_hits, $results_per_page ), $page, 'page' ),
154 output_html_with_http_headers
$input, $cookie, $template->output;