View | Details | Raw Unified | Return to bug 7751
Collapse All | Expand All

(-)a/C4/Circulation.pm (-21 / +14 lines)
Lines 927-933 sub CanBookBeIssued { Link Here
927
            }
927
            }
928
        }
928
        }
929
    }
929
    }
930
    
930
931
    ## check for high holds decreasing loan period
931
    ## check for high holds decreasing loan period
932
    if (C4::Context->preference("decreaseLoanHighHolds") == 1)
932
    if (C4::Context->preference("decreaseLoanHighHolds") == 1)
933
    {
933
    {
Lines 938-944 sub CanBookBeIssued { Link Here
938
            $needsconfirmation{HIGHHOLDS} = {
938
            $needsconfirmation{HIGHHOLDS} = {
939
                num_holds  => $num,
939
                num_holds  => $num,
940
                duration   => $duration,
940
                duration   => $duration,
941
                returndate => format_date($returndate),
941
                returndate => output_pref($returndate),
942
            };
942
            };
943
        }
943
        }
944
    }
944
    }
Lines 959-996 sub checkHighHolds { Link Here
959
    my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
959
    my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
960
    my $branch = _GetCircControlBranch($item,$borrower);
960
    my $branch = _GetCircControlBranch($item,$borrower);
961
    my $dbh = C4::Context->dbh;
961
    my $dbh = C4::Context->dbh;
962
    my $sth;
962
    my $sth = $dbh->prepare('select count(borrowernumber) as num_holds from reserves where biblionumber=?');
963
    $sth = $dbh->prepare("select count(borrowernumber) as num_holds from reserves where biblionumber=?");
964
    $sth->execute($item->{'biblionumber'});
963
    $sth->execute($item->{'biblionumber'});
965
    my $holds = $sth->fetchrow_array;
964
    my ($holds) = $sth->fetchrow_array;
966
    if ($holds>0)
965
    if ($holds)
967
    {
966
    {
968
        my $issuedate = strftime( "%Y-%m-%d", localtime );
967
        my $issuedate = DateTime->new( time_zone => C4::Context->tz());
969
        my $startdate=C4::Dates->new( $issuedate, 'iso' );
968
        #    my $startdate=C4::Dates->new( $issuedate, 'iso' );
970
        my $calendar = C4::Calendar->new(  branchcode => $branch );
969
        my $calendar = Koha::Calendar->new(  branchcode => $branch );
971
970
972
        my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'};
971
        my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'};
973
        my $due = C4::Circulation::CalcDateDue( C4::Dates->new( $issuedate, 'iso' ), $itype, $branch, $borrower );
972
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
974
        my $normaldue = sprintf("%04d-%02d-%02d",($due->{'dmy_arrayref'}[5]+1900),($due->{'dmy_arrayref'}[4]+1),
975
            $due->{'dmy_arrayref'}[3]);
976
973
977
        my $datedue = $calendar->addDate($startdate, C4::Context->preference("decreaseLoanHighHoldsDuration"));
974
        my $reduced_datedue = $calendar->addDate($issuedate, C4::Context->preference("decreaseLoanHighHoldsDuration"));
978
        my $returndate = sprintf("%04d-%02d-%02d",($datedue->{'dmy_arrayref'}[5]+1900),($datedue->{'dmy_arrayref'}[4]+1),
979
            $datedue->{'dmy_arrayref'}[3]);
980
975
981
        my $daysBetween = $calendar->daysBetween($datedue, $due);
976
        if (DateTime->compare($reduced_datedue,$orig_due) == -1 )
982
        if ($daysBetween>0)
983
        {
977
        {
984
            return (1,$holds,C4::Context->preference("decreaseLoanHighHoldsDuration"),$returndate);
978
            return (1,$holds,C4::Context->preference("decreaseLoanHighHoldsDuration"),$reduced_datedue);
985
        }
979
        }
986
        else
980
        else
987
        {
981
        {
988
            return (0,0,0,0);
982
            return (0,0,0,undef);
989
        }
983
        }
990
    }
984
    }
991
    else
985
    else
992
    {
986
    {
993
        return (0,0,0,0);
987
        return (0,0,0,undef);
994
    }
988
    }
995
}
989
}
996
990
997
- 

Return to bug 7751