Bug 13268: the size should not be emptied in pl script
[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 qw ( -utf8 );
24
25 use C4::Auth;
26 use C4::Output;
27 use C4::Context;
28 use C4::Breeding;
29 use C4::Koha;
30
31 my $input        = new CGI;
32 my $error         = $input->param('error');
33 my $biblionumber  = $input->param('biblionumber') || 0;
34 my $frameworkcode = $input->param('frameworkcode');
35 my $title         = $input->param('title');
36 my $author        = $input->param('author');
37 my $isbn          = $input->param('isbn');
38 my $issn          = $input->param('issn');
39 my $lccn          = $input->param('lccn');
40 my $lccall        = $input->param('lccall');
41 my $subject       = $input->param('subject');
42 my $dewey         = $input->param('dewey');
43 my $controlnumber = $input->param('controlnumber');
44 my $stdid         = $input->param('stdid');
45 my $srchany       = $input->param('srchany');
46 my $op            = $input->param('op')||'';
47
48 my $page            = $input->param('current_page') || 1;
49 $page = $input->param('goto_page') if $input->param('changepage_goto');
50
51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
52         template_name   => "cataloguing/z3950_search.tt",
53         query           => $input,
54         type            => "intranet",
55         flagsrequired   => { catalogue => 1 },
56 });
57
58 $template->param(
59     frameworkcode => $frameworkcode,
60     isbn         => $isbn,
61     issn         => $issn,
62     lccn         => $lccn,
63     lccall       => $lccall,
64     title        => $title,
65     author       => $author,
66     controlnumber=> $controlnumber,
67     stdid        => $stdid,
68     srchany      => $srchany,
69     biblionumber => $biblionumber,
70     dewey        => $dewey,
71     subject      => $subject,
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     );
83     $template->param(
84         serverloop   => [ $rs->all ],
85         opsearch     => "search",
86     );
87     output_html_with_http_headers $input, $cookie, $template->output;
88     exit;
89 }
90
91 my @id = $input->param('id');
92 if ( @id==0 ) {
93         # empty server list -> report and exit
94         $template->param( emptyserverlist => 1 );
95         output_html_with_http_headers $input, $cookie, $template->output;
96         exit;
97 }
98
99 my $pars= {
100         biblionumber => $biblionumber,
101         page => $page,
102         id => \@id,
103         isbn => $isbn,
104         issn => $issn,
105         title => $title,
106         author => $author,
107         dewey => $dewey,
108         subject => $subject,
109         lccall => $lccall,
110         controlnumber => $controlnumber,
111         stdid => $stdid,
112         srchany => $srchany,
113 };
114 Z3950Search($pars, $template);
115 output_html_with_http_headers $input, $cookie, $template->output;