|
Lines 1-21
Link Here
|
| 1 |
my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay |
1 |
$DBversion = 'XXX'; #Replaced by RM |
| 2 |
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; }); |
2 |
if( CheckVersion( $DBversion ) ) { |
| 3 |
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; }); |
3 |
my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay |
| 4 |
# //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait |
4 |
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; }); |
| 5 |
# //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules. |
5 |
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; }); |
| 6 |
$dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; }); |
6 |
# //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait |
| 7 |
$dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); |
7 |
# //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules. |
| 8 |
$dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); |
8 |
unless( column_exists( 'issuingrules', 'holdspickupwait' ) ) { |
| 9 |
my $sth = $dbh->prepare(q{ |
9 |
$dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; }); |
| 10 |
UPDATE issuingrules SET holdspickupwait = ? |
10 |
} |
| 11 |
}); |
11 |
unless( column_exists( 'reserves', 'lastpickupdate' ) ) { |
| 12 |
$sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all! |
12 |
$dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); |
| 13 |
##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay' |
13 |
} |
| 14 |
print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n"; |
14 |
unless( column_exists( 'old_reserves', 'lastpickupdate' ) ) { |
| 15 |
$sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; }); |
15 |
$dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); |
| 16 |
$sth->execute( ); |
16 |
} |
| 17 |
my $dtdur = DateTime::Duration->new( days => 0 ); |
17 |
|
| 18 |
while ( my $res = $sth->fetchrow_hashref ) { |
18 |
my $sth = $dbh->prepare(q{ |
| 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. |
19 |
UPDATE issuingrules SET holdspickupwait = ? |
|
|
20 |
}); |
| 21 |
$sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all! |
| 22 |
##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay' |
| 23 |
print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n"; |
| 24 |
$sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; }); |
| 25 |
$sth->execute( ); |
| 26 |
my $dtdur = DateTime::Duration->new( days => 0 ); |
| 27 |
while ( my $res = $sth->fetchrow_hashref ) { |
| 28 |
C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB. |
| 29 |
} |
| 30 |
print "Upgrade to $DBversion done (Bug 8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n"; |
| 20 |
} |
31 |
} |
| 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 |
|
|
| 22 |
- |