summaryrefslogtreecommitdiff
path: root/FS/FS/pkg_category.pm
diff options
context:
space:
mode:
authorjeff <jeff>2009-10-05 00:49:34 +0000
committerjeff <jeff>2009-10-05 00:49:34 +0000
commit947c1f964f1304242f8a6ffabacccf040f1d505e (patch)
treeba3e3a042f40ac4b1b660e944973a2f1b29f80fa /FS/FS/pkg_category.pm
parent161eeea92a87e07d071a6c953f2dbd30daeb480c (diff)
leading summary page invoices #RT5086
Diffstat (limited to 'FS/FS/pkg_category.pm')
-rw-r--r--FS/FS/pkg_category.pm35
1 files changed, 33 insertions, 2 deletions
diff --git a/FS/FS/pkg_category.pm b/FS/FS/pkg_category.pm
index 69578c9..0beaf1c 100644
--- a/FS/FS/pkg_category.pm
+++ b/FS/FS/pkg_category.pm
@@ -1,11 +1,13 @@
package FS::pkg_category;
use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch );
+use vars qw( @ISA $me $DEBUG );
+use FS::Record qw( qsearch dbh );
use FS::part_pkg;
@ISA = qw( FS::Record );
+$DEBUG = 0;
+$me = '[FS::pkg_category]';
=head1 NAME
@@ -95,10 +97,39 @@ sub check {
$self->ut_numbern('categorynum')
or $self->ut_text('categoryname')
+ or $self->ut_snumber('weight')
or $self->SUPER::check;
}
+# _ upgrade_data
+#
+# Used by FS::Upgrade to migrate to a new database.
+#
+#
+
+sub _upgrade_data {
+ my ($class, %opts) = @_;
+ my $dbh = dbh;
+
+ warn "$me upgrading $class\n" if $DEBUG;
+
+ my @pkg_category =
+ qsearch('pkg_category', { weight => { op => '!=', value => '' } } );
+
+ unless( scalar(@pkg_category) ) {
+ my @pkg_category = qsearch('pkg_category', {} );
+ my $weight = 0;
+ foreach ( sort { $a->description cmp $b->description } @pkg_category ) {
+ $_->weight($weight);
+ my $error = $_->replace;
+ die "error setting pkg_category weight: $error\n" if $error;
+ $weight += 10;
+ }
+ }
+ '';
+}
+
=back
=head1 BUGS