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

(-)a/C4/Reserves.pm (-16 / +25 lines)
Lines 1137-1149 sub ModReserveStatus { Link Here
1137
1137
1138
    #first : check if we have a reservation for this item .
1138
    #first : check if we have a reservation for this item .
1139
    my ($itemnumber, $newstatus) = @_;
1139
    my ($itemnumber, $newstatus) = @_;
1140
    my $dbh          = C4::Context->dbh;
1140
    my $dbh = C4::Context->dbh;
1141
    my $query = " UPDATE reserves
1141
    
1142
    SET    found=?,waitingdate = now()
1142
    my $expire_sql = '';
1143
    WHERE itemnumber=?
1143
    if ( $newstatus eq 'W' && C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
1144
      AND found IS NULL
1144
        my $days_until_expiration = C4::Context->preference("ReservesMaxPickUpDelay");
1145
      AND priority = 0
1145
        $expire_sql = ", expirationdate = DATE( DATE_ADD( NOW(), INTERVAL $days_until_expiration DAY ) )";
1146
    ";
1146
    }
1147
    
1148
    my $query = "UPDATE reserves SET found = ?, waitingdate = NOW()$expire_sql WHERE itemnumber = ? AND found IS NULL AND priority = 0";
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 = '';
1200
        UPDATE reserves
1202
        if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
1201
        SET     priority = 0,
1203
            my $days_until_expiration = C4::Context->preference("ReservesMaxPickUpDelay");
1202
                found = 'W',
1204
            $expire_sql = ", expirationdate = DATE( DATE_ADD( NOW(), INTERVAL $days_until_expiration DAY ) )";
1203
                waitingdate=now(),
1205
        }
1204
                itemnumber = ?
1206
1205
        WHERE borrowernumber = ?
1207
        $query = "
1206
          AND biblionumber = ?
1208
            UPDATE reserves
1207
    ";
1209
            SET     priority = 0,
1210
                    found = 'W',
1211
                    waitingdate = NOW(),
1212
                    itemnumber = ?
1213
                    $expire_sql
1214
            WHERE borrowernumber = ?
1215
              AND biblionumber = ?
1216
        ";
1208
    }
1217
    }
1209
    $sth = $dbh->prepare($query);
1218
    $sth = $dbh->prepare($query);
1210
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
1219
    $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
(-)a/installer/data/mysql/sysprefs.sql (+1 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');
(-)a/installer/data/mysql/updatedatabase.pl (+7 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 ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo')");
4718
    print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay)\n";
4719
    SetVersion($DBversion);
4720
}
4721
4715
=head1 FUNCTIONS
4722
=head1 FUNCTIONS
4716
4723
4717
=head2 DropAllForeignKeys($table)
4724
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 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
        -
282
            - Satisfy holds from the libraries
288
            - Satisfy holds from the libraries
283
            - pref: StaticHoldsQueueWeight
289
            - pref: StaticHoldsQueueWeight
284
              class: multi
290
              class: multi
285
- 

Return to bug 7408