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

(-)a/C4/Reserves.pm (-4 / +20 lines)
Lines 36-41 use C4::Members qw(); Link Here
36
use C4::Letters;
36
use C4::Letters;
37
use C4::Branch qw( GetBranchDetail );
37
use C4::Branch qw( GetBranchDetail );
38
use C4::Dates qw( format_date_in_iso );
38
use C4::Dates qw( format_date_in_iso );
39
use C4::Calendar;
39
40
40
use Koha::DateUtils;
41
use Koha::DateUtils;
41
42
Lines 958-974 sub CancelExpiredReserves { Link Here
958
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
959
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
959
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
960
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
960
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
961
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
962
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
963
964
        my $today = C4::Dates->new();
961
965
962
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
966
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
963
        $sth = $dbh->prepare( $query );
967
        $sth = $dbh->prepare( $query );
964
        $sth->execute( $max_pickup_delay );
968
        $sth->execute( $max_pickup_delay );
965
969
966
        while (my $res = $sth->fetchrow_hashref ) {
970
        while ( my $res = $sth->fetchrow_hashref ) {
967
            if ( $charge ) {
971
            my $do_cancel = 1;
968
                manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
972
            unless ( $cancel_on_holidays ) {
973
                my $calendar = C4::Calendar->new( branchcode => $res->{'branchcode'} );
974
                my $is_holiday = $calendar->isHoliday( split( '/', $today->output('metric') ) );
975
976
                if ( $is_holiday ) {
977
                    $do_cancel = 0;
978
                }
969
            }
979
            }
970
980
971
            CancelReserve({ reserve_id => $res->{'reserve_id'} });
981
            if ( $do_cancel ) {
982
                if ( $charge ) {
983
                    manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
984
                }
985
986
                CancelReserve({ reserve_id => $res->{'reserve_id'} });
987
            }
972
        }
988
        }
973
    }
989
    }
974
990
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 108-113 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
108
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
108
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
109
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
109
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
110
('ExpireReservesMaxPickUpDelayCharge','0',NULL,'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.','free'),
110
('ExpireReservesMaxPickUpDelayCharge','0',NULL,'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.','free'),
111
('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo'),
111
('ExtendedPatronAttributes','0',NULL,'Use extended patron IDs and attributes','YesNo'),
112
('ExtendedPatronAttributes','0',NULL,'Use extended patron IDs and attributes','YesNo'),
112
('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'),
113
('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'),
113
('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'),
114
('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+6 lines)
Lines 7930-7935 if(CheckVersion($DBversion)) { Link Here
7930
    SetVersion($DBversion);
7930
    SetVersion($DBversion);
7931
}
7931
}
7932
7932
7933
$DBversion = "3.15.00.XXX";
7934
if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7935
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo')");
7936
    print "Upgrade to $DBversion done (Add syspref ExpireReservesOnHolidays\n";
7937
    SetVersion ($DBversion);
7938
}
7933
7939
7934
=head1 FUNCTIONS
7940
=head1 FUNCTIONS
7935
7941
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 lines)
Lines 479-484 Circulation: Link Here
479
                  no: "Don't allow"
479
                  no: "Don't allow"
480
            - holds to be suspended from the OPAC.
480
            - holds to be suspended from the OPAC.
481
        -
481
        -
482
            - pref: ExpireReservesOnHolidays
483
              choices:
484
                  yes: Allow
485
                  no: "Don't allow"
486
            - expired holds to be canceled on days the library is closed..
487
        -
482
            - pref: decreaseLoanHighHolds
488
            - pref: decreaseLoanHighHolds
483
              choices:
489
              choices:
484
                  yes: Enable
490
                  yes: Enable
485
- 

Return to bug 8735