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

(-)a/C4/Reserves.pm (-16 / +31 lines)
Lines 868-873 sub CancelExpiredReserves { Link Here
868
    $sth->execute();
868
    $sth->execute();
869
869
870
    while ( my $res = $sth->fetchrow_hashref() ) {
870
    while ( my $res = $sth->fetchrow_hashref() ) {
871
        if ( $res->{'found'} eq 'W' && C4::Context->preference("ExpireReservesMaxPickUpDelayCharge") ) {
872
            manualinvoice( $res->{'borrowernumber', undef, "Hold waiting too long Fine", 'F', C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"), undef );
873
        }
874
871
        CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
875
        CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
872
    }
876
    }
873
  
877
  
Lines 1137-1149 sub ModReserveStatus { Link Here
1137
1141
1138
    #first : check if we have a reservation for this item .
1142
    #first : check if we have a reservation for this item .
1139
    my ($itemnumber, $newstatus) = @_;
1143
    my ($itemnumber, $newstatus) = @_;
1140
    my $dbh          = C4::Context->dbh;
1144
    my $dbh = C4::Context->dbh;
1141
    my $query = " UPDATE reserves
1145
    
1142
    SET    found=?,waitingdate = now()
1146
    my $expire_sql = _GetExpireResevesSQL();
1143
    WHERE itemnumber=?
1147
    
1144
      AND found IS NULL
1148
    my $query = "UPDATE reserves SET found = ?, waitingdate = NOW()$expire_sql WHERE itemnumber = ? AND found IS NULL AND priority = 0";
1145
      AND priority = 0
1146
    ";
1147
    my $sth_set = $dbh->prepare($query);
1149
    my $sth_set = $dbh->prepare($query);
1148
    $sth_set->execute( $newstatus, $itemnumber );
1150
    $sth_set->execute( $newstatus, $itemnumber );
1149
1151
Lines 1196-1210 sub ModReserveAffect { Link Here
1196
    }
1198
    }
1197
    else {
1199
    else {
1198
    # affect the reserve to Waiting as well.
1200
    # affect the reserve to Waiting as well.
1199
    $query = "
1201
        my $expire_sql = _GetExpireResevesSQL();
1200
        UPDATE reserves
1202
1201
        SET     priority = 0,
1203
        $query = "
1202
                found = 'W',
1204
            UPDATE reserves
1203
                waitingdate=now(),
1205
            SET     priority = 0,
1204
                itemnumber = ?
1206
                    found = 'W',
1205
        WHERE borrowernumber = ?
1207
                    waitingdate = NOW(),
1206
          AND biblionumber = ?
1208
                    itemnumber = ?
1207
    ";
1209
                    $expire_sql
1210
            WHERE borrowernumber = ?
1211
              AND biblionumber = ?
1212
        ";
1208
    }
1213
    }
1209
    $sth = $dbh->prepare($query);
1214
    $sth = $dbh->prepare($query);
1210
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
1215
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
Lines 1907-1912 sub MergeHolds { Link Here
1907
    }
1912
    }
1908
}
1913
}
1909
1914
1915
sub _GetExpireResevesSQL {
1916
    my $sql = '';
1917
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
1918
        my $days_until_expiration = C4::Context->preference("ReservesMaxPickUpDelay");
1919
        $sql = ", expirationdate = DATE( DATE_ADD( NOW(), INTERVAL $days_until_expiration DAY ) )";
1920
    }
1921
    
1922
    return $sql;
1923
}
1924
1910
1925
1911
=head1 AUTHOR
1926
=head1 AUTHOR
1912
1927
(-)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