Bug 22254: Correction to datehandling in test
[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
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
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
32 use Koha::Acquisition::Booksellers;
33 use Koha::BiblioFrameworks;
34
35 my $input           = new CGI;
36 my $biblionumber    = $input->param('biblionumber')||0;
37 my $frameworkcode   = $input->param('frameworkcode') || q{};
38 my $title           = $input->param('title');
39 my $author          = $input->param('author');
40 my $isbn            = $input->param('isbn');
41 my $issn            = $input->param('issn');
42 my $lccn            = $input->param('lccn');
43 my $lccall          = $input->param('lccall');
44 my $subject         = $input->param('subject');
45 my $srchany         = $input->param('srchany');
46 my $stdid           = $input->param('stdid');
47 my $dewey           = $input->param('dewey');
48 my $controlnumber   = $input->param('controlnumber');
49 my $op              = $input->param('op')||'';
50 my $booksellerid    = $input->param('booksellerid');
51 my $basketno        = $input->param('basketno');
52 my $page            = $input->param('current_page') || 1;
53 $page               = $input->param('goto_page') if $input->param('changepage_goto');
54
55 # get framework list
56 my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
57
58 my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
59
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61     {
62         template_name   => "acqui/z3950_search.tt",
63         query           => $input,
64         type            => "intranet",
65         flagsrequired   => { acquisition => 'order_manage' },
66     }
67 );
68 $template->param(
69         frameworkcode => $frameworkcode,
70         frameworks   => $frameworks,
71         booksellerid => $booksellerid,
72         basketno     => $basketno,
73         name         => $vendor->name,
74         isbn         => $isbn,
75         issn         => $issn,
76         lccn         => $lccn,
77         lccall       => $lccall,
78         title        => $title,
79         author       => $author,
80         controlnumber=> $controlnumber,
81         biblionumber => $biblionumber,
82         dewey        => $dewey,
83         subject      => $subject,
84         srchany      => $srchany,
85         stdid        => $stdid,
86 );
87
88 if ( $op ne "do_search" ) {
89     my $schema = Koha::Database->new()->schema();
90     my $rs = $schema->resultset('Z3950server')->search(
91         {
92             recordtype => 'biblio',
93             servertype => ['zed', 'sru'],
94         },
95         {   result_class => 'DBIx::Class::ResultClass::HashRefInflator',
96             order_by     => ['rank', 'servername'],
97         },
98     );
99     $template->param(
100         serverloop   => [ $rs->all ],
101         opsearch     => "search",
102     );
103     output_html_with_http_headers $input, $cookie, $template->output;
104     exit;
105 }
106
107 my @id = $input->multi_param('id');
108 if (@id==0) {
109     $template->param( emptyserverlist => 1 );
110     output_html_with_http_headers $input, $cookie, $template->output;
111     exit;
112 }
113
114 my $pars= {
115         biblionumber => $biblionumber,
116         page => $page,
117         id => \@id,
118         isbn => $isbn,
119         issn => $issn,
120         title => $title,
121         author => $author,
122         dewey => $dewey,
123         subject => $subject,
124         lccall => $lccall,
125         controlnumber => $controlnumber,
126         stdid => $stdid,
127         srchany => $srchany,
128 };
129 Z3950Search($pars, $template);
130 output_html_with_http_headers $input, $cookie, $template->output;