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
31 use C4::Interface::CGI::Output;
35 use C4::Koha; # XXX subfield_is_koha_internal_p
37 # Creates a scrolling list with the associated default value.
38 # Using more than one scrolling list in a CGI assigns the same default value to all the
39 # scrolling lists on the page !?!? That's why this function was written.
42 my $type = $query->param('type');
43 my $op = $query->param('op');
44 my $dbh = C4::Context->dbh;
46 my $startfrom = $query->param('startfrom');
47 $startfrom = 0 if ( !defined $startfrom );
48 my ( $template, $loggedinuser, $cookie );
51 if ( $op eq "do_search" ) {
52 my @marclist = $query->param('marclist');
53 my @and_or = $query->param('and_or');
54 my @excluding = $query->param('excluding');
55 my @operator = $query->param('operator');
56 my @value = $query->param('value');
58 $resultsperpage = $query->param('resultsperpage');
59 $resultsperpage = 19 if ( !defined $resultsperpage );
60 my $orderby = $query->param('orderby');
62 # builds tag and subfield arrays
65 foreach my $marc (@marclist) {
67 my ( $tag, $subfield ) =
68 MARCfind_marc_from_kohafield( $dbh, $marc );
70 push @tags, $dbh->quote("$tag$subfield");
73 push @tags, $dbh->quote( substr( $marc, 0, 4 ) );
80 my ( $results, $total ) =
81 catalogsearch( $dbh, \@tags, \@and_or, \@excluding, \@operator, \@value,
82 $startfrom * $resultsperpage,
83 $resultsperpage, $orderby );
85 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
87 template_name => "barcodes/result.tmpl",
91 flagsrequired => { borrowers => 1 },
92 flagsrequired => { catalogue => 1 },
97 # multi page display gestion
99 my $displayprev = $startfrom;
100 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
106 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
107 push @field_data, { term => "marclist", val => $marclist[$i] };
108 push @field_data, { term => "and_or", val => $and_or[$i] };
109 push @field_data, { term => "excluding", val => $excluding[$i] };
110 push @field_data, { term => "operator", val => $operator[$i] };
111 push @field_data, { term => "value", val => $value[$i] };
116 if ( $total > $resultsperpage ) {
117 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
120 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
124 highlight => $highlight,
125 searchdata => \@field_data,
126 startfrom => ( $i - 1 )
132 my $from = $startfrom * $resultsperpage + 1;
135 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
139 $to = ( ( $startfrom + 1 ) * $resultsperpage );
142 # this gets the results of the search (which are bibs)
143 # and then does a lookup on all items that exist for that bib
144 # then pushes the items onto a new array, as we really want the
145 # items attached to the bibs not thew bibs themselves
149 for ( $i = 0 ; $i <= ( $total - 1 ) ; $i++ )
150 { #total-1 coz the array starts at 0
152 #warn Dumper $results->[$i]{'bibid'};
154 my @item_results = &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type );
156 foreach my $item (@item_results) {
159 push @results2, $item;
165 result => \@results2,
166 startfrom => $startfrom,
167 displaynext => $displaynext,
168 displayprev => $displayprev,
169 resultsperpage => $resultsperpage,
170 startfromnext => $startfrom + 1,
171 startfromprev => $startfrom - 1,
172 searchdata => \@field_data,
176 numbers => \@numbers,
180 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
182 template_name => "barcodes/search.tmpl",
185 authnotrequired => 0,
186 flagsrequired => { catalogue => 1 },
192 "Select itemtype,description from itemtypes order by description");
198 while ( my ( $value, $lib ) = $sth->fetchrow_array ) {
199 push @itemtype, $value;
200 $itemtypes{$value} = $lib;
203 my $CGIitemtype = CGI::scrolling_list(
205 -values => \@itemtype,
206 -labels => \%itemtypes,
212 $template->param( CGIitemtype => $CGIitemtype, );
217 intranetcolorstylesheet =>
218 C4::Context->preference("intranetcolorstylesheet"),
219 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
220 IntranetNav => C4::Context->preference("IntranetNav"),
222 output_html_with_http_headers $query, $cookie, $template->output;