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
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
30 use C4::Interface::CGI::Output;
31 use C4::AuthoritiesMarc;
34 use C4::Koha; # XXX subfield_is_koha_internal_p
37 my $op = $query->param('op');
38 my $authtypecode = $query->param('authtypecode');
39 my $index = $query->param('index');
40 my $tagid=$query->param('tagid');
41 my $resultstring = $query->param('result');
42 my $dbh = C4::Context->dbh;
44 my $startfrom=$query->param('startfrom');
45 $startfrom=0 if(!defined $startfrom);
46 my ($template, $loggedinuser, $cookie);
49 my $authtypes = getauthtypes;
51 foreach my $thisauthtype (keys %$authtypes) {
52 my $selected = 1 if $thisauthtype eq $authtypecode;
53 my %row =(value => $thisauthtype,
54 selected => $selected,
55 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
58 push @authtypesloop, \%row;
61 if ($op eq "do_search") {
62 my @marclist = $query->param('marclist');
63 my @and_or = $query->param('and_or');
64 my @excluding = $query->param('excluding');
65 my @operator = $query->param('operator');
66 my @value = $query->param('value');
68 $resultsperpage= $query->param('resultsperpage');
69 $resultsperpage = 19 if(!defined $resultsperpage);
71 my ($results,$total) = authoritysearch($dbh, \@marclist,\@and_or,
72 \@excluding, \@operator, \@value,
73 $startfrom*$resultsperpage, $resultsperpage,$authtypecode);# $orderby);
75 ($template, $loggedinuser, $cookie)
76 = get_template_and_user({template_name => "authorities/searchresultlist-auth.tmpl",
80 flagsrequired => {borrowers => 1},
81 flagsrequired => {catalogue => 1},
85 # multi page display gestion
87 my $displayprev=$startfrom;
88 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
95 my @marclist_ini = $query->param('marclist'); # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name
96 for(my $i = 0 ; $i <= $#marclist ; $i++) {
97 push @field_data, { term => "marclist", val=>$marclist_ini[$i] };
98 push @field_data, { term => "and_or", val=>$and_or[$i] };
99 push @field_data, { term => "excluding", val=>$excluding[$i] };
100 push @field_data, { term => "operator", val=>$operator[$i] };
101 push @field_data, { term => "value", val=>$value[$i] };
106 if ($total>$resultsperpage) {
107 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
110 ($startfrom==($i-1)) && ($highlight=1);
111 push @numbers, { number => $i,
112 highlight => $highlight ,
113 searchdata=> \@field_data,
114 startfrom => ($i-1)};
119 my $from = $startfrom*$resultsperpage+1;
122 if($total < (($startfrom+1)*$resultsperpage)) {
125 $to = (($startfrom+1)*$resultsperpage);
127 $template->param(result => $results) if $results;
128 $template->param(index => $query->param('index')."");
129 $template->param(startfrom=> $startfrom,
130 displaynext=> $displaynext,
131 displayprev=> $displayprev,
132 resultsperpage => $resultsperpage,
133 startfromnext => $startfrom+1,
134 startfromprev => $startfrom-1,
137 searchdata=>\@field_data,
142 authtypecode =>$authtypecode,
143 resultstring =>$value[0],
146 ($template, $loggedinuser, $cookie)
147 = get_template_and_user({template_name => "authorities/auth_finder.tmpl",
150 authnotrequired => 0,
151 flagsrequired => {catalogue => 1},
155 $template->param(index=>$query->param('index')."",
157 resultstring => $resultstring,
161 $template->param(authtypesloop => \@authtypesloop,
162 authtypecode => $authtypecode,
163 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
164 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
165 IntranetNav => C4::Context->preference("IntranetNav"),
169 output_html_with_http_headers $query, $cookie, $template->output;