summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2001-09-06 20:42:00 +0000
committerivan <ivan>2001-09-06 20:42:00 +0000
commit57d69d5c1f98f778a0df82795ce21ee7bd21042a (patch)
tree63f890cf25311b66c712933c84f64e43718039cd
parentdb1b6ebfe35aba1f4d2580b13a0a74ac317784ba (diff)
finally fix part_svc!!!
-rw-r--r--FS/FS.pm11
-rw-r--r--FS/FS/UID.pm4
-rw-r--r--FS/FS/part_svc.pm144
-rw-r--r--FS/FS/svc_Common.pm10
-rw-r--r--FS/FS/svc_acct.pm8
-rw-r--r--FS/FS/svc_acct_sm.pm4
-rw-r--r--FS/FS/svc_domain.pm4
-rw-r--r--FS/FS/svc_forward.pm4
-rw-r--r--FS/FS/svc_www.pm4
-rw-r--r--FS/MANIFEST2
-rw-r--r--FS/t/part_svc_column.t5
-rw-r--r--README.1.4.0pre2-316
-rwxr-xr-xbin/fs-migrate-part_svc40
-rwxr-xr-xbin/fs-migrate-payref7
-rwxr-xr-xbin/fs-radius-add-check4
-rwxr-xr-xbin/fs-radius-add-reply4
-rwxr-xr-xbin/fs-setup67
-rwxr-xr-xhttemplate/browse/part_svc.cgi22
-rw-r--r--httemplate/docs/schema.html11
-rw-r--r--httemplate/docs/upgrade8.html20
-rwxr-xr-xhttemplate/edit/part_svc.cgi37
-rwxr-xr-xhttemplate/edit/process/part_svc.cgi6
22 files changed, 310 insertions, 124 deletions
diff --git a/FS/FS.pm b/FS/FS.pm
index 652e458aa..cd11e96d2 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -46,12 +46,16 @@ L<FS::svc_domain> - Domain class
L<FS::domain_record> - DNS zone entries
-L<FS::svc_acct_sm> - Vitual mail alias class
+L<FS::svc_forward> - Mail forwarding class
+
+L<FS::svc_acct_sm> - (Depreciated) Vitual mail alias class
L<FS::svc_www> - Web virtual host class.
L<FS::part_svc> - Service definition class
+L<FS::part_svc_column> - Column constraint class
+
L<FS::part_pkg> - Package (billing item) definition class
L<FS::pkg_svc> - Class linking package (billing item)
@@ -117,6 +121,9 @@ To quote perl(1), "If you're intending to read these straight through for the
first time, the suggested order will tend to reduce the number of forward
references."
+If you've never used OO modules before,
+http://www.cpan.org/doc/FMTEYEWTK/easy_objects.html might help you out.
+
=head1 DESCRIPTION
Freeside is a billing and administration package for Internet Service
@@ -128,7 +135,7 @@ The main documentation is in htdocs/docs.
=head1 VERSION
-$Id: FS.pm,v 1.6 2001-09-02 04:25:55 ivan Exp $
+$Id: FS.pm,v 1.7 2001-09-06 20:41:59 ivan Exp $
=head1 SUPPORT
diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm
index 3e71f09f1..f80156e97 100644
--- a/FS/FS/UID.pm
+++ b/FS/FS/UID.pm
@@ -118,7 +118,7 @@ Returns the CGI (see L<CGI>) object.
=cut
sub cgi {
- carp "warning: \$FS::UID::cgi isa Apache" if $cgi->isa('Apache');
+ #carp "warning: \$FS::UID::cgi isa Apache" if $cgi->isa('Apache');
$cgi;
}
@@ -249,7 +249,7 @@ coderef into the hash %FS::UID::callback :
=head1 VERSION
-$Id: UID.pm,v 1.8 2001-08-21 09:34:13 ivan Exp $
+$Id: UID.pm,v 1.9 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm
index ccf0413b3..e64f09a70 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -2,7 +2,8 @@ package FS::part_svc;
use strict;
use vars qw( @ISA );
-use FS::Record qw( fields );
+use FS::Record qw( qsearchs fields dbh );
+use FS::part_svc_column;
@ISA = qw(FS::Record);
@@ -14,8 +15,8 @@ FS::part_svc - Object methods for part_svc objects
use FS::part_svc;
- $record = new FS::part_referral \%hash
- $record = new FS::part_referral { 'column' => 'value' };
+ $record = new FS::part_svc \%hash
+ $record = new FS::part_svc { 'column' => 'value' };
$error = $record->insert;
@@ -37,7 +38,7 @@ FS::Record. The following fields are currently supported:
=item svc - text name of this service definition
=item svcdb - table used for this service. See L<FS::svc_acct>,
-L<FS::svc_domain>, and L<FS::svc_acct_sm>, among others.
+L<FS::svc_domain>, and L<FS::svc_forward>, among others.
=item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
@@ -62,6 +63,73 @@ sub table { 'part_svc'; }
Adds this service definition to the database. If there is an error, returns
the error, otherwise returns false.
+=item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
+
+=item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null, `D' for default, or `F' for fixed
+
+=cut
+
+sub insert {
+ my $self = shift;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ my $error = $self->SUPER::insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ my $svcdb = $self->svcdb;
+# my @rows = map { /^${svcdb}__(.*)$/; $1 }
+# grep ! /_flag$/,
+# grep /^${svcdb}__/,
+# fields('part_svc');
+ foreach my $field (
+ grep { $_ ne 'svcnum'
+ && defined( $self->getfield($svcdb.'__'.$_.'_flag') )
+ } fields($svcdb)
+ ) {
+ my $part_svc_column = $self->part_svc_column($field);
+ my $previous = qsearchs('part_svc_column', {
+ 'svcpart' => $self->svcpart,
+ 'columnname' => $field,
+ } );
+
+ my $flag = $self->getfield($svcdb.'__'.$field.'_flag');
+ if ( uc($flag) =~ /^([DF])$/ ) {
+ $part_svc_column->setfield('columnflag', $1);
+ $part_svc_column->setfield('columnvalue',
+ $self->getfield($svcdb.'__'.$field)
+ );
+ if ( $previous ) {
+ $error = $part_svc_column->replace($previous);
+ } else {
+ $error = $part_svc_column->insert;
+ }
+ } else {
+ $error = $part_svc_column->delete;
+ }
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ '';
+}
=item delete
@@ -113,38 +181,58 @@ sub check {
my @fields = eval { fields( $recref->{svcdb} ) }; #might die
return "Unknown svcdb!" unless @fields;
- my $svcdb;
- foreach $svcdb ( qw(
- svc_acct svc_acct_sm svc_domain
- ) ) {
- my @rows = map { /^${svcdb}__(.*)$/; $1 }
- grep ! /_flag$/,
- grep /^${svcdb}__/,
- fields('part_svc');
- foreach my $row (@rows) {
- unless ( $svcdb eq $recref->{svcdb} ) {
- $recref->{$svcdb.'__'.$row}='';
- $recref->{$svcdb.'__'.$row.'_flag'}='';
- next;
- }
- $recref->{$svcdb.'__'.$row.'_flag'} =~ /^([DF]?)$/
- or return "Illegal flag for $svcdb $row";
- $recref->{$svcdb.'__'.$row.'_flag'} = $1;
+# my $svcdb;
+# foreach $svcdb ( qw(
+# svc_acct svc_acct_sm svc_domain
+# ) ) {
+# my @rows = map { /^${svcdb}__(.*)$/; $1 }
+# grep ! /_flag$/,
+# grep /^${svcdb}__/,
+# fields('part_svc');
+# foreach my $row (@rows) {
+# unless ( $svcdb eq $recref->{svcdb} ) {
+# $recref->{$svcdb.'__'.$row}='';
+# $recref->{$svcdb.'__'.$row.'_flag'}='';
+# next;
+# }
+# $recref->{$svcdb.'__'.$row.'_flag'} =~ /^([DF]?)$/
+# or return "Illegal flag for $svcdb $row";
+# $recref->{$svcdb.'__'.$row.'_flag'} = $1;
+#
+# my $error = $self->ut_anything($svcdb.'__'.$row);
+# return $error if $error;
+#
+# }
+# }
+
+ ''; #no error
+}
- my $error = $self->ut_anything($svcdb.'__'.$row);
- return $error if $error;
+=item part_svc_column COLUMNNAME
- }
- }
+Returns the part_svc_column object (see L<FS::part_svc_column>) for the given
+COLUMNNAME, or a new part_svc_column object if none exists.
- ''; #no error
+=cut
+
+sub part_svc_column {
+ my $self = shift;
+ my $columnname = shift;
+ qsearchs('part_svc_column', {
+ 'svcpart' => $self->svcpart,
+ 'columnname' => $columnname,
+ }
+ ) or new FS::part_svc_column {
+ 'svcpart' => $self->svcpart,
+ 'columnname' => $columnname,
+ };
}
=back
=head1 VERSION
-$Id: part_svc.pm,v 1.2 2001-08-11 05:51:24 ivan Exp $
+$Id: part_svc.pm,v 1.3 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
@@ -156,7 +244,7 @@ should be fixed.
=head1 SEE ALSO
L<FS::Record>, L<FS::part_pkg>, L<FS::pkg_svc>, L<FS::cust_svc>,
-L<FS::svc_acct>, L<FS::svc_acct_sm>, L<FS::svc_domain>, schema.html from the
+L<FS::svc_acct>, L<FS::svc_forward>, L<FS::svc_domain>, schema.html from the
base documentation.
=cut
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index bc5b75640..c47cdbf8f 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -164,9 +164,11 @@ sub setx {
return "Unkonwn svcpart" unless $part_svc;
#set default/fixed/whatever fields from part_svc
- foreach my $field ( fields('svc_acct') ) {
- if ( $part_svc->getfield('svc_acct__'. $field. '_flag') eq $x ) {
- $self->setfield( $field, $part_svc->getfield('svc_acct__'. $field) );
+ my $table = $self->table;
+ foreach my $field ( grep { $_ ne 'svcnum' } fields($table) ) {
+ my $part_svc_column = $part_svc->part_svc_column($field);
+ if ( $part_svc_column->columnflag eq $x ) {
+ $self->setfield( $field, $part_svc_column->columnvalue );
}
}
@@ -193,7 +195,7 @@ sub cancel { ''; }
=head1 VERSION
-$Id: svc_Common.pm,v 1.4 2001-04-22 00:49:30 ivan Exp $
+$Id: svc_Common.pm,v 1.5 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 7e27fd859..a4ce3f7c9 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -185,7 +185,7 @@ sub insert {
my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
return "Unknown svcpart" unless $part_svc;
return "uid in use"
- if $part_svc->svc_acct__uid_flag ne 'F'
+ if $part_svc->part_svc_column('uid')->columnflag ne 'F'
&& qsearchs( 'svc_acct', { 'uid' => $self->uid } )
&& $self->username !~ /^(hyla)?fax$/
;
@@ -456,7 +456,7 @@ sub check {
! $recref->{popnum} ||
qsearchs('svc_acct_pop',{'popnum'=> $recref->{popnum} } );
- unless ( $part_svc->getfield('svc_acct__uid_flag') eq 'F' ) {
+ unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
$recref->{uid} =~ /^(\d*)$/ or return "Illegal uid";
$recref->{uid} = $1 eq '' ? $self->unique('uid') : $1;
@@ -506,7 +506,7 @@ sub check {
return "Can't have quota without uid" : ( $recref->{quota}='' );
}
- unless ( $part_svc->getfield('svc_acct__slipip_flag') eq 'F' ) {
+ unless ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) {
unless ( $recref->{slipip} eq '0e0' ) {
$recref->{slipip} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
or return "Illegal slipip". $self->slipip;
@@ -633,7 +633,7 @@ sub email {
=head1 VERSION
-$Id: svc_acct.pm,v 1.29 2001-09-02 04:51:11 ivan Exp $
+$Id: svc_acct.pm,v 1.30 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/svc_acct_sm.pm b/FS/FS/svc_acct_sm.pm
index 7615c211d..c92f1421f 100644
--- a/FS/FS/svc_acct_sm.pm
+++ b/FS/FS/svc_acct_sm.pm
@@ -211,7 +211,7 @@ sub check {
my $x = $self->setfixed;
return $x unless ref($x);
- my $part_svc = $x;
+ #my $part_svc = $x;
my($recref) = $self->hashref;
@@ -238,7 +238,7 @@ sub check {
=head1 VERSION
-$Id: svc_acct_sm.pm,v 1.4 2001-08-20 09:41:52 ivan Exp $
+$Id: svc_acct_sm.pm,v 1.5 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm
index 4d652f8d3..58c6423c3 100644
--- a/FS/FS/svc_domain.pm
+++ b/FS/FS/svc_domain.pm
@@ -338,7 +338,7 @@ sub check {
my $x = $self->setfixed;
return $x unless ref($x);
- my $part_svc = $x;
+ #my $part_svc = $x;
my $error = $self->ut_numbern('svcnum')
|| $self->ut_numbern('catchall')
@@ -533,7 +533,7 @@ sub submit_internic {
=head1 VERSION
-$Id: svc_domain.pm,v 1.19 2001-08-21 00:39:07 ivan Exp $
+$Id: svc_domain.pm,v 1.20 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/svc_forward.pm b/FS/FS/svc_forward.pm
index 288ab3408..6ee1d5b85 100644
--- a/FS/FS/svc_forward.pm
+++ b/FS/FS/svc_forward.pm
@@ -263,7 +263,7 @@ sub check {
my $x = $self->setfixed;
return $x unless ref($x);
- my $part_svc = $x;
+ #my $part_svc = $x;
my $error = $self->ut_numbern('svcnum')
|| $self->ut_number('srcsvc')
@@ -299,7 +299,7 @@ sub check {
=head1 VERSION
-$Id: svc_forward.pm,v 1.6 2001-08-21 00:39:07 ivan Exp $
+$Id: svc_forward.pm,v 1.7 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/svc_www.pm b/FS/FS/svc_www.pm
index 44d7487da..d4e398810 100644
--- a/FS/FS/svc_www.pm
+++ b/FS/FS/svc_www.pm
@@ -198,7 +198,7 @@ sub check {
my $x = $self->setfixed;
return $x unless ref($x);
- my $part_svc = $x;
+ #my $part_svc = $x;
my $error =
$self->ut_numbern('svcnum')
@@ -220,7 +220,7 @@ sub check {
=head1 VERSION
-$Id: svc_www.pm,v 1.5 2001-08-21 02:44:47 ivan Exp $
+$Id: svc_www.pm,v 1.6 2001-09-06 20:41:59 ivan Exp $
=head1 BUGS
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 209c93a10..2db053d44 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -34,6 +34,7 @@ FS/cust_svc.pm
FS/part_pkg.pm
FS/part_referral.pm
FS/part_svc.pm
+FS/part_svc_column.pm
FS/pkg_svc.pm
FS/svc_Common.pm
FS/svc_acct.pm
@@ -73,6 +74,7 @@ t/nas.t
t/part_pkg.t
t/part_referral.t
t/part_svc.t
+t/part_svc_column.t
t/pkg_svc.t
t/port.t
t/prepay_credit.t
diff --git a/FS/t/part_svc_column.t b/FS/t/part_svc_column.t
new file mode 100644
index 000000000..467025c1e
--- /dev/null
+++ b/FS/t/part_svc_column.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::part_svc_column;
+$loaded=1;
+print "ok 1\n";
diff --git a/README.1.4.0pre2-3 b/README.1.4.0pre2-3
new file mode 100644
index 000000000..23b838e3b
--- /dev/null
+++ b/README.1.4.0pre2-3
@@ -0,0 +1,16 @@
+the following is necessary to upgrade from 1.4.0pre2 to pre3 or later.
+
+CREATE TABLE part_svc_column (
+ columnnum int primary key,
+ svcpart int not null,
+ columnname varchar(64) not null,
+ columnvalue varchar(80) null,
+ columnflag char(1) null
+);
+
+CREATE UNIQUE INDEX part_svc_column1 ON part_svc_column ( svcpart, columnname );
+
+Run bin/fs-migrate-part_svc
+
+Run bin/dbdef-create
+
diff --git a/bin/fs-migrate-part_svc b/bin/fs-migrate-part_svc
new file mode 100755
index 000000000..96332f72a
--- /dev/null
+++ b/bin/fs-migrate-part_svc
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+
+use strict;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearchs);
+use FS::part_svc
+
+my $user = shift or die &usage;
+my $dbh = adminsuidsetup $user;
+
+my $oldAutoCommit = $FS::UID::AutoCommit;
+local $FS::UID::AutoCommit = 0
+
+foreach my $part_svc ( qsearch('part_svc', {} ) ) {
+ foreach my $field (
+ grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag') ) }
+ fields($self->svcdb)
+ ) {
+ my $flag = $self->getfield($part_svc->svcdb.'__'.$field.'_flag');
+ if ( uc($flag) =~ /^([DF])$/ ) {
+ $part_svc_column->setfield('columnflag', $1);
+ $part_svc_column->setfield('columnvalue',
+ $self->getfield($part_svc->svcdb.'__'.$field)
+ );
+ $error = $part_svc_column->insert;
+ } else {
+ $error = $part_svc_column->delete;
+ }
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ die $error;
+ }
+
+ }
+}
+
+sub usage {
+ die "Usage:\n fs-migrate-part_svc user\n";
+}
+
diff --git a/bin/fs-migrate-payref b/bin/fs-migrate-payref
index f1513112b..158419706 100755
--- a/bin/fs-migrate-payref
+++ b/bin/fs-migrate-payref
@@ -9,9 +9,6 @@ use FS::cust_refund;
my $user = shift or die &usage;
my $dbh = adminsuidsetup $user;
-#local $FS::UID::AutoCommit = 0; #quelle hack, in this case
-# $FS::UID::AutoCommit = 0; #quelle hack, in this case
-
# apply payments to invoices
foreach my $cust_pay ( qsearch('cust_pay', {} ) ) {
@@ -28,3 +25,7 @@ foreach my $cust_refund ( qsearch('cust_refund') ) {
# ? apply credits to invoices
+sub usage {
+ die "Usage:\n fs-migrate-payref user\n";
+}
+
diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check
index 92523eb95..fadba0165 100755
--- a/bin/fs-radius-add-check
+++ b/bin/fs-radius-add-check
@@ -35,8 +35,8 @@ my($char_d) = 80; #default maxlength for text fields
foreach my $attribute ( @attributes ) {
foreach my $statement (
"ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL",
- "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;",
- "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;",
+# "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;",
+# "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;",
) {
$dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; }
}
diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply
index 7938feac6..997a8eac7 100755
--- a/bin/fs-radius-add-reply
+++ b/bin/fs-radius-add-reply
@@ -35,8 +35,8 @@ my($char_d) = 80; #default maxlength for text fields
foreach my $attribute ( @attributes ) {
foreach my $statement (
"ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL",
- "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;",
- "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;",
+# "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;",
+# "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;",
) {
$dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; }
}
diff --git a/bin/fs-setup b/bin/fs-setup
index 5dc666a1e..53d96f692 100755
--- a/bin/fs-setup
+++ b/bin/fs-setup
@@ -1,6 +1,6 @@
#!/usr/bin/perl -Tw
#
-# $Id: fs-setup,v 1.53 2001-09-04 11:15:58 ivan Exp $
+# $Id: fs-setup,v 1.54 2001-09-06 20:41:59 ivan Exp $
#to delay loading dbdef until we're ready
BEGIN { $FS::Record::setup_hack = 1; }
@@ -122,32 +122,32 @@ foreach $attribute (@check_attributes) {
));
}
-#make part_svc table (but now as object)
-
-my($part_svc)=$dbdef->table('part_svc');
-
-#because of svc_acct_pop
-#foreach (grep /^svc_/, $dbdef->tables) {
-#foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) {
-foreach (qw(svc_acct svc_domain svc_forward svc_www)) {
- my($table)=$dbdef->table($_);
- my($col);
- foreach $col ( $table->columns ) {
- next if $col =~ /^svcnum$/;
- $part_svc->addcolumn( new DBIx::DBSchema::Column (
- $table->name. '__' . $table->column($col)->name,
- 'varchar', #$table->column($col)->type,
- 'NULL',
- $char_d, #$table->column($col)->length,
- ));
- $part_svc->addcolumn ( new DBIx::DBSchema::Column (
- $table->name. '__'. $table->column($col)->name . "_flag",
- 'char',
- 'NULL',
- 1,
- ));
- }
-}
+##make part_svc table (but now as object)
+#
+#my($part_svc)=$dbdef->table('part_svc');
+#
+##because of svc_acct_pop
+##foreach (grep /^svc_/, $dbdef->tables) {
+##foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) {
+#foreach (qw(svc_acct svc_domain svc_forward svc_www)) {
+# my($table)=$dbdef->table($_);
+# my($col);
+# foreach $col ( $table->columns ) {
+# next if $col =~ /^svcnum$/;
+# $part_svc->addcolumn( new DBIx::DBSchema::Column (
+# $table->name. '__' . $table->column($col)->name,
+# 'varchar', #$table->column($col)->type,
+# 'NULL',
+# $char_d, #$table->column($col)->length,
+# ));
+# $part_svc->addcolumn ( new DBIx::DBSchema::Column (
+# $table->name. '__'. $table->column($col)->name . "_flag",
+# 'char',
+# 'NULL',
+# 1,
+# ));
+# }
+#}
#important
$dbdef->save($dbdef_file);
@@ -580,6 +580,19 @@ sub tables_hash_hack {
'index' => [ [] ],
},
+ 'part_svc_column' => {
+ 'columns' => [
+ 'columnnum', 'int', '', '',
+ 'svcpart', 'int', '', '',
+ 'columnname', 'varchar', '', 64,
+ 'columnvalue', 'varchar', 'NULL', $char_d,
+ 'columnflag', 'char', 'NULL', 1,
+ ],
+ 'primary_key' => 'columnnum',
+ 'unique' => [ [ 'svcpart', 'columnname' ] ],
+ 'index' => [ [ 'svcpart' ] ],
+ }
+
#(this should be renamed to part_pop)
'svc_acct_pop' => {
'columns' => [
diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi
index 1306ac057..cfb1ad82b 100755
--- a/httemplate/browse/part_svc.cgi
+++ b/httemplate/browse/part_svc.cgi
@@ -1,4 +1,4 @@
-<!-- $Id: part_svc.cgi,v 1.3 2001-09-04 14:44:06 ivan Exp $ -->
+<!-- $Id: part_svc.cgi,v 1.4 2001-09-06 20:41:59 ivan Exp $ -->
<%= header('Service Definition Listing', menubar( 'Main Menu' => $p) ) %>
Services are items you offer to your customers.<BR><BR>
@@ -15,14 +15,11 @@
} qsearch('part_svc',{}) ) {
my($hashref)=$part_svc->hashref;
my($svcdb)=$hashref->{svcdb};
- my(@rows)=
- grep $hashref->{${svcdb}.'__'.$_.'_flag'},
- map { /^${svcdb}__(.*)$/; $1 }
- grep ! /_flag$/,
- grep /^${svcdb}__/,
- fields('part_svc')
- ;
- my($rowspan)=scalar(@rows) || 1;
+ my @fields =
+ grep { $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag }
+ fields($svcdb);
+
+ my($rowspan)=scalar(@fields) || 1;
my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}";
%>
@@ -35,9 +32,8 @@
<%= $hashref->{svcdb} %></TD>
<% my($n1)='';
- my($row);
- foreach $row ( @rows ) {
- my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag');
+ foreach my $field ( @fields ) {
+ my $flag = $part_svc->part_svc_column($field)->columnflag;
%>
<%= $n1 %><TD><%= $row %></TD><TD>
@@ -45,7 +41,7 @@
elsif ( $flag eq "F" ) { print "Fixed"; }
else { print "(Unknown!)"; }
%>
- </TD><TD><%= $part_svc->getfield($svcdb."__".$row) %></TD>
+ </TD><TD><%= $part_svc->part_svc_column($field)->columnvalue%></TD>
<% $n1="</TR><TR>";
}
%>
diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html
index c90f47641..59d68b718 100644
--- a/httemplate/docs/schema.html
+++ b/httemplate/docs/schema.html
@@ -196,8 +196,17 @@
<li>svcpart - primary key
<li>svc - name of this service
<li>svcdb - table used for this service: svc_acct, svc_acct_sm, svc_forward, svc_domain, svc_charge or svc_wo
- <li><i>table</i>__<i>field</i> - Default or fixed value for <i>field</i> in <i>table</i>
+<!-- <li><i>table</i>__<i>field</i> - Default or fixed value for <i>field</i> in <i>table</i>
<li><i>table</i>__<i>field</i>_flag - null, D or F
+-->
+ </ul>
+ <li><a name="part_svc_column" href="man/FS/part_svc_column.html">part_svc_column</a>
+ <ul>
+ <li>columnnum - primary key
+ <li>svcpart - <a href="#part_svc">Service definition</a>
+ <li>columnname - column name in part_svc.svcdb table
+ <li>columnvalue - default or fixed value for the column
+ <li>columnflag - null, D or F
</ul>
<li><a name="pkg_svc" href="man/FS/pkg_svc.html">pkg_svc</a>
<ul>
diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html
index 518d76168..67b0e5fe1 100644
--- a/httemplate/docs/upgrade8.html
+++ b/httemplate/docs/upgrade8.html
@@ -95,19 +95,17 @@ CREATE TABLE cust_credit_refund (
amount decimal(10,2) not null
);
+CREATE TABLE part_svc_column (
+ columnnum int primary key,
+ svcpart int not null,
+ columnname varchar(64) not null,
+ columnvalue varchar(80) null,
+ columnflag char(1) null
+);
+
ALTER TABLE svc_acct ADD domsvc integer NOT NULL;
ALTER TABLE svc_domain ADD catchall integer NULL;
-ALTER TABLE part_svc ADD svc_acct__domsvc integer NULL;
-ALTER TABLE part_svc ADD svc_acct__domsvc_flag char(1) NULL;
-ALTER TABLE part_svc ADD svc_domain__catchall integer NULL;
-ALTER TABLE part_svc ADD svc_domain__catchall_flag char(1) NULL;
-ALTER TABLE part_svc ADD svc_forward__srcsvc integer NULL;
-ALTER TABLE part_svc ADD svc_forward__srcsvc_flag char(1) NULL;
-ALTER TABLE part_svc ADD svc_forward__dstsvc integer NULL;
-ALTER TABLE part_svc ADD svc_forward__dstsvc_flag char(1) NULL;
-ALTER TABLE part_svc ADD svc_forward__dst integer NULL;
-ALTER TABLE part_svc ADD svc_forward__dst_flag char(1) NULL;
ALTER TABLE cust_main ADD referral_custnum integer NULL;
ALTER TABLE cust_pay ADD custnum integer;
ALTER TABLE cust_refund ADD custnum integer;
@@ -118,6 +116,7 @@ CREATE INDEX cust_bill_pay1 ON cust_bill_pay ( invnum );
CREATE INDEX cust_bill_pay2 ON cust_bill_pay ( paynum );
CREATE INDEX cust_credit_refund1 ON cust_credit_refund ( crednum );
CREATE INDEX cust_credit_refund2 ON cust_credit_refund ( refundnum );
+CREATE UNIQUE INDEX part_svc_column1 ON part_svc_column ( svcpart, columnname );
</pre>
<li>If you are using PostgreSQL, apply the following changes to your database:
@@ -177,6 +176,7 @@ ALTER TABLE cust_main ADD COLUMN comments varchar NULL;
<li>create a service based on svc_forward
<li>Run bin/fs-migrate-svc_acct_sm
<li>Run bin/fs-migrate-payref
+ <li>Run bin/fs-migrate-part_svc
<li><b>After running bin/fs-migrate-payref</b>, apply the following changes to your database:
<table border><tr><th>PostgreSQL</th><th>MySQL, others</th></tr>
<tr><td>
diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi
index 01574e992..c0d632fa5 100755
--- a/httemplate/edit/part_svc.cgi
+++ b/httemplate/edit/part_svc.cgi
@@ -1,4 +1,4 @@
-<!-- $Id: part_svc.cgi,v 1.6 2001-09-04 14:44:06 ivan Exp $ -->
+<!-- $Id: part_svc.cgi,v 1.7 2001-09-06 20:42:00 ivan Exp $ -->
<%
my $part_svc;
if ( $cgi->param('error') ) { #error
@@ -145,10 +145,9 @@ foreach my $svcdb ( qw(
konq_kludge svc_acct svc_domain svc_acct_sm svc_forward svc_www
) ) {
- my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
- grep ! /_flag$/,
- grep /^${svcdb}__/,
- fields('part_svc');
+ my(@fields) = $svcdb eq 'konq_kludge'
+ ? ()
+ : grep { $_ ne 'svcnum' } fields($svcdb) );
#my($rowspan)=scalar(@rows);
#my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
@@ -177,22 +176,26 @@ function fixup(what) {
print "$svcdb" unless $svcdb eq 'konq_kludge';
print "<BR><TABLE BORDER=1><TH>Field</TH><TH COLSPAN=2>Modifier</TH>" unless $svcdb eq 'konq_kludge';
- my($row);
- foreach $row (@rows) {
- my $value = $part_svc->getfield($svcdb. '__'. $row);
- my $flag = $part_svc->getfield($svcdb. '__'. $row. '_flag');
- #print "<TR>$ptmp<TD>$row";
- print "<TR><TD>$row";
- print "- <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT>"
- if defined $defs{$svcdb}{$row};
+ foreach my $field (@fields) {
+ my $part_svc_column = $part_svc->part_svc_column($field);
+ my $value = $cgi->param('error')
+ ? $cgi->param("${svcdb}__${field}")
+ : $$part_svc_column->columnvalue;
+ my $flag = $cgi->param('error')
+ ? $cgi->param("${svcdb}__${field}_flag")
+ : $part_svc_column->columnflag;
+ #print "<TR>$ptmp<TD>$field";
+ print "<TR><TD>$field";
+ print "- <FONT SIZE=-1>$defs{$svcdb}{$field}</FONT>"
+ if defined $defs{$svcdb}{$field};
print "</TD>";
- print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
+ print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE=""!.
' CHECKED'x($flag eq ''). ">Off</TD>";
- print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
+ print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE="D"!.
' CHECKED'x($flag eq 'D'). ">Default ";
- print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
+ print qq!<INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE="F"!.
' CHECKED'x($flag eq 'F'). ">Fixed ";
- print qq!<INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
+ print qq!<INPUT TYPE="text" NAME="${svcdb}__${field}" VALUE="$value">!,
"</TD></TR>\n";
#$ptmp='';
}
diff --git a/httemplate/edit/process/part_svc.cgi b/httemplate/edit/process/part_svc.cgi
index 093d86a75..5652c5805 100755
--- a/httemplate/edit/process/part_svc.cgi
+++ b/httemplate/edit/process/part_svc.cgi
@@ -8,7 +8,11 @@ my $new = new FS::part_svc ( {
map {
$_, scalar($cgi->param($_));
# } qw(svcpart svc svcdb)
- } fields('part_svc')
+ } ( fields('part_svc'),
+ map { my $svcdb = $_;
+ map { ( $svcdb.'__'.$_, $svcdb.'__'.$_.'_flag' ) }
+ fields($svcdb)
+ } qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ) )
} );
my $error;