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 979-995 sub CancelExpiredReserves { Link Here
979
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
980
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
980
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
981
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
981
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
982
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
983
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
984
985
        my $today = C4::Dates->new();
982
986
983
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
987
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
984
        $sth = $dbh->prepare( $query );
988
        $sth = $dbh->prepare( $query );
985
        $sth->execute( $max_pickup_delay );
989
        $sth->execute( $max_pickup_delay );
986
990
987
        while (my $res = $sth->fetchrow_hashref ) {
991
        while ( my $res = $sth->fetchrow_hashref ) {
988
            if ( $charge ) {
992
            my $do_cancel = 1;
989
                manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
993
            unless ( $cancel_on_holidays ) {
994
                my $calendar = C4::Calendar->new( branchcode => $res->{'branchcode'} );
995
                my $is_holiday = $calendar->isHoliday( split( '/', $today->output('metric') ) );
996
997
                if ( $is_holiday ) {
998
                    $do_cancel = 0;
999
                }
990
            }
1000
            }
991
1001
992
            CancelReserve({ reserve_id => $res->{'reserve_id'} });
1002
            if ( $do_cancel ) {
1003
                if ( $charge ) {
1004
                    manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
1005
                }
1006
1007
                CancelReserve({ reserve_id => $res->{'reserve_id'} });
1008
            }
993
        }
1009
        }
994
    }
1010
    }
995
1011
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 115-120 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
115
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
115
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
116
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
116
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
117
('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'),
117
('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'),
118
('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo'),
118
('ExtendedPatronAttributes','0',NULL,'Use extended patron IDs and attributes','YesNo'),
119
('ExtendedPatronAttributes','0',NULL,'Use extended patron IDs and attributes','YesNo'),
119
('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'),
120
('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'),
120
('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'),
121
('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 8589-8594 if ( CheckVersion($DBversion) ) { Link Here
8589
    SetVersion ($DBversion);
8589
    SetVersion ($DBversion);
8590
}
8590
}
8591
8591
8592
$DBversion = "3.17.00.XXX";
8593
if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8594
    $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')");
8595
    print "Upgrade to $DBversion done (Add syspref ExpireReservesOnHolidays\n";
8596
    SetVersion ($DBversion);
8597
}
8598
8592
=head1 FUNCTIONS
8599
=head1 FUNCTIONS
8593
8600
8594
=head2 TableExists($table)
8601
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 lines)
Lines 492-497 Circulation: Link Here
492
                  no: "Don't allow"
492
                  no: "Don't allow"
493
            - holds to be suspended from the OPAC.
493
            - holds to be suspended from the OPAC.
494
        -
494
        -
495
            - pref: ExpireReservesOnHolidays
496
              choices:
497
                  yes: Allow
498
                  no: "Don't allow"
499
            - expired holds to be canceled on days the library is closed..
500
        -
495
            - pref: decreaseLoanHighHolds
501
            - pref: decreaseLoanHighHolds
496
              choices:
502
              choices:
497
                  yes: Enable
503
                  yes: Enable
498
- 

Return to bug 8735