Browse Source

Now use the new hash based results returned from Search.pm

3.0.x
rangi 22 years ago
parent
commit
f1e1110cf9
  1. 107
      acqui/newbasket2.pl
  2. 93
      search.pl

107
acqui/newbasket2.pl

@ -29,9 +29,9 @@ my %search;
#build hash of users input #build hash of users input
my $title=$input->param('search'); my $title=$input->param('search');
$search{'title'}=$title; $search{'title'}=$title;
my $keyword=$input->param('search'); my $keyword=$input->param('d');
$search{'keyword'}=$keyword; $search{'keyword'}=$keyword;
my $author=$input->param('search'); my $author=$input->param('author');
$search{'author'}=$author; $search{'author'}=$author;
my @results; my @results;
@ -45,17 +45,25 @@ if ($num eq ''){
} }
my $id=$input->param('id'); my $id=$input->param('id');
my $basket=$input->param('basket'); my $basket=$input->param('basket');
my $sub=$input->param('sub');
my $donation;
if ($id == 72){
$donation='yes';
}
#print $sub;
my ($count,@booksellers)=bookseller($id); my ($count,@booksellers)=bookseller($id);
print startpage();
print startpage(); print startpage();
print startmenu('acquisitions'); print startmenu('acquisitions');
print mkheadr(1,"Shopping Basket For: $booksellers[0]->{'name'}"); print mkheadr(1,"Shopping Basket For: $booksellers[0]->{'name'}");
if ($donation ne 'yes'){
print "<a href=newbiblio.pl?id=$id&basket=$basket&sub=$sub>";
} else {
print "<a href=newdonation.pl?id=$id&basket=$basket&sub=$sub>";
}
print <<printend print <<printend
<img src=/images/add-biblio.gif width=187 heigth=42 border=0 align=right alt="Add New Biblio"></a>
<a href=newbiblio.pl?id=$id&basket=$basket><img src=/images/add-biblio.gif width=187 heigth=42 border=0 align=right alt="Add New Biblio"></a>
<a href=basket.pl?basket=$basket><img src=/images/view-basket.gif width=187 heigth=42 border=0 align=right alt="View Basket"></a> <a href=basket.pl?basket=$basket><img src=/images/view-basket.gif width=187 heigth=42 border=0 align=right alt="View Basket"></a>
<FORM ACTION="/cgi-bin/koha/acqui/newbasket2.pl"> <FORM ACTION="/cgi-bin/koha/acqui/newbasket2.pl">
@ -71,15 +79,9 @@ print center();
my $count; my $count;
my @results; my @results;
if ($keyword ne ''){
# print "hey";
($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
} elsif ($search{'front'} ne '') {
($count,@results)&FrontSearch(\$blah,'intra',\%search,$num,$offset);
}else {
($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset); ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
# print "hey";
}
print "You searched on "; print "You searched on ";
while ( my ($key, $value) = each %search) { while ( my ($key, $value) = each %search) {
@ -110,81 +112,88 @@ my $i=0;
my $colour=1; my $colour=1;
while ($i < $count2){ while ($i < $count2){
# print $results[$i]."\n"; # print $results[$i]."\n";
my @stuff=split('\t',$results[$i]); # my @stuff=split('\t',$results[$i]);
$stuff[1]=~ s/\`/\\\'/g; my $result=$results[$i];
my $title2=$stuff[1]; $result->{'title'}=~ s/\`/\\\'/g;
my $author2=$stuff[0]; my $title2=$result->{'title'};
my $copyright=$stuff[3]; my $author2=$result->{'author'};
my $copyright=$result->{'copyrightdate'};
$author2=~ s/ /%20/g; $author2=~ s/ /%20/g;
$title2=~ s/ /%20/g; $title2=~ s/ /%20/g;
$title2=~ s/\#/\&\#x23;/g; $title2=~ s/\#/\&\#x23;/g;
$stuff[1]=mklink("/cgi-bin/koha/acqui/newbiblio.pl?title=$title2&author=$author2&copyright=$copyright&id=$id&basket=$basket&biblio=$stuff[2]",$stuff[1]); $title2=~ s/\"/\&quot\;/g;
my $word=$stuff[0]; my $itemcount;
# print $word; my $location='';
if ($donation eq 'yes'){
$result->{'title'}=mklink("/cgi-bin/koha/acqui/newdonation.pl?author=$author2&copyright=$copyright&id=$id&basket=$basket&biblio=$result->{'biblionumber'}&title=$title2",$result->{'title'});
} else {
$result->{'title'}=mklink("/cgi-bin/koha/acqui/newbiblio.pl?sub=$sub&author=$author2&copyright=$copyright&id=$id&basket=$basket&biblio=$result->{'biblionumber'}&title=$title2",$result->{'title'});
}
my $word=$result->{'author'};
$word=~ s/([a-z]) +([a-z])/$1%20$2/ig; $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
$word=~ s/ //g; $word=~ s/ //g;
$word=~ s/ /%20/g; $word=~ s/ /%20/g;
$word=~ s/\,/\,%20/g; $word=~ s/\,/\,%20/g;
$word=~ s/\n//g; $word=~ s/\n//g;
my $url="/cgi-bin/koha/search.pl?author=$word&type=$type"; my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
$stuff[0]=mklink($url,$stuff[0]); $result->{'author'}=mklink($url,$result->{'author'});
my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=itemcount($env,$stuff[2],$type); my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit)=itemcount($env,$result->{'biblionumber'},$type);
$stuff[4]=$count; $itemcount=$count;
if ($nacount > 0){ if ($nacount > 0){
$stuff[5]=$stuff[5]."On Loan"; $location=$location."On Loan";
if ($nacount >1 ){ if ($nacount >1 ){
$stuff[5]=$stuff[5]." ($nacount)"; $location=$location." ($nacount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($lcount > 0){ if ($lcount > 0){
$stuff[5]=$stuff[5]."Levin"; $location=$location."Levin";
if ($lcount >1 ){ if ($lcount >1 ){
$stuff[5]=$stuff[5]." ($lcount)"; $location=$location." ($lcount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($fcount > 0){ if ($fcount > 0){
$stuff[5]=$stuff[5]."Foxton"; $location=$location."Foxton";
if ($fcount >1 ){ if ($fcount >1 ){
$stuff[5]=$stuff[5]." ($fcount)"; $location=$location." ($fcount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($scount > 0){ if ($scount > 0){
$stuff[5]=$stuff[5]."Shannon"; $location=$location."Shannon";
if ($scount >1 ){ if ($scount >1 ){
$stuff[5]=$stuff[5]." ($scount)"; $location=$location." ($scount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($lostcount > 0){ if ($lostcount > 0){
$stuff[5]=$stuff[5]."Lost"; $location=$location."Lost";
if ($lostcount >1 ){ if ($lostcount >1 ){
$stuff[5]=$stuff[5]." ($lostcount)"; $location=$location." ($lostcount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($mending > 0){ if ($mending > 0){
$stuff[5]=$stuff[5]."Mending"; $location=$location."Mending";
if ($mending >1 ){ if ($mending >1 ){
$stuff[5]=$stuff[5]." ($mending)"; $location=$location." ($mending)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($transit > 0){ if ($transit > 0){
$stuff[5]=$stuff[5]."In Transiit"; $location=$location."In Transiit";
if ($transit >1 ){ if ($transit >1 ){
$stuff[5]=$stuff[5]." ($transit)"; $location=$location." ($transit)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($colour == 1){ if ($colour == 1){
print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]); print mktablerow(6,$secondary,$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
$colour=0; $colour=0;
} else{ } else{
print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]); print mktablerow(6,'white',$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
$colour=1; $colour=1;
} }
$i++; $i++;
@ -195,7 +204,7 @@ $offset=$num+$offset;
print mktableft(); print mktableft();
if ($offset < $count){ if ($offset < $count){
my $search="num=$num&offset=$offset&type=$type&id=$id&basket=$basket&search=$keyword"; my $search="num=$num&offset=$offset&type=$type&id=$id&basket=$basket&search=$title&author=$author";
my $stuff=mklink("/cgi-bin/koha/acqui/newbasket2.pl?$search",'Next'); my $stuff=mklink("/cgi-bin/koha/acqui/newbasket2.pl?$search",'Next');
print $stuff; print $stuff;
} }

93
search.pl

@ -149,106 +149,109 @@ my $i=0;
my $colour=1; my $colour=1;
while ($i < $count2){ while ($i < $count2){
# print $results[$i]."\n"; # print $results[$i]."\n";
my @stuff=split('\t',$results[$i]); # my @stuff=split('\t',$results[$i]);
$stuff[1]=~ s/\`/\\\'/g; my $result=$results[$i];
my $title2=$stuff[1]; $result->{'title'}=~ s/\`/\\\'/g;
my $title2=$result->{'title'};
$title2=~ s/ /%20/g; $title2=~ s/ /%20/g;
my $location='';
my $itemcount;
if ($subject eq ''){ if ($subject eq ''){
# print $stuff[0]; $result->{'title'}=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$result->{'biblionumber'}&title=$title2",$result->{'title'});
$stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]); my $word=$result->{'author'};
my $word=$stuff[0];
# print $word;
$word=~ s/([a-z]) +([a-z])/$1%20$2/ig; $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
$word=~ s/ //g; $word=~ s/ //g;
$word=~ s/ /%20/g; $word=~ s/ /%20/g;
$word=~ s/\,/\,%20/g; $word=~ s/\,/\,%20/g;
$word=~ s/\n//g; $word=~ s/\n//g;
my $url="/cgi-bin/koha/search.pl?author=$word&type=$type"; my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
$stuff[7]=$stuff[5]; $result->{'author'}=mklink($url,$result->{'author'});
$stuff[5]=''; my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$result->{'biblionumber'},$type);
$stuff[0]=mklink($url,$stuff[0]); $itemcount=$count;
my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$stuff[2],$type); ####
$stuff[4]=$count; # Fix this chunk below, remove all hardcoded branch references
# need to fix itemcount as well
###
if ($nacount > 0){ if ($nacount > 0){
$stuff[5]=$stuff[5]."On Loan"; $location=$location."On Loan";
if ($nacount >1 ){ if ($nacount >1 ){
$stuff[5]=$stuff[5]." ($nacount)"; $location=$location." ($nacount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($lcount > 0){ if ($lcount > 0){
$stuff[5]=$stuff[5]."Levin"; $location=$location."Levin";
if ($lcount >1 ){ if ($lcount >1 ){
$stuff[5]=$stuff[5]." ($lcount)"; $location=$location." ($lcount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($fcount > 0){ if ($fcount > 0){
$stuff[5]=$stuff[5]."Foxton"; $location=$location."Foxton";
if ($fcount >1 ){ if ($fcount >1 ){
$stuff[5]=$stuff[5]." ($fcount)"; $location=$location." ($fcount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($scount > 0){ if ($scount > 0){
$stuff[5]=$stuff[5]."Shannon"; $location=$location."Shannon";
if ($scount >1 ){ if ($scount >1 ){
$stuff[5]=$stuff[5]." ($scount)"; $location=$location." ($scount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($lostcount > 0){ if ($lostcount > 0){
$stuff[5]=$stuff[5]."Lost"; $location=$location."Lost";
if ($lostcount >1 ){ if ($lostcount >1 ){
$stuff[5]=$stuff[5]." ($lostcount)"; $location=$location." ($lostcount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($mending > 0){ if ($mending > 0){
$stuff[5]=$stuff[5]."Mending"; $location=$location."Mending";
if ($mending >1 ){ if ($mending >1 ){
$stuff[5]=$stuff[5]." ($mending)"; $location=$location." ($mending)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($transit > 0){ if ($transit > 0){
$stuff[5]=$stuff[5]."In Transiit"; $location=$location."In Transiit";
if ($transit >1 ){ if ($transit >1 ){
$stuff[5]=$stuff[5]." ($transit)"; $location=$location." ($transit)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($ocount > 0){ if ($ocount > 0){
$stuff[5]=$stuff[5]."On Order"; $location=$location."On Order";
if ($ocount >1 ){ if ($ocount >1 ){
$stuff[5]=$stuff[5]." ($ocount)"; $location=$location." ($ocount)";
} }
$stuff[5].=" "; $location.=" ";
} }
if ($type ne 'opac'){ # if ($type ne 'opac'){
$stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request"); # $result->{'request'}=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
} # }
} else { } else {
my $word=$stuff[1]; my $word=$result->{'subject'};
$word=~ s/ /%20/g; $word=~ s/ /%20/g;
$stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]); $result->{'title'}=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$result->{'subject'});
} }
if ($colour == 1){ if ($colour == 1){
if ($illustrator) { if ($illustrator) {
print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]); print mktablerow(7,$secondary,$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
} else { } else {
print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]); print mktablerow(6,$secondary,$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
} }
$colour=0; $colour=0;
} else { } else {
if ($illustrator) { if ($illustrator) {
print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]); print mktablerow(7,'white',$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
} else { } else {
print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]); print mktablerow(6,'white',$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
} }
$colour=1; $colour=1;
} }

Loading…
Cancel
Save