|
Lines 2-7
package C4::Circulation;
Link Here
|
| 2 |
|
2 |
|
| 3 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
| 4 |
# copyright 2010 BibLibre |
4 |
# copyright 2010 BibLibre |
|
|
5 |
# Copyright 2011 Catalyst IT |
| 5 |
# |
6 |
# |
| 6 |
# This file is part of Koha. |
7 |
# This file is part of Koha. |
| 7 |
# |
8 |
# |
|
Lines 569-576
sub itemissues {
Link Here
|
| 569 |
|
570 |
|
| 570 |
=head2 CanBookBeIssued |
571 |
=head2 CanBookBeIssued |
| 571 |
|
572 |
|
| 572 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, |
573 |
( $issuingimpossible, $needsconfirmation, $itemnumber ) = |
| 573 |
$barcode, $duedatespec, $inprocess ); |
574 |
CanBookBeIssued( $borrower, $barcode, $duedatespec, $inprocess, $itemnumber ); |
| 574 |
|
575 |
|
| 575 |
Check if a book can be issued. |
576 |
Check if a book can be issued. |
| 576 |
|
577 |
|
|
Lines 586-591
C<$issuingimpossible> and C<$needsconfirmation> are some hashref.
Link Here
|
| 586 |
|
587 |
|
| 587 |
=item C<$inprocess> |
588 |
=item C<$inprocess> |
| 588 |
|
589 |
|
|
|
590 |
=item C<$itemnumber> is used to look up the record by item number if the barcode |
| 591 |
doesn't match, based on the C<CircFallbackItemnumber> syspref. If C<$itemnumber> |
| 592 |
is unset, then C<$barcode> will be tried as an item number instead. |
| 593 |
|
| 589 |
=back |
594 |
=back |
| 590 |
|
595 |
|
| 591 |
Returns : |
596 |
Returns : |
|
Lines 658-680
sticky due date is invalid or due date in the past
Link Here
|
| 658 |
|
663 |
|
| 659 |
if the borrower borrows to much things |
664 |
if the borrower borrows to much things |
| 660 |
|
665 |
|
|
|
666 |
C<$itemnumber> if the itemnumber was found. |
| 667 |
|
| 661 |
=cut |
668 |
=cut |
| 662 |
|
669 |
|
| 663 |
sub CanBookBeIssued { |
670 |
sub CanBookBeIssued { |
| 664 |
my ( $borrower, $barcode, $duedate, $inprocess ) = @_; |
671 |
my ( $borrower, $barcode, $duedate, $inprocess, $itemnumber ) = @_; |
| 665 |
my %needsconfirmation; # filled with problems that needs confirmations |
672 |
my %needsconfirmation; # filled with problems that needs confirmations |
| 666 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
673 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
| 667 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
674 |
my $item = GetItem( GetItemnumberFromBarcode($barcode) ); |
| 668 |
my $issue = GetItemIssue($item->{itemnumber}); |
675 |
# If we should fall back to searching by item number... |
| 669 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
676 |
my $fallback_itemnumber = C4::Context->preference('CircFallbackItemnumber'); |
| 670 |
$item->{'itemtype'}=$item->{'itype'}; |
677 |
if ( !defined( $item->{biblioitemnumber} ) |
| 671 |
my $dbh = C4::Context->dbh; |
678 |
&& $fallback_itemnumber) |
| 672 |
|
679 |
{ |
|
|
680 |
$item = GetItem( $itemnumber // $barcode ); |
| 681 |
} |
| 673 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
682 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
| 674 |
unless ( $item->{barcode} ) { |
683 |
unless ( defined($item->{biblioitemnumber}) ) { |
| 675 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
684 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
| 676 |
} |
685 |
} |
| 677 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
686 |
return ( \%issuingimpossible, \%needsconfirmation, undef ) |
|
|
687 |
if %issuingimpossible; |
| 688 |
|
| 689 |
my $issue = GetItemIssue( $item->{itemnumber} ); |
| 690 |
my $biblioitem = GetBiblioItemData( $item->{biblioitemnumber} ); |
| 691 |
$item->{'itemtype'} = $item->{'itype'}; |
| 692 |
my $dbh = C4::Context->dbh; |
| 678 |
|
693 |
|
| 679 |
# |
694 |
# |
| 680 |
# DUE DATE is OK ? -- should already have checked. |
695 |
# DUE DATE is OK ? -- should already have checked. |
|
Lines 699-709
sub CanBookBeIssued {
Link Here
|
| 699 |
# |
714 |
# |
| 700 |
# BORROWER STATUS |
715 |
# BORROWER STATUS |
| 701 |
# |
716 |
# |
| 702 |
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { |
717 |
if ( $borrower->{'category_type'} eq 'X' |
| 703 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
718 |
&& ( defined( $item->{itemnumber} ) ) ) |
| 704 |
&UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'}); |
719 |
{ |
|
|
720 |
|
| 721 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
| 722 |
&UpdateStats( C4::Context->userenv->{'branch'}, |
| 723 |
'localuse', '', '', $item->{'itemnumber'}, $item->{'itemtype'}, |
| 724 |
$borrower->{'borrowernumber'} ); |
| 705 |
ModDateLastSeen( $item->{'itemnumber'} ); |
725 |
ModDateLastSeen( $item->{'itemnumber'} ); |
| 706 |
return( { STATS => 1 }, {}); |
726 |
return ( { STATS => 1 }, {}, $item->{itemnumber} ); |
| 707 |
} |
727 |
} |
| 708 |
if ( $borrower->{flags}->{GNA} ) { |
728 |
if ( $borrower->{flags}->{GNA} ) { |
| 709 |
$issuingimpossible{GNA} = 1; |
729 |
$issuingimpossible{GNA} = 1; |
|
Lines 720-726
sub CanBookBeIssued {
Link Here
|
| 720 |
my @expirydate= split /-/,$borrower->{'dateexpiry'}; |
740 |
my @expirydate= split /-/,$borrower->{'dateexpiry'}; |
| 721 |
if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 || |
741 |
if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 || |
| 722 |
Date_to_Days(Today) > Date_to_Days( @expirydate )) { |
742 |
Date_to_Days(Today) > Date_to_Days( @expirydate )) { |
| 723 |
$issuingimpossible{EXPIRED} = 1; |
743 |
$issuingimpossible{EXPIRED} = 1; |
| 724 |
} |
744 |
} |
| 725 |
} |
745 |
} |
| 726 |
# |
746 |
# |
|
Lines 898-909
sub CanBookBeIssued {
Link Here
|
| 898 |
$needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'}); |
918 |
$needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'}); |
| 899 |
} |
919 |
} |
| 900 |
} |
920 |
} |
| 901 |
return ( \%issuingimpossible, \%needsconfirmation ); |
921 |
return ( \%issuingimpossible, \%needsconfirmation, $item->{itemnumber} ); |
| 902 |
} |
922 |
} |
| 903 |
|
923 |
|
| 904 |
=head2 AddIssue |
924 |
=head2 AddIssue |
| 905 |
|
925 |
|
| 906 |
&AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate]) |
926 |
&AddIssue($borrower, $itemnumber, [$datedue], [$cancelreserve], [$issuedate]) |
| 907 |
|
927 |
|
| 908 |
Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this sub, it means the user confirmed if needed. |
928 |
Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this sub, it means the user confirmed if needed. |
| 909 |
|
929 |
|
|
Lines 911-917
Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this
Link Here
|
| 911 |
|
931 |
|
| 912 |
=item C<$borrower> is a hash with borrower informations (from GetMember or GetMemberDetails). |
932 |
=item C<$borrower> is a hash with borrower informations (from GetMember or GetMemberDetails). |
| 913 |
|
933 |
|
| 914 |
=item C<$barcode> is the barcode of the item being issued. |
934 |
=item C<$itemnumber> is the itemnumber of the item being issued. |
| 915 |
|
935 |
|
| 916 |
=item C<$datedue> is a C4::Dates object for the max date of return, i.e. the date due (optional). |
936 |
=item C<$datedue> is a C4::Dates object for the max date of return, i.e. the date due (optional). |
| 917 |
Calculated if empty. |
937 |
Calculated if empty. |
|
Lines 923-929
Defaults to today. Unlike C<$datedue>, NOT a C4::Dates object, unfortunately.
Link Here
|
| 923 |
|
943 |
|
| 924 |
AddIssue does the following things : |
944 |
AddIssue does the following things : |
| 925 |
|
945 |
|
| 926 |
- step 01: check that there is a borrowernumber & a barcode provided |
946 |
- step 01: check that there is a borrowernumber & an itemnumber provided |
| 927 |
- check for RENEWAL (book issued & being issued to the same patron) |
947 |
- check for RENEWAL (book issued & being issued to the same patron) |
| 928 |
- renewal YES = Calculate Charge & renew |
948 |
- renewal YES = Calculate Charge & renew |
| 929 |
- renewal NO = |
949 |
- renewal NO = |
|
Lines 940-965
AddIssue does the following things :
Link Here
|
| 940 |
=cut |
960 |
=cut |
| 941 |
|
961 |
|
| 942 |
sub AddIssue { |
962 |
sub AddIssue { |
| 943 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
963 |
my ( $borrower, $itemnumber, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
| 944 |
my $dbh = C4::Context->dbh; |
964 |
my $dbh = C4::Context->dbh; |
| 945 |
my $barcodecheck=CheckValidBarcode($barcode); |
|
|
| 946 |
# $issuedate defaults to today. |
965 |
# $issuedate defaults to today. |
| 947 |
if ( ! defined $issuedate ) { |
966 |
if ( ! defined $issuedate ) { |
| 948 |
$issuedate = strftime( "%Y-%m-%d", localtime ); |
967 |
$issuedate = strftime( "%Y-%m-%d", localtime ); |
| 949 |
# TODO: for hourly circ, this will need to be a C4::Dates object |
968 |
# TODO: for hourly circ, this will need to be a C4::Dates object |
| 950 |
# and all calls to AddIssue including issuedate will need to pass a Dates object. |
969 |
# and all calls to AddIssue including issuedate will need to pass a Dates object. |
| 951 |
} |
970 |
} |
| 952 |
if ($borrower and $barcode and $barcodecheck ne '0'){ |
971 |
if (defined($borrower) and defined($itemnumber)){ |
| 953 |
# find which item we issue |
972 |
# find which item we issue |
| 954 |
my $item = GetItem('', $barcode) or return undef; # if we don't get an Item, abort. |
973 |
my $item = GetItem($itemnumber) or return undef; # if we don't get an Item, abort. |
| 955 |
my $branch = _GetCircControlBranch($item,$borrower); |
974 |
my $branch = _GetCircControlBranch($item,$borrower); |
| 956 |
|
975 |
|
| 957 |
# get actual issuing if there is one |
976 |
# get actual issuing if there is one |
| 958 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
977 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
| 959 |
|
978 |
|
| 960 |
# get biblioinformation for this item |
979 |
# get biblioinformation for this item |
| 961 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
980 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
| 962 |
|
981 |
|
| 963 |
# |
982 |
# |
| 964 |
# check if we just renew the issue. |
983 |
# check if we just renew the issue. |
| 965 |
# |
984 |
# |