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

(-)a/installer/data/mysql/updatedatabase.pl (-15 / +22 lines)
Lines 11469-11481 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
11469
        ADD serialseq_z VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y
11469
        ADD serialseq_z VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y
11470
   ");
11470
   ");
11471
11471
11472
    my $schema        = Koha::Database->new()->schema();
11472
    my $sth = $dbh->prepare("SELECT * FROM subscription");
11473
    my @subscriptions = $schema->resultset('Subscription')->all();
11473
    $sth->execute();
11474
11475
    my $sth2 = $dbh->prepare("SELECT * FROM subscription_numberpatterns WHERE id = ?");
11476
11477
    my $sth3 = $dbh->prepare("UPDATE serials SET serialseq_x = ?, serialseq_y = ?, serialseq_z = ? WHERE serialid = ?");
11474
11478
11475
    foreach my $subscription (@subscriptions) {
11479
    foreach my $subscription ( $sth->fetchrow_hashref() ) {
11476
        my $number_pattern = $subscription->numberpattern();
11480
        my $number_pattern = $subscription->numberpattern();
11481
        $sth2->execute( $subscription->{numberpattern} );
11482
        my $number_pattern = $sth2->fetchrow_hashref();
11477
11483
11478
        my $numbering_method = $number_pattern->numberingmethod();
11484
        my $numbering_method = $number_pattern->{numberingmethod};
11479
        # Get all the data between the enumeration values, we need
11485
        # Get all the data between the enumeration values, we need
11480
        # to split each enumeration string based on these values.
11486
        # to split each enumeration string based on these values.
11481
        my @splits = split( /\{[XYZ]\}/, $numbering_method );
11487
        my @splits = split( /\{[XYZ]\}/, $numbering_method );
Lines 11487-11498 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
11487
        }
11493
        }
11488
        my @indexes = sort { $indexes{$a} <=> $indexes{$b} } keys(%indexes);
11494
        my @indexes = sort { $indexes{$a} <=> $indexes{$b} } keys(%indexes);
11489
11495
11490
        my @serials =
11496
        my @serials = @{
11491
          $schema->resultset('Serial')
11497
            $dbh->selectall_arrayref(
11492
          ->search( { subscriptionid => $subscription->subscriptionid() } );
11498
                "SELECT * FROM serial WHERE subscriptionid = $subscription->{subscriptionid}",
11499
                { Slice => {} }
11500
            )
11501
        };
11493
11502
11494
        foreach my $serial (@serials) {
11503
        foreach my $serial (@serials) {
11495
            my $serialseq = $serial->serialseq();
11504
            my $serialseq = $serial->{serialseq};
11496
            my %enumeration_data;
11505
            my %enumeration_data;
11497
11506
11498
            ## We cannot split on multiple values at once,
11507
            ## We cannot split on multiple values at once,
Lines 11514-11525 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
11514
                $enumeration_data{ $indexes[0] } = $serialseq;
11523
                $enumeration_data{ $indexes[0] } = $serialseq;
11515
            }
11524
            }
11516
11525
11517
            $serial->update(
11526
            $sth3->execute(
11518
                {
11527
                    $enumeration_data{'X'},
11519
                    serialseq_x => $enumeration_data{'X'},
11528
                    $enumeration_data{'Y'},
11520
                    serialseq_y => $enumeration_data{'Y'},
11529
                    $enumeration_data{'Z'},
11521
                    serialseq_z => $enumeration_data{'Z'},
11530
                    $serial->{serialid},
11522
                }
11523
            );
11531
            );
11524
        }
11532
        }
11525
    }
11533
    }
11526
- 

Return to bug 17292