Lines 927-935
sub CanBookBeIssued {
Link Here
|
927 |
} |
927 |
} |
928 |
} |
928 |
} |
929 |
} |
929 |
} |
|
|
930 |
|
931 |
## check for high holds decreasing loan period |
932 |
if (C4::Context->preference("decreaseLoanHighHolds") == 1) |
933 |
{ |
934 |
my ($reserved,$num,$duration,$returndate)=checkHighHolds($item,$borrower); |
935 |
#print "reserved: $reserved\n".Dumper($num); |
936 |
if ($num>=C4::Context->preference("decreaseLoanHighHoldsValue")) |
937 |
{ |
938 |
$needsconfirmation{HIGHHOLDS} = 1; |
939 |
$needsconfirmation{'num_holds'} = $num; |
940 |
$needsconfirmation{'duration'} = $duration; |
941 |
$needsconfirmation{'returndate'} = format_date($returndate); |
942 |
} |
943 |
} |
944 |
|
930 |
return ( \%issuingimpossible, \%needsconfirmation ); |
945 |
return ( \%issuingimpossible, \%needsconfirmation ); |
931 |
} |
946 |
} |
932 |
|
947 |
|
|
|
948 |
=head2 CheckHighHolds |
949 |
|
950 |
used when syspref decreaseLoanHighHolds is active. Returns 1 or 0 to define whether the minimum value held in |
951 |
decreaseLoanHighHoldsValue is exceeded, the total number of outstanding holds, the number of days the loan |
952 |
has been decreased to (held in syspref decreaseLoanHighHoldsValue), and the new due date |
953 |
|
954 |
=cut |
955 |
|
956 |
sub checkHighHolds { |
957 |
my ($item,$borrower) = @_; |
958 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
959 |
my $branch = _GetCircControlBranch($item,$borrower); |
960 |
my $dbh = C4::Context->dbh; |
961 |
my $sth; |
962 |
$sth = $dbh->prepare("select count(borrowernumber) as num_holds from reserves where biblionumber=?"); |
963 |
$sth->execute($item->{'biblionumber'}); |
964 |
my $holds = $sth->fetchrow_array; |
965 |
if ($holds>0) |
966 |
{ |
967 |
my $issuedate = strftime( "%Y-%m-%d", localtime ); |
968 |
my $startdate=C4::Dates->new( $issuedate, 'iso' ); |
969 |
my $calendar = C4::Calendar->new( branchcode => $branch ); |
970 |
|
971 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
972 |
my $due = C4::Circulation::CalcDateDue( C4::Dates->new( $issuedate, 'iso' ), $itype, $branch, $borrower ); |
973 |
my $normaldue = sprintf("%04d-%02d-%02d",($due->{'dmy_arrayref'}[5]+1900),($due->{'dmy_arrayref'}[4]+1), |
974 |
$due->{'dmy_arrayref'}[3]); |
975 |
|
976 |
my $datedue = $calendar->addDate($startdate, C4::Context->preference("decreaseLoanHighHoldsDuration")); |
977 |
my $returndate = sprintf("%04d-%02d-%02d",($datedue->{'dmy_arrayref'}[5]+1900),($datedue->{'dmy_arrayref'}[4]+1), |
978 |
$datedue->{'dmy_arrayref'}[3]); |
979 |
|
980 |
my $daysBetween = $calendar->daysBetween($datedue, $due); |
981 |
if ($daysBetween>0) |
982 |
{ |
983 |
return (1,$holds,C4::Context->preference("decreaseLoanHighHoldsDuration"),$returndate); |
984 |
} |
985 |
else |
986 |
{ |
987 |
return (0,0,0,0); |
988 |
} |
989 |
} |
990 |
else |
991 |
{ |
992 |
return (0,0,0,0); |
993 |
} |
994 |
} |
995 |
|
933 |
=head2 AddIssue |
996 |
=head2 AddIssue |
934 |
|
997 |
|
935 |
&AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate]) |
998 |
&AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate]) |