Merge branch '3.18.x-new' into 3.18.x
[koha.git] / acqui / z3950_search.pl
blob47ad89d7e0e26bfac2f4ddbd75ad7065b851cea1
1 #!/usr/bin/perl
3 # This is a completely new Z3950 clients search using async ZOOM -TG 02/11/06
4 # Copyright 2000-2002 Katipo Communications
5 # Copyright 2010 Catalyst IT
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use warnings;
23 use strict;
24 use CGI qw/-utf8/;
26 use C4::Auth;
27 use C4::Output;
28 use C4::Context;
29 use C4::Breeding;
30 use C4::Koha;
31 use C4::Bookseller qw/ GetBookSellerFromId /;
33 my $input = new CGI;
34 my $biblionumber = $input->param('biblionumber')||0;
35 my $frameworkcode = $input->param('frameworkcode')||'';
36 my $title = $input->param('title');
37 my $author = $input->param('author');
38 my $isbn = $input->param('isbn');
39 my $issn = $input->param('issn');
40 my $lccn = $input->param('lccn');
41 my $lccall = $input->param('lccall');
42 my $subject = $input->param('subject');
43 my $dewey = $input->param('dewey');
44 my $controlnumber = $input->param('controlnumber');
45 my $op = $input->param('op')||'';
46 my $booksellerid = $input->param('booksellerid');
47 my $basketno = $input->param('basketno');
48 my $page = $input->param('current_page') || 1;
49 $page = $input->param('goto_page') if $input->param('changepage_goto');
51 # get framework list
52 my $frameworks = getframeworks;
53 my @frameworkcodeloop;
54 foreach my $thisframeworkcode ( keys %$frameworks ) {
55 my %row = (
56 value => $thisframeworkcode,
57 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
59 if ( $row{'value'} eq $frameworkcode){
60 $row{'active'} = 'true';
62 push @frameworkcodeloop, \%row;
65 my $vendor = GetBookSellerFromId($booksellerid);
67 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69 template_name => "acqui/z3950_search.tt",
70 query => $input,
71 type => "intranet",
72 flagsrequired => { acquisition => 'order_manage' },
75 $template->param(
76 frameworkcode => $frameworkcode,
77 frameworkcodeloop => \@frameworkcodeloop,
78 booksellerid => $booksellerid,
79 basketno => $basketno,
80 name => $vendor->{'name'},
81 isbn => $isbn,
82 issn => $issn,
83 lccn => $lccn,
84 lccall => $lccall,
85 title => $title,
86 author => $author,
87 controlnumber=> $controlnumber,
88 biblionumber => $biblionumber,
89 dewey => $dewey,
90 subject => $subject,
93 if ( $op ne "do_search" ) {
94 my $schema = Koha::Database->new()->schema();
95 my $rs = $schema->resultset('Z3950server')->search(
97 recordtype => 'biblio',
98 servertype => ['zed', 'sru'],
100 { result_class => 'DBIx::Class::ResultClass::HashRefInflator' },
102 $template->param(
103 serverloop => [ $rs->all ],
104 opsearch => "search",
106 output_html_with_http_headers $input, $cookie, $template->output;
107 exit;
110 my @id = $input->param('id');
111 if (@id==0) {
112 $template->param( emptyserverlist => 1 );
113 output_html_with_http_headers $input, $cookie, $template->output;
114 exit;
117 my $pars= {
118 biblionumber => $biblionumber,
119 page => $page,
120 id => \@id,
121 isbn => $isbn,
122 issn => $issn,
123 title => $title,
124 author => $author,
125 dewey => $dewey,
126 subject => $subject,
127 lccall => $lccall,
128 controlnumber => $controlnumber,
129 stdid => 0,
130 srchany => 0,
132 Z3950Search($pars, $template);
133 output_html_with_http_headers $input, $cookie, $template->output;