|
Lines 5392-5397
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
Link Here
|
| 5392 |
SetVersion ($DBversion); |
5392 |
SetVersion ($DBversion); |
| 5393 |
} |
5393 |
} |
| 5394 |
|
5394 |
|
|
|
5395 |
$DBversion ="3.09.00.XXX"; |
| 5396 |
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { |
| 5397 |
my $query = " |
| 5398 |
SELECT * FROM accountlines |
| 5399 |
WHERE ( accounttype = 'FU' OR accounttype = 'F' ) |
| 5400 |
AND description like '%23:59%' |
| 5401 |
ORDER BY borrowernumber, itemnumber, accountno, description |
| 5402 |
"; |
| 5403 |
my $sth = $dbh->prepare( $query ); |
| 5404 |
$sth->execute(); |
| 5405 |
my $results = $sth->fetchall_arrayref({}); |
| 5406 |
|
| 5407 |
$query = "SELECT * FROM accountlines WHERE description LIKE ? AND description NOT LIKE ?"; |
| 5408 |
$sth = $dbh->prepare( $query ); |
| 5409 |
|
| 5410 |
my @fines; |
| 5411 |
foreach my $keeper ( @$results ) { |
| 5412 |
#warn "WORKING ON KEEPER: " . Data::Dumper::Dumper( $keeper ); |
| 5413 |
my ( $description_to_match ) = split( / 23:59/, $keeper->{'description'} ); |
| 5414 |
$description_to_match .= '%'; |
| 5415 |
#warn "DESCRIPTION TO MATCH: " . $description_to_match; |
| 5416 |
|
| 5417 |
$sth->execute( $description_to_match, $keeper->{'description'} ); |
| 5418 |
|
| 5419 |
my $has_changed = 0; |
| 5420 |
|
| 5421 |
while ( my $f = $sth->fetchrow_hashref() ) { |
| 5422 |
#warn "DELETING: " . Data::Dumper::Dumper( $f ); |
| 5423 |
|
| 5424 |
if ( $f->{'amountoutstanding'} < $keeper->{'amountoutstanding'} ) { |
| 5425 |
$keeper->{'amountoutstanding'} = $f->{'amountoutstanding'}; |
| 5426 |
$has_changed = 1; |
| 5427 |
} |
| 5428 |
|
| 5429 |
my $sql = "DELETE FROM accountlines WHERE borrowernumber = ? AND accountno = ? AND itemnumber = ? AND date = ? AND description = ? LIMIT 1"; |
| 5430 |
$dbh->do($sql,undef,$f->{'borrowernumber'},$f->{'accountno'},$f->{'itemnumber'}, $f->{'date'}, $f->{'description'}); |
| 5431 |
} |
| 5432 |
|
| 5433 |
if ( $has_changed ) { |
| 5434 |
my $sql = "UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? AND accountno = ? AND itemnumber = ? AND date = ? AND description = ? LIMIT 1"; |
| 5435 |
$dbh->do($sql,undef,$keeper->{'amountoutstanding'},$keeper->{'borrowernumber'},$keeper->{'accountno'},$keeper->{'itemnumber'}, $keeper->{'date'}, $keeper->{'description'}); |
| 5436 |
} |
| 5437 |
} |
| 5438 |
|
| 5439 |
print "Upgrade to $DBversion done (Remove duplicate fines))\n"; |
| 5440 |
SetVersion($DBversion); |
| 5441 |
} |
| 5442 |
|
| 5395 |
=head1 FUNCTIONS |
5443 |
=head1 FUNCTIONS |
| 5396 |
|
5444 |
|
| 5397 |
=head2 TableExists($table) |
5445 |
=head2 TableExists($table) |
| 5398 |
- |
|
|