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 971-987 sub CancelExpiredReserves { Link Here
971
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
972
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
972
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
973
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
973
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
974
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
975
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
976
977
        my $today = C4::Dates->new();
974
978
975
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
979
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
976
        $sth = $dbh->prepare( $query );
980
        $sth = $dbh->prepare( $query );
977
        $sth->execute( $max_pickup_delay );
981
        $sth->execute( $max_pickup_delay );
978
982
979
        while (my $res = $sth->fetchrow_hashref ) {
983
        while ( my $res = $sth->fetchrow_hashref ) {
980
            if ( $charge ) {
984
            my $do_cancel = 1;
981
                manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
985
            unless ( $cancel_on_holidays ) {
986
                my $calendar = C4::Calendar->new( branchcode => $res->{'branchcode'} );
987
                my $is_holiday = $calendar->isHoliday( split( '/', $today->output('metric') ) );
988
989
                if ( $is_holiday ) {
990
                    $do_cancel = 0;
991
                }
982
            }
992
            }
983
993
984
            CancelReserve({ reserve_id => $res->{'reserve_id'} });
994
            if ( $do_cancel ) {
995
                if ( $charge ) {
996
                    manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
997
                }
998
999
                CancelReserve({ reserve_id => $res->{'reserve_id'} });
1000
            }
985
        }
1001
        }
986
    }
1002
    }
987
1003
(-)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 (+7 lines)
Lines 7945-7950 if (CheckVersion($DBversion)) { Link Here
7945
    SetVersion($DBversion);
7945
    SetVersion($DBversion);
7946
}
7946
}
7947
7947
7948
$DBversion = "3.15.00.XXX";
7949
if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7950
    $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')");
7951
    print "Upgrade to $DBversion done (Add syspref ExpireReservesOnHolidays\n";
7952
    SetVersion ($DBversion);
7953
}
7954
7948
=head1 FUNCTIONS
7955
=head1 FUNCTIONS
7949
7956
7950
=head2 TableExists($table)
7957
=head2 TableExists($table)
(-)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