Bug 9105: Move Z3950 search code to Breeding module
[koha.git] / acqui / 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 # Copyright 2010 Catalyst IT
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 use warnings;
23 use strict;
24 use CGI;
25
26 use C4::Auth;
27 use C4::Output;
28 #use C4::Biblio;
29 use C4::Context;
30 use C4::Breeding;
31 use C4::Koha;
32 #use C4::Charset;
33 use C4::Bookseller qw/ GetBookSellerFromId /;
34 #use ZOOM;
35
36 my $input        = new CGI;
37 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38     {
39         template_name   => "acqui/z3950_search.tmpl",
40         query           => $input,
41         type            => "intranet",
42         authnotrequired => 1,
43         flagsrequired   => { acquisition => 'order_manage' },
44         debug           => 1,
45     }
46 );
47
48
49 my $dbh             = C4::Context->dbh;
50 my $biblionumber    = $input->param('biblionumber')||0;
51 my $frameworkcode   = $input->param('frameworkcode')||'';
52 my $title           = $input->param('title');
53 my $author          = $input->param('author');
54 my $isbn            = $input->param('isbn');
55 my $issn            = $input->param('issn');
56 my $lccn            = $input->param('lccn');
57 my $lccall          = $input->param('lccall');
58 my $subject         = $input->param('subject');
59 my $dewey           = $input->param('dewey');
60 my $controlnumber   = $input->param('controlnumber');
61 my $op              = $input->param('op')||'';
62 my $booksellerid    = $input->param('booksellerid');
63 my $basketno        = $input->param('basketno');
64
65 my $page            = $input->param('current_page') || 1;
66 $page               = $input->param('goto_page') if $input->param('changepage_goto');
67
68 # get framework list
69 my $frameworks = getframeworks;
70 my @frameworkcodeloop;
71 foreach my $thisframeworkcode ( keys %$frameworks ) {
72     my %row = (
73         value         => $thisframeworkcode,
74         frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
75     );
76     if ( $row{'value'} eq $frameworkcode){
77         $row{'active'} = 'true';
78     }
79     push @frameworkcodeloop, \%row;
80 }
81
82 my $vendor = GetBookSellerFromId($booksellerid);
83 $template->param( frameworkcode => $frameworkcode, 
84                                     frameworkcodeloop => \@frameworkcodeloop,
85                                     booksellerid => $booksellerid,
86                                     basketno => $basketno,
87                                     name => $vendor->{'name'},
88         isbn         => $isbn,
89         issn         => $issn,
90         lccn         => $lccn,
91         lccall       => $lccall,
92         title        => $title,
93         author       => $author,
94         controlnumber=> $controlnumber,
95         biblionumber => $biblionumber,
96         dewey        => $dewey,
97         subject      => $subject,
98                                     );
99                                     
100 if ( $op ne "do_search" ) {
101     my $sth = $dbh->prepare("select id,host,name,checked from z3950servers  order by host");
102     $sth->execute();
103     my $serverloop = $sth->fetchall_arrayref( {} );
104     $template->param(
105         serverloop   => $serverloop,
106         opsearch     => "search",
107     );
108     output_html_with_http_headers $input, $cookie, $template->output;
109     exit;
110 }
111
112 my @id = $input->param('id');
113 if (@id==0) {
114     $template->param( emptyserverlist => 1 );
115     output_html_with_http_headers $input, $cookie, $template->output;
116     exit;
117 }
118
119 my $pars= {
120         random => $input->param('random') || rand(1000000000),
121         biblionumber => $biblionumber,
122         page => $page,
123         id => \@id,
124         isbn => $isbn,
125         title => $title,
126         author => $author,
127         dewey => $dewey,
128         subject => $subject,
129         lccall => $lccall,
130         controlnumber => $controlnumber,
131         stdid => 0,
132         srchany => 0,
133 };
134 Z3950Search($pars, $template);
135 output_html_with_http_headers $input, $cookie, $template->output;