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

(-)a/installer/data/mysql/updatedatabase.pl (-9 / +23 lines)
Lines 10655-10661 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
10655
    foreach my $subscription (@subscriptions) {
10655
    foreach my $subscription (@subscriptions) {
10656
        my $number_pattern = $subscription->numberpattern();
10656
        my $number_pattern = $subscription->numberpattern();
10657
10657
10658
        my @splits = split( /\{[XYZ]\}/, $number_pattern->numberingmethod() );
10658
        my $numbering_method = $number_pattern->numberingmethod();
10659
        # Get all the data between the enumeration values, we need
10660
        # to split each enumeration string based on these values.
10661
        my @splits = split( /\{[XYZ]\}/, $numbering_method );
10662
        # Get the order in which the X Y and Z values are used
10663
        my %indexes;
10664
        foreach my $i (qw(X Y Z)) {
10665
            $indexes{$i} = index( $numbering_method, "{$i}" );
10666
            delete $indexes{$i} if $indexes{$i} == -1;
10667
        }
10668
        my @indexes = sort { $indexes{$a} <=> $indexes{$b} } keys(%indexes);
10659
10669
10660
        my @serials =
10670
        my @serials =
10661
          $schema->resultset('Serial')
10671
          $schema->resultset('Serial')
Lines 10663-10686 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
10663
10673
10664
        foreach my $serial (@serials) {
10674
        foreach my $serial (@serials) {
10665
            my $serialseq = $serial->serialseq();
10675
            my $serialseq = $serial->serialseq();
10666
            my ( $x, $y, $z );
10676
            my %enumeration_data;
10667
10677
10668
            ## We cannot split on multiple values at once,
10678
            ## We cannot split on multiple values at once,
10669
            ## so let's replace each of those values with __SPLIT__
10679
            ## so let's replace each of those values with __SPLIT__
10670
            if (@splits) {
10680
            if (@splits) {
10671
                map( $serialseq =~ s/$_/__SPLIT__/, @splits );
10681
                map( $serialseq =~ s/$_/__SPLIT__/, @splits );
10672
                ( undef, $x, $y, $z ) = split( /__SPLIT__/, $serialseq );
10682
                (
10683
                    undef,
10684
                    $enumeration_data{ $indexes[0] },
10685
                    $enumeration_data{ $indexes[1] },
10686
                    $enumeration_data{ $indexes[2] }
10687
                ) = split( /__SPLIT__/, $serialseq );
10673
            }
10688
            }
10674
            else
10689
            else
10675
            {    ## Nothing to split on means the only thing in serialseq is {X}
10690
            {    ## Nothing to split on means the only thing in serialseq is a single placeholder e.g. {X} 
10676
                $x = $serialseq;
10691
                $enumeration_data{ $indexes[0] } = $serialseq;
10677
            }
10692
            }
10678
10693
10679
            $serial->update(
10694
            $serial->update(
10680
                {
10695
                {
10681
                    serialseq_x => $x,
10696
                    serialseq_x => $enumeration_data{'X'},
10682
                    serialseq_y => $y,
10697
                    serialseq_y => $enumeration_data{'Y'},
10683
                    serialseq_z => $z,
10698
                    serialseq_z => $enumeration_data{'Z'},
10684
                }
10699
                }
10685
            );
10700
            );
10686
        }
10701
        }
10687
- 

Return to bug 12375