|
Lines 6983-6988
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
Link Here
|
| 6983 |
SetVersion($DBversion); |
6983 |
SetVersion($DBversion); |
| 6984 |
} |
6984 |
} |
| 6985 |
|
6985 |
|
|
|
6986 |
$DBversion = "3.13.00.XXX"; |
| 6987 |
if (C4::Context->preference("Version") < TransformToNum($DBversion)) { |
| 6988 |
$dbh->do("ALTER TABLE serial ADD published_end_date DATE NULL DEFAULT NULL AFTER publisheddate"); |
| 6989 |
$dbh->do(" |
| 6990 |
ALTER TABLE serial ADD serialseq_x VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq, |
| 6991 |
ADD serialseq_y VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_x, |
| 6992 |
ADD serialseq_z VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y |
| 6993 |
"); |
| 6994 |
$dbh->do(" |
| 6995 |
ALTER TABLE subscription ADD serialseq_x_label VARCHAR( 100 ) NULL DEFAULT NULL AFTER numberingmethod, |
| 6996 |
ADD serialseq_y_label VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_x_label, |
| 6997 |
ADD serialseq_z_label VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y_label |
| 6998 |
"); |
| 6999 |
|
| 7000 |
my $trim = sub { |
| 7001 |
my $string = shift; |
| 7002 |
$string =~ s/^\s+//; |
| 7003 |
$string =~ s/\s+$//; |
| 7004 |
return $string; |
| 7005 |
}; |
| 7006 |
|
| 7007 |
my $dbh = C4::Context->dbh; |
| 7008 |
my $sth = $dbh->prepare("SELECT * FROM subscription ORDER BY numberingmethod ASC"); |
| 7009 |
$sth->execute(); |
| 7010 |
while ( my $subscription = $sth->fetchrow_hashref() ) { |
| 7011 |
## parse out the labels and save them |
| 7012 |
my $nm = $subscription->{'numberingmethod'}; |
| 7013 |
print "NUMBERING METHOD: '$nm'\n"; |
| 7014 |
my @labels = split(/\{[XYZ]\}[, ]?/, $nm); |
| 7015 |
@labels = map( $trim->( $_ ), @labels ); |
| 7016 |
my ( $x_label, $y_label, $z_label ) = @labels; |
| 7017 |
|
| 7018 |
$dbh->do( |
| 7019 |
"UPDATE subscription SET serialseq_x_label = ?, serialseq_y_label = ?, serialseq_z_label = ? WHERE subscriptionid = ?", |
| 7020 |
undef, |
| 7021 |
( $x_label, $y_label, $z_label, $subscription->{'subscriptionid'} ) |
| 7022 |
); |
| 7023 |
|
| 7024 |
## parse of the data and save |
| 7025 |
my @splits = split(/\{[XYZ]\}/, $nm); |
| 7026 |
foreach my $s ( @splits ) { |
| 7027 |
$s = quotemeta( $s ); |
| 7028 |
} |
| 7029 |
|
| 7030 |
my $sth2 = $dbh->prepare("SELECT * FROM serial WHERE subscriptionid = ?"); |
| 7031 |
$sth2->execute( $subscription->{'subscriptionid'} ); |
| 7032 |
while( my $serial = $sth2->fetchrow_hashref() ) { |
| 7033 |
my $serialseq = $serial->{'serialseq'}; |
| 7034 |
my ( $x, $y, $z ); |
| 7035 |
## We cannot split on multiple values at once, |
| 7036 |
## so let's replace each of those values with __SPLIT__ |
| 7037 |
if ( @splits ) { |
| 7038 |
map( $serialseq =~ s/$_/__SPLIT__/ , @splits ); |
| 7039 |
( undef, $x, $y, $z ) = split(/__SPLIT__/, $serialseq); |
| 7040 |
} else { ## Nothing to split on means the only thing in serialseq is {X} |
| 7041 |
$x = $serialseq; |
| 7042 |
} |
| 7043 |
|
| 7044 |
$dbh->do( |
| 7045 |
"UPDATE serial SET serialseq_x = ?, serialseq_y = ?, serialseq_z = ? WHERE serialid = ?", |
| 7046 |
undef, |
| 7047 |
( $x, $y, $z, $serial->{'serialid'} ) |
| 7048 |
); |
| 7049 |
} |
| 7050 |
} |
| 7051 |
|
| 7052 |
print "Upgrade to $DBversion done ( Split serials enumeration data into separate fields )\n"; |
| 7053 |
SetVersion ($DBversion); |
| 7054 |
|
| 7055 |
} |
| 6986 |
|
7056 |
|
| 6987 |
=head1 FUNCTIONS |
7057 |
=head1 FUNCTIONS |
| 6988 |
|
7058 |
|
| 6989 |
- |
|
|