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 $booksellerid=$input->param('booksellerid');
65 my $basket=$input->param('basket');
66 my $sub=$input->param('sub');
68 my ($count,@booksellers)=bookseller($booksellerid);
69 my ($template, $loggedinuser, $cookie)
70 = get_template_and_user({template_name => "acqui/newbasket2.tmpl",
74 flagsrequired => {superlibrarian => 1},
78 #my $template = gettemplate("acqui/newbasket2.tmpl");
80 #print startmenu('acquisitions');
83 ($count,@results)=KeywordSearch(undef,'intra',\%search,$num,$offset);
84 } elsif ($search{'front'} ne '') {
85 ($count,@results)=FrontSearch(undef,'intra',\%search,$num,$offset);
87 ($count,@results)=CatSearch(undef,'loose',\%search,$num,$offset);
92 while ( my ($key, $value) = each %search) {
96 $linesearch{key}=$key;
97 $linesearch{value}=$value;
98 push(@loopsearch,\%linesearch);
102 my $offset2=$num+$offset;
103 my $dispnum=$offset+1;
104 if ($offset2>$count) {
110 if ($keyword ne '' && $offset > 0){
111 $count2=$count-$offset;
121 while ($i < $count2){
125 my $result=$results[$i];
126 $result->{'title'}=~ s/\`/\\\'/g;
127 my $title2=$result->{'title'};
128 my $author2=$result->{'author'};
129 $author2=~ s/ /%20/g;
131 $title2=~ s/\#/\&\#x23;/g;
132 $title2=~ s/\"/\"\;/g;
136 my $location_only='';
137 my $word=$result->{'author'};
138 $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
141 $word=~ s/\,/\,%20/g;
143 $lineres{word}=$word;
144 $lineres{type}=$type;
146 my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=C4::Search::itemcount($env,$result->{'biblionumber'},$type);
148 $location .= "On Loan";
150 $location .= " ($nacount)";
153 $lineres{'on-loan-p'}=1;
156 $location .= "Levin";
157 $location_only .= "Levin";
159 $location .= " ($lcount)";
160 $location_only .= " ($lcount)";
166 $location .= "Foxton";
167 $location_only .= "Foxton";
169 $location .= " ($fcount)";
170 $location_only .= " ($fcount)";
176 $location .= "Shannon";
177 $location_only .= "Shannon";
179 $location .= " ($scount)";
180 $location_only .= " ($scount)";
188 $location .= " ($lostcount)";
191 $lineres{'lost-p'}=1;
194 $location .= "Mending";
196 $location .= " ($mending)";
199 $lineres{'mending-p'}=1;
202 $location .= "In Transit";
204 $location .= " ($transit)";
207 $lineres{'in-transit-p'}=1;
216 $lineres{author2}=$author2;
217 $lineres{title2}=$title2;
218 $lineres{copyright}=$result->{'copyrightdate'};
219 $lineres{booksellerid}=$booksellerid;
220 $lineres{basket}=$basket;
222 $lineres{biblionumber}=$result->{biblionumber};
223 $lineres{title}=$result->{title};
224 $lineres{author}=$result->{author};
225 $lineres{toggle}=$toggle;
226 $lineres{itemcount}=$count;
227 $lineres{location}=$location;
228 $lineres{'location-only'}=$location_only;
229 push(@loopresult,\%lineres);
233 $offset=$num+$offset;
234 $template->param( bookselname => $booksellers[0]->{'name'},
235 booksellerid => $booksellerid,
241 offsetover => ($offset < $count ),
248 loopsearch =>\@loopsearch,
249 loopresult =>\@loopresult,
250 'use-location-flags-p' => 1);
252 output_html_with_http_headers $input, $cookie, $template->output;