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

(-)a/installer/data/mysql/updatedatabase.pl (-1 / +56 lines)
Lines 5369-5374 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5369
    SetVersion($DBversion);
5369
    SetVersion($DBversion);
5370
}
5370
}
5371
5371
5372
$DBversion ="3.09.00.XXX";
5373
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5374
    my $pref = C4::Context->preference('dateformat');
5375
    my ( $date_format, $date_regex );
5376
5377
    if ( $pref =~ /^iso/ ) {
5378
        $date_format = '____-__-__';
5379
    }
5380
    elsif ( $pref =~ /^metric/ ) {
5381
        $date_format = '__/__/____';
5382
    }
5383
    elsif ( $pref =~ /^us/ ) {
5384
        $date_format = '__/__/____';
5385
    }
5386
    else {
5387
        $date_format = '____-__-__';
5388
    }
5389
5390
    my $sql = "SELECT * FROM accountlines WHERE description LIKE '%$date_format%' AND description NOT LIKE '%$date_format __:__%' AND ( accounttype = 'FU' OR accounttype = 'F' )";
5391
    my $sth = $dbh->prepare( $sql );
5392
    $sth->execute();
5393
5394
    while ( my $row = $sth->fetchrow_hashref() ) {
5395
        my $old_description = $row->{'description'};
5396
        
5397
        my ( $year, $month, $day );
5398
        my $date;
5399
5400
        if ( $pref =~ /^iso/ ) {
5401
            ( $year, $month, $day ) = $old_description =~ /(\d+)-(\d+)-(\d+)/;
5402
            $date = "$year-$month-$day";
5403
        }
5404
        elsif ( $pref =~ /^metric/ ) {
5405
            ( $day, $month, $year ) = $old_description =~ /(\d+)\/(\d+)\/(\d+)/;
5406
            $date = "$day/$month/$year";
5407
        }
5408
        elsif ( $pref =~ /^us/ ) {
5409
            ( $month, $day, $year ) = $old_description =~ /(\d+)\/(\d+)\/(\d+)/;
5410
            $date = "$month/$day/$year";
5411
        }
5412
        else { ## default to iso
5413
            ( $year, $month, $day ) = $old_description =~ /(\d+)-(\d+)-(\d+)/;
5414
            $date = "$year-$month-$day";
5415
        }
5416
5417
        my $datetime = "$date 23:59";
5418
5419
        my $new_description = $old_description; 
5420
        $new_description =~ s/$date/$datetime/g;
5421
        
5422
        $dbh->do("UPDATE accountlines SET description = ? WHERE description = ?", undef, $new_description, $old_description);
5423
    }
5424
    
5425
    print "Upgrade to $DBversion done (Fix fine descriptions)\n";
5426
    SetVersion($DBversion);
5427
}
5372
5428
5373
=head1 FUNCTIONS
5429
=head1 FUNCTIONS
5374
5430
5375
- 

Return to bug 8253