Bug 29723: Add a "Configure table" button for KohaTable tables
[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
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21 use Modern::Perl;
22 use CGI qw ( -utf8 );
23
24 use C4::Auth qw( get_template_and_user );
25 use C4::Output qw( output_html_with_http_headers );
26 use C4::Context;
27 use C4::Breeding qw( Z3950Search );
28
29 my $input        = CGI->new;
30 my $error         = $input->param('error');
31 my $biblionumber  = $input->param('biblionumber') || 0;
32 my $frameworkcode = $input->param('frameworkcode');
33 my $title         = $input->param('title');
34 my $author        = $input->param('author');
35 my $isbn          = $input->param('isbn');
36 my $issn          = $input->param('issn');
37 my $lccn          = $input->param('lccn');
38 my $lccall        = $input->param('lccall');
39 my $subject       = $input->param('subject');
40 my $dewey         = $input->param('dewey');
41 my $controlnumber = $input->param('controlnumber');
42 my $stdid         = $input->param('stdid');
43 my $srchany       = $input->param('srchany');
44 my $publicationyear = $input->param('publicationyear');
45 my $op            = $input->param('op')||'';
46
47 my $page            = $input->param('current_page') || 1;
48 $page = $input->param('goto_page') if $input->param('changepage_goto');
49
50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
51         template_name   => "cataloguing/z3950_search.tt",
52         query           => $input,
53         type            => "intranet",
54         flagsrequired   => { catalogue => 1 },
55 });
56
57 $template->param(
58     frameworkcode => $frameworkcode,
59     isbn         => $isbn,
60     issn         => $issn,
61     lccn         => $lccn,
62     lccall       => $lccall,
63     title        => $title,
64     author       => $author,
65     controlnumber=> $controlnumber,
66     stdid        => $stdid,
67     srchany      => $srchany,
68     biblionumber => $biblionumber,
69     dewey        => $dewey,
70     subject      => $subject,
71     publicationyear => $publicationyear,
72 );
73
74 if ( $op ne "do_search" ) {
75     my $schema = Koha::Database->new()->schema();
76     my $rs = $schema->resultset('Z3950server')->search(
77         {
78             recordtype => 'biblio',
79             servertype => ['zed', 'sru'],
80         },
81         {   result_class => 'DBIx::Class::ResultClass::HashRefInflator',
82             order_by     => ['rank', 'servername'],
83         },
84     );
85     $template->param(
86         serverloop   => [ $rs->all ],
87         opsearch     => "search",
88     );
89     output_html_with_http_headers $input, $cookie, $template->output;
90     exit;
91 }
92
93 my @id = $input->multi_param('id');
94 if ( @id==0 ) {
95         # empty server list -> report and exit
96         $template->param( emptyserverlist => 1 );
97         output_html_with_http_headers $input, $cookie, $template->output;
98         exit;
99 }
100
101 my $pars= {
102         biblionumber => $biblionumber,
103         page => $page,
104         id => \@id,
105         isbn => $isbn,
106         issn => $issn,
107         title => $title,
108         author => $author,
109         dewey => $dewey,
110         subject => $subject,
111         lccall => $lccall,
112         controlnumber => $controlnumber,
113         stdid => $stdid,
114         srchany => $srchany,
115         publicationyear => $publicationyear,
116 };
117 Z3950Search($pars, $template);
118 output_html_with_http_headers $input, $cookie, $template->output;