Bug 9105: Move Z3950 search code to Breeding module
[koha.git] / cataloguing / z3950_search.pl
1 #!/usr/bin/perl
2
3 # This is a completely new Z3950 clients search using async ZOOM -TG 02/11/06
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 use strict;
22 use warnings;
23 use CGI;
24
25 use C4::Auth;
26 use C4::Output;
27 #use C4::Biblio;
28 use C4::Context;
29 use C4::Breeding;
30 use C4::Koha;
31 #use C4::Charset;
32 #use ZOOM;
33
34 my $input        = new CGI;
35 my $dbh          = C4::Context->dbh;
36 my $error         = $input->param('error');
37 my $biblionumber  = $input->param('biblionumber') || 0;
38 my $frameworkcode = $input->param('frameworkcode');
39 my $title         = $input->param('title');
40 my $author        = $input->param('author');
41 my $isbn          = $input->param('isbn');
42 my $issn          = $input->param('issn');
43 my $lccn          = $input->param('lccn');
44 my $lccall        = $input->param('lccall');
45 my $subject       = $input->param('subject');
46 my $dewey         = $input->param('dewey');
47 my $controlnumber       = $input->param('controlnumber');
48 my $stdid                       = $input->param('stdid');
49 my $srchany                     = $input->param('srchany');
50 my $op            = $input->param('op')||'';
51
52 my $page            = $input->param('current_page') || 1;
53 $page = $input->param('goto_page') if $input->param('changepage_goto');
54
55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
56         template_name   => "cataloguing/z3950_search.tmpl",
57         query           => $input,
58         type            => "intranet",
59         authnotrequired => 1,
60         flagsrequired   => { catalogue => 1 },
61         debug           => 1,
62 });
63
64 $template->param( frameworkcode => $frameworkcode, );
65 $template->param(
66     isbn         => $isbn,
67     issn         => $issn,
68     lccn         => $lccn,
69     lccall       => $lccall,
70     title        => $title,
71     author       => $author,
72     controlnumber=> $controlnumber,
73     stdid        => $stdid,
74     srchany      => $srchany,
75     biblionumber => $biblionumber,
76     dewey        => $dewey,
77     subject      => $subject,
78 );
79
80 if ( $op ne "do_search" ) {
81     my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers ORDER BY rank, name");
82     $sth->execute();
83     my $serverloop = $sth->fetchall_arrayref( {} );
84     $template->param(
85         serverloop   => $serverloop,
86         opsearch     => "search",
87     );
88     output_html_with_http_headers $input, $cookie, $template->output;
89     exit;
90 }
91
92 my @id = $input->param('id');
93 if ( @id==0 ) {
94         # empty server list -> report and exit
95         $template->param( emptyserverlist => 1 );
96         output_html_with_http_headers $input, $cookie, $template->output;
97         exit;
98 }
99
100 my $pars= {
101         random => $input->param('random') || rand(1000000000),
102         biblionumber => $biblionumber,
103         page => $page,
104         id => \@id,
105         isbn => $isbn,
106         title => $title,
107         author => $author,
108         dewey => $dewey,
109         subject => $subject,
110         lccall => $lccall,
111         controlnumber => $controlnumber,
112         stdid => 0,
113         srchany => 0,
114 };
115 Z3950Search($pars, $template);
116 output_html_with_http_headers $input, $cookie, $template->output;