190 lines
5.7 KiB
Perl
Executable file
190 lines
5.7 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# Copyright 2000-2002 Katipo Communications
|
|
#
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along with
|
|
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
|
# Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
use strict;
|
|
use CGI;
|
|
|
|
use C4::Auth;
|
|
use C4::Biblio;
|
|
use C4::Search;
|
|
use C4::Output;
|
|
use C4::Interface::CGI::Output;
|
|
use C4::Breeding;
|
|
use C4::Koha;
|
|
|
|
my $input = new CGI;
|
|
my $isbn = $input->param('isbn');
|
|
my $title = $input->param('title');
|
|
my $offset = $input->param('offset');
|
|
my $num = $input->param('num');
|
|
my $showoffset = $offset + 1;
|
|
my $total;
|
|
my $count;
|
|
my @results;
|
|
my $facets;
|
|
my %search;
|
|
my $toggle;
|
|
my $marc_p = C4::Context->boolean_preference("marc");
|
|
my $SQLorZEBRA=C4::Context->preference("SQLorZEBRA");
|
|
if ( !$isbn && !$title ) {
|
|
print $input->redirect('addbooks.pl');
|
|
}
|
|
else {
|
|
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|
{
|
|
template_name => "cataloguing/isbnsearch.tmpl",
|
|
query => $input,
|
|
type => "intranet",
|
|
authnotrequired => 0,
|
|
flagsrequired => { editcatalogue => 1 },
|
|
debug => 1,
|
|
}
|
|
);
|
|
|
|
# fill with books in ACTIVE DB (biblio)
|
|
if ( !$offset ) {
|
|
$offset = 0;
|
|
$showoffset = 1;
|
|
}
|
|
if ( !$num ) { $num = 10 }
|
|
my @kohafield;
|
|
my @value;
|
|
my @relation;
|
|
my @and_or;
|
|
my $order="title,1";
|
|
if ($isbn){
|
|
$search{'isbn'}=$isbn;
|
|
push @kohafield, "isbn";
|
|
push @value,$isbn;
|
|
}else{
|
|
$search{'title'}=$title;
|
|
push @kohafield, "title";
|
|
push @value,$title;
|
|
push @relation, "\@attr 5=1 \@attr 6=3 \@attr 4=1 \@attr 3=1 ";
|
|
}
|
|
$search{avoidquerylog}=1;
|
|
if ($SQLorZEBRA eq "sql"){
|
|
($count, @results) =cataloguing_search(\%search,$num,$offset);
|
|
}else{
|
|
($count,$facets,@results) =ZEBRAsearch_kohafields(\@kohafield,\@value, \@relation,$order, \@and_or, 1,"",$offset, $num,"intranet");
|
|
|
|
}
|
|
my $grandtotal=$count;
|
|
if ( $count < ( $offset + $num ) ) {
|
|
$total = $count;
|
|
}
|
|
else {
|
|
$total = $offset + $num;
|
|
} # else
|
|
|
|
my @loop_data;
|
|
|
|
@loop_data=@results if $count >0;;
|
|
$template->param( startfrom => $offset + 1 );
|
|
( $offset + $num <= $count )
|
|
? ( $template->param( endat => $offset + $num ) )
|
|
: ( $template->param( endat => $count ) );
|
|
$template->param( numrecords => $count );
|
|
my $nextstartfrom = ( $offset + $num < $count ) ? ( $offset + $num ) : (-1);
|
|
my $prevstartfrom = ( $offset - $num >= 0 ) ? ( $offset - $num ) : (-1);
|
|
$template->param( nextstartfrom => $nextstartfrom );
|
|
my $displaynext = 1;
|
|
my $displayprev = 0;
|
|
( $nextstartfrom == -1 ) ? ( $displaynext = 0 ) : ( $displaynext = 1 );
|
|
( $prevstartfrom == -1 ) ? ( $displayprev = 0 ) : ( $displayprev = 1 );
|
|
$template->param( displaynext => $displaynext );
|
|
$template->param( displayprev => $displayprev );
|
|
my @numbers = ();
|
|
my $term;
|
|
my $value;
|
|
|
|
if ($isbn) {
|
|
$term = "isbn";
|
|
$value = $isbn;
|
|
}
|
|
else {
|
|
$term = "title";
|
|
$value = $title;
|
|
}
|
|
if ( $count > 10 ) {
|
|
for ( my $i = 1 ; $i < $count / 10 + 1 ; $i++ ) {
|
|
if ( $i < 16 ) {
|
|
my $highlight = 0;
|
|
( $offset == ( $i - 1 ) * 10 ) && ( $highlight = 1 );
|
|
push @numbers,
|
|
{
|
|
number => $i,
|
|
highlight => $highlight,
|
|
term => $term,
|
|
value => $value,
|
|
startfrom => ( $i - 1 ) * 10
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
# fill with books in breeding farm
|
|
( $count, @results ) = BreedingSearch( $title, $isbn );
|
|
my @breeding_loop = ();
|
|
for ( my $i = 0 ; $i <= $#results ; $i++ ) {
|
|
my %row_data;
|
|
if ( $i % 2 ) {
|
|
$toggle = "#ffffcc";
|
|
}
|
|
else {
|
|
$toggle = "white";
|
|
}
|
|
$row_data{toggle} = $toggle;
|
|
$row_data{id} = $results[$i]->{'id'};
|
|
$row_data{isbn} = $results[$i]->{'isbn'};
|
|
$row_data{file} = $results[$i]->{'file'};
|
|
$row_data{title} = $results[$i]->{'title'};
|
|
$row_data{author} = $results[$i]->{'author'};
|
|
$row_data{classification} = $results[$i]->{'classification'};
|
|
$row_data{subclass} = $results[$i]->{'subclass'};
|
|
push ( @breeding_loop, \%row_data );
|
|
}
|
|
# get framework list
|
|
my $frameworks = getframeworks;
|
|
my @frameworkcodeloop;
|
|
foreach my $thisframeworkcode (keys %$frameworks) {
|
|
my %row =(value => $thisframeworkcode,
|
|
frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
|
|
);
|
|
push @frameworkcodeloop, \%row;
|
|
}
|
|
|
|
|
|
$template->param(
|
|
isbn => $isbn,
|
|
title => $title,
|
|
showoffset => $showoffset,
|
|
total => $total,
|
|
grandtotal => $grandtotal,
|
|
offset => $offset,
|
|
results_loop => \@loop_data,
|
|
breeding_loop => \@breeding_loop,
|
|
numbers => \@numbers,
|
|
term => $term,
|
|
value => $value,
|
|
frameworkcodeloop => \@frameworkcodeloop
|
|
);
|
|
|
|
output_html_with_http_headers $input, $cookie, $template->output;
|
|
} # else
|