#!/usr/bin/perl -Tw
#
-# $Id: fs-setup,v 1.42 2001-08-13 00:19:02 ivan Exp $
+# $Id: fs-setup,v 1.59 2001-09-26 09:17:06 ivan Exp $
#to delay loading dbdef until we're ready
BEGIN { $FS::Record::setup_hack = 1; }
use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
use FS::Record;
use FS::cust_main_county;
+use FS::raddb;
die "Not running uid freeside!" unless checkeuid();
+my %attrib2db =
+ map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
+
my $user = shift or die &usage;
getsecrets($user);
check and reply attributes. First enter any additional RADIUS check attributes
you need to track for each user, separated by whitespace.
END
-my @check_attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
+my @check_attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
+ split(" ",&getvalue);
print "\n\n", <<END, ":";
Now enter any additional reply attributes you need to track for each user,
separated by whitespace.
END
-my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
+my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
+ split(" ",&getvalue);
print "\n\n", <<END, ":";
Do you wish to enable the tracking of a second, separate shipping/service
);
} (keys %tables) );
-#remove ship_ from cust_main
-unless ($ship) {
- my $cust_main = $dbdef->table('cust_main');
+my $cust_main = $dbdef->table('cust_main');
+unless ($ship) { #remove ship_ from cust_main
$cust_main->delcolumn($_) foreach ( grep /^ship_/, $cust_main->columns );
+} else { #add indices on ship_last and ship_company
+ push @{$cust_main->index->lol_ref}, ( ['ship_last'], ['ship_company'] )
}
#add radius attributes to svc_acct
));
}
-#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);
'index' => [ ['custnum'] ],
},
+ 'cust_credit_bill' => {
+ 'columns' => [
+ 'creditbillnum', 'int', '', '',
+ 'crednum', 'int', '', '',
+ 'invnum', 'int', '', '',
+ '_date', @date_type,
+ 'amount', @money_type,
+ ],
+ 'primary_key' => 'creditbillnum',
+ 'unique' => [ [] ],
+ 'index' => [ ['crednum'], ['invnum'] ],
+ },
+
'cust_main' => {
'columns' => [
'custnum', 'int', '', '',
'tax', 'char', 'NULL', 1,
'otaker', 'varchar', '', 8,
'refnum', 'int', '', '',
+ 'referral_custnum', 'int', 'NULL', '',
'comments', 'varchar', 'NULL', '',
],
'primary_key' => 'custnum',
'unique' => [ [] ],
#'index' => [ ['last'], ['company'] ],
- 'index' => [ ['last'], ],
+ 'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ] ],
},
'cust_main_invoice' => {
'cust_pay' => {
'columns' => [
'paynum', 'int', '', '',
- 'invnum', 'int', '', '',
+ #now cust_bill_pay #'invnum', 'int', '', '',
+ 'custnum', 'int', '', '',
'paid', @money_type,
'_date', @date_type,
'payby', 'char', '', 4, # CARD/BILL/COMP, should be index into
],
'primary_key' => 'paynum',
'unique' => [ [] ],
- 'index' => [ ['invnum'] ],
+ 'index' => [ [] ],
+ },
+
+ 'cust_bill_pay' => {
+ 'columns' => [
+ 'billpaynum', 'int', '', '',
+ 'invnum', 'int', '', '',
+ 'paynum', 'int', '', '',
+ 'amount', @money_type,
+ '_date', @date_type
+ ],
+ 'primary_key' => 'billpaynum',
+ 'unique' => [ [] ],
+ 'index' => [ [ 'paynum', 'invnum' ] ],
},
'cust_pay_batch' => { #what's this used for again? list of customers
'cust_refund' => {
'columns' => [
'refundnum', 'int', '', '',
- 'crednum', 'int', '', '',
+ #now cust_credit_refund #'crednum', 'int', '', '',
+ 'custnum', 'int', '', '',
'_date', @date_type,
'refund', @money_type,
'otaker', 'varchar', '', 8,
'payby', 'char', '', 4, # CARD/BILL/COMP, should be index
# into payment type table.
'payinfo', 'varchar', 'NULL', 16, #see cust_main above
+ 'paybatch', 'varchar', 'NULL', $char_d,
],
'primary_key' => 'refundnum',
'unique' => [ [] ],
- 'index' => [ ['crednum'] ],
+ 'index' => [ [] ],
+ },
+
+ 'cust_credit_refund' => {
+ 'columns' => [
+ 'creditrefundnum', 'int', '', '',
+ 'crednum', 'int', '', '',
+ 'refundnum', 'int', '', '',
+ 'amount', @money_type,
+ '_date', @date_type
+ ],
+ 'primary_key' => 'creditrefundnum',
+ 'unique' => [ [] ],
+ 'index' => [ [ 'crednum', 'refundnum' ] ],
},
+
'cust_svc' => {
'columns' => [
'svcnum', 'int', '', '',
'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' => [
],
'primary_key' => 'popnum',
'unique' => [ [] ],
- 'index' => [ [] ],
+ 'index' => [ [ 'state' ] ],
+ },
+
+ 'part_pop_local' => {
+ 'columns' => [
+ 'localnum', 'int', '', '',
+ 'popnum', 'int', '', '',
+ 'city', 'varchar', 'NULL', $char_d,
+ 'state', 'char', 'NULL', 2,
+ 'npa', 'char', '', 3,
+ 'nxx', 'char', '', 3,
+ ],
+ 'primary_key' => 'popnum',
+ 'unique' => [ [] ],
+ 'index' => [ [ 'npa', 'nxx' ] ],
},
'svc_acct' => {
'columns' => [
'svcnum', 'int', '', '',
'domain', 'varchar', '', $char_d,
- 'catchall', 'int', '', '',
+ 'catchall', 'int', 'NULL', '',
],
'primary_key' => 'svcnum',
'unique' => [ ['domain'] ],
'index' => [ [ 'portnum' ] ],
},
+ 'queue' => {
+ 'columns' => [
+ 'jobnum', 'int', '', '',
+ 'job', 'varchar', '', '',
+ '_date', 'int', '', '',
+ 'status', 'varchar', '', $char_d,
+ ],
+ 'primary_key' => 'jobnum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
+ 'queue_arg' => {
+ 'columns' => [
+ 'argnum', 'int', '', '',
+ 'jobnum', 'int', '', '',
+ 'arg', 'varchar', 'NULL', '',
+ ],
+ 'primary_key' => 'argnum',
+ 'unique' => [],
+ 'index' => [ [ 'jobnum' ] ],
+ },
);
%tables;