Bug 15801: Koha::BiblioFrameworks - Remove C4::Koha::getframeworks
[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::Bookseller;
33 use Koha::BiblioFrameworks;
34
35 my $input           = new CGI;
36 my $biblionumber    = $input->param('biblionumber')||0;
37 my $title           = $input->param('title');
38 my $author          = $input->param('author');
39 my $isbn            = $input->param('isbn');
40 my $issn            = $input->param('issn');
41 my $lccn            = $input->param('lccn');
42 my $lccall          = $input->param('lccall');
43 my $subject         = $input->param('subject');
44 my $dewey           = $input->param('dewey');
45 my $controlnumber   = $input->param('controlnumber');
46 my $op              = $input->param('op')||'';
47 my $booksellerid    = $input->param('booksellerid');
48 my $basketno        = $input->param('basketno');
49 my $page            = $input->param('current_page') || 1;
50 $page               = $input->param('goto_page') if $input->param('changepage_goto');
51
52 # get framework list
53 my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
54
55 my $vendor = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
56
57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
58     {
59         template_name   => "acqui/z3950_search.tt",
60         query           => $input,
61         type            => "intranet",
62         flagsrequired   => { acquisition => 'order_manage' },
63     }
64 );
65 $template->param(
66         frameworks   => $frameworks,
67         booksellerid => $booksellerid,
68         basketno     => $basketno,
69         name         => $vendor->{'name'},
70         isbn         => $isbn,
71         issn         => $issn,
72         lccn         => $lccn,
73         lccall       => $lccall,
74         title        => $title,
75         author       => $author,
76         controlnumber=> $controlnumber,
77         biblionumber => $biblionumber,
78         dewey        => $dewey,
79         subject      => $subject,
80 );
81
82 if ( $op ne "do_search" ) {
83     my $schema = Koha::Database->new()->schema();
84     my $rs = $schema->resultset('Z3950server')->search(
85         {
86             recordtype => 'biblio',
87             servertype => ['zed', 'sru'],
88         },
89         {   result_class => 'DBIx::Class::ResultClass::HashRefInflator',
90             order_by     => ['rank', 'servername'],
91         },
92     );
93     $template->param(
94         serverloop   => [ $rs->all ],
95         opsearch     => "search",
96     );
97     output_html_with_http_headers $input, $cookie, $template->output;
98     exit;
99 }
100
101 my @id = $input->multi_param('id');
102 if (@id==0) {
103     $template->param( emptyserverlist => 1 );
104     output_html_with_http_headers $input, $cookie, $template->output;
105     exit;
106 }
107
108 my $pars= {
109         biblionumber => $biblionumber,
110         page => $page,
111         id => \@id,
112         isbn => $isbn,
113         issn => $issn,
114         title => $title,
115         author => $author,
116         dewey => $dewey,
117         subject => $subject,
118         lccall => $lccall,
119         controlnumber => $controlnumber,
120         stdid => 0,
121         srchany => 0,
122 };
123 Z3950Search($pars, $template);
124 output_html_with_http_headers $input, $cookie, $template->output;