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 |
warn Dumper($item); |
669 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
676 |
# If we should fall back to searching by item number... |
670 |
$item->{'itemtype'}=$item->{'itype'}; |
677 |
my $fallback_itemnumber = C4::Context->preference('CircFallbackItemnumber'); |
671 |
my $dbh = C4::Context->dbh; |
678 |
warn "Fallback is set to: $fallback_itemnumber"; |
672 |
|
679 |
if ( !defined( $item->{biblioitemnumber} ) |
|
|
680 |
&& $fallback_itemnumber) |
681 |
{ |
682 |
warn "Falling back to itemnumber $itemnumber // $barcode"; |
683 |
$item = GetItem( $itemnumber // $barcode ); |
684 |
} |
673 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
685 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
674 |
unless ( $item->{barcode} ) { |
686 |
unless ( defined($item->{biblioitemnumber}) ) { |
|
|
687 |
warn "Oh no, nothing found."; |
675 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
688 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
676 |
} |
689 |
} |
677 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
690 |
return ( \%issuingimpossible, \%needsconfirmation, undef ) |
|
|
691 |
if %issuingimpossible; |
692 |
|
693 |
my $issue = GetItemIssue( $item->{itemnumber} ); |
694 |
my $biblioitem = GetBiblioItemData( $item->{biblioitemnumber} ); |
695 |
$item->{'itemtype'} = $item->{'itype'}; |
696 |
my $dbh = C4::Context->dbh; |
678 |
|
697 |
|
679 |
# |
698 |
# |
680 |
# DUE DATE is OK ? -- should already have checked. |
699 |
# DUE DATE is OK ? -- should already have checked. |
Lines 699-709
sub CanBookBeIssued {
Link Here
|
699 |
# |
718 |
# |
700 |
# BORROWER STATUS |
719 |
# BORROWER STATUS |
701 |
# |
720 |
# |
702 |
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { |
721 |
if ( $borrower->{'category_type'} eq 'X' |
703 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
722 |
&& ( defined( $item->{itemnumber} ) ) ) |
704 |
&UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'}); |
723 |
{ |
|
|
724 |
|
725 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
726 |
&UpdateStats( C4::Context->userenv->{'branch'}, |
727 |
'localuse', '', '', $item->{'itemnumber'}, $item->{'itemtype'}, |
728 |
$borrower->{'borrowernumber'} ); |
705 |
ModDateLastSeen( $item->{'itemnumber'} ); |
729 |
ModDateLastSeen( $item->{'itemnumber'} ); |
706 |
return( { STATS => 1 }, {}); |
730 |
return ( { STATS => 1 }, {}, $item->{itemnumber} ); |
707 |
} |
731 |
} |
708 |
if ( $borrower->{flags}->{GNA} ) { |
732 |
if ( $borrower->{flags}->{GNA} ) { |
709 |
$issuingimpossible{GNA} = 1; |
733 |
$issuingimpossible{GNA} = 1; |
Lines 720-726
sub CanBookBeIssued {
Link Here
|
720 |
my @expirydate= split /-/,$borrower->{'dateexpiry'}; |
744 |
my @expirydate= split /-/,$borrower->{'dateexpiry'}; |
721 |
if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 || |
745 |
if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 || |
722 |
Date_to_Days(Today) > Date_to_Days( @expirydate )) { |
746 |
Date_to_Days(Today) > Date_to_Days( @expirydate )) { |
723 |
$issuingimpossible{EXPIRED} = 1; |
747 |
$issuingimpossible{EXPIRED} = 1; |
724 |
} |
748 |
} |
725 |
} |
749 |
} |
726 |
# |
750 |
# |
Lines 898-909
sub CanBookBeIssued {
Link Here
|
898 |
$needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'}); |
922 |
$needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'}); |
899 |
} |
923 |
} |
900 |
} |
924 |
} |
901 |
return ( \%issuingimpossible, \%needsconfirmation ); |
925 |
return ( \%issuingimpossible, \%needsconfirmation, $item->{itemnumber} ); |
902 |
} |
926 |
} |
903 |
|
927 |
|
904 |
=head2 AddIssue |
928 |
=head2 AddIssue |
905 |
|
929 |
|
906 |
&AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate]) |
930 |
&AddIssue($borrower, $itemnumber, [$datedue], [$cancelreserve], [$issuedate]) |
907 |
|
931 |
|
908 |
Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this sub, it means the user confirmed if needed. |
932 |
Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this sub, it means the user confirmed if needed. |
909 |
|
933 |
|
Lines 911-917
Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this
Link Here
|
911 |
|
935 |
|
912 |
=item C<$borrower> is a hash with borrower informations (from GetMember or GetMemberDetails). |
936 |
=item C<$borrower> is a hash with borrower informations (from GetMember or GetMemberDetails). |
913 |
|
937 |
|
914 |
=item C<$barcode> is the barcode of the item being issued. |
938 |
=item C<$itemnumber> is the itemnumber of the item being issued. |
915 |
|
939 |
|
916 |
=item C<$datedue> is a C4::Dates object for the max date of return, i.e. the date due (optional). |
940 |
=item C<$datedue> is a C4::Dates object for the max date of return, i.e. the date due (optional). |
917 |
Calculated if empty. |
941 |
Calculated if empty. |
Lines 923-929
Defaults to today. Unlike C<$datedue>, NOT a C4::Dates object, unfortunately.
Link Here
|
923 |
|
947 |
|
924 |
AddIssue does the following things : |
948 |
AddIssue does the following things : |
925 |
|
949 |
|
926 |
- step 01: check that there is a borrowernumber & a barcode provided |
950 |
- step 01: check that there is a borrowernumber & an itemnumber provided |
927 |
- check for RENEWAL (book issued & being issued to the same patron) |
951 |
- check for RENEWAL (book issued & being issued to the same patron) |
928 |
- renewal YES = Calculate Charge & renew |
952 |
- renewal YES = Calculate Charge & renew |
929 |
- renewal NO = |
953 |
- renewal NO = |
Lines 940-965
AddIssue does the following things :
Link Here
|
940 |
=cut |
964 |
=cut |
941 |
|
965 |
|
942 |
sub AddIssue { |
966 |
sub AddIssue { |
943 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
967 |
my ( $borrower, $itemnumber, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
944 |
my $dbh = C4::Context->dbh; |
968 |
my $dbh = C4::Context->dbh; |
945 |
my $barcodecheck=CheckValidBarcode($barcode); |
|
|
946 |
# $issuedate defaults to today. |
969 |
# $issuedate defaults to today. |
947 |
if ( ! defined $issuedate ) { |
970 |
if ( ! defined $issuedate ) { |
948 |
$issuedate = strftime( "%Y-%m-%d", localtime ); |
971 |
$issuedate = strftime( "%Y-%m-%d", localtime ); |
949 |
# TODO: for hourly circ, this will need to be a C4::Dates object |
972 |
# 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. |
973 |
# and all calls to AddIssue including issuedate will need to pass a Dates object. |
951 |
} |
974 |
} |
952 |
if ($borrower and $barcode and $barcodecheck ne '0'){ |
975 |
if (defined($borrower) and defined($itemnumber)){ |
953 |
# find which item we issue |
976 |
# find which item we issue |
954 |
my $item = GetItem('', $barcode) or return undef; # if we don't get an Item, abort. |
977 |
my $item = GetItem($itemnumber) or return undef; # if we don't get an Item, abort. |
955 |
my $branch = _GetCircControlBranch($item,$borrower); |
978 |
my $branch = _GetCircControlBranch($item,$borrower); |
956 |
|
979 |
|
957 |
# get actual issuing if there is one |
980 |
# get actual issuing if there is one |
958 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
981 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
959 |
|
982 |
|
960 |
# get biblioinformation for this item |
983 |
# get biblioinformation for this item |
961 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
984 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
962 |
|
985 |
|
963 |
# |
986 |
# |
964 |
# check if we just renew the issue. |
987 |
# check if we just renew the issue. |
965 |
# |
988 |
# |