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

(-)a/installer/data/mysql/atomicupdate/bug_8367.perl (+21 lines)
Line 0 Link Here
1
my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay
2
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; });
3
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; });
4
#        //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait
5
#        //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules.
6
$dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; });
7
$dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
8
$dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
9
my $sth = $dbh->prepare(q{
10
    UPDATE issuingrules SET holdspickupwait = ?
11
});
12
$sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all!
13
##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay'
14
print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n";
15
$sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; });
16
$sth->execute( );
17
my $dtdur = DateTime::Duration->new( days => 0 );
18
while ( my $res = $sth->fetchrow_hashref ) {
19
     C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB.
20
}
21
print "Upgrade to $DBversion done (8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n";>>>>>>> Bug 8367: Template fixes + fixes to C4/Reserves.pm and Koha/Hold.pm
(-)a/installer/data/mysql/updatedatabase.pl (-29 lines)
Lines 16480-16513 if( CheckVersion( $DBversion ) ) { Link Here
16480
    print "Upgrade to $DBversion done (Bug 21403 - Add Indian Amazon Affiliate option to AmazonLocale setting)\n";
16480
    print "Upgrade to $DBversion done (Bug 21403 - Add Indian Amazon Affiliate option to AmazonLocale setting)\n";
16481
}
16481
}
16482
16482
16483
$DBversion = "18.06.00.XXX";
16484
if ( CheckVersion($DBversion) ) {
16485
    my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay
16486
    $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; });
16487
    $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; });
16488
    #        //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait
16489
    #        //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules.
16490
    $dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; });
16491
    $dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
16492
    $dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
16493
    my $sth = $dbh->prepare(q{
16494
        UPDATE issuingrules SET holdspickupwait = ?
16495
    });
16496
    $sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all!
16497
16498
    ##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay'
16499
    print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n";
16500
    $sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; });
16501
    $sth->execute( );
16502
    my $dtdur = DateTime::Duration->new( days => 0 );
16503
16504
    while ( my $res = $sth->fetchrow_hashref ) {
16505
         C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB.
16506
    }
16507
    print "Upgrade to $DBversion done (8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n";
16508
    SetVersion($DBversion);
16509
}
16510
16511
# SEE bug 13068
16483
# SEE bug 13068
16512
# if there is anything in the atomicupdate, read and execute it.
16484
# if there is anything in the atomicupdate, read and execute it.
16513
16485
16514
- 

Return to bug 8367