Added 'Branch Transfer Limits' Feature requested by Geauga County Library System.
[koha.git] / authorities / auth_finder.pl
blobfef6cbf894dbcacc29ad04f8806afba8ff1a403a
1 #!/usr/bin/perl
2 # WARNING: 4-character tab stops here
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
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.
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.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
23 use CGI;
24 use C4::Output;
25 use C4::Auth;
26 use C4::Context;
27 use C4::AuthoritiesMarc;
28 use C4::Acquisition;
29 use C4::Koha; # XXX subfield_is_koha_internal_p
31 my $query = new CGI;
32 my $op = $query->param('op');
33 my $authtypecode = $query->param('authtypecode');
34 my $index = $query->param('index');
35 my $tagid = $query->param('tagid');
36 my $resultstring = $query->param('result');
37 my $dbh = C4::Context->dbh;
39 my $startfrom = $query->param('startfrom');
40 $startfrom = 0 if ( !defined $startfrom );
41 my ( $template, $loggedinuser, $cookie );
42 my $resultsperpage;
44 my $authtypes = getauthtypes;
45 my @authtypesloop;
46 foreach my $thisauthtype ( keys %$authtypes ) {
47 my $selected = 1 if $thisauthtype eq $authtypecode;
48 my %row = (
49 value => $thisauthtype,
50 selected => $selected,
51 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
52 index => $index,
54 push @authtypesloop, \%row;
57 if ( $op eq "do_search" ) {
58 my @marclist = $query->param('marclist');
59 my @and_or = $query->param('and_or');
60 my @excluding = $query->param('excluding');
61 my @operator = $query->param('operator');
62 my @value = $query->param('value');
63 my $orderby = $query->param('orderby');
65 $resultsperpage = $query->param('resultsperpage');
66 $resultsperpage = 20 if ( !defined $resultsperpage );
68 my ( $results, $total ) =
69 SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value,
70 $startfrom * $resultsperpage,
71 $resultsperpage, $authtypecode, $orderby);
72 # multi page display gestion
73 my $displaynext = 0;
74 my $displayprev = $startfrom;
75 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
76 $displaynext = 1;
79 my @field_data = ();
81 my @marclist_ini =
82 $query->param('marclist')
83 ; # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name
84 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
85 push @field_data, { term => "marclist", val => $marclist_ini[$i] };
86 push @field_data, { term => "and_or", val => $and_or[$i] };
87 push @field_data, { term => "excluding", val => $excluding[$i] };
88 push @field_data, { term => "operator", val => $operator[$i] };
89 push @field_data, { term => "value", val => $value[$i] };
92 my @numbers = ();
94 if ( $total > $resultsperpage ) {
95 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
96 if ( $i < 16 ) {
97 my $highlight = 0;
98 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
99 push @numbers,
101 number => $i,
102 highlight => $highlight,
103 searchdata => \@field_data,
104 startfrom => ( $i - 1 )
110 my $from = $startfrom * $resultsperpage + 1;
111 my $to;
113 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
114 $to = $total;
116 else {
117 $to = ( ( $startfrom + 1 ) * $resultsperpage );
119 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
121 template_name => "authorities/searchresultlist-auth.tmpl",
122 query => $query,
123 type => 'intranet',
124 authnotrequired => 0,
125 flagsrequired => { catalogue => 1 },
129 $template->param( result => $results ) if $results;
130 $template->param(
131 orderby => $orderby,
132 startfrom => $startfrom,
133 displaynext => $displaynext,
134 displayprev => $displayprev,
135 resultsperpage => $resultsperpage,
136 startfromnext => $startfrom + 1,
137 startfromprev => $startfrom - 1,
138 searchdata => \@field_data,
139 total => $total,
140 from => $from,
141 to => $to,
142 numbers => \@numbers,
143 authtypecode => $authtypecode,
144 mainmainstring => $value[0],
145 mainstring => $value[1],
146 anystring => $value[2],
148 } else {
149 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
151 template_name => "authorities/auth_finder.tmpl",
152 query => $query,
153 type => 'intranet',
154 authnotrequired => 0,
155 flagsrequired => { catalogue => 1 },
159 $template->param(
160 resultstring => $resultstring,
164 $template->param(
165 tagid => $tagid,
166 index => $index,
167 authtypesloop => \@authtypesloop,
168 authtypecode => $authtypecode,
171 # Print the page
172 output_html_with_http_headers $query, $cookie, $template->output;
174 # Local Variables:
175 # tab-width: 4
176 # End: