Bug 11126: (RM followup) remove diags from tests
[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 qw/-utf8/;
25
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 /;
32
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');
50
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'},
58     );
59     if ( $row{'value'} eq $frameworkcode){
60         $row{'active'} = 'true';
61     }
62     push @frameworkcodeloop, \%row;
63 }
64
65 my $vendor = GetBookSellerFromId($booksellerid);
66
67 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
68     {
69         template_name   => "acqui/z3950_search.tt",
70         query           => $input,
71         type            => "intranet",
72         flagsrequired   => { acquisition => 'order_manage' },
73     }
74 );
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,
91 );
92
93 if ( $op ne "do_search" ) {
94     my $schema = Koha::Database->new()->schema();
95     my $rs = $schema->resultset('Z3950server')->search(
96         {
97             recordtype => 'biblio',
98             servertype => ['zed', 'sru'],
99         },
100         { result_class => 'DBIx::Class::ResultClass::HashRefInflator' },
101     );
102     $template->param(
103         serverloop   => [ $rs->all ],
104         opsearch     => "search",
105     );
106     output_html_with_http_headers $input, $cookie, $template->output;
107     exit;
108 }
109
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;
115 }
116
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,
131 };
132 Z3950Search($pars, $template);
133 output_html_with_http_headers $input, $cookie, $template->output;