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');
53 #build hash of users input
54 my $title=$input->param('search');
55 $search{'title'}=$title;
56 my $keyword=$input->param('d');
57 $search{'keyword'}=$keyword;
58 my $author=$input->param('author');
59 $search{'author'}=$author;
62 my $offset=$input->param('offset');
66 my $num=$input->param('num');
70 my $id=$input->param('id');
71 my $basket=$input->param('basket');
72 my $sub=$input->param('sub');
78 my ($count,@booksellers)=bookseller($id);
79 my ($template, $loggedinuser, $cookie)
80 = get_template_and_user({template_name => "acqui/newbasket2.tmpl",
84 flagsrequired => {superlibrarian => 1},
88 #my $template = gettemplate("acqui/newbasket2.tmpl");
90 #print startmenu('acquisitions');
92 my $testdonation = ($donation ne 'yes'); #tests if donation = true
94 ($count,@results)=KeywordSearch(undef,'intra',\%search,$num,$offset);
95 } elsif ($search{'front'} ne '') {
96 ($count,@results)=FrontSearch(undef,'intra',\%search,$num,$offset);
98 ($count,@results)=CatSearch(undef,'loose',\%search,$num,$offset);
103 while ( my ($key, $value) = each %search) {
107 $linesearch{key}=$key;
108 $linesearch{value}=$value;
109 push(@loopsearch,\%linesearch);
113 my $offset2=$num+$offset;
114 my $dispnum=$offset+1;
115 if ($offset2>$count) {
121 if ($keyword ne '' && $offset > 0){
122 $count2=$count-$offset;
132 while ($i < $count2){
136 my $result=$results[$i];
137 $result->{'title'}=~ s/\`/\\\'/g;
138 my $title2=$result->{'title'};
139 my $author2=$result->{'author'};
140 $author2=~ s/ /%20/g;
142 $title2=~ s/\#/\&\#x23;/g;
143 $title2=~ s/\"/\"\;/g;
147 my $word=$result->{'author'};
148 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
151 $word=~ s/\,/\,%20/g;
153 $lineres{word}=$word;
154 $lineres{type}=$type;
156 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=C4::Search::itemcount($env,$result->{'biblionumber'},$type);
158 $location .= "On Loan";
160 $location .= " ($nacount)";
165 $location .= "Levin";
167 $location .= " ($lcount)";
172 $location .= "Foxton";
174 $location .= " ($fcount)";
179 $location .= "Shannon";
181 $location .= " ($scount)";
188 $location .= " ($lostcount)";
193 $location .= "Mending";
195 $location .= " ($mending)";
200 $location .= "In Transit";
202 $location .= " ($transit)";
213 $lineres{author2}=$author2;
214 $lineres{title2}=$title2;
215 $lineres{copyright}=$result->{'copyrightdate'};
217 $lineres{basket}=$basket;
219 $lineres{biblionumber}=$result->{biblionumber};
220 $lineres{title}=$result->{title};
221 $lineres{author}=$result->{author};
222 $lineres{coltab}=$coltab;
223 $lineres{itemcount}=$count;
224 $lineres{location}=$location;
225 push(@loopresult,\%lineres);
229 $offset=$num+$offset;
230 $template->param( bookselname => $booksellers[0]->{'name'},
234 testdonation => $testdonation,
238 offsetover => ($offset < $count ),
246 loopsearch =>\@loopsearch,
247 loopresult =>\@loopresult);
249 output_html_with_http_headers $input, $cookie, $template->output;