2 #origninally script to provide intranet (librarian) advanced search facility
3 #now script to do searching for acquisitions
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
31 use C4::Interface::CGI::Output;
36 #print $input->header;
38 #whether it is called from the opac of the intranet
39 my $type=$input->param('type');
47 #build hash of users input
48 my $title=$input->param('search');
49 $search{'title'}=$title;
50 my $keyword=$input->param('d');
51 $search{'keyword'}=$keyword;
52 my $author=$input->param('author');
53 $search{'author'}=$author;
56 my $offset=$input->param('offset');
60 my $num=$input->param('num');
64 my $id=$input->param('id');
65 my $basket=$input->param('basket');
66 my $sub=$input->param('sub');
72 my ($count,@booksellers)=bookseller($id);
73 my ($template, $loggedinuser, $cookie)
74 = get_template_and_user({template_name => "acqui/newbasket2.tmpl",
78 flagsrequired => {superlibrarian => 1},
82 #my $template = gettemplate("acqui/newbasket2.tmpl");
84 #print startmenu('acquisitions');
86 my $testdonation = ($donation ne 'yes'); #tests if donation = true
88 ($count,@results)=KeywordSearch(undef,'intra',\%search,$num,$offset);
89 } elsif ($search{'front'} ne '') {
90 ($count,@results)=FrontSearch(undef,'intra',\%search,$num,$offset);
92 ($count,@results)=CatSearch(undef,'loose',\%search,$num,$offset);
97 while ( my ($key, $value) = each %search) {
101 $linesearch{key}=$key;
102 $linesearch{value}=$value;
103 push(@loopsearch,\%linesearch);
107 my $offset2=$num+$offset;
108 my $dispnum=$offset+1;
109 if ($offset2>$count) {
115 if ($keyword ne '' && $offset > 0){
116 $count2=$count-$offset;
126 while ($i < $count2){
130 my $result=$results[$i];
131 $result->{'title'}=~ s/\`/\\\'/g;
132 my $title2=$result->{'title'};
133 my $author2=$result->{'author'};
134 $author2=~ s/ /%20/g;
136 $title2=~ s/\#/\&\#x23;/g;
137 $title2=~ s/\"/\"\;/g;
141 my $location_only='';
142 my $word=$result->{'author'};
143 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
146 $word=~ s/\,/\,%20/g;
148 $lineres{word}=$word;
149 $lineres{type}=$type;
151 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=C4::Search::itemcount($env,$result->{'biblionumber'},$type);
153 $location .= "On Loan";
155 $location .= " ($nacount)";
158 $lineres{'on-loan-p'}=1;
161 $location .= "Levin";
162 $location_only .= "Levin";
164 $location .= " ($lcount)";
165 $location_only .= " ($lcount)";
171 $location .= "Foxton";
172 $location_only .= "Foxton";
174 $location .= " ($fcount)";
175 $location_only .= " ($fcount)";
181 $location .= "Shannon";
182 $location_only .= "Shannon";
184 $location .= " ($scount)";
185 $location_only .= " ($scount)";
193 $location .= " ($lostcount)";
196 $lineres{'lost-p'}=1;
199 $location .= "Mending";
201 $location .= " ($mending)";
204 $lineres{'mending-p'}=1;
207 $location .= "In Transit";
209 $location .= " ($transit)";
212 $lineres{'in-transit-p'}=1;
221 $lineres{author2}=$author2;
222 $lineres{title2}=$title2;
223 $lineres{copyright}=$result->{'copyrightdate'};
225 $lineres{basket}=$basket;
227 $lineres{biblionumber}=$result->{biblionumber};
228 $lineres{title}=$result->{title};
229 $lineres{author}=$result->{author};
230 $lineres{toggle}=$toggle;
231 $lineres{itemcount}=$count;
232 $lineres{location}=$location;
233 $lineres{'location-only'}=$location_only;
234 push(@loopresult,\%lineres);
238 $offset=$num+$offset;
239 $template->param( bookselname => $booksellers[0]->{'name'},
243 testdonation => $testdonation,
247 offsetover => ($offset < $count ),
255 loopsearch =>\@loopsearch,
256 loopresult =>\@loopresult,
257 'use-location-flags-p' => 1);
259 output_html_with_http_headers $input, $cookie, $template->output;