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
27 use C4::Interface::CGI::Output;
28 use C4::AuthoritiesMarc;
29 use C4::Koha; # XXX subfield_is_koha_internal_p
32 my $op = $query->param('op');
33 my $authtypecode = $query->param('authtypecode');
34 my $index = $query->param('index');
35 my $resultstring = $query->param('result');
36 my $dbh = C4::Context->dbh;
38 my $startfrom=$query->param('startfrom');
39 $startfrom=0 if(!defined $startfrom);
40 my ($template, $loggedinuser, $cookie);
43 my $authtypes = getauthtypes;
45 foreach my $thisauthtype (keys %$authtypes) {
46 my $selected = 1 if $thisauthtype eq $authtypecode;
47 my %row =(value => $thisauthtype,
48 selected => $selected,
49 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
52 push @authtypesloop, \%row;
55 if ($op eq "do_search") {
56 my @marclist = $query->param('marclist');
58 my @operator = $query->param('operator');
59 my @value = $query->param('value');
61 $resultsperpage= $query->param('resultsperpage');
62 $resultsperpage = 10 ;
64 my ($results,$total) = authoritysearch($dbh, \@marclist, \@operator, \@value,$startfrom*$resultsperpage, $resultsperpage,$authtypecode);# $orderby);
66 ($template, $loggedinuser, $cookie)
67 = get_template_and_user({template_name => "authorities/searchresultlist-auth.tmpl",
71 flagsrequired => {borrowers => 1},
72 flagsrequired => {catalogue => 1},
76 # multi page display gestion
78 my $displayprev=$startfrom;
79 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
86 my @marclist_ini = $query->param('marclist'); # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name
87 for(my $i = 0 ; $i <= $#marclist ; $i++) {
88 push @field_data, { term => "marclist", val=>$marclist_ini[$i] };
89 push @field_data, { term => "operator", val=>$operator[$i] };
90 push @field_data, { term => "value", val=>$value[$i] };
95 if ($total>$resultsperpage) {
96 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
99 ($startfrom==($i-1)) && ($highlight=1);
100 push @numbers, { number => $i,
101 highlight => $highlight ,
102 searchdata=> \@field_data,
103 startfrom => ($i-1)};
108 my $from = $startfrom*$resultsperpage+1;
111 if($total < (($startfrom+1)*$resultsperpage)) {
114 $to = (($startfrom+1)*$resultsperpage);
116 $template->param(result => $results) if $results;
117 $template->param(index => $query->param('index')."");
118 $template->param(startfrom=> $startfrom,
119 displaynext=> $displaynext,
120 displayprev=> $displayprev,
121 resultsperpage => $resultsperpage,
122 startfromnext => $startfrom+1,
123 startfromprev => $startfrom-1,
125 searchdata=>\@field_data,
130 authtypecode =>$authtypecode,
131 resultstring =>$value[0],
134 ($template, $loggedinuser, $cookie)
135 = get_template_and_user({template_name => "authorities/auth_finder.tmpl",
138 authnotrequired => 0,
139 flagsrequired => {catalogue => 1},
143 $template->param(index=>$query->param('index')."",
144 resultstring => $resultstring,
148 $template->param(authtypesloop => \@authtypesloop,
149 authtypecode => $authtypecode,
153 output_html_with_http_headers $query, $cookie, $template->output;