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