Lines 33-39
use C4::Debug;
Link Here
|
33 |
use C4::Items; |
33 |
use C4::Items; |
34 |
use YAML; |
34 |
use YAML; |
35 |
use URI::Escape; |
35 |
use URI::Escape; |
36 |
use POSIX; |
36 |
use Business::ISBN; |
37 |
|
37 |
|
38 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); |
38 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); |
39 |
|
39 |
|
Lines 1424-1430
sub searchResults {
Link Here
|
1424 |
#find branchname |
1424 |
#find branchname |
1425 |
#get branch information..... |
1425 |
#get branch information..... |
1426 |
my %branches; |
1426 |
my %branches; |
1427 |
my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches "); |
1427 |
my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches "); |
1428 |
$bsth->execute(); |
1428 |
$bsth->execute(); |
1429 |
while ( my $bdata = $bsth->fetchrow_hashref ) { |
1429 |
while ( my $bdata = $bsth->fetchrow_hashref ) { |
1430 |
$branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'}; |
1430 |
$branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'}; |
Lines 1687-1692
sub searchResults {
Link Here
|
1687 |
$item_in_transit_count++ if $transfertwhen ne ''; |
1695 |
$item_in_transit_count++ if $transfertwhen ne ''; |
1688 |
$item_onhold_count++ if $reservestatus eq 'Waiting'; |
1696 |
$item_onhold_count++ if $reservestatus eq 'Waiting'; |
1689 |
$item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan}; |
1697 |
$item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan}; |
1690 |
# can place hold on item ? |
1698 |
# can place hold on item ? |
1691 |
if ((!$item->{damaged} || C4::Context->preference('AllowHoldsOnDamagedItems')) |
1699 |
if ((!$item->{damaged} || C4::Context->preference('AllowHoldsOnDamagedItems')) |
1692 |
&& !$item->{itemlost} |
1700 |
&& !$item->{itemlost} |
1693 |
&& !$item->{withdrawn} |
1701 |
&& !$item->{withdrawn} |
1694 |
) { |
1702 |
) { |
1695 |
$can_place_holds = 1; |
1703 |
$can_place_holds = 1; |
1696 |
} |
1704 |
} |
1697 |
|
1705 |
|
1698 |
$other_count++; |
1706 |
$other_count++; |
1699 |
|
1707 |
|
1700 |
my $key = $prefix . $item->{status}; |
1708 |
my $key = $prefix . $item->{status}; |
Lines 2596-2604
$template->param ( MYLOOP => C4::Search::z3950_search_args($searchscalar) )
Link Here
|
2596 |
|
2614 |
|
2597 |
sub z3950_search_args { |
2615 |
sub z3950_search_args { |
2598 |
my $bibrec = shift; |
2616 |
my $bibrec = shift; |
2599 |
|
2617 |
my $isbn = Business::ISBN->new($bibrec); |
2600 |
|
2618 |
|
2601 |
if (validate_isbn($bibrec) == 1) |
2619 |
if (defined $isbn && $isbn->is_valid) |
2602 |
{ |
2620 |
{ |
2603 |
$bibrec = { isbn => $bibrec } if !ref $bibrec; |
2621 |
$bibrec = { isbn => $bibrec } if !ref $bibrec; |
2604 |
} |
2622 |
} |
Lines 2644-2694
OR adds a new authority record
Link Here
|
2644 |
=cut |
2662 |
=cut |
2645 |
|
2663 |
|
2646 |
|
2664 |
|
2647 |
=head |
|
|
2648 |
BOOL validate_isbn($isbn_number) |
2649 |
|
2665 |
|
2650 |
This function validates an isbn number by: |
|
|
2651 |
|
2666 |
|
2652 |
1. Checking it is 10 or 13 characters long |
|
|
2653 |
2. If it is 10 characters long, checks the lasd character is an 'X' and all other characters are digits |
2654 |
3. If it is 13 characters long, checks it begins with '97' and all other characters are digits |
2655 |
|
2656 |
=cut |
2657 |
sub validate_isbn { |
2658 |
my $isbn = shift; |
2659 |
|
2660 |
# Handle ISBNs with spaces or hyphens in them |
2661 |
$isbn =~ s/\s+//g; |
2662 |
$isbn =~ s/\-//g; |
2663 |
|
2664 |
# Is it the correct length ? |
2665 |
if (length($isbn) != 10 && length($isbn) != 13) |
2666 |
{ return 0; } |
2667 |
else { |
2668 |
|
2669 |
# Is the last char 'x' for ISBN10 ? |
2670 |
my @chars = split('', $isbn); |
2671 |
if (length($isbn) == 10 && uc($chars[9]) eq 'X') |
2672 |
{ |
2673 |
# Are all but the last characters digits ? |
2674 |
if (isdigit(substr($isbn,0,length($isbn)-1)) ) |
2675 |
{ return 1;} |
2676 |
} |
2677 |
|
2678 |
# Is it 13 chars long and begin with '97' ? |
2679 |
if ( ($chars[0] eq '9' && $chars[1] eq '7') && length($isbn) == 13) |
2680 |
{ |
2681 |
# is it made up of digits? |
2682 |
if (isdigit($isbn)) |
2683 |
{ return 1;} |
2684 |
|
2685 |
|
2686 |
} |
2687 |
|
2688 |
} |
2689 |
# If this function has not yet successfully returned the return failure |
2690 |
return 0; |
2691 |
} |
2692 |
|
2667 |
|
2693 |
sub BiblioAddAuthorities{ |
2668 |
sub BiblioAddAuthorities{ |
2694 |
my ( $record, $frameworkcode ) = @_; |
2669 |
my ( $record, $frameworkcode ) = @_; |
2695 |
- |
|
|