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

(-)a/C4/Reserves.pm (-17 / +31 lines)
Lines 860-865 Cancels all reserves with an expiration date from before today. Link Here
860
860
861
sub CancelExpiredReserves {
861
sub CancelExpiredReserves {
862
862
863
    # Cancel reserves that have passed their expiration date.
863
    my $dbh = C4::Context->dbh;
864
    my $dbh = C4::Context->dbh;
864
    my $sth = $dbh->prepare( "
865
    my $sth = $dbh->prepare( "
865
        SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) 
866
        SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) 
Lines 871-876 sub CancelExpiredReserves { Link Here
871
        CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
872
        CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
872
    }
873
    }
873
  
874
  
875
    # Cancel reserves that have been waiting too long
876
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
877
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
878
        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
879
        
880
        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
881
        $sth = $dbh->prepare( $query );
882
        $sth->execute( $max_pickup_delay );
883
        
884
        while (my $res = $sth->fetchrow_hashref ) {
885
            if ( $charge ) {
886
                manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
887
            }
888
            
889
            CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
890
        }
891
    }
892
                            
874
}
893
}
875
894
876
=head2 CancelReserve
895
=head2 CancelReserve
Lines 1137-1149 sub ModReserveStatus { Link Here
1137
1156
1138
    #first : check if we have a reservation for this item .
1157
    #first : check if we have a reservation for this item .
1139
    my ($itemnumber, $newstatus) = @_;
1158
    my ($itemnumber, $newstatus) = @_;
1140
    my $dbh          = C4::Context->dbh;
1159
    my $dbh = C4::Context->dbh;
1141
    my $query = " UPDATE reserves
1160
    
1142
    SET    found=?,waitingdate = now()
1161
    my $query = "UPDATE reserves SET found = ?, waitingdate = NOW() WHERE itemnumber = ? AND found IS NULL AND priority = 0";
1143
    WHERE itemnumber=?
1144
      AND found IS NULL
1145
      AND priority = 0
1146
    ";
1147
    my $sth_set = $dbh->prepare($query);
1162
    my $sth_set = $dbh->prepare($query);
1148
    $sth_set->execute( $newstatus, $itemnumber );
1163
    $sth_set->execute( $newstatus, $itemnumber );
1149
1164
Lines 1196-1210 sub ModReserveAffect { Link Here
1196
    }
1211
    }
1197
    else {
1212
    else {
1198
    # affect the reserve to Waiting as well.
1213
    # affect the reserve to Waiting as well.
1199
    $query = "
1214
        $query = "
1200
        UPDATE reserves
1215
            UPDATE reserves
1201
        SET     priority = 0,
1216
            SET     priority = 0,
1202
                found = 'W',
1217
                    found = 'W',
1203
                waitingdate=now(),
1218
                    waitingdate = NOW(),
1204
                itemnumber = ?
1219
                    itemnumber = ?
1205
        WHERE borrowernumber = ?
1220
            WHERE borrowernumber = ?
1206
          AND biblionumber = ?
1221
              AND biblionumber = ?
1207
    ";
1222
        ";
1208
    }
1223
    }
1209
    $sth = $dbh->prepare($query);
1224
    $sth = $dbh->prepare($query);
1210
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
1225
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
Lines 1907-1913 sub MergeHolds { Link Here
1907
    }
1922
    }
1908
}
1923
}
1909
1924
1910
1911
=head1 AUTHOR
1925
=head1 AUTHOR
1912
1926
1913
Koha Development Team <http://koha-community.org/>
1927
Koha Development Team <http://koha-community.org/>
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 336-338 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
336
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BorrowerRenewalPeriodBase', 'now', 'Set whether the borrower renewal date should be counted from the dateexpiry or from the current date ','dateexpiry|now','Choice');
336
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BorrowerRenewalPeriodBase', 'now', 'Set whether the borrower renewal date should be counted from the dateexpiry or from the current date ','dateexpiry|now','Choice');
337
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('AllowItemsOnHoldCheckout',0,'Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else. This allows self checkouts for those items.','','YesNo');
337
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('AllowItemsOnHoldCheckout',0,'Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else. This allows self checkouts for those items.','','YesNo');
338
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define export options available on OPAC detail page.','','free');
338
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define export options available on OPAC detail page.','','free');
339
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay',  '0',  '',  'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay',  'YesNo');
340
INSERT INTO systempreferences` (variable,value,options,explanation,type) VALUES ('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')
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 4712-4717 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4712
    SetVersion($DBversion);
4712
    SetVersion($DBversion);
4713
}
4713
}
4714
4714
4715
$DBversion = "3.07.00.XXX";
4716
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4717
    $dbh->do("INSERT INTO systempreferences` (variable,value,options,explanation,type) VALUES ('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')");
4718
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo')");
4719
    print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
4720
    SetVersion($DBversion);
4721
}
4722
4715
=head1 FUNCTIONS
4723
=head1 FUNCTIONS
4716
4724
4717
=head2 DropAllForeignKeys($table)
4725
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +10 lines)
Lines 279-284 Circulation: Link Here
279
              class: integer
279
              class: integer
280
            - days.
280
            - days.
281
        -
281
        -
282
            - pref: ExpireReservesMaxPickUpDelay
283
              choices:
284
                  yes: Allow
285
                  no: "Don't allow"
286
            - "holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay"
287
        -
288
            - If using ExpireReservesMaxPickUpDelay, charge a borrower who allows his or her waiting hold to expire a fee of
289
            - pref: ExpireReservesMaxPickUpDelayCharge
290
              class: integer
291
        -
282
            - Satisfy holds from the libraries
292
            - Satisfy holds from the libraries
283
            - pref: StaticHoldsQueueWeight
293
            - pref: StaticHoldsQueueWeight
284
              class: multi
294
              class: multi
285
- 

Return to bug 7408