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 $word=$result->{'author'};
142 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
145 $word=~ s/\,/\,%20/g;
147 $lineres{word}=$word;
148 $lineres{type}=$type;
150 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=C4::Search::itemcount($env,$result->{'biblionumber'},$type);
152 $location .= "On Loan";
154 $location .= " ($nacount)";
159 $location .= "Levin";
161 $location .= " ($lcount)";
166 $location .= "Foxton";
168 $location .= " ($fcount)";
173 $location .= "Shannon";
175 $location .= " ($scount)";
182 $location .= " ($lostcount)";
187 $location .= "Mending";
189 $location .= " ($mending)";
194 $location .= "In Transit";
196 $location .= " ($transit)";
207 $lineres{author2}=$author2;
208 $lineres{title2}=$title2;
209 $lineres{copyright}=$result->{'copyrightdate'};
211 $lineres{basket}=$basket;
213 $lineres{biblionumber}=$result->{biblionumber};
214 $lineres{title}=$result->{title};
215 $lineres{author}=$result->{author};
216 $lineres{toggle}=$toggle;
217 $lineres{itemcount}=$count;
218 $lineres{location}=$location;
219 push(@loopresult,\%lineres);
223 $offset=$num+$offset;
224 $template->param( bookselname => $booksellers[0]->{'name'},
228 testdonation => $testdonation,
232 offsetover => ($offset < $count ),
240 loopsearch =>\@loopsearch,
241 loopresult =>\@loopresult);
243 output_html_with_http_headers $input, $cookie, $template->output;