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
32 use C4::Koha; # XXX subfield_is_koha_internal_p
34 # Creates a scrolling list with the associated default value.
35 # Using more than one scrolling list in a CGI assigns the same default value to all the
36 # scrolling lists on the page !?!? That's why this function was written.
39 my $type = $query->param('type');
40 my $op = $query->param('op');
41 my $dbh = C4::Context->dbh;
43 my $startfrom = $query->param('startfrom');
44 $startfrom = 0 if ( !defined $startfrom );
45 my ( $template, $loggedinuser, $cookie );
48 if ( $op eq "do_search" ) {
49 my @marclist = $query->param('marclist');
50 my @and_or = $query->param('and_or');
51 my @excluding = $query->param('excluding');
52 my @operator = $query->param('operator');
53 my @value = $query->param('value');
55 $resultsperpage = $query->param('resultsperpage');
56 $resultsperpage = 19 if ( !defined $resultsperpage );
57 my $orderby = $query->param('orderby');
59 # builds tag and subfield arrays
62 foreach my $marc (@marclist) {
64 my ( $tag, $subfield ) =
65 GetMarcFromKohaField( $marc );
67 push @tags, $dbh->quote("$tag$subfield");
70 push @tags, $dbh->quote( substr( $marc, 0, 4 ) );
77 my ( $results, $total ) =
78 catalogsearch( $dbh, \@tags, \@and_or, \@excluding, \@operator, \@value,
79 $startfrom * $resultsperpage,
80 $resultsperpage, $orderby );
82 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
84 template_name => "barcodes/result.tmpl",
88 flagsrequired => { tools => 1 },
93 # multi page display gestion
95 my $displayprev = $startfrom;
96 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
102 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
103 push @field_data, { term => "marclist", val => $marclist[$i] };
104 push @field_data, { term => "and_or", val => $and_or[$i] };
105 push @field_data, { term => "excluding", val => $excluding[$i] };
106 push @field_data, { term => "operator", val => $operator[$i] };
107 push @field_data, { term => "value", val => $value[$i] };
112 if ( $total > $resultsperpage ) {
113 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
116 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
120 highlight => $highlight,
121 searchdata => \@field_data,
122 startfrom => ( $i - 1 )
128 my $from = $startfrom * $resultsperpage + 1;
131 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
135 $to = ( ( $startfrom + 1 ) * $resultsperpage );
138 # this gets the results of the search (which are bibs)
139 # and then does a lookup on all items that exist for that bib
140 # then pushes the items onto a new array, as we really want the
141 # items attached to the bibs not thew bibs themselves
145 for ( $i = 0 ; $i <= ( $total - 1 ) ; $i++ )
146 { #total-1 coz the array starts at 0
151 &GetItemsInfo( $results->[$i]{'biblionumber'}, $type );
153 foreach my $item (@item_results) {
156 push @results2, $item;
162 result => \@results2,
163 startfrom => $startfrom,
164 displaynext => $displaynext,
165 displayprev => $displayprev,
166 resultsperpage => $resultsperpage,
167 startfromnext => $startfrom + 1,
168 startfromprev => $startfrom - 1,
169 searchdata => \@field_data,
173 numbers => \@numbers,
177 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
179 template_name => "barcodes/search.tmpl",
182 authnotrequired => 0,
183 flagsrequired => { tools => 1 },
189 "Select itemtype,description from itemtypes order by description");
195 while ( my ( $value, $lib ) = $sth->fetchrow_array ) {
196 push @itemtype, $value;
197 $itemtypes{$value} = $lib;
200 my $CGIitemtype = CGI::scrolling_list(
202 -values => \@itemtype,
203 -labels => \%itemtypes,
209 $template->param( CGIitemtype => $CGIitemtype, );
214 intranetcolorstylesheet =>
215 C4::Context->preference("intranetcolorstylesheet"),
216 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
217 IntranetNav => C4::Context->preference("IntranetNav"),
219 output_html_with_http_headers $query, $cookie, $template->output;