Lines 913-919
sub CanBookBeIssued {
Link Here
|
913 |
} |
913 |
} |
914 |
} |
914 |
} |
915 |
} |
915 |
} |
916 |
|
916 |
|
917 |
## check for high holds decreasing loan period |
917 |
## check for high holds decreasing loan period |
918 |
if (C4::Context->preference("decreaseLoanHighHolds") == 1) |
918 |
if (C4::Context->preference("decreaseLoanHighHolds") == 1) |
919 |
{ |
919 |
{ |
Lines 924-930
sub CanBookBeIssued {
Link Here
|
924 |
$needsconfirmation{HIGHHOLDS} = 1; |
924 |
$needsconfirmation{HIGHHOLDS} = 1; |
925 |
$needsconfirmation{'num_holds'} = $num; |
925 |
$needsconfirmation{'num_holds'} = $num; |
926 |
$needsconfirmation{'duration'} = $duration; |
926 |
$needsconfirmation{'duration'} = $duration; |
927 |
$needsconfirmation{'returndate'} = format_date($returndate); |
927 |
$needsconfirmation{'returndate'} = output_pref($returndate); |
928 |
} |
928 |
} |
929 |
} |
929 |
} |
930 |
|
930 |
|
Lines 944-981
sub checkHighHolds {
Link Here
|
944 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
944 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
945 |
my $branch = _GetCircControlBranch($item,$borrower); |
945 |
my $branch = _GetCircControlBranch($item,$borrower); |
946 |
my $dbh = C4::Context->dbh; |
946 |
my $dbh = C4::Context->dbh; |
947 |
my $sth; |
947 |
my $sth = $dbh->prepare('select count(borrowernumber) as num_holds from reserves where biblionumber=?'); |
948 |
$sth = $dbh->prepare("select count(borrowernumber) as num_holds from reserves where biblionumber=?"); |
|
|
949 |
$sth->execute($item->{'biblionumber'}); |
948 |
$sth->execute($item->{'biblionumber'}); |
950 |
my $holds = $sth->fetchrow_array; |
949 |
my ($holds) = $sth->fetchrow_array; |
951 |
if ($holds>0) |
950 |
if ($holds) |
952 |
{ |
951 |
{ |
953 |
my $issuedate = strftime( "%Y-%m-%d", localtime ); |
952 |
my $issuedate = DateTime->new( time_zone => C4::Context->tz()); |
954 |
my $startdate=C4::Dates->new( $issuedate, 'iso' ); |
953 |
# my $startdate=C4::Dates->new( $issuedate, 'iso' ); |
955 |
my $calendar = C4::Calendar->new( branchcode => $branch ); |
954 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
956 |
|
955 |
|
957 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
956 |
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 ); |
957 |
my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $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 |
|
958 |
|
962 |
my $datedue = $calendar->addDate($startdate, C4::Context->preference("decreaseLoanHighHoldsDuration")); |
959 |
my $reduced_datedue = $calendar->addDate($issuedate, 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 |
|
960 |
|
966 |
my $daysBetween = $calendar->daysBetween($datedue, $due); |
961 |
if (DateTime->compare($reduced_datedue,$orig_due) == -1 ) |
967 |
if ($daysBetween>0) |
|
|
968 |
{ |
962 |
{ |
969 |
return (1,$holds,C4::Context->preference("decreaseLoanHighHoldsDuration"),$returndate); |
963 |
return (1,$holds,C4::Context->preference("decreaseLoanHighHoldsDuration"),$reduced_datedue); |
970 |
} |
964 |
} |
971 |
else |
965 |
else |
972 |
{ |
966 |
{ |
973 |
return (0,0,0,0); |
967 |
return (0,0,0,undef); |
974 |
} |
968 |
} |
975 |
} |
969 |
} |
976 |
else |
970 |
else |
977 |
{ |
971 |
{ |
978 |
return (0,0,0,0); |
972 |
return (0,0,0,undef); |
979 |
} |
973 |
} |
980 |
} |
974 |
} |
981 |
|
975 |
|
982 |
- |
|
|