From 0b62b95185b28bfb2a4eec5639abb2a7d1207ffe Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 8 Sep 2002 12:40:31 +0000 Subject: error out if can't open .HEADER files --- bin/bind.export | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/bind.export b/bin/bind.export index 7d1452dc6..63fb0f60c 100755 --- a/bin/bind.export +++ b/bin/bind.export @@ -38,7 +38,8 @@ foreach my $export ( @exports ) { open(NAMED_CONF,">$prefix/named.conf") or die "can't open $prefix/named.conf: $!"; - open(CONF_HEADER,"<$prefix/named.conf.HEADER"); #or die + open(CONF_HEADER,"<$prefix/named.conf.HEADER") + or die "can't open $prefix/named.conf.HEADER: $!" while () { print NAMED_CONF $_; } close CONF_HEADER; @@ -137,7 +138,8 @@ foreach my $sexport ( @sexports ) { #false laziness with above open(NAMED_CONF,">$prefix/named.conf") or die "can't open $prefix/named.conf: $!"; - open(CONF_HEADER,"<$prefix/named.conf.HEADER"); #or die + open(CONF_HEADER,"<$prefix/named.conf.HEADER") + or die "can't open $prefix/named.conf.HEADER: $!" while () { print NAMED_CONF $_; } close CONF_HEADER; -- cgit v1.2.1 From 49006303c63cc2a6fffb5df5d1d3f8947f700b02 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 8 Sep 2002 12:58:00 +0000 Subject: ordering fix on delete: domain_record records first, then svc_domain --- FS/FS/svc_domain.pm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index b06d03013..637d0493c 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -269,12 +269,6 @@ sub delete { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - my $error = $self->SUPER::delete; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error; - } - foreach my $domain_record ( reverse $self->domain_record ) { my $error = $domain_record->delete; if ( $error ) { @@ -282,6 +276,13 @@ sub delete { return $error; } } + + my $error = $self->SUPER::delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; } @@ -448,10 +449,6 @@ sub submit_internic { =back -=head1 VERSION - -$Id: svc_domain.pm,v 1.31 2002-06-10 02:52:48 ivan Exp $ - =head1 BUGS All BIND/DNS fields should be included (and exported). -- cgit v1.2.1 From a7013a87b67301d8b43c7847b84e06be4802d948 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 9 Sep 2002 12:34:55 +0000 Subject: : is not legal in GECOS --- FS/FS/ClientAPI.pm | 4 ++-- FS/FS/ClientAPI/passwd.pm | 9 +++++---- FS/FS/InitHandler.pm | 4 ++++ FS/FS/svc_acct.pm | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/FS/FS/ClientAPI.pm b/FS/FS/ClientAPI.pm index f7b8eb028..7cbbdbf67 100644 --- a/FS/FS/ClientAPI.pm +++ b/FS/FS/ClientAPI.pm @@ -1,13 +1,13 @@ package FS::ClientAPI; use strict; -use vars qw(%handler); +use vars qw(%handler $domain); %handler = (); #find modules foreach my $INC ( @INC ) { - foreach my $file ( glob("$INC/FS/ClientAPI/*") ) { + foreach my $file ( glob("$INC/FS/ClientAPI/*.pm") ) { $file =~ /\/(\w+)\.pm$/ or do { warn "unrecognized ClientAPI file: $file"; next diff --git a/FS/FS/ClientAPI/passwd.pm b/FS/FS/ClientAPI/passwd.pm index 29606227d..016ebff79 100644 --- a/FS/FS/ClientAPI/passwd.pm +++ b/FS/FS/ClientAPI/passwd.pm @@ -15,8 +15,9 @@ FS::ClientAPI->register_handlers( sub passwd { my $packet = shift; - #my $domain = qsearchs('svc_domain', { 'domain' => $packet->{'domain'} } ) - # or return { error => "Domain $domain not found" }; + my $domain = $FS::ClientAPI::domain || $packet->{'domain'}; + my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } ) + or return { error => "Domain $domain not found" }; my $old_password = $packet->{'old_password'}; my $new_password = $packet->{'new_password'}; @@ -27,11 +28,11 @@ sub passwd { my $svc_acct = ( length($old_password) < 13 && qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, - #'domsvc' => $svc_domain->svcnum, + 'domsvc' => $svc_domain->svcnum, '_password' => $old_password } ) ) || qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, - #'domsvc' => $svc_domain->svcnum, + 'domsvc' => $svc_domain->svcnum, '_password' => $old_password } ); unless ( $svc_acct ) { return { error => 'Incorrect password.' } } diff --git a/FS/FS/InitHandler.pm b/FS/FS/InitHandler.pm index 87f507c22..0216615da 100644 --- a/FS/FS/InitHandler.pm +++ b/FS/FS/InitHandler.pm @@ -1,5 +1,9 @@ package FS::InitHandler; +# this leaks memory under graceful restarts and i wouldn't use it on any +# modern server. useful for very slow machines with memory to spare, just +# always do a full restart + use strict; use vars qw($DEBUG); use FS::UID qw(adminsuidsetup); diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index e62cdd7bb..9032e20c1 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -752,7 +752,7 @@ sub check { # $error = $self->ut_textn('finger'); # return $error if $error; $self->getfield('finger') =~ - /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\*\<\>]*)$/ + /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\'\"\,\.\?\/\*\<\>]*)$/ or return "Illegal finger: ". $self->getfield('finger'); $self->setfield('finger', $1); -- cgit v1.2.1 From ed0c10c5969c60fd2be050a9a5f3830bc347739a Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 9 Sep 2002 19:54:00 +0000 Subject: doc clarification about users --- httemplate/docs/ssh.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httemplate/docs/ssh.html b/httemplate/docs/ssh.html index 5503a242e..9716f1e86 100755 --- a/httemplate/docs/ssh.html +++ b/httemplate/docs/ssh.html @@ -6,8 +6,8 @@
Unattended remote login - Freeside can login to remote machines unattended using SSH. This can pose a security risk if not configured correctly, and will allow an intruder who breaks into your freeside machine full access to your remote machines. Do not use this feature unless you understand what you are doing!
  • As the freeside user (on your freeside machine), generate an authentication key using ssh-keygen. Since this is for unattended operation, use a blank passphrase. -
  • Append the newly-created identity.pub file to ~root/.ssh/authorized_keys on the remote machine(s). -
  • Some new SSH v2 implementation accept v2 style keys only. Use the -t option to ssh-keygen, and append the created id_dsa.pub or id_rsa.pub to ~root/.ssh/authorized_keys2 on the remote machine(s). +
  • Append the newly-created identity.pub file to ~root/.ssh/authorized_keys (or the appopriate ~username/.ssh/authorized_keys) on the remote machine(s). +
  • Some new SSH v2 implementation accept v2 style keys only. Use the -t option to ssh-keygen, and append the created id_dsa.pub or id_rsa.pub to ~root/.ssh/authorized_keys2 (or the appopriate ~username/.ssh/authorized_keys) on the remote machine(s).
  • You may need to set PermitRootLogin without-password (meaning with keys only) in your sshd_config file on the remote machine(s).
-- cgit v1.2.1 From bcd23d236c4846bee6285c1ff862e7e3c3f59cd9 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 9 Sep 2002 19:56:06 +0000 Subject: vpopmail export doc clarification: ssh as vpopmail user --- FS/FS/part_export.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 3c1a3de8e..bc6a4d735 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -778,7 +778,7 @@ tie my %sqlmail_options, 'Tie::IxHash', 'vpopmail' => { 'desc' => 'Real-time export to vpopmail text files', 'options' => \%vpopmail_options, - 'notes' => 'Real time export to vpopmail text files. File::Rsync must be installed, and you will need to setup SSH for unattended operation', + 'notes' => 'Real time export to vpopmail text files. File::Rsync must be installed, and you will need to setup SSH for unattended operation to vpopmail@export.host.', }, }, -- cgit v1.2.1 From eb46cd3822674cecdc474b175b1e6f3ede8cc49b Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 9 Sep 2002 22:56:14 +0000 Subject: svc_broadband merge --- FS/MANIFEST | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/FS/MANIFEST b/FS/MANIFEST index fff95c8c8..4a250d77b 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -36,6 +36,9 @@ FS/UI/Gtk.pm FS/UI/agent.pm FS/UID.pm FS/Msgcat.pm +FS/ac.pm +FS/ac_block.pm +FS/ac_type.pm FS/agent.pm FS/agent_type.pm FS/cust_bill.pm @@ -54,6 +57,7 @@ FS/cust_refund.pm FS/cust_credit_refund.pm FS/cust_svc.pm FS/part_bill_event.pm +FS/part_ac_field.pm FS/export_svc.pm FS/part_export.pm FS/part_export_option.pm @@ -84,6 +88,7 @@ FS/svc_Common.pm FS/svc_acct.pm FS/svc_acct_pop.pm FS/svc_acct_sm.pm +FS/svc_broadband.pm FS/svc_domain.pm FS/type_pkgs.pm FS/nas.pm -- cgit v1.2.1 From 91292eadb6254740a9b72e5dc95f575593f6a35d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 9 Sep 2002 22:57:34 +0000 Subject: allow . in untaint_argv, for usernames --- FS/bin/freeside-cc-receipts-report | 4 ++-- FS/bin/freeside-credit-report | 4 ++-- FS/bin/freeside-receivables-report | 4 ++-- FS/bin/freeside-tax-report | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FS/bin/freeside-cc-receipts-report b/FS/bin/freeside-cc-receipts-report index 06e3aba81..136851aec 100755 --- a/FS/bin/freeside-cc-receipts-report +++ b/FS/bin/freeside-cc-receipts-report @@ -206,7 +206,7 @@ if($email && $opt_m) # subroutines sub untaint_argv { foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV - $ARGV[$_] =~ /^([\w\-\/ :]*)$/ || die "Illegal argument \"$ARGV[$_]\""; + $ARGV[$_] =~ /^([\w\-\/ :\.]*)$/ || die "Illegal argument \"$ARGV[$_]\""; $ARGV[$_]=$1; } } @@ -245,7 +245,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-cc-receipts-report,v 1.4 2002-03-07 19:50:23 jeff Exp $ +$Id: freeside-cc-receipts-report,v 1.5 2002-09-09 22:57:34 ivan Exp $ =head1 BUGS diff --git a/FS/bin/freeside-credit-report b/FS/bin/freeside-credit-report index 7699daf4d..410dabe8f 100755 --- a/FS/bin/freeside-credit-report +++ b/FS/bin/freeside-credit-report @@ -160,7 +160,7 @@ if($email && $opt_m) # subroutines sub untaint_argv { foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV - $ARGV[$_] =~ /^([\w\-\/ :]*)$/ || die "Illegal argument \"$ARGV[$_]\""; + $ARGV[$_] =~ /^([\w\-\/ :\.]*)$/ || die "Illegal argument \"$ARGV[$_]\""; $ARGV[$_]=$1; } } @@ -199,7 +199,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-credit-report,v 1.4 2002-03-07 19:50:24 jeff Exp $ +$Id: freeside-credit-report,v 1.5 2002-09-09 22:57:34 ivan Exp $ =head1 BUGS diff --git a/FS/bin/freeside-receivables-report b/FS/bin/freeside-receivables-report index b5a49031e..f3ad2a1a6 100755 --- a/FS/bin/freeside-receivables-report +++ b/FS/bin/freeside-receivables-report @@ -157,7 +157,7 @@ if($email && $opt_m) sub untaint_argv { foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV - $ARGV[$_] =~ /^([\w\-\/ ]*)$/ || die "Illegal argument \"$ARGV[$_]\""; + $ARGV[$_] =~ /^([\w\-\/ \.]*)$/ || die "Illegal argument \"$ARGV[$_]\""; $ARGV[$_]=$1; } } @@ -192,7 +192,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-receivables-report,v 1.5 2002-03-07 19:50:24 jeff Exp $ +$Id: freeside-receivables-report,v 1.6 2002-09-09 22:57:34 ivan Exp $ =head1 BUGS diff --git a/FS/bin/freeside-tax-report b/FS/bin/freeside-tax-report index 8d5021358..240f3ad37 100755 --- a/FS/bin/freeside-tax-report +++ b/FS/bin/freeside-tax-report @@ -228,7 +228,7 @@ if($email && $opt_m) # subroutines sub untaint_argv { foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV - $ARGV[$_] =~ /^([\w\-\/ :]*)$/ || die "Illegal argument \"$ARGV[$_]\""; + $ARGV[$_] =~ /^([\w\-\/ :\.]*)$/ || die "Illegal argument \"$ARGV[$_]\""; $ARGV[$_]=$1; } } @@ -267,7 +267,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-tax-report,v 1.4 2002-03-07 19:50:24 jeff Exp $ +$Id: freeside-tax-report,v 1.5 2002-09-09 22:57:34 ivan Exp $ =head1 BUGS -- cgit v1.2.1 From 44398c83f25bf4e43838df9f39331c29fdeff19d Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 9 Sep 2002 23:05:30 +0000 Subject: svc_broadband merge --- FS/FS/ac.pm | 148 +++++++++++++++ FS/FS/ac_block.pm | 148 +++++++++++++++ FS/FS/ac_field.pm | 138 ++++++++++++++ FS/FS/ac_type.pm | 128 +++++++++++++ FS/FS/cust_svc.pm | 4 +- FS/FS/part_ac_field.pm | 102 +++++++++++ FS/FS/part_export.pm | 3 + FS/FS/svc_broadband.pm | 295 ++++++++++++++++++++++++++++++ bin/fs-setup | 72 +++++++- htetc/global.asa | 6 + httemplate/browse/ac.cgi | 57 ++++++ httemplate/browse/ac_type.cgi | 47 +++++ httemplate/edit/ac.cgi | 163 +++++++++++++++++ httemplate/edit/ac_type.cgi | 106 +++++++++++ httemplate/edit/part_svc.cgi | 13 +- httemplate/edit/process/ac.cgi | 28 +++ httemplate/edit/process/ac_block.cgi | 21 +++ httemplate/edit/process/ac_field.cgi | 21 +++ httemplate/edit/process/ac_type.cgi | 28 +++ httemplate/edit/process/part_ac_field.cgi | 21 +++ httemplate/edit/process/part_svc.cgi | 2 +- httemplate/edit/process/svc_broadband.cgi | 45 +++++ httemplate/edit/svc_broadband.cgi | 219 ++++++++++++++++++++++ httemplate/index.html | 4 + httemplate/view/svc_broadband.cgi | 75 ++++++++ 25 files changed, 1890 insertions(+), 4 deletions(-) create mode 100644 FS/FS/ac.pm create mode 100755 FS/FS/ac_block.pm create mode 100755 FS/FS/ac_field.pm create mode 100755 FS/FS/ac_type.pm create mode 100755 FS/FS/part_ac_field.pm create mode 100755 FS/FS/svc_broadband.pm create mode 100755 httemplate/browse/ac.cgi create mode 100755 httemplate/browse/ac_type.cgi create mode 100755 httemplate/edit/ac.cgi create mode 100755 httemplate/edit/ac_type.cgi create mode 100755 httemplate/edit/process/ac.cgi create mode 100755 httemplate/edit/process/ac_block.cgi create mode 100755 httemplate/edit/process/ac_field.cgi create mode 100755 httemplate/edit/process/ac_type.cgi create mode 100755 httemplate/edit/process/part_ac_field.cgi create mode 100644 httemplate/edit/process/svc_broadband.cgi create mode 100644 httemplate/edit/svc_broadband.cgi create mode 100644 httemplate/view/svc_broadband.cgi diff --git a/FS/FS/ac.pm b/FS/FS/ac.pm new file mode 100644 index 000000000..5a2b36079 --- /dev/null +++ b/FS/FS/ac.pm @@ -0,0 +1,148 @@ +package FS::ac; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearchs qsearch ); +use FS::ac_type; +use FS::ac_block; + +@ISA = qw( FS::Record ); + +=head1 NAME + +FS::ac - Object methods for ac records + +=head1 SYNOPSIS + + use FS::ac; + + $record = new FS::ac \%hash; + $record = new FS::ac { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::ac record describes a broadband Access Concentrator, such as a DSLAM +or a wireless access point. FS::ac inherits from FS::Record. The following +fields are currently supported: + +narf + +=over 4 + +=item acnum - primary key + +=item actypenum - AC type, see L + +=item acname - descriptive name for the AC + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Create a new record. To add the record to the database, see L<"insert">. + +=cut + +sub table { 'ac'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=item delete + +Deletes this record from the database. If there is an error, returns the +error, otherwise returns false. + +=item replace OLD_RECORD + +Replaces OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=item check + +Checks all fields to make sure this is a valid record. If there is an error, +returns the error, otherwise returns false. Called by the insert and replace +methods. + +=cut + +sub check { + my $self = shift; + + my $error = + $self->ut_numbern('acnum') + || $self->ut_number('actypenum') + || $self->ut_text('acname'); + return $error if $error; + + return "Unknown actypenum" + unless $self->ac_type; + ''; +} + +=item ac_type + +Returns the L object corresponding to this object. + +=cut + +sub ac_type { + my $self = shift; + return qsearchs('ac_type', { actypenum => $self->actypenum }); +} + +=item ac_block + +Returns a list of L objects (address blocks) associated +with this object. + +=cut + +sub ac_block { + my $self = shift; + return qsearch('ac_block', { acnum => $self->acnum }); +} + +=item ac_field + +Returns a hash of L objects assigned to this object. + +=cut + +sub ac_field { + my $self = shift; + + return qsearch('ac_field', { acnum => $self->acnum }); +} + +=back + +=head1 VERSION + +$Id: + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, schema.html +from the base documentation. + +=cut + +1; + diff --git a/FS/FS/ac_block.pm b/FS/FS/ac_block.pm new file mode 100755 index 000000000..09de6a4d8 --- /dev/null +++ b/FS/FS/ac_block.pm @@ -0,0 +1,148 @@ +package FS::ac_block; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearchs qsearch ); +use FS::ac_type; +use FS::ac; +use FS::svc_broadband; +use NetAddr::IP; + +@ISA = qw( FS::Record ); + +=head1 NAME + +FS::ac - Object methods for ac records + +=head1 SYNOPSIS + + use FS::ac_block; + + $record = new FS::ac_block \%hash; + $record = new FS::ac_block { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::ac_block record describes an address block assigned for broadband +access. FS::ac_block inherits from FS::Record. The following fields are +currently supported: + +=over 4 + +=item acnum - the access concentrator (see L) to which this +block is assigned. + +=item ip_gateway - the gateway address used by customers within this block. +This functions as the primary key. + +=item ip_netmask - the netmask of the block, expressed as an integer. + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Create a new record. To add the record to the database, see L<"insert">. + +=cut + +sub table { 'ac_block'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=item delete + +Deletes this record from the database. If there is an error, returns the +error, otherwise returns false. + +=item replace OLD_RECORD + +Replaces OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=item check + +Checks all fields to make sure this is a valid record. If there is an error, +returns the error, otherwise returns false. Called by the insert and replace +methods. + +=cut + +sub check { + my $self = shift; + + my $error = + $self->ut_number('acnum') + || $self->ut_ip('ip_gateway') + || $self->ut_number('ip_netmask') + ; + return $error if $error; + + return "Unknown acnum" + unless $self->ac; + + my $self_addr = new NetAddr::IP ($self->ip_gateway, $self->ip_netmask); + return "Cannot parse address: ". $self->ip_gateway . '/' . $self->ip_netmask + unless $self_addr; + + my @block = grep { + my $block_addr = new NetAddr::IP ($_->ip_gateway, $_->ip_netmask); + if($block_addr->contains($self_addr) + or $self_addr->contains($block_addr)) { $_; }; + } qsearch( 'ac_block', {}); + + foreach(@block) { + return "Block intersects existing block ".$_->ip_gateway."/".$_->ip_netmask; + } + + ''; +} + + +=item ac + +Returns the L object corresponding to this object. + +=cut + +sub ac { + my $self = shift; + return qsearchs('ac', { acnum => $self->acnum }); +} + +=item svc_broadband + +Returns a list of L objects associated +with this object. + +=cut + +#sub svc_broadband { +# my $self = shift; +# my @svc = qsearch('svc_broadband', { actypenum => $self->ac->ac_type->actypenum }); +# return grep { +# my $svc_addr = new NetAddr::IP($_->ip_addr, $_->ip_netmask); +# $self_addr->contains($svc_addr); +# } @svc; +#} + +=back + +=cut + +1; + diff --git a/FS/FS/ac_field.pm b/FS/FS/ac_field.pm new file mode 100755 index 000000000..f6011192f --- /dev/null +++ b/FS/FS/ac_field.pm @@ -0,0 +1,138 @@ +package FS::ac_field; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearchs ); +use FS::part_ac_field; +use FS::ac; + +use UNIVERSAL qw( can ); + +@ISA = qw( FS::Record ); + +=head1 NAME + +FS::ac_field - Object methods for ac_field records + +=head1 SYNOPSIS + + use FS::ac_field; + + $record = new FS::ac_field \%hash; + $record = new FS::ac_field { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +L contains values of fields defined by L +for an L. Values must be of the data type defined by ut_type in +L. +Supported fields as follows: + +=over 4 + +=item acfieldpart - Type of ac_field as defined by L + +=item acnum - The L to which this value belongs. + +=item value - The contents of the field. + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Create a new record. To add the record to the database, see L<"insert">. + +=cut + +sub table { 'ac_field'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=item delete + +Deletes this record from the database. If there is an error, returns the +error, otherwise returns false. + +=item replace OLD_RECORD + +Replaces OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=item check + +Checks all fields to make sure this is a valid record. If there is an error, +returns the error, otherwise returns false. Called by the insert and replace +methods. + +=cut + +sub check { + my $self = shift; + + return "acnum must be defined" unless $self->acnum; + return "acfieldpart must be defined" unless $self->acfieldpart; + + my $ut_func = $self->can("ut_" . $self->part_ac_field->ut_type); + my $error = $self->$ut_func('value'); + + return $error if $error; + + ''; #no error +} + +=item part_ac_field + +Returns a reference to the L that defines this L + +=cut + +sub part_ac_field { + my $self = shift; + + return qsearchs('part_ac_field', { acfieldpart => $self->acfieldpart }); +} + +=item ac + +Returns a reference to the L to which this L belongs. + +=cut + +sub ac { + my $self = shift; + + return qsearchs('ac', { acnum => $self->acnum }); +} + +=back + +=head1 VERSION + +$Id: + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, schema.html +from the base documentation. + +=cut + +1; + diff --git a/FS/FS/ac_type.pm b/FS/FS/ac_type.pm new file mode 100755 index 000000000..e83c5c5f0 --- /dev/null +++ b/FS/FS/ac_type.pm @@ -0,0 +1,128 @@ +package FS::ac_type; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearchs ); +use FS::ac; + +@ISA = qw( FS::Record ); + +=head1 NAME + +FS::ac_type - Object methods for ac_type records + +=head1 SYNOPSIS + + use FS::ac_type; + + $record = new FS::ac_type \%hash; + $record = new FS::ac_type { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +L refers to a type of access concentrator. L +records refer to a specific L limiting the choice of access +concentrator to one of the chosen type. This should be set as a fixed +default in part_svc to prevent provisioning the wrong type of service for +a given package or service type. Supported fields as follows: + +=over 4 + +=item actypenum - Primary key. see L + +=item actypename - Text identifier for access concentrator type. + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Create a new record. To add the record to the database, see L<"insert">. + +=cut + +sub table { 'ac_type'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=item delete + +Deletes this record from the database. If there is an error, returns the +error, otherwise returns false. + +=item replace OLD_RECORD + +Replaces OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=item check + +Checks all fields to make sure this is a valid record. If there is an error, +returns the error, otherwise returns false. Called by the insert and replace +methods. + +=cut + +sub check { + my $self = shift; + + # What do we check? + + ''; #no error +} + +=item ac + +Returns a list of all L records of this type. + +=cut + +sub ac { + my $self = shift; + + return qsearch('ac', { actypenum => $self->actypenum }); +} + +=item part_ac_field + +Returns a list of all L records of this type. + +=cut + +sub part_ac_field { + my $self = shift; + + return qsearch('part_ac_field', { actypenum => $self->actypenum }); +} + +=back + +=head1 VERSION + +$Id: + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, schema.html +from the base documentation. + +=cut + +1; + diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index c7cc4b322..d54fb2d40 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -295,6 +295,8 @@ sub label { } elsif ( $svcdb eq 'svc_www' ) { my $domain = qsearchs( 'domain_record', { 'recnum' => $svc_x->recnum } ); $tag = $domain->reczone; + } elsif ( $svcdb eq 'svc_broadband' ) { + $tag = $svc_x->ip_addr . '/' . $svc_x->ip_netmask; } else { cluck "warning: asked for label of unsupported svcdb; using svcnum"; $tag = $svc_x->getfield('svcnum'); @@ -344,7 +346,7 @@ sub seconds_since { =head1 VERSION -$Id: cust_svc.pm,v 1.15 2002-05-22 12:17:06 ivan Exp $ +$Id: cust_svc.pm,v 1.16 2002-09-09 23:01:35 khoff Exp $ =head1 BUGS diff --git a/FS/FS/part_ac_field.pm b/FS/FS/part_ac_field.pm new file mode 100755 index 000000000..dcb445253 --- /dev/null +++ b/FS/FS/part_ac_field.pm @@ -0,0 +1,102 @@ +package FS::part_ac_field; + +use strict; +use vars qw( @ISA ); +use FS::Record qw( qsearchs ); +use FS::ac_field; +use FS::ac; + + +@ISA = qw( FS::Record ); + +=head1 NAME + +FS::part_ac_field - Object methods for part_ac_field records + +=head1 SYNOPSIS + + use FS::part_ac_field; + + $record = new FS::part_ac_field \%hash; + $record = new FS::part_ac_field { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + + +=over 4 + +=item blank + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Create a new record. To add the record to the database, see L<"insert">. + +=cut + +sub table { 'part_ac_field'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=item delete + +Deletes this record from the database. If there is an error, returns the +error, otherwise returns false. + +=item replace OLD_RECORD + +Replaces OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=item check + +Checks all fields to make sure this is a valid record. If there is an error, +returns the error, otherwise returns false. Called by the insert and replace +methods. + +=cut + +sub check { + my $self = shift; + my $error = ''; + + $self->name =~ /^([a-z0-9_\-\.]{1,15})$/i + or return "Invalid field name for part_ac_field"; + + ''; #no error +} + + +=back + +=head1 VERSION + +$Id: + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, schema.html +from the base documentation. + +=cut + +1; + diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index bc6a4d735..69cd8058b 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -839,6 +839,9 @@ tie my %sqlmail_options, 'Tie::IxHash', }, + 'svc_broadband' => { + }, + ); =back diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm new file mode 100755 index 000000000..ab92fb3d7 --- /dev/null +++ b/FS/FS/svc_broadband.pm @@ -0,0 +1,295 @@ +package FS::svc_broadband; + +use strict; +use vars qw(@ISA $conf); +#use FS::Record qw( qsearch qsearchs ); +use FS::Record qw( qsearchs qsearch dbh ); +use FS::svc_Common; +use FS::cust_svc; +use NetAddr::IP; + +@ISA = qw( FS::svc_Common ); + +$FS::UID::callback{'FS::svc_broadband'} = sub { + $conf = new FS::Conf; +}; + +=head1 NAME + +FS::svc_broadband - Object methods for svc_broadband records + +=head1 SYNOPSIS + + use FS::svc_broadband; + + $record = new FS::svc_broadband \%hash; + $record = new FS::svc_broadband { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + + $error = $record->suspend; + + $error = $record->unsuspend; + + $error = $record->cancel; + +=head1 DESCRIPTION + +An FS::svc_broadband object represents a 'broadband' Internet connection, such +as a DSL, cable modem, or fixed wireless link. These services are assumed to +have the following properties: + +=over 2 + +=item +The network consists of one or more 'Access Concentrators' (ACs), such as +DSLAMs or wireless access points. (See L.) + +=item +Each AC provides connectivity to one or more contiguous blocks of IP addresses, +each described by a gateway address and a netmask. (See L.) + +=item +Each connection has one or more static IP addresses within one of these blocks. + +=item +The details of configuring routers and other devices are to be handled by a +site-specific L subclass. + +=back + +FS::svc_broadband inherits from FS::svc_Common. The following fields are +currently supported: + +=over 4 + +=item svcnum - primary key + +=item +actypenum - access concentrator type; see L. This is included here +so that a part_svc can specifically be a 'wireless' or 'DSL' service by +designating actypenum as a fixed field. It does create a redundant functional +dependency between this table and ac_type, in that the matching ac_type could +be found by looking up the IP address in ac_block and then finding the block's +AC, but part_svc can't do that, and we don't feel like hacking it so that it +can. + +=item +speed_up - maximum upload speed, in bits per second. If set to zero, upload +speed will be unlimited. Exports that do traffic shaping should handle this +correctly, and not blindly set the upload speed to zero and kill the customer's +connection. + +=item +speed_down - maximum download speed, as above + +=item +ip_addr - the customer's IP address. If the customer needs more than one IP +address, set this to the address of the customer's router. As a result, the +customer's router will have the same address for both it's internal and external +interfaces thus saving address space. This has been found to work on most NAT +routers available. + +=item +ip_netmask - the customer's netmask, as a single integer in the range 0-32. +(E.g. '24', not '255.255.255.0'. We assume that address blocks are contiguous.) +This should be 32 unless the customer has multiple IP addresses. + +=item +mac_addr - the MAC address of the customer's router or other device directly +connected to the network, if needed. Some systems (e.g. DHCP, MAC address-based +access control) may need this. If not, you may leave it blank. + +=item +location - a human-readable description of the location of the connected site, +such as its address. This should not be used for billing or contact purposes; +that information is stored in L. + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new svc_broadband. To add the record to the database, see +L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to. You can ask the object for a copy with the I method. + +=cut + +sub table { 'svc_broadband'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +The additional fields pkgnum and svcpart (see L) should be +defined. An FS::cust_svc record will be created and inserted. + +=cut + +# sub insert {} +# Standard FS::svc_Common::insert +# (any necessary Deep Magic is handled by exports) + +=item delete + +Delete this record from the database. + +=cut + +# Standard FS::svc_Common::delete + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=cut + +# Standard FS::svc_Common::replace +# Notice a pattern here? + +=item suspend + +Called by the suspend method of FS::cust_pkg (see L). + +=item unsuspend + +Called by the unsuspend method of FS::cust_pkg (see L). + +=item cancel + +Called by the cancel method of FS::cust_pkg (see L). + +=item check + +Checks all fields to make sure this is a valid broadband service. If there is +an error, returns the error, otherwise returns false. Called by the insert +and replace methods. + +=cut + +sub check { + my $self = shift; + my $x = $self->setfixed; + + return $x unless ref($x); + + my $error = + $self->ut_numbern('svcnum') + || $self->ut_foreign_key('actypenum', 'ac_type', 'actypenum') + || $self->ut_number('speed_up') + || $self->ut_number('speed_down') + || $self->ut_ip('ip_addr') + || $self->ut_numbern('ip_netmask') + || $self->ut_textn('mac_addr') + || $self->ut_textn('location') + ; + return $error if $error; + + if($self->speed_up < 0) { return 'speed_up must be positive'; } + if($self->speed_down < 0) { return 'speed_down must be positive'; } + + # This should catch errors in the ip_addr and ip_netmask. If it doesn't, + # they'll almost certainly not map into a valid block anyway. + my $self_addr = new NetAddr::IP ($self->ip_addr, $self->ip_netmask); + return 'Cannot parse address: ' . $self->ip_addr . '/' . $self->ip_netmask unless $self_addr; + + my @block = grep { + my $block_addr = new NetAddr::IP ($_->ip_gateway, $_->ip_netmask); + if ($block_addr->contains($self_addr)) { $_ }; + } qsearch( 'ac_block', { acnum => $self->acnum }); + + if(scalar @block == 0) { + return 'Block not found for address '.$self->ip_addr.' in actype '.$self->actypenum; + } elsif(scalar @block > 1) { + return 'ERROR: Intersecting blocks found for address '.$self->ip_addr.' :'. + join ', ', map {$_->ip_addr . '/' . $_->ip_netmask} @block; + } + # OK, we've found a valid block. We don't actually _do_ anything with it, though; we + # just take comfort in the knowledge that it exists. + + # A simple qsearchs won't work here. Since we can assign blocks to customers, + # we have to make sure the new address doesn't fall within someone else's + # block. Ugh. + + my @conflicts = grep { + my $cust_addr = new NetAddr::IP($_->ip_addr, $_->ip_netmask); + if (($cust_addr->contains($self_addr)) and + ($_->svcnum ne $self->svcnum)) { $_; }; + } qsearch('svc_broadband', {}); + + if (scalar @conflicts > 0) { + return 'Address in use by existing service'; + } + + # Are we trying to use a network, broadcast, or the AC's address? + foreach (qsearch('ac_block', { acnum => $self->acnum })) { + my $block_addr = new NetAddr::IP($_->ip_gateway, $_->ip_netmask); + if ($block_addr->network->addr eq $self_addr->addr) { + return 'Address is network address for block '. $block_addr->network; + } + if ($block_addr->broadcast->addr eq $self_addr->addr) { + return 'Address is broadcast address for block '. $block_addr->network; + } + if ($block_addr->addr eq $self_addr->addr) { + return 'Address belongs to the access concentrator: '. $block_addr->addr; + } + } + + ''; #no error +} + +=item ac_block + +Returns the FS::ac_block record (i.e. the address block) for this broadband service. + +=cut + +sub ac_block { + my $self = shift; + my $self_addr = new NetAddr::IP ($self->ip_addr, $self->ip_netmask); + + foreach my $block (qsearch( 'ac_block', {} )) { + my $block_addr = new NetAddr::IP ($block->ip_addr, $block->ip_netmask); + if($block_addr->contains($self_addr)) { return $block; } + } + return ''; +} + +=item ac_type + +Returns the FS::ac_type record for this broadband service. + +=cut + +sub ac_type { + my $self = shift; + return qsearchs('ac_type', { actypenum => $self->actypenum }); +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, +L, schema.html from the base documentation. + +=cut + +1; + diff --git a/bin/fs-setup b/bin/fs-setup index 9522ce370..81f1c26b0 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.96 2002-07-06 12:13:49 ivan Exp $ +# $Id: fs-setup,v 1.97 2002-09-09 23:01:36 khoff Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -1023,7 +1023,77 @@ sub tables_hash_hack { 'index' => [], }, + 'ac_type' => { + 'columns' => [ + 'actypenum', 'int', '', '', + 'actypename', 'varchar', '', 15, + ], + 'primary_key' => 'actypenum', + 'unique' => [], + 'index' => [], + }, + + 'ac' => { + 'columns' => [ + 'acnum', 'int', '', '', + 'actypenum', 'int', '', '', + 'acname', 'varchar', '', 15, + ], + 'primary_key' => 'acnum', + 'unique' => [], + 'index' => [], + }, + + 'part_ac_field' => { + 'columns' => [ + 'acfieldpart', 'int', '', '', + 'actypenum', 'int', '', '', + 'name', 'varchar', '', 15, + 'ut_type', 'varchar', '', 15, + ], + 'primary_key' => 'acfieldpart', + 'unique' => [], + 'index' => [], + }, + + 'ac_field' => { + 'columns' => [ + 'acfieldpart', 'int', '', '', + 'acnum', 'int', '', '', + 'value', 'varchar', '', 127, + ], + 'primary_key' => '', + 'unique' => [ [ 'acfieldpart', 'acnum' ] ], + 'index' => [], + }, + + 'ac_block' => { + 'columns' => [ + 'acnum', 'int', '', '', + 'ip_gateway', 'char', '', 15, + 'ip_netmask', 'int', '', '', + ], + 'primary_key' => '', + 'unique' => [], + 'index' => [], + }, + 'svc_broadband' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'actypenum', 'int', '', '', + 'speed_up', 'int', '', '', + 'speed_down', 'int', '', '', + 'acnum', 'int', '', '', + 'ip_addr', 'char', '', 15, + 'ip_netmask', 'int', '', '', + 'mac_addr', 'char', '', 17, + 'location', 'varchar', '', 127, + ], + 'primary_key' => 'svcnum', + 'unique' => [], + 'index' => [], + }, ); diff --git a/htetc/global.asa b/htetc/global.asa index d04a5edbf..3c8380fd4 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -46,6 +46,12 @@ use FS::svc_acct_sm; use FS::svc_domain; use FS::svc_forward; use FS::svc_www; +use FS::ac_type; +use FS::ac; +use FS::part_ac_field; +use FS::ac_field; +use FS::ac_block; +use FS::svc_broadband; use FS::type_pkgs; use FS::part_export; use FS::part_export_option; diff --git a/httemplate/browse/ac.cgi b/httemplate/browse/ac.cgi new file mode 100755 index 000000000..0ae138d3b --- /dev/null +++ b/httemplate/browse/ac.cgi @@ -0,0 +1,57 @@ + +<%= header('Access Concentrator Listing', menubar( + 'Main Menu' => $p, + 'Access Concentrator Types' => $p. 'browse/ac_type.cgi', +)) %> +
+Add a new Access Concentrator

+ +<%= table() %> + + AC + AC Type + Fields + Network/Mask + +<% + +foreach my $ac ( qsearch('ac',{}) ) { + my($hashref)=$ac->hashref; + my($actypenum)=$hashref->{actypenum}; + my($ac_type)=qsearchs('ac_type',{'actypenum'=>$actypenum}); + my($actypename)=$ac_type->getfield('actypename'); + print < + + $hashref->{acnum} + + $hashref->{acname} + $actypename + +END + + foreach my $ac_field ( qsearch('ac_field', { acnum => $hashref->{acnum} }) ) { + my $part_ac_field = qsearchs('part_ac_field', + { acfieldpart => $ac_field->getfield('acfieldpart') }); + print $part_ac_field->getfield('name') . ' '; + print $ac_field->getfield('value') . '
'; + } + print ''; + + foreach (qsearch('ac_block', { acnum => $hashref->{acnum} })) { + my $net_addr = new NetAddr::IP($_->getfield('ip_gateway'), + $_->getfield('ip_netmask')); + print $net_addr->network->addr . '/' . $net_addr->network->mask . '
'; + } + + print "\n"; + +} + +print < + + +END + +%> diff --git a/httemplate/browse/ac_type.cgi b/httemplate/browse/ac_type.cgi new file mode 100755 index 000000000..0ad8271d3 --- /dev/null +++ b/httemplate/browse/ac_type.cgi @@ -0,0 +1,47 @@ + +<% + +print header('Access Concentrator Types', menubar( + 'Main Menu' => $p, + 'Access Concentrators' => $p. 'browse/ac.cgi', +)) %> +
+Add new AC Type

+<%= table() %> + + + Type + Fields + + +<% +foreach my $ac_type ( qsearch('ac_type',{}) ) { + my($hashref)=$ac_type->hashref; + print < + + $hashref->{actypenum} + + $hashref->{actypename} + +END + + foreach ( qsearch('part_ac_field', { actypenum => $hashref->{actypenum} }) ) { + my ($part_ac_field) = $_->hashref; + print $part_ac_field->{'name'} . + ' (' . $part_ac_field->{'ut_type'} . ')
'; + } + +} + +print < + + + + + + +END + +%> diff --git a/httemplate/edit/ac.cgi b/httemplate/edit/ac.cgi new file mode 100755 index 000000000..86b05a4a1 --- /dev/null +++ b/httemplate/edit/ac.cgi @@ -0,0 +1,163 @@ + +<% + +my($ac); +if ( $cgi->param('error') ) { + $ac = new FS::ac ( { + map { $_, scalar($cgi->param($_)) } fields('ac') + } ); +} elsif ( $cgi->keywords ) { #editing + my( $query ) = $cgi->keywords; + $query =~ /^(\d+)$/; + $ac=qsearchs('ac',{'acnum'=>$1}); +} else { #adding + $ac = new FS::ac {}; +} +my $action = $ac->acnum ? 'Edit' : 'Add'; +my $hashref = $ac->hashref; + +print header("$action Access Concentrator", menubar( + 'Main Menu' => "$p", + 'View all access concentrators' => "${p}browse/ac.cgi", +)); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print '
', + qq!!, + "Access Concentrator #", $hashref->{acnum} ? $hashref->{acnum} : "(NEW)"; + +print < + + Access Concentrator + + + + +END + + +if (! $ac->acnum) { + print < + Access Concentrator Type + !; +} + +print qq!

!; + +if ($hashref->{acnum}) { + print table(); + print < + + Field Name + Field Value + +END + + #my @ac_fields = qsearch('ac_field', { acnum => $hashref->{acnum} }); + my @ac_fields = $ac->ac_field; + foreach (@ac_fields) { + print qq!\n!; + my $part_ac_field = qsearchs('part_ac_field', + { acfieldpart => $_->getfield('acfieldpart') }); + print '' . $part_ac_field->getfield('name') . + '' . $_->getfield('value') . ''; + print "\n"; + } + + print '
'; + print < + + + + (NEW) + + + + + + +END + +} + +if ($hashref->{acnum}) { + + print qq!

IP Address Blocks:
! . table() . + qq!Network/Mask! . + qq!Gateway AddressMask length\n!; + + foreach (qsearch('ac_block', { acnum => $hashref->{acnum} })) { + my $ip_addr = new NetAddr::IP($_->getfield('ip_gateway'), + $_->getfield('ip_netmask')); + print qq!! . $ip_addr->network->addr() . '/' . + $ip_addr->network->mask() . qq!!; + + print qq!! . $_->getfield('ip_gateway') . qq!\n! . + qq!! . $_->getfield('ip_netmask') . qq!!; + + } + + print '
'; + print < + + + + (NEW) + + + + + + + + +END + +} + +print < + +END + +%> diff --git a/httemplate/edit/ac_type.cgi b/httemplate/edit/ac_type.cgi new file mode 100755 index 000000000..ccc3d579c --- /dev/null +++ b/httemplate/edit/ac_type.cgi @@ -0,0 +1,106 @@ + +<% + +my $ac_type; +if ( $cgi->param('error') ) { + $ac_type = new FS::ac_type ( { + map { $_, scalar($cgi->param($_)) } fields('ac_type') + } ); +} elsif ( $cgi->keywords ) { #editing + my($query)=$cgi->keywords; + $query =~ /^(\d+)$/; + $ac_type=qsearchs('ac_type',{'actypenum'=>$1}); +} else { #adding + $ac_type = new FS::ac_type {}; +} +my $action = $ac_type->actypenum ? 'Edit' : 'Add'; +my $hashref = $ac_type->hashref; + +my @ut_types = qw( float number text alpha anything ip domain ); + +my $p1 = popurl(1); +print header("$action Access Concentrator Type", menubar( + 'Main Menu' => popurl(2), + 'View all Access Concentrator types' => popurl(2). "browse/ac_type.cgi", +)); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print qq!
!; + +#display + +print qq!!, + "AC Type #", $hashref->{actypenum} ? $hashref->{actypenum} : "(NEW)"; + +print < +AC Type Name + + +TROZ + +print qq!
!; + + +if ($hashref->{actypenum}) { + print qq!
Available fields:
! . table(); + + print qq! Field nameField type!; + + my @part_ac_field = qsearch ( 'part_ac_field', + { actypenum => $hashref->{actypenum} } ); + foreach ( @part_ac_field ) { + my $pf_hashref = $_->hashref; + print < + $pf_hashref->{acfieldpart} + $pf_hashref->{name} + $pf_hashref->{ut_type} + +END + } + + my $name, $ut_type = ''; + if ($cgi->param('error')) { + $name = $cgi->param('name'); + $ut_type = $cgi->param('ut_type'); + } + + print < + + (NEW) + + + + + + + + + + +END + +} + +%> + + + + diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 4ccb770fb..a23107a40 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -53,6 +53,7 @@ Services are items you offer to your customers.
  • svc_acct_sm - deprecated (use svc_forward for new installations) Virtual domain mail aliasing.
  • svc_forward - mail forwarding
  • svc_www - Virtual domain website +
  • svc_broadband - Broadband/High-speed Internet service @@ -122,11 +123,21 @@ my %defs = ( #'recnum' => '', #'usersvc' => '', }, + 'svc_broadband' => { + 'actypenum' => 'This is the actypenum that refers to the type of AC that can be provisioned for this service. This field must be set fixed.', + 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.', + 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.', + 'acnum' => 'acnum of a specific AC that this service is restricted to. Not required', + 'ip_addr' => 'IP address. Leave blank for automatic assignment.', + 'ip_netmask' => 'Mask length, aka. netmask bits. (Eg. 255.255.255.0 == 24)', + 'mac_addr' => 'MAC address which is used by some ACs for access control. Specified by 6 colon seperated hex octets. (Eg. 00:00:0a:bc:1a:2b)', + 'location' => 'Defines the physically location at which this service was installed. This is not necessarily the billing address', + }, ); my @dbs = $hashref->{svcdb} ? ( $hashref->{svcdb} ) - : qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ); + : qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www svc_broadband ); tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } @dbs; my $widget = new HTML::Widgets::SelectLayers( diff --git a/httemplate/edit/process/ac.cgi b/httemplate/edit/process/ac.cgi new file mode 100755 index 000000000..fc434a807 --- /dev/null +++ b/httemplate/edit/process/ac.cgi @@ -0,0 +1,28 @@ +<% + +my $acnum = $cgi->param('acnum'); + +my $old = qsearchs('ac',{'acnum'=>$acnum}) if $acnum; + +my $new = new FS::ac ( { + map { + $_, scalar($cgi->param($_)); + } fields('ac') +} ); + +my $error = ''; +if ( $acnum ) { + $error = $new->replace($old); +} else { + $error = $new->insert; + $acnum=$new->getfield('acnum'); +} + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "ac.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(3). "browse/ac.cgi"); +} + +%> diff --git a/httemplate/edit/process/ac_block.cgi b/httemplate/edit/process/ac_block.cgi new file mode 100755 index 000000000..b1c3c726b --- /dev/null +++ b/httemplate/edit/process/ac_block.cgi @@ -0,0 +1,21 @@ +<% + +my $new = new FS::ac_block ( { + map { + $_, scalar($cgi->param($_)); + } fields('ac_block') +} ); + +my $error = ''; +$error = $new->check; + +unless ( $error ) { $error = $new->insert; } + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "ac.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(2). "ac.cgi?". $cgi->param('acnum')); +} + +%> diff --git a/httemplate/edit/process/ac_field.cgi b/httemplate/edit/process/ac_field.cgi new file mode 100755 index 000000000..2bfe3312f --- /dev/null +++ b/httemplate/edit/process/ac_field.cgi @@ -0,0 +1,21 @@ +<% + +my $new = new FS::ac_field ( { + map { + $_, scalar($cgi->param($_)); + } fields('ac_field') +} ); + +my $error = ''; +$error = $new->check; + +unless ( $error ) { $error = $new->insert; } + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "ac.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(2). "ac.cgi?". $cgi->param('acnum')); +} + +%> diff --git a/httemplate/edit/process/ac_type.cgi b/httemplate/edit/process/ac_type.cgi new file mode 100755 index 000000000..ca232ba58 --- /dev/null +++ b/httemplate/edit/process/ac_type.cgi @@ -0,0 +1,28 @@ +<% + +my $actypenum = $cgi->param('actypenum'); + +my $old = qsearchs('ac_type',{'actypenum'=>$actypenum}) if $actypenum; + +my $new = new FS::ac_type ( { + map { + $_, scalar($cgi->param($_)); + } fields('ac_type') +} ); + +my $error = ''; +if ( $actypenum ) { + $error = $new->replace($old); +} else { + $error = $new->insert; + $actypenum=$new->getfield('actypenum'); +} + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "ac_type.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(3). "browse/ac_type.cgi"); +} + +%> diff --git a/httemplate/edit/process/part_ac_field.cgi b/httemplate/edit/process/part_ac_field.cgi new file mode 100755 index 000000000..38ad586f7 --- /dev/null +++ b/httemplate/edit/process/part_ac_field.cgi @@ -0,0 +1,21 @@ +<% + +my $new = new FS::part_ac_field ( { + map { + $_, scalar($cgi->param($_)); + } fields('part_ac_field') +} ); + +my $error = ''; +$error = $new->check; + +unless ( $error ) { $error = $new->insert; } + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "ac_type.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(2). "ac_type.cgi?". $cgi->param('actypenum')); +} + +%> diff --git a/httemplate/edit/process/part_svc.cgi b/httemplate/edit/process/part_svc.cgi index 859670b17..69e8ac2fa 100755 --- a/httemplate/edit/process/part_svc.cgi +++ b/httemplate/edit/process/part_svc.cgi @@ -17,7 +17,7 @@ my $new = new FS::part_svc ( { push @fields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge map { ( $svcdb.'__'.$_, $svcdb.'__'.$_.'_flag' ) } @fields; } grep defined( $FS::Record::dbdef->table($_) ), - qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ) + qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www svc_broadband ) ) } ); diff --git a/httemplate/edit/process/svc_broadband.cgi b/httemplate/edit/process/svc_broadband.cgi new file mode 100644 index 000000000..fd7ba20d5 --- /dev/null +++ b/httemplate/edit/process/svc_broadband.cgi @@ -0,0 +1,45 @@ +<% + +$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +my $svcnum = $1; + +my $old; +if ( $svcnum ) { + $old = qsearchs('svc_broadband', { 'svcnum' => $svcnum } ) + or die "fatal: can't find broadband service (svcnum $svcnum)!"; +} else { + $old = ''; +} + +my $new = new FS::svc_broadband ( { + map { + ($_, scalar($cgi->param($_))); + } ( fields('svc_broadband'), qw( pkgnum svcpart ) ) +} ); + +unless ( $new->ip_addr ) { + $new->ip_addr(join('.', (map $cgi->param('ip_addr_'.$_), (a..d)))); +} + +unless ( $new->mac_addr) { + $new->mac_addr(join(':', (map $cgi->param('mac_addr_'.$_), (a..f)))); +} + +my $error; +if ( $svcnum ) { + $error = $new->replace($old); +} else { + $error = $new->insert; + $svcnum = $new->svcnum; +} + +if ( $error ) { + $cgi->param('error', $error); + $cgi->param('ip_addr', $new->ip_addr); + $cgi->param('mac_addr', $new->mac_addr); + print $cgi->redirect(popurl(2). "svc_broadband.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(3). "view/svc_broadband.cgi?" . $svcnum ); +} + +%> diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi new file mode 100644 index 000000000..d8a1f7a2a --- /dev/null +++ b/httemplate/edit/svc_broadband.cgi @@ -0,0 +1,219 @@ + +<% + +my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_broadband ); +if ( $cgi->param('error') ) { + $svc_broadband = new FS::svc_broadband ( { + map { $_, scalar($cgi->param($_)) } fields('svc_broadband') + } ); + $svcnum = $svc_broadband->svcnum; + $pkgnum = $cgi->param('pkgnum'); + $svcpart = $cgi->param('svcpart'); + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; +} else { + my($query) = $cgi->keywords; + if ( $query =~ /^(\d+)$/ ) { #editing + $svcnum=$1; + $svc_broadband=qsearchs('svc_broadband',{'svcnum'=>$svcnum}) + or die "Unknown (svc_broadband) svcnum!"; + + my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) + or die "Unknown (cust_svc) svcnum!"; + + $pkgnum=$cust_svc->pkgnum; + $svcpart=$cust_svc->svcpart; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; + + } else { #adding + + $svc_broadband = new FS::svc_broadband({}); + + foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart + $pkgnum=$1 if /^pkgnum(\d+)$/; + $svcpart=$1 if /^svcpart(\d+)$/; + } + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; + + $svcnum=''; + + #set fixed and default fields from part_svc + foreach my $part_svc_column ( + grep { $_->columnflag } $part_svc->all_part_svc_column + ) { + $svc_broadband->setfield( $part_svc_column->columnname, + $part_svc_column->columnvalue, + ); + } + + } +} +my $action = $svc_broadband->svcnum ? 'Edit' : 'Add'; + +my @ac_list; + +if ($pkgnum) { + + unless ($svc_broadband->actypenum) {die "actypenum must be set fixed";}; + @ac_list = qsearch('ac', { actypenum => $svc_broadband->getfield('actypenum') }); + +} elsif ( $action eq 'Edit' ) { + + #Nothing? + +} else { + die "\$action eq Add, but \$pkgnum is null!\n"; +} + + +my $p1 = popurl(1); +print header("Broadband Service $action", ''); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print qq!
    !; + +#display + + + +#svcnum +print qq!!; +print qq!Service #!, $svcnum ? $svcnum : "(NEW)", "

    "; + +#pkgnum +print qq!!; + +#svcpart +print qq!!; + +#actypenum +print ''; + + +print &ntable("#cccccc",2) . qq!AC!; + +#acnum +if (( $part_svc->part_svc_column('acnum')->columnflag eq 'F' ) or + ( !$pkgnum )) { + + my $ac = qsearchs('ac', { acnum => $svc_broadband->acnum }); + my ($acnum, $acname) = ($ac->acnum, $ac->acname); + + print qq!! . + qq!${acnum}: ${acname}!; + +} else { + + my @ac_list = qsearch('ac', { actypenum => $svc_broadband->actypenum }); + print qq!! . + qq!${speed_down}Kbps!; +} else { + print qq!! . + qq!Kbps!; +} + +print 'Upload speed'; +if ( $part_svc->part_svc_column('speed_up')->columnflag eq 'F' ) { + print qq!! . + qq!${speed_up}Kbps!; +} else { + print qq!! . + qq!Kbps!; +} + +#ip_addr & ip_netmask +#We're assuming that ip_netmask is fixed if ip_addr is fixed. +#If it isn't, well, what the heck are you doing!?!? + +my ($ip_addr, $ip_netmask) = ($svc_broadband->ip_addr, + $svc_broadband->ip_netmask); + +print 'IP address/Mask'; +if ( $part_svc->part_svc_column('ip_addr')->columnflag eq 'F' ) { + print qq!! . + qq!! . + qq!${ip_addr}/${ip_netmask}!; +} else { + $ip_addr =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; + print <. + . + . + / + + + +

    Leave the IP address and netmask blank for automatic assignment of a /32 address. Specifing the netmask and not the address will force assignment of a larger block.

    + +END +} + +#mac_addr +my $mac_addr = $svc_broadband->mac_addr; + +unless (( $part_svc->part_svc_column('mac_addr')->columnflag eq 'F' ) and + ( $mac_addr eq '' )) { + print 'MAC Address'; + if ( $part_svc->part_svc_column('mac_addr')->columnflag eq 'F' ) { #Why? + print qq!! . + qq!${mac_addr}!; + } else { + #Ewwww + $mac_addr =~ /^([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2})$/i; + print <: + : + : + : + : + + +END + + } +} + +#location +my $location = $svc_broadband->location; + +print 'Location'; +if ( $part_svc->part_svc_column('location')->columnflag eq 'F' ) { + print qq!
    ${location}
    !; +} else { + print qq!!; +} + +print '
    '; + +print < + + +END +%> diff --git a/httemplate/index.html b/httemplate/index.html index dce020b1b..2cb707326 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -194,6 +194,10 @@ into counties and assign different tax rates to each.
  • View/Edit Access Numbers - Points of Presence +
  • View/Edit AC Types + - Broadband service access concentrator types. +
  • View/Edit AC + - Broadband service access concentrators.
  • View/Edit invoice events - Actions for overdue invoices
  • View/Edit message catalog - Change error messages and other customizable labels. diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi new file mode 100644 index 000000000..156edfaec --- /dev/null +++ b/httemplate/view/svc_broadband.cgi @@ -0,0 +1,75 @@ + +<% + +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +my $svcnum = $1; +my $svc_broadband = qsearchs( 'svc_broadband', { 'svcnum' => $svcnum } ) + or die "svc_broadband: Unknown svcnum $svcnum"; + +#false laziness w/all svc_*.cgi +my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); +my $pkgnum = $cust_svc->getfield('pkgnum'); +my($cust_pkg, $custnum); +if ($pkgnum) { + $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); + $custnum = $cust_pkg->custnum; +} else { + $cust_pkg = ''; + $custnum = ''; +} +#eofalse + +my $ac = qsearchs('ac', { acnum => $svc_broadband->getfield('acnum') }); + +my ( + $acname, + $acnum, + $speed_down, + $speed_up, + $ip_addr, + $ip_netmask, + $mac_addr, + $location + ) = ( + $ac->getfield('acname'), + $ac->getfield('acnum'), + $svc_broadband->getfield('speed_down'), + $svc_broadband->getfield('speed_up'), + $svc_broadband->getfield('ip_addr'), + $svc_broadband->getfield('ip_netmask'), + $svc_broadband->getfield('mac_addr'), + $svc_broadband->getfield('location') + ); + +print header('Broadband Service View', menubar( + ( ( $custnum ) + ? ( "View this package (#$pkgnum)" => "${p}view/cust_pkg.cgi?$pkgnum", + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + ) + : ( "Cancel this (unaudited) website" => + "${p}misc/cancel-unaudited.cgi?$svcnum" ) + ), + "Main menu" => $p, +)). + qq!Edit this information
    !. + ntable("#cccccc"). ''. ntable("#cccccc",2). + qq!Service number!. + qq!$svcnum!. + qq!AC!. + qq!$acnum: $acname!. + qq!Download Speed!. + qq!$speed_down!. + qq!Upload Speed!. + qq!$speed_up!. + qq!IP Address/Mask!. + qq!$ip_addr/$ip_netmask!. + qq!MAC Address!. + qq!$mac_addr!. + qq!Location!. + qq!
    $location
    !. + ''. + '
    '. joblisting({'svcnum'=>$svcnum}, 1). + '' +; +%> -- cgit v1.2.1 From 88357d0c76bd7c257d4d87da0a59f8814f925049 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 10 Sep 2002 00:37:36 +0000 Subject: doc: need Net::SSH 0.07 for 1.4.1 --- httemplate/docs/upgrade9.html | 1 + 1 file changed, 1 insertion(+) diff --git a/httemplate/docs/upgrade9.html b/httemplate/docs/upgrade9.html index fff1d8690..efd25887d 100644 --- a/httemplate/docs/upgrade9.html +++ b/httemplate/docs/upgrade9.html @@ -9,5 +9,6 @@
  • Run make aspdocs or make masondocs.
  • Copy aspdocs/ or masondocs/ to your web server's document space.
  • Run make install-perl-modules. +
  • Install Net::SSH minimum version 0.07
  • Restart Apache and freeside-queued. -- cgit v1.2.1 From 27b1e8e41b7d4ace60b286ec02a171009aee83f2 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 10 Sep 2002 03:31:00 +0000 Subject: Business::OnlinePaymet fix for processors w/o order numbers, like VirtualNet --- FS/FS/cust_bill.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 5e041ea59..d49657e2e 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -674,7 +674,9 @@ sub realtime_card { if ( $transaction->is_success() && $action2 ) { my $auth = $transaction->authorization; - my $ordernum = $transaction->order_number; + my $ordernum = $transaction->can('order_number') + ? $transaction->order_number + : ''; #warn "********* $auth ***********\n"; #warn "********* $ordernum ***********\n"; @@ -1112,7 +1114,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.41 2002-09-05 16:51:49 ivan Exp $ +$Id: cust_bill.pm,v 1.42 2002-09-10 03:31:00 ivan Exp $ =head1 BUGS -- cgit v1.2.1 From 93773ff8f4e002cb70a07cb4f7956279eb630acf Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 11 Sep 2002 09:09:23 +0000 Subject: mason warnings --- httemplate/search/cust_main.cgi | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 586f8d991..0a98b1891 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -82,22 +82,22 @@ if ( $cgi->param('browse') if ( driver_name eq 'mysql' ) { - my $query = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM - SELECT cust_pkg.custnum,COUNT(*) as count - FROM cust_pkg,cust_main - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 ) - GROUP BY cust_pkg.custnum"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; - $query = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM - SELECT cust_pkg.custnum,COUNT(*) as count - FROM cust_pkg,cust_main - WHERE cust_pkg.custnum = cust_main.custnum - GROUP BY cust_pkg.custnum"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + my $sql = "CREATE TEMPORARY TABLE temp1_$$ TYPE=MYISAM + SELECT cust_pkg.custnum,COUNT(*) as count + FROM cust_pkg,cust_main + WHERE cust_pkg.custnum = cust_main.custnum + AND ( cust_pkg.cancel IS NULL + OR cust_pkg.cancel = 0 ) + GROUP BY cust_pkg.custnum"; + my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; + $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; + $sql = "CREATE TEMPORARY TABLE temp2_$$ TYPE=MYISAM + SELECT cust_pkg.custnum,COUNT(*) as count + FROM cust_pkg,cust_main + WHERE cust_pkg.custnum = cust_main.custnum + GROUP BY cust_pkg.custnum"; + $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; + $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; } if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me @@ -167,9 +167,9 @@ if ( $cgi->param('browse') "$ncancelled $orderby $limit" ); } if ( driver_name eq 'mysql' ) { - $query = "DROP TABLE temp1_$$,temp2_$$;"; - my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; - $sth->execute or die "Error executing \"$query\": ". $sth->errstr; + my $sql = "DROP TABLE temp1_$$,temp2_$$;"; + my $sth = dbh->prepare($sql) or die dbh->errstr. " preparing $sql"; + $sth->execute or die "Error executing \"$sql\": ". $sth->errstr; } @cust_main = @just_cust_main; @@ -457,7 +457,7 @@ sub custnumsearch { my $custnum = $cgi->param('custnum_text'); $custnum =~ s/\D//g; $custnum =~ /^(\d{1,23})$/ or eidiot "Illegal customer number\n"; - my $custnum = $1; + $custnum = $1; [ qsearchs('cust_main', { 'custnum' => $custnum } ) ]; } -- cgit v1.2.1 From 1a4ba4fc23449a4bb189c8e7a69a10a2a793efc3 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 11 Sep 2002 09:28:13 +0000 Subject: mason error --- httemplate/browse/svc_acct_pop.cgi | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/httemplate/browse/svc_acct_pop.cgi b/httemplate/browse/svc_acct_pop.cgi index e890f07bf..8d35cb56a 100755 --- a/httemplate/browse/svc_acct_pop.cgi +++ b/httemplate/browse/svc_acct_pop.cgi @@ -1,9 +1,5 @@ -<% - -print header('Access Number Listing', menubar( - 'Main Menu' => $p, -)) %> +<%= header('Access Number Listing', menubar( 'Main Menu' => $p )) %> Points of Presence

    Add new Access Number

    <%= table() %> -- cgit v1.2.1 From 3548c2951a51ece84687e3bfb5e435008191a713 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Sep 2002 09:27:14 +0000 Subject: skip empty expiration dates --- FS/bin/freeside-expiration-alerter | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FS/bin/freeside-expiration-alerter b/FS/bin/freeside-expiration-alerter index ee3c1fb92..5399f6d22 100755 --- a/FS/bin/freeside-expiration-alerter +++ b/FS/bin/freeside-expiration-alerter @@ -80,16 +80,18 @@ $alerter->compile() or die "can't compile template: Text::Template::ERROR"; # Now I can start looping foreach my $customer (@customers) { + my $paydate = $customer->getfield('paydate'); + next if $paydate =~ /^\s*$/; #skip empty expiration dates + my $custnum = $customer->getfield('custnum'); my $first = $customer->getfield('first'); my $last = $customer->getfield('last'); my $company = $customer->getfield('company'); my $payby = $customer->getfield('payby'); my $payinfo = $customer->getfield('payinfo'); - my $paydate = $customer->getfield('paydate'); my $daytime = $customer->getfield('daytime'); my $night = $customer->getfield('night'); - + my ($payyear,$paymonth,$payday) = split (/-/,$paydate); my $expire_time = timelocal(0,0,0,$payday,--$paymonth,$payyear); @@ -200,7 +202,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-expiration-alerter,v 1.3 2002-04-16 09:38:19 ivan Exp $ +$Id: freeside-expiration-alerter,v 1.4 2002-09-16 09:27:14 ivan Exp $ =head1 BUGS -- cgit v1.2.1 From bc7312f2a83c76674aa3478ba989d6f9fb7a5cb3 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Sep 2002 00:33:17 +0000 Subject: - "emailinvoiceauto" implementation rewritten to work properly, stop overwriting existing invoice destinations --- FS/FS/Conf.pm | 2 +- FS/FS/cust_bill.pm | 4 ++-- FS/FS/cust_main.pm | 25 ++++++++++++++++++------- FS/FS/svc_acct.pm | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index e93eaf3fc..e50cb29b9 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -369,7 +369,7 @@ httemplate/docs/config.html { 'key' => 'emailinvoiceauto', 'section' => 'billing', - 'description' => 'Automatically adds new accounts to the email invoice list upon customer creation', + 'description' => 'Automatically adds new accounts to the email invoice list', 'type' => 'checkbox', }, diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index d49657e2e..65c41d5c9 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -623,7 +623,7 @@ sub realtime_card { my @invoicing_list = grep { $_ ne 'POST' } $cust_main->invoicing_list; if ( $conf->exists('emailinvoiceauto') || ( $conf->exists('emailinvoiceonly') && ! @invoicing_list ) ) { - push @invoicing_list, $cust_main->default_invoicing_list; + push @invoicing_list, $cust_main->all_emails; } my $email = $invoicing_list[0]; @@ -1114,7 +1114,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.42 2002-09-10 03:31:00 ivan Exp $ +$Id: cust_bill.pm,v 1.43 2002-09-17 00:33:17 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index cfa6b8bb6..84fd3d150 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1584,7 +1584,6 @@ sub invoicing_list { } my %seen = map { $_->address => 1 } @cust_main_invoice; foreach my $address ( @{$arrayref} ) { - #unless ( grep { $address eq $_->address } @cust_main_invoice ) { next if exists $seen{$address} && $seen{$address}; $seen{$address} = 1; my $cust_main_invoice = new FS::cust_main_invoice ( { @@ -1626,24 +1625,36 @@ sub check_invoicing_list { ''; } -=item default_invoicing_list +=item set_default_invoicing_list -Sets the invoicing list to all accounts associated with this customer. +Sets the invoicing list to all accounts associated with this customer, +overwriting any previous invoicing list. =cut -sub default_invoicing_list { +sub set_default_invoicing_list { my $self = shift; - my @list = (); + $self->invoicing_list($self->all_emails); +} + +=item all_emails + +Returns the email addresses of all accounts provisioned for this customer. + +=cut + +sub all_emails { + my $self = shift; + my %list; foreach my $cust_pkg ( $self->all_pkgs ) { my @cust_svc = qsearch('cust_svc', { 'pkgnum' => $cust_pkg->pkgnum } ); my @svc_acct = map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } grep { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } @cust_svc; - push @list, map { $_->email } @svc_acct; + $list{$_}=1 foreach map { $_->email } @svc_acct; } - $self->invoicing_list(\@list); + keys %list; } =item invoicing_list_addpost diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 9032e20c1..f73ab82da 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -341,11 +341,20 @@ sub insert { return "queueing job (transaction rolled back): $error"; } - #welcome email my $cust_pkg = $self->cust_svc->cust_pkg; - my( $cust_main, $to ) = ( '', '' ); + my $cust_main = $cust_pkg->cust_main; + + my $cust_pkg = $self->cust_svc->cust_pkg; + + if ( $conf->exists('emailinvoiceauto') ) { + my @invoicing_list = $cust_main->invoicing_list; + push @invoicing_list, $self->email; + $cust_main->invoicing_list(@invoicing_list); + } + + #welcome email + my $to = ''; if ( $welcome_template && $cust_pkg ) { - my $cust_main = $cust_pkg->cust_main; my $to = join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list ); if ( $to ) { my $wqueue = new FS::queue { -- cgit v1.2.1 From 3999cc30d219a7ebf6db985d0904ffe42b79860e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Sep 2002 00:40:07 +0000 Subject: send_ftp doc fix --- FS/FS/cust_bill.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 65c41d5c9..52fc94235 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -443,23 +443,39 @@ first two fields (B and B) and the last five fields (B through B) are filled in. =item invnum - invoice number + =item custnum - customer number + =item _date - invoice date + =item charged - total invoice amount + =item first - customer first name + =item last - customer first name + =item company - company name + =item address1 - address line 1 + =item address2 - address line 1 + =item city + =item state + =item zip + =item country =item pkg - line item description -=item setup - line item setup fee (only or both of B and B will be defined) -=item recur - line item recurring fee (only or both of B and B will be defined) + +=item setup - line item setup fee (one or both of B and B will be defined) + +=item recur - line item recurring fee (one or both of B and B will be defined) + =item sdate - start date for recurring fee + =item edate - end date for recurring fee =back @@ -1114,7 +1130,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.43 2002-09-17 00:33:17 ivan Exp $ +$Id: cust_bill.pm,v 1.44 2002-09-17 00:40:07 ivan Exp $ =head1 BUGS -- cgit v1.2.1 From 3595c874f8e476e58b98b7ab6d86918d4dbb1d5c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Sep 2002 09:19:42 +0000 Subject: remove svc_acct_sm --- FS/FS.pm | 2 - FS/FS/InitHandler.pm | 1 - FS/FS/cust_pkg.pm | 14 +- FS/FS/part_export.pm | 2 - FS/FS/part_svc.pm | 27 +--- FS/FS/svc_acct.pm | 9 +- FS/FS/svc_acct_sm.pm | 260 -------------------------------- FS/MANIFEST | 2 - FS/t/svc_acct_sm.t | 5 - httemplate/docs/schema.dia | Bin 14414 -> 14438 bytes httemplate/docs/schema.html | 9 +- httemplate/edit/part_svc.cgi | 8 +- httemplate/edit/process/part_svc.cgi | 2 +- httemplate/edit/process/svc_acct_sm.cgi | 34 ----- httemplate/edit/svc_acct_sm.cgi | 178 ---------------------- httemplate/index.html | 1 - httemplate/misc/link.cgi | 1 - httemplate/search/svc_acct_sm.cgi | 84 ----------- httemplate/search/svc_acct_sm.html | 23 --- httemplate/search/svc_domain.cgi | 12 -- httemplate/view/svc_acct_sm.cgi | 58 ------- 21 files changed, 12 insertions(+), 720 deletions(-) delete mode 100644 FS/FS/svc_acct_sm.pm delete mode 100644 FS/t/svc_acct_sm.t delete mode 100755 httemplate/edit/process/svc_acct_sm.cgi delete mode 100755 httemplate/edit/svc_acct_sm.cgi delete mode 100755 httemplate/search/svc_acct_sm.cgi delete mode 100755 httemplate/search/svc_acct_sm.html delete mode 100755 httemplate/view/svc_acct_sm.cgi diff --git a/FS/FS.pm b/FS/FS.pm index 963c73548..c22557a2d 100644 --- a/FS/FS.pm +++ b/FS/FS.pm @@ -62,8 +62,6 @@ L - DNS zone entries L - Mail forwarding class -L - (Depreciated) Vitual mail alias class - L - Web virtual host class. L - Service definition class diff --git a/FS/FS/InitHandler.pm b/FS/FS/InitHandler.pm index 0216615da..5038cf352 100644 --- a/FS/FS/InitHandler.pm +++ b/FS/FS/InitHandler.pm @@ -52,7 +52,6 @@ sub handler { use FS::session; use FS::svc_acct; use FS::svc_acct_pop; - use FS::svc_acct_sm; use FS::svc_domain; use FS::svc_forward; use FS::svc_www; diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 12508e1aa..0c71435e1 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -14,7 +14,6 @@ use FS::pkg_svc; # setup } # because they load configuraion by setting FS::UID::callback (see TODO) use FS::svc_acct; -use FS::svc_acct_sm; use FS::svc_domain; use FS::svc_www; use FS::svc_forward; @@ -679,7 +678,7 @@ sub order { =head1 VERSION -$Id: cust_pkg.pm,v 1.23 2002-08-26 20:40:55 ivan Exp $ +$Id: cust_pkg.pm,v 1.24 2002-09-17 09:19:06 ivan Exp $ =head1 BUGS @@ -690,11 +689,12 @@ In sub order, the @pkgparts array (passed by reference) is clobbered. Also in sub order, no money is adjusted. Once FS::part_pkg defines a standard method to pass dates to the recur_prog expression, it should do so. -FS::svc_acct, FS::svc_acct_sm, and FS::svc_domain are loaded via 'use' at -compile time, rather than via 'require' in sub { setup, suspend, unsuspend, -cancel } because they use %FS::UID::callback to load configuration values. -Probably need a subroutine which decides what to do based on whether or not -we've fetched the user yet, rather than a hash. See FS::UID and the TODO. +FS::svc_acct, FS::svc_domain, FS::svc_www and FS::svc_forward are loaded via +'use' at compile time, rather than via 'require' in sub +{ setup, suspend, unsuspend, cancel } because they use %FS::UID::callback to +load configuration values. Probably need a subroutine which decides what to +do based on whether or not we've fetched the user yet, rather than a hash. +See FS::UID and the TODO. Now that things are transactional should the check in the insert method be moved to check ? diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 69cd8058b..647666b86 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -819,8 +819,6 @@ tie my %sqlmail_options, 'Tie::IxHash', }, - 'svc_acct_sm' => {}, - 'svc_forward' => { 'sqlmail' => { 'desc' => 'Real-time export to SQL-backed mail server', diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 959a3f887..7c6acdbcd 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -254,31 +254,6 @@ sub check { my @fields = eval { fields( $recref->{svcdb} ) }; #might die return "Unknown svcdb!" unless @fields; -##REPLACED BY part_svc_column -# 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 } @@ -325,7 +300,7 @@ sub part_export { =head1 VERSION -$Id: part_svc.pm,v 1.13 2002-04-11 22:05:31 ivan Exp $ +$Id: part_svc.pm,v 1.14 2002-09-17 09:19:06 ivan Exp $ =head1 BUGS diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index f73ab82da..bd348f8ed 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -18,11 +18,9 @@ use FS::UID qw( datasrc ); use FS::Conf; use FS::Record qw( qsearch qsearchs fields dbh ); use FS::svc_Common; -use Net::SSH; use FS::cust_svc; use FS::part_svc; use FS::svc_acct_pop; -use FS::svc_acct_sm; use FS::cust_main_invoice; use FS::svc_domain; use FS::raddb; @@ -410,11 +408,6 @@ The corresponding FS::cust_svc record will be deleted as well. sub delete { my $self = shift; - if ( defined( $FS::Record::dbdef->table('svc_acct_sm') ) ) { - return "Can't delete an account which has (svc_acct_sm) mail aliases!" - if $self->uid && qsearch( 'svc_acct_sm', { 'domuid' => $self->uid } ); - } - return "Can't delete an account which is a (svc_forward) source!" if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } ); @@ -1148,7 +1141,7 @@ probably live somewhere else... L, edit/part_svc.cgi from an installed web interface, export.html from the base documentation, L, L, L, L, L, L, -L), L, L, L, +L), L, schema.html from the base documentation. =cut diff --git a/FS/FS/svc_acct_sm.pm b/FS/FS/svc_acct_sm.pm deleted file mode 100644 index c92f1421f..000000000 --- a/FS/FS/svc_acct_sm.pm +++ /dev/null @@ -1,260 +0,0 @@ -package FS::svc_acct_sm; - -use strict; -use vars qw( @ISA $nossh_hack $conf $shellmachine @qmailmachines ); -use FS::Record qw( fields qsearch qsearchs ); -use FS::svc_Common; -use FS::cust_svc; -use Net::SSH qw(ssh); -use FS::Conf; -use FS::svc_acct; -use FS::svc_domain; - -@ISA = qw( FS::svc_Common ); - -#ask FS::UID to run this stuff for us later -#$FS::UID::callback{'FS::svc_acct_sm'} = sub { -# $conf = new FS::Conf; -# $shellmachine = $conf->exists('qmailmachines') -# ? $conf->config('shellmachine') -# : ''; -#}; - -=head1 NAME - -FS::svc_acct_sm - Object methods for svc_acct_sm records - -=head1 SYNOPSIS - - use FS::svc_acct_sm; - - $record = new FS::svc_acct_sm \%hash; - $record = new FS::svc_acct_sm { 'column' => 'value' }; - - $error = $record->insert; - - $error = $new_record->replace($old_record); - - $error = $record->delete; - - $error = $record->check; - - $error = $record->suspend; - - $error = $record->unsuspend; - - $error = $record->cancel; - -=head1 WARNING - -FS::svc_acct_sm is B. This class is only included for migration -purposes. See L. - -=head1 DESCRIPTION - -An FS::svc_acct_sm object represents a virtual mail alias. FS::svc_acct_sm -inherits from FS::Record. The following fields are currently supported: - -=over 4 - -=item svcnum - primary key (assigned automatcially for new accounts) - -=item domsvc - svcnum of the virtual domain (see L) - -=item domuid - uid of the target account (see L) - -=item domuser - virtual username - -=back - -=head1 METHODS - -=over 4 - -=item new HASHREF - -Creates a new virtual mail alias. To add the virtual mail alias to the -database, see L<"insert">. - -=cut - -sub table { 'svc_acct_sm'; } - -=item insert - -Adds this virtual mail alias to the database. If there is an error, returns -the error, otherwise returns false. - -The additional fields pkgnum and svcpart (see L) should be -defined. An FS::cust_svc record will be created and inserted. - - #If the configuration values (see L) shellmachine and qmailmachines - #exist, and domuser is `*' (meaning a catch-all mailbox), the command: - # - # [ -e $dir/.qmail-$qdomain-default ] || { - # touch $dir/.qmail-$qdomain-default; - # chown $uid:$gid $dir/.qmail-$qdomain-default; - # } - # - #is executed on shellmachine via ssh (see L). - #This behaviour can be surpressed by setting $FS::svc_acct_sm::nossh_hack true. - -=cut - -sub insert { - my $self = shift; - my $error; - - local $SIG{HUP} = 'IGNORE'; - local $SIG{INT} = 'IGNORE'; - local $SIG{QUIT} = 'IGNORE'; - local $SIG{TERM} = 'IGNORE'; - local $SIG{TSTP} = 'IGNORE'; - local $SIG{PIPE} = 'IGNORE'; - - $error=$self->check; - return $error if $error; - - return "Domain username (domuser) in use for this domain (domsvc)" - if qsearchs('svc_acct_sm',{ 'domuser'=> $self->domuser, - 'domsvc' => $self->domsvc, - } ); - - return "First domain username (domuser) for domain (domsvc) must be " . - qq='*' (catch-all)!= - if $self->domuser ne '*' - && ! qsearch('svc_acct_sm',{ 'domsvc' => $self->domsvc } ) - && ! $conf->exists('maildisablecatchall'); - - $error = $self->SUPER::insert; - return $error if $error; - - #my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } ); - #my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $self->domuid } ); - #my ( $uid, $gid, $dir, $domain ) = ( - # $svc_acct->uid, - # $svc_acct->gid, - # $svc_acct->dir, - # $svc_domain->domain, - #); - #my $qdomain = $domain; - #$qdomain =~ s/\./:/g; #see manpage for 'dot-qmail': EXTENSION ADDRESSES - #ssh("root\@$shellmachine","[ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }") - # if ( ! $nossh_hack && $shellmachine && $dir && $self->domuser eq '*' ); - - ''; #no error - -} - -=item delete - -Deletes this virtual mail alias from the database. If there is an error, -returns the error, otherwise returns false. - -The corresponding FS::cust_svc record will be deleted as well. - -=item replace OLD_RECORD - -Replaces OLD_RECORD with this one in the database. If there is an error, -returns the error, otherwise returns false. - -=cut - -sub replace { - my ( $new, $old ) = ( shift, shift ); - my $error; - - return "Domain username (domuser) in use for this domain (domsvc)" - if ( $old->domuser ne $new->domuser - || $old->domsvc != $new->domsvc - ) && qsearchs('svc_acct_sm',{ - 'domuser'=> $new->domuser, - 'domsvc' => $new->domsvc, - } ) - ; - - $new->SUPER::replace($old); - -} - -=item suspend - -Just returns false (no error) for now. - -Called by the suspend method of FS::cust_pkg (see L). - -=item unsuspend - -Just returns false (no error) for now. - -Called by the unsuspend method of FS::cust_pkg (see L). - -=item cancel - -Just returns false (no error) for now. - -Called by the cancel method of FS::cust_pkg (see L). - -=item check - -Checks all fields to make sure this is a valid virtual mail alias. If there is -an error, returns the error, otherwise returns false. Called by the insert and -replace methods. - -Sets any fixed values; see L. - -=cut - -sub check { - my $self = shift; - my $error; - - my $x = $self->setfixed; - return $x unless ref($x); - #my $part_svc = $x; - - my($recref) = $self->hashref; - - $recref->{domuser} =~ /^(\*|[a-z0-9_\-]{2,32})$/ - or return "Illegal domain username (domuser)"; - $recref->{domuser} = $1; - - $recref->{domsvc} =~ /^(\d+)$/ or return "Illegal domsvc"; - $recref->{domsvc} = $1; - my($svc_domain); - return "Unknown domsvc" unless - $svc_domain=qsearchs('svc_domain',{'svcnum'=> $recref->{domsvc} } ); - - $recref->{domuid} =~ /^(\d+)$/ or return "Illegal uid"; - $recref->{domuid} = $1; - my($svc_acct); - return "Unknown uid" unless - $svc_acct=qsearchs('svc_acct',{'uid'=> $recref->{domuid} } ); - - ''; #no error -} - -=back - -=head1 VERSION - -$Id: svc_acct_sm.pm,v 1.5 2001-09-06 20:41:59 ivan Exp $ - -=head1 BUGS - -The remote commands should be configurable. - -The $recref stuff in sub check should be cleaned up. - -=head1 SEE ALSO - -L - -L, L, L, L, L, -L, L, L, L, L, -schema.html from the base documentation. - -=cut - -1; - diff --git a/FS/MANIFEST b/FS/MANIFEST index 4a250d77b..3cf4c2ba3 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -87,7 +87,6 @@ FS/pkg_svc.pm FS/svc_Common.pm FS/svc_acct.pm FS/svc_acct_pop.pm -FS/svc_acct_sm.pm FS/svc_broadband.pm FS/svc_domain.pm FS/type_pkgs.pm @@ -165,7 +164,6 @@ t/radius_usergroup.t t/session.t t/svc_acct.t t/svc_acct_pop.t -t/svc_acct_sm.t t/svc_Common.t t/svc_domain.t t/svc_forward.t diff --git a/FS/t/svc_acct_sm.t b/FS/t/svc_acct_sm.t deleted file mode 100644 index 1082f2cdb..000000000 --- a/FS/t/svc_acct_sm.t +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN { $| = 1; print "1..1\n" } -END {print "not ok 1\n" unless $loaded;} -use FS::svc_acct_sm; -$loaded=1; -print "ok 1\n"; diff --git a/httemplate/docs/schema.dia b/httemplate/docs/schema.dia index 092d2f88b..c0842a602 100644 Binary files a/httemplate/docs/schema.dia and b/httemplate/docs/schema.dia differ diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index 2b8b3a132..54adec3a7 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -248,7 +248,7 @@
    • svcpart - primary key
    • svc - name of this service -
    • svcdb - table used for this service: svc_acct, svc_acct_sm, svc_forward, svc_domain, svc_charge or svc_wo +
    • svcdb - table used for this service: svc_acct, svc_forward, svc_domain, svc_charge or svc_wo
    • disabled - Disabled flag, empty or `Y' -<% - -my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); - -my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct_sm ); -if ( $cgi->param('error') ) { - $svc_acct_sm = new FS::svc_acct_sm ( { - map { $_, scalar($cgi->param($_)) } fields('svc_acct_sm') - } ); - $svcnum = $svc_acct_sm->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - #$part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - #die "No part_svc entry!" unless $part_svc; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_acct_sm=qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) - or die "Unknown (svc_acct_sm) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - #$part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - #die "No part_svc entry!" unless $part_svc; - - } else { #adding - - $svc_acct_sm = new FS::svc_acct_sm({}); - - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $pkgnum=$1 if /^pkgnum(\d+)$/; - $svcpart=$1 if /^svcpart(\d+)$/; - } - my $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svcnum=''; - - #set fixed and default fields from part_svc - foreach my $part_svc_column ( - grep { $_->columnflag } $part_svc->all_part_svc_column - ) { - $svc_acct_sm->setfield( $part_svc_column->columnname, - $part_svc_column->columnvalue, - ); - } - - } -} -my $action = $svc_acct_sm->svcnum ? 'Edit' : 'Add'; - -my %username = (); -my %domain = (); -if ($pkgnum) { - - #find all possible uids (and usernames) - - my @u_acct_svcparts = (); - foreach my $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { - push @u_acct_svcparts,$u_part_svc->getfield('svcpart'); - } - - my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - my($custnum)=$cust_pkg->getfield('custnum'); - foreach my $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { - my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); - my($acct_svcpart); - foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding - #record(s) in cust_svc ( for this - #pkgnum ! ) - my($i_cust_svc); - foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); - $username{$svc_acct->getfield('uid')}=$svc_acct->getfield('username'); - } - } - } - - #find all possible domains (and domsvc's) - - my @d_acct_svcparts = (); - foreach my $d_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_domain'}) ) { - push @d_acct_svcparts,$d_part_svc->getfield('svcpart'); - } - - foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { - my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); - my($acct_svcpart); - foreach $acct_svcpart (@d_acct_svcparts) { - my($i_cust_svc); - foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { - my($svc_domain)=qsearch('svc_domain',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); - $domain{$svc_domain->getfield('svcnum')}=$svc_domain->getfield('domain'); - } - } - } - -} elsif ( $action eq 'Edit' ) { - - my($svc_acct)=qsearchs('svc_acct',{'uid'=>$svc_acct_sm->domuid}); - $username{$svc_acct_sm->uid} = $svc_acct->username; - - my($svc_domain)=qsearchs('svc_domain',{'svcnum'=>$svc_acct_sm->domsvc}); - $domain{$svc_acct_sm->domsvc} = $svc_domain->domain; - -} else { - die "\$action eq Add, but \$pkgnum is null!\n"; -} - -my $p1 = popurl(1); -print header("Mail Alias $action", ''); - -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); - -print qq!!; - -#display - - #formatting - print "
      ";
      -
      -#svcnum
      -print qq!!;
      -print qq!Service #!, $svcnum ? $svcnum : " (NEW)", "";
      -
      -#pkgnum
      -print qq!!;
      - 
      -#svcpart
      -print qq!!;
      -
      -my($domuser,$domsvc,$domuid)=(
      -  $svc_acct_sm->domuser,
      -  $svc_acct_sm->domsvc,
      -  $svc_acct_sm->domuid,
      -);
      -
      -#domuser
      -print qq!\n\nMail to  ( * for anything )!;
      -
      -#domsvc
      -print qq! \@ ";
      -
      -#uid
      -print qq!\nforwards to \@$mydomain mailbox.";
      -
      -	#formatting
      -	print "
      \n"; - -print qq!
      !; - -print < - - -END - -%> diff --git a/httemplate/index.html b/httemplate/index.html index 2cb707326..f17639d44 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -34,7 +34,6 @@ Phone #
      Username or all accounts by username or uid

      Domain or all domains
      -
      diff --git a/httemplate/misc/link.cgi b/httemplate/misc/link.cgi index efc762cc5..79adce88c 100755 --- a/httemplate/misc/link.cgi +++ b/httemplate/misc/link.cgi @@ -4,7 +4,6 @@ my %link_field = ( 'svc_acct' => 'username', 'svc_domain' => 'domain', - 'svc_acct_sm' => '', 'svc_charge' => '', 'svc_wo' => '', ); diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi deleted file mode 100755 index 4ee300612..000000000 --- a/httemplate/search/svc_acct_sm.cgi +++ /dev/null @@ -1,84 +0,0 @@ -<% - -my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); - -$cgi->param('domuser') =~ /^([a-z0-9_\-]{0,32})$/; -my $domuser = $1; - -$cgi->param('domain') =~ /^([\w\-\.]+)$/ or die "Illegal domain"; -my $svc_domain = qsearchs('svc_domain',{'domain'=>$1}) - or die "Unknown domain"; -my $domsvc = $svc_domain->svcnum; - -my @svc_acct_sm; -if ($domuser) { - @svc_acct_sm=qsearch('svc_acct_sm',{ - 'domuser' => $domuser, - 'domsvc' => $domsvc, - }); -} else { - @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $domsvc}); -} - -if ( scalar(@svc_acct_sm) == 1 ) { - my($svcnum)=$svc_acct_sm[0]->svcnum; - print $cgi->redirect(popurl(2). "view/svc_acct_sm.cgi?$svcnum"); -} elsif ( scalar(@svc_acct_sm) > 1 ) { -%> - -<% - print header('Mail Alias Search Results'), &table(), < - Mail to
      (click to view mail alias) - Forwards to
      (click to view account) - -END - - my($svc_acct_sm); - foreach $svc_acct_sm (@svc_acct_sm) { - my($svcnum,$domuser,$domuid,$domsvc)=( - $svc_acct_sm->svcnum, - $svc_acct_sm->domuser, - $svc_acct_sm->domuid, - $svc_acct_sm->domsvc, - ); - - my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } ); - if ( $svc_domain ) { - my $domain = $svc_domain->domain; - - print qq!!, - #print '', ( ($domuser eq '*') ? "(anything)" : $domuser ); - ( ($domuser eq '*') ? "(anything)" : $domuser ), - qq!\@$domain !, - ; - } else { - my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum"; - warn $warning; - print "WARNING: $warning"; - } - - my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } ); - if ( $svc_acct ) { - my $username = $svc_acct->username; - my $svc_acct_svcnum =$svc_acct->svcnum; - print qq!$username\@$mydomain!, - qq!! - ; - } else { - my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!"; - warn $warning; - print "WARNING: $warning"; - } - - } - - print ''; - -} else { #error - idiot("Mail Alias not found"); -} - -%> diff --git a/httemplate/search/svc_acct_sm.html b/httemplate/search/svc_acct_sm.html deleted file mode 100755 index 0719856db..000000000 --- a/httemplate/search/svc_acct_sm.html +++ /dev/null @@ -1,23 +0,0 @@ - - - Mail Alias Search - - -
      -

      Mail Alias Search

      -
      -
      -
      - Search for mail alias: - (opt.) @ - (req.) - -

      - -

      - -
      - - - - diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index fb372db14..0bb39f191 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -67,18 +67,6 @@ END $svc_domain->svcnum, $svc_domain->domain, ); - #my($malias); - #if ( qsearch('svc_acct_sm',{'domsvc'=>$svcnum}) ) { - # $malias=( - # qq|
      |. - # qq||. - # qq||. - # qq||. - # qq|
      | - # ); - #} else { - # $malias=''; - #} my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum}); my $rowspan = 0; diff --git a/httemplate/view/svc_acct_sm.cgi b/httemplate/view/svc_acct_sm.cgi deleted file mode 100755 index 4e5acc427..000000000 --- a/httemplate/view/svc_acct_sm.cgi +++ /dev/null @@ -1,58 +0,0 @@ - -<% - -my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); - -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -my $svcnum = $1; -my $svc_acct_sm = qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}); -die "Unknown svcnum" unless $svc_acct_sm; - -my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); -my $pkgnum = $cust_svc->getfield('pkgnum'); -my($cust_pkg, $custnum); -if ($pkgnum) { - $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); - $custnum=$cust_pkg->getfield('custnum'); -} else { - $cust_pkg = ''; - $custnum = ''; -} - -my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ) - or die "Unkonwn svcpart"; - -print header('Mail Alias View', menubar( - ( ( $pkgnum || $custnum ) - ? ( "View this package (#$pkgnum)" => "${p}view/cust_pkg.cgi?$pkgnum", - "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", - ) - : ( "Cancel this (unaudited) account" => - "${p}misc/cancel-unaudited.cgi?$svcnum" ) - ), - "Main menu" => $p, -)); - -my($domsvc,$domuid,$domuser) = ( - $svc_acct_sm->domsvc, - $svc_acct_sm->domuid, - $svc_acct_sm->domuser, -); -my $svc = $part_svc->svc; -my $svc_domain = qsearchs('svc_domain',{'svcnum'=>$domsvc}) - or die "Corrupted database: no svc_domain.svcnum matching domsvc $domsvc"; -my $domain = $svc_domain->domain; -my $svc_acct = qsearchs('svc_acct',{'uid'=>$domuid}) - or die "Corrupted database: no svc_acct.uid matching domuid $domuid"; -my $username = $svc_acct->username; - -print qq!Edit this information!, - "
      Service #$svcnum", - "
      Service: $svc", - qq!
      Mail to !, ( ($domuser eq '*') ? "(anything)" : $domuser ) , qq!\@$domain forwards to $username\@$mydomain mailbox.!, - '' -; - -%> -- cgit v1.2.1 From 0c9f7a9f0e0cb21407051b7804f8454e85421f14 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Sep 2002 10:21:47 +0000 Subject: remove obsolete cybercash support --- FS/FS/Conf.pm | 7 --- FS/FS/cust_bill.pm | 103 +----------------------------------- httemplate/edit/part_bill_event.cgi | 6 --- 3 files changed, 2 insertions(+), 114 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index e50cb29b9..36ee69a36 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -289,13 +289,6 @@ httemplate/docs/config.html 'type' => 'text', }, - { - 'key' => 'cybercash3.2', - 'section' => 'billing', - 'description' => 'CyberCash Cashregister v3.2 support. Two lines: the full path and name of your merchant_conf file, and the transaction type (`mauthonly\' or `mauthcapture\').', - 'type' => 'textarea', - }, - { 'key' => 'cyrus', 'section' => 'deprecated', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 52fc94235..258b32e15 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -35,28 +35,7 @@ $FS::UID::callback{'FS::cust_bill'} = sub { $invoice_from = $conf->config('invoice_from'); $smtpmachine = $conf->config('smtpmachine'); - if ( $conf->exists('cybercash3.2') ) { - require CCMckLib3_2; - #qw($MCKversion %Config InitConfig CCError CCDebug CCDebug2); - require CCMckDirectLib3_2; - #qw(SendCC2_1Server); - require CCMckErrno3_2; - #qw(MCKGetErrorMessage $E_NoErr); - import CCMckErrno3_2 qw($E_NoErr); - - my $merchant_conf; - ($merchant_conf,$xaction)= $conf->config('cybercash3.2'); - my $status = &CCMckLib3_2::InitConfig($merchant_conf); - if ( $status != $E_NoErr ) { - warn "CCMckLib3_2::InitConfig error:\n"; - foreach my $key (keys %CCMckLib3_2::Config) { - warn " $key => $CCMckLib3_2::Config{$key}\n" - } - my($errmsg) = &CCMckErrno3_2::MCKGetErrorMessage($status); - die "CCMckLib3_2::InitConfig fatal error: $errmsg\n"; - } - $processor='cybercash3.2'; - } elsif ( $conf->exists('business-onlinepayment') ) { + if ( $conf->exists('business-onlinepayment') ) { ( $bop_processor, $bop_login, $bop_password, @@ -800,84 +779,6 @@ sub realtime_card { } -=item realtime_card_cybercash - -Attempts to pay this invoice with the CyberCash CashRegister realtime gateway. - -=cut - -sub realtime_card_cybercash { - my $self = shift; - my $cust_main = $self->cust_main; - my $amount = $self->owed; - - return "CyberCash CashRegister real-time card processing not enabled!" - unless $processor eq 'cybercash3.2'; - - my $address = $cust_main->address1; - $address .= ", ". $cust_main->address2 if $cust_main->address2; - - #fix exp. date - #$cust_main->paydate =~ /^(\d+)\/\d*(\d{2})$/; - $cust_main->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; - my $exp = "$2/$1"; - - # - - my $paybatch = $self->invnum. - '-' . time2str("%y%m%d%H%M%S", time); - - my $payname = $cust_main->payname || - $cust_main->getfield('first').' '.$cust_main->getfield('last'); - - my $country = $cust_main->country eq 'US' ? 'USA' : $cust_main->country; - - my @full_xaction = ( $xaction, - 'Order-ID' => $paybatch, - 'Amount' => "usd $amount", - 'Card-Number' => $cust_main->getfield('payinfo'), - 'Card-Name' => $payname, - 'Card-Address' => $address, - 'Card-City' => $cust_main->getfield('city'), - 'Card-State' => $cust_main->getfield('state'), - 'Card-Zip' => $cust_main->getfield('zip'), - 'Card-Country' => $country, - 'Card-Exp' => $exp, - ); - - my %result; - %result = &CCMckDirectLib3_2::SendCC2_1Server(@full_xaction); - - if ( $result{'MStatus'} eq 'success' ) { #cybercash smps v.2 or 3 - my $cust_pay = new FS::cust_pay ( { - 'invnum' => $self->invnum, - 'paid' => $amount, - '_date' => '', - 'payby' => 'CARD', - 'payinfo' => $cust_main->payinfo, - 'paybatch' => "$processor:$paybatch", - } ); - my $error = $cust_pay->insert; - if ( $error ) { - # gah, even with transactions. - my $e = 'WARNING: Card debited but database not updated - '. - 'error applying payment, invnum #' . $self->invnum. - " (CyberCash Order-ID $paybatch): $error"; - warn $e; - return $e; - } else { - return ''; - } -# } elsif ( $result{'Mstatus'} ne 'failure-bad-money' -# || $options{'report_badcard'} -# ) { - } else { - return 'Cybercash error, invnum #' . - $self->invnum. ':'. $result{'MErrMsg'}; - } - -} - =item batch_card Adds a payment for this invoice to the pending credit card batch (see @@ -1130,7 +1031,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.44 2002-09-17 00:40:07 ivan Exp $ +$Id: cust_bill.pm,v 1.45 2002-09-17 10:21:47 ivan Exp $ =head1 BUGS diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index a10a186a9..1b20ef1d2 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -108,12 +108,6 @@ tie my %events, 'Tie::IxHash', 'weight' => 30, }, - 'realtime-card-cybercash' => { - 'name' => '(deprecated) Run card with CyberCash CashRegister realtime gateway', - 'code' => '$cust_bill->realtime_card_cybercash();', - 'weight' => 30, - }, - 'batch-card' => { 'name' => 'Add card to the pending credit card batch', 'code' => '$cust_bill->batch_card();', -- cgit v1.2.1 From 63f70756521f544ce1a1a36ae9847dc9865e17f4 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 18 Sep 2002 12:10:07 +0000 Subject: doc --- httemplate/docs/index.html | 3 -- httemplate/docs/legacy.html | 3 +- httemplate/docs/upgrade4.html | 27 ------------------ httemplate/docs/upgrade5.html | 34 ---------------------- httemplate/docs/upgrade6.html | 66 ------------------------------------------- 5 files changed, 2 insertions(+), 131 deletions(-) delete mode 100644 httemplate/docs/upgrade4.html delete mode 100644 httemplate/docs/upgrade5.html delete mode 100644 httemplate/docs/upgrade6.html diff --git a/httemplate/docs/index.html b/httemplate/docs/index.html index eaa5b9b92..8f6f91378 100644 --- a/httemplate/docs/index.html +++ b/httemplate/docs/index.html @@ -6,9 +6,6 @@ -
    • bin/svc_acct_sm.import - Import qmail ( `virtualdomains' and `rcpthosts' ), or sendmail ( `virtusertable' and `sendmail.cw' ) files. Before running bin/svc_acct_sm.import, you need services as follows: +
    • Importing customer data
      • Manually diff --git a/httemplate/docs/upgrade4.html b/httemplate/docs/upgrade4.html deleted file mode 100644 index 1d70f8b73..000000000 --- a/httemplate/docs/upgrade4.html +++ /dev/null @@ -1,27 +0,0 @@ - - Upgrading to 1.2.2 - - -

        Upgrading to 1.2.2 from 1.2.x

        -
          -
        • If migrating from 1.0.0, see these instructions first. -
        • If migrating from less than 1.1.4, see these instructions first. -
        • If migrating from less than 1.2.0, see these instructions first. -
        • Back up your data and current Freeside installation. -
        • Install the Perl modules Locale-Codes and Net-Whois. -
        • Apply the following changes to your database: -
          -ALTER TABLE cust_pay_batch CHANGE exp exp VARCHAR(11);
          -
          -
        • Copy or symlink htdocs to the new copy. -
        • Remove the symlink or directory (your_site_perl_directory)/FS. -
        • Change to the FS directory in the new tarball, and build and install the - Perl modules: -
          -$ cd FS/
          -$ perl Makefile.PL
          -$ make
          -$ su
          -# make install
          -
        • Run bin/dbdef-create. This file uses MySQL-specific syntax. If you are running a different database engine you will need to modify it slightly. - diff --git a/httemplate/docs/upgrade5.html b/httemplate/docs/upgrade5.html deleted file mode 100644 index 3f3431653..000000000 --- a/httemplate/docs/upgrade5.html +++ /dev/null @@ -1,34 +0,0 @@ - - Upgrading to 1.3.0 - - -

          Upgrading to 1.2.3 from 1.2.2

          -
            -
          • If migrating from 1.0.0, see these instructions first. -
          • If migrating from less than 1.1.4, see these instructions first. -
          • If migrating from less than 1.2.0, see these instructions first. -
          • If migrating from less than 1.2.2, see these instructions first. -
          • Back up your data and current Freeside installation. -
          • Apply the following changes to your database: -
            -ALTER TABLE svc_acct_pop ADD loc CHAR(4);
            -CREATE TABLE prepay_credit (
            -  prepaynum int NOT NULL,
            -  identifier varchar(80) NOT NULL,
            -  amount decimal(10,2) NOT NULL,
            -  PRIMARY KEY (prepaynum),
            -  INDEX (identifier)
            -);
            -
            -
          • Copy or symlink htdocs to the new copy. -
          • Remove the symlink or directory (your_site_perl_directory)/FS. -
          • Change to the FS directory in the new tarball, and build and install the - Perl modules: -
            -$ cd FS/
            -$ perl Makefile.PL
            -$ make
            -$ su
            -# make install
            -
          • Run bin/dbdef-create. This file uses MySQL-specific syntax. If you are running a different database engine you will need to modify it slightly. - diff --git a/httemplate/docs/upgrade6.html b/httemplate/docs/upgrade6.html deleted file mode 100644 index dc82975f3..000000000 --- a/httemplate/docs/upgrade6.html +++ /dev/null @@ -1,66 +0,0 @@ - - Upgrading to 1.3.0 - - -

            Upgrading to 1.3.0 from 1.2.3

            -
              -
            • If migrating from 1.0.0, see these instructions first. -
            • If migrating from less than 1.1.4, see these instructions first. -
            • If migrating from less than 1.2.0, see these instructions first. -
            • If migrating from less than 1.2.2, see these instructions first. -
            • If migrating from less than 1.2.3, see these instructions first. -
            • Back up your data and current Freeside installation. -
            • As 1.3.0 requires transactions, MySQL's default MyISAM and ISAM table types are no longer supported. Converting to PostgreSQL is recommended. If you really want to use MySQL, convert your tables to one of the transaction-safe table types such as BDB. -
            • Copy the invoice_template file from the conf/ directory in the distribution to your configuration directory. -
            • Install the Text-Template, DBIx-DBSchema, Net-SSH, String-ShellQuote and Net-SCP Perl modules. -
            • Apply the following changes to your database: -
              -CREATE TABLE domain_record (
              -  recnum int NOT NULL,
              -  svcnum int NOT NULL,
              -  reczone varchar(80) NOT NULL,
              -  recaf char(2) NOT NULL,
              -  rectype char(5) NOT NULL,
              -  recdata varchar(80) NOT NULL,
              -  PRIMARY KEY (recnum)
              -);
              -CREATE TABLE svc_www (
              -  svcnum int NOT NULL,
              -  recnum int NOT NULL,
              -  usersvc int NOT NULL,
              -  PRIMARY KEY (svcnum)
              -);
              -ALTER TABLE part_svc ADD svc_www__recnum varchar(80) NULL;
              -ALTER TABLE part_svc ADD svc_www__recnum_flag char(1) NULL;
              -ALTER TABLE part_svc ADD svc_www__usersvc varchar(80) NULL;
              -ALTER TABLE part_svc ADD svc_www__uesrsvc_flag char(1) NULL;
              -ALTER TABLE svc_acct CHANGE _password _password varchar(50) NULL;
              -ALTER TABLE svc_acct ADD seconds integer NULL;
              -ALTER TABLE part_svc ADD svc_acct__seconds integer NULL;
              -ALTER TABLE part_svc ADD svc_acct__seconds_flag char(1) NULL;
              -ALTER TABLE prepay_credit ADD seconds integer NULL;
              -
              -
              -
            • If your database supports dropping columns: -
              -ALTER TABLE cust_bill DROP owed;
              -ALTER TABLE cust_credit DROP credited;
              -
              - Or, if your database does not support dropping columns, you can do this: -
              -ALTER TABLE cust_bill CHANGE owed depriciated decimal(10,2);
              -ALTER TABLE cust_credit CHANGE credited depriciated2 decimal(10,2);
              -
              - -
            • Copy or symlink htdocs to the new copy. -
            • Remove the symlink or directory (your_site_perl_directory)/FS. -
            • Change to the FS directory in the new tarball, and build and install the - Perl modules: -
              -$ cd FS/
              -$ perl Makefile.PL
              -$ make
              -$ su
              -# make install
              -
            • Run bin/dbdef-create. - -- cgit v1.2.1 From 89d15555270a63ab09116107f3dc327e86d831c5 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 18 Sep 2002 22:39:01 +0000 Subject: removing svc_acct_sm --- FS/FS/cust_svc.pm | 8 +------- FS/FS/svc_domain.pm | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index d54fb2d40..9d510b38a 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -9,7 +9,6 @@ use FS::part_pkg; use FS::part_svc; use FS::pkg_svc; use FS::svc_acct; -use FS::svc_acct_sm; use FS::svc_domain; use FS::svc_forward; use FS::domain_record; @@ -276,11 +275,6 @@ sub label { my $tag; if ( $svcdb eq 'svc_acct' ) { $tag = $svc_x->email; - } elsif ( $svcdb eq 'svc_acct_sm' ) { - my $domuser = $svc_x->domuser eq '*' ? '(anything)' : $svc_x->domuser; - my $svc_domain = qsearchs ( 'svc_domain', { 'svcnum' => $svc_x->domsvc } ); - my $domain = $svc_domain->domain; - $tag = "$domuser\@$domain"; } elsif ( $svcdb eq 'svc_forward' ) { my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_x->srcsvc } ); $tag = $svc_acct->email. '->'; @@ -346,7 +340,7 @@ sub seconds_since { =head1 VERSION -$Id: cust_svc.pm,v 1.16 2002-09-09 23:01:35 khoff Exp $ +$Id: cust_svc.pm,v 1.17 2002-09-18 22:39:01 ivan Exp $ =head1 BUGS diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index 637d0493c..0d71b2775 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -251,10 +251,6 @@ sub delete { return "Can't delete a domain which has accounts!" if qsearch( 'svc_acct', { 'domsvc' => $self->svcnum } ); - return "Can't delete a domain with (svc_acct_sm) mail aliases!" - if defined( $FS::Record::dbdef->table('svc_acct_sm') ) - && qsearch('svc_acct_sm', { 'domsvc' => $self->svcnum } ); - #return "Can't delete a domain with (domain_record) zone entries!" # if qsearch('domain_record', { 'svcnum' => $self->svcnum } ); -- cgit v1.2.1 From c1e33a61324f4e06157c522af7882a97a021830f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 18 Sep 2002 22:50:44 +0000 Subject: remove domain config file, closes: Bug#269 --- FS/FS/Conf.pm | 7 ------- FS/FS/cust_main_invoice.pm | 9 +-------- FS/FS/svc_acct.pm | 14 ++++---------- FS/bin/freeside-email | 6 ++---- httemplate/edit/svc_forward.cgi | 1 - httemplate/search/svc_acct.cgi | 25 ++++--------------------- httemplate/search/svc_domain.cgi | 1 - httemplate/view/svc_acct.cgi | 7 +------ 8 files changed, 12 insertions(+), 58 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 36ee69a36..e9defdafd 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -331,13 +331,6 @@ httemplate/docs/config.html 'type' => 'checkbox', }, - { - 'key' => 'domain', - 'section' => 'deprecated', - 'description' => 'Your domain name.', - 'type' => 'text', - }, - { 'key' => 'editreferrals', 'section' => 'UI', diff --git a/FS/FS/cust_main_invoice.pm b/FS/FS/cust_main_invoice.pm index a5533a088..bcb1437af 100644 --- a/FS/FS/cust_main_invoice.pm +++ b/FS/FS/cust_main_invoice.pm @@ -134,13 +134,6 @@ sub checkdest { unless qsearchs( 'svc_acct', { 'svcnum' => $self->dest } ); } elsif ( $self->dest =~ /^([\w\.\-\&\+]+)\@(([\w\.\-]+\.)+\w+)$/ ) { my($user, $domain) = ($1, $2); -# if ( $domain eq $mydomain ) { -# my $svc_acct = qsearchs( 'svc_acct', { 'username' => $user } ); -# return "Unknown local account: $user\@$domain (specified literally)" -# unless $svc_acct; -# $svc_acct->svcnum =~ /^(\d+)$/ or die "Non-numeric svcnum?!"; -# $self->dest($1); -# } $self->dest("$1\@$2"); } else { return gettext("illegal_email_invoice_address"); @@ -170,7 +163,7 @@ sub address { =head1 VERSION -$Id: cust_main_invoice.pm,v 1.12 2002-04-12 13:22:02 ivan Exp $ +$Id: cust_main_invoice.pm,v 1.13 2002-09-18 22:50:44 ivan Exp $ =head1 BUGS diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index bd348f8ed..420c6f422 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -7,7 +7,6 @@ use vars qw( @ISA $noexport_hack $conf $username_ampersand $username_letter $username_letterfirst $username_noperiod $username_nounderscore $username_nodash $username_uppercase - $mydomain $welcome_template $welcome_from $welcome_subject $welcome_mimetype $smtpmachine $dirhash @@ -48,7 +47,6 @@ $FS::UID::callback{'FS::svc_acct'} = sub { $username_nodash = $conf->exists('username-nodash'); $username_uppercase = $conf->exists('username-uppercase'); $username_ampersand = $conf->exists('username-ampersand'); - $mydomain = $conf->config('domain'); $dirhash = $conf->config('dirhash') || 0; if ( $conf->exists('welcome_email') ) { $welcome_template = new Text::Template ( @@ -875,14 +873,10 @@ Returns the domain associated with this account. sub domain { my $self = shift; - if ( $self->domsvc ) { - #$self->svc_domain->domain; - my $svc_domain = $self->svc_domain - or die "no svc_domain.svcnum for svc_acct.domsvc ". $self->domsvc; - $svc_domain->domain; - } else { - $mydomain or die "svc_acct.domsvc is null and no legacy domain config file"; - } + die "svc_acct.domsvc is null for svcnum ". $self->svcnum unless $self->domsvc; + my $svc_domain = $self->svc_domain + or die "no svc_domain.svcnum for svc_acct.domsvc ". $self->domsvc; + $svc_domain->domain; } =item svc_domain diff --git a/FS/bin/freeside-email b/FS/bin/freeside-email index c7ff41114..400dc2ac7 100755 --- a/FS/bin/freeside-email +++ b/FS/bin/freeside-email @@ -12,11 +12,9 @@ my $user = shift or die &usage; adminsuidsetup $user; my $conf = new FS::Conf; -my $domain = $conf->config('domain'); my @svc_acct = qsearch('svc_acct', {}); -my @usernames = map $_->username, @svc_acct; -my @emails = map "$_\@$domain", @usernames; +my @emails = map $_->email, @svc_acct; print join("\n", @emails), "\n"; @@ -51,7 +49,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-email,v 1.1 2001-05-15 07:52:34 ivan Exp $ +$Id: freeside-email,v 1.2 2002-09-18 22:50:44 ivan Exp $ =head1 BUGS diff --git a/httemplate/edit/svc_forward.cgi b/httemplate/edit/svc_forward.cgi index bc19fe1de..0d815b9e5 100755 --- a/httemplate/edit/svc_forward.cgi +++ b/httemplate/edit/svc_forward.cgi @@ -2,7 +2,6 @@ <% my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_forward); if ( $cgi->param('error') ) { diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 549231d3f..dcf261296 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,7 +1,5 @@ <% -my $mydomain = ''; - my $conf = new FS::Conf; my $maxrecords = $conf->config('maxsearchrecordsperpage'); @@ -147,14 +145,8 @@ END $domain = "svcnum. "\">". $svc_domain->domain. ""; } else { - unless ( $mydomain ) { - my $conf = new FS::Conf; - unless ( $mydomain = $conf->config('domain') ) { - die "No legacy domain config file and no svc_domain.svcnum record ". - "for svc_acct.domsvc: ". $svc_acct->domsvc; - } - } - $domain = "$mydomain*"; + die "No svc_domain.svcnum record for svc_acct.domsvc: ".' + $svc_acct->domsvc; } my($cust_pkg,$cust_main); if ( $cust_svc->pkgnum ) { @@ -216,17 +208,8 @@ END } - print "$pager
              "; - - if ( $mydomain ) { - print "
              * The $mydomain domain ". - "is contained in your legacy domain ". - "configuration file. ". - "You should run the bin/fs-migrate-svc_acct_sm script ". - "to create a proper svc_domain record for this domain."; - } - - print ''; + print "$pager
              ". + ''; } diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 0bb39f191..60f1f8c81 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,7 +1,6 @@ <% my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 19953bafd..df55e85bf 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -2,7 +2,6 @@ <% my $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); my($query) = $cgi->keywords; $query =~ /^(\d+)$/; @@ -32,11 +31,7 @@ if ( $svc_acct->domsvc ) { die "Unknown domain" unless $svc_domain; $domain = $svc_domain->domain; } else { - unless ( $mydomain ) { - die "No legacy domain config file and no svc_domain.svcnum record ". - "for svc_acct.domsvc: ". $cust_svc->domsvc; - } - $domain = $mydomain; + die "No svc_domain.svcnum record for svc_acct.domsvc: ". $cust_svc->domsvc; } %> -- cgit v1.2.1 From 641abe71e152f194c551d21ceeb26c15265795f6 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Sep 2002 07:15:03 +0000 Subject: cancel later in view UI... hmm --- httemplate/view/cust_pkg.cgi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/httemplate/view/cust_pkg.cgi b/httemplate/view/cust_pkg.cgi index 09a2a7a8b..aa3b3b15a 100755 --- a/httemplate/view/cust_pkg.cgi +++ b/httemplate/view/cust_pkg.cgi @@ -83,12 +83,14 @@ print 'Order taker', '' ; -# print < -# -#Expire (date): -# -#END +unless ($expire) { + print < + +Expire (date): + +END +} unless ($cancel) { -- cgit v1.2.1 From cf730711a39c28c720d475cc9e3a94d712c2b798 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Sep 2002 08:34:41 +0000 Subject: remove extra definition of $cust_pkg --- FS/FS/svc_acct.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 420c6f422..991bbef48 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -340,8 +340,6 @@ sub insert { my $cust_pkg = $self->cust_svc->cust_pkg; my $cust_main = $cust_pkg->cust_main; - my $cust_pkg = $self->cust_svc->cust_pkg; - if ( $conf->exists('emailinvoiceauto') ) { my @invoicing_list = $cust_main->invoicing_list; push @invoicing_list, $self->email; -- cgit v1.2.1 From 0f5ad6c181cccbbdec6c48ea74e41d92ef5e3a26 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Sep 2002 08:43:03 +0000 Subject: package expiration --- FS/bin/freeside-daily | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily index 142b0c73a..22bf2c963 100755 --- a/FS/bin/freeside-daily +++ b/FS/bin/freeside-daily @@ -28,15 +28,23 @@ my($time)= $opt_d ? str2time($opt_d) : $^T; my($cust_main,%saw); foreach $cust_main ( @cust_main ) { - my $error; + # $^T not $time because -d is for pre-printing invoices + foreach my $cust_pkg ( + grep { $_->expire && $_->expire >= $^T } $cust_main->ncancelled_pkgs + ) { + my $error = $cust_pkg->cancel; + warn "Error cancelling expired pkg ". $cust_pkg->pkgnum. " for custnum ". + $cust_main->custnum. ": $error" + if $error; + } - $error = $cust_main->bill( 'time' => $time ); + my $error = $cust_main->bill( 'time' => $time ); warn "Error billing, custnum ". $cust_main->custnum. ": $error" if $error; $cust_main->apply_payments; $cust_main->apply_credits; - $error=$cust_main->collect( 'invoice_time' => $time ); + $error = $cust_main->collect( 'invoice_time' => $time ); warn "Error collecting, custnum". $cust_main->custnum. ": $error" if $error; } -- cgit v1.2.1 From c956b311e4cb0c7db17e3da9c5f2449ff07fd7de Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Sep 2002 13:25:27 +0000 Subject: preliminary upgrade instructions --- README.1.5.0pre1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 README.1.5.0pre1 diff --git a/README.1.5.0pre1 b/README.1.5.0pre1 new file mode 100644 index 000000000..776899e31 --- /dev/null +++ b/README.1.5.0pre1 @@ -0,0 +1,12 @@ +preliminary upgrade instructions + +schema changes: + *** get svc_broadband changes from pc-intouch + *** otaker changes + *** optional: sequence changes + +install DBIx::DBSchema 0.21 + +Run dbdef-create +something about history tables +Restart apache and freeside-queued -- cgit v1.2.1 From 4c5b1b08168b20da1a87e9b82ee87ad18cb3ddd6 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Sep 2002 13:34:52 +0000 Subject: use database SERIAL or AUTO_INCREMENT for primary keys, finally, yay! closes: bug#69 --- FS/FS/Record.pm | 142 ++++++++++++++++++++++++++++++++++++++----------------- bin/dbdef-create | 4 +- bin/fs-setup | 123 ++++++++++++++++------------------------------- 3 files changed, 143 insertions(+), 126 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index c247ed2db..8778dee79 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -9,8 +9,8 @@ use Carp qw(carp cluck croak confess); use File::CounterFile; use Locale::Country; use DBI qw(:sql_types); -use DBIx::DBSchema 0.19; -use FS::UID qw(dbh checkruid getotaker datasrc driver_name); +use DBIx::DBSchema 0.21; +use FS::UID qw(dbh getotaker datasrc driver_name); use FS::SearchCache; use FS::Msgcat qw(gettext); @@ -60,14 +60,12 @@ FS::Record - Database record objects $hashref = $record->hashref; $error = $record->insert; - #$error = $record->add; #deprecated $error = $record->delete; - #$error = $record->del; #deprecated $error = $new_record->replace($old_record); - #$error = $new_record->rep($old_record); #deprecated + # external use deprecated - handled by the database (at least for Pg, mysql) $value = $record->unique('column'); $error = $record->ut_float('column'); @@ -88,7 +86,7 @@ FS::Record - Database record objects $quoted_value = _quote($value,'table','field'); - #depriciated + #deprecated $fields = hfields('table'); if ( $fields->{Field} ) { # etc. @@ -167,7 +165,7 @@ sub create { my $self = {}; bless ($self, $class); if ( defined $self->table ) { - cluck "create constructor is depriciated, use new!"; + cluck "create constructor is deprecated, use new!"; $self->new(@_); } else { croak "FS::Record::create called (not from a subclass)!"; @@ -212,25 +210,25 @@ sub qsearch { my $op = '='; if ( ref($record->{$_}) ) { $op = $record->{$_}{'op'} if $record->{$_}{'op'}; - $op = 'LIKE' if $op =~ /^ILIKE$/i && driver_name !~ /^Pg$/i; + $op = 'LIKE' if $op =~ /^ILIKE$/i && driver_name ne 'Pg'; $record->{$_} = $record->{$_}{'value'} } if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) { if ( $op eq '=' ) { - if ( driver_name =~ /^Pg$/i ) { + if ( driver_name eq 'Pg' ) { qq-( $_ IS NULL OR $_ = '' )-; } else { qq-( $_ IS NULL OR $_ = "" )-; } } elsif ( $op eq '!=' ) { - if ( driver_name =~ /^Pg$/i ) { + if ( driver_name eq 'Pg' ) { qq-( $_ IS NOT NULL AND $_ != '' )-; } else { qq-( $_ IS NOT NULL AND $_ != "" )-; } } else { - if ( driver_name =~ /^Pg$/i ) { + if ( driver_name eq 'Pg' ) { qq-( $_ $op '' )-; } else { qq-( $_ $op "" )-; @@ -345,7 +343,7 @@ Returns the table name. =cut sub table { -# cluck "warning: FS::Record::table depriciated; supply one in subclass!"; +# cluck "warning: FS::Record::table deprecated; supply one in subclass!"; my $self = shift; $self -> {'Table'}; } @@ -472,24 +470,33 @@ sub insert { return $error if $error; #single-field unique keys are given a value if false - #(like MySQL's AUTO_INCREMENT) + #(like MySQL's AUTO_INCREMENT or Pg SERIAL) foreach ( $self->dbdef_table->unique->singles ) { $self->unique($_) unless $self->getfield($_); } - #and also the primary key + + #and also the primary key, if the database isn't going to my $primary_key = $self->dbdef_table->primary_key; - $self->unique($primary_key) - if $primary_key && ! $self->getfield($primary_key); + my $db_seq = 0; + if ( $primary_key ) { + my $col = $self->dbdef_table->column($primary_key); + my $db_seq = + uc($col->type) eq 'SERIAL' + || ( driver_name eq 'Pg' && $col->default =~ /^nextval\(/i ) + || ( driver_name eq 'mysql' && $col->local =~ /AUTO_INCREMENT/i ); + $self->unique($primary_key) unless $self->getfield($primary_key) || $db_seq; + } + my $table = $self->table; #false laziness w/delete my @fields = grep defined($self->getfield($_)) && $self->getfield($_) ne "", $self->fields ; - my @values = map { _quote( $self->getfield($_), $self->table, $_) } @fields; + my @values = map { _quote( $self->getfield($_), $table, $_) } @fields; #eslaf - my $statement = "INSERT INTO ". $self->table. " ( ". + my $statement = "INSERT INTO $table ( ". join( ', ', @fields ). ") VALUES (". join( ', ', @values ). @@ -498,15 +505,6 @@ sub insert { warn "[debug]$me $statement\n" if $DEBUG > 1; my $sth = dbh->prepare($statement) or return dbh->errstr; - my $h_sth; - if ( defined $dbdef->table('h_'. $self->table) ) { - my $h_statement = $self->_h_statement('insert'); - warn "[debug]$me $h_statement\n" if $DEBUG > 2; - $h_sth = dbh->prepare($h_statement) or return dbh->errstr; - } else { - $h_sth = ''; - } - local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -515,7 +513,63 @@ sub insert { local $SIG{PIPE} = 'IGNORE'; $sth->execute or return $sth->errstr; + + if ( $db_seq ) { # get inserted id from the database, if applicable + my $insertid = ''; + if ( driver_name eq 'Pg' ) { + + my $oid = $sth->{'pg_oid_status'}; + my $i_sql = "SELECT id FROM $table WHERE oid = ?"; + my $i_sth = dbh->prepare($i_sql) or do { + dbh->rollback if $FS::UID::AutoCommit; + return dbh->errstr; + }; + $i_sth->execute($oid) or do { + dbh->rollback if $FS::UID::AutoCommit; + return $i_sth->errstr; + }; + $insertid = $i_sth->fetchrow_arrayref->[0]; + + } elsif ( driver_name eq 'mysql' ) { + + $insertid = dbh->{'mysql_insertid'}; + # work around mysql_insertid being null some of the time, ala RT :/ + unless ( $insertid ) { + warn "WARNING: DBD::mysql didn't return mysql_insertid; ". + "using SELECT LAST_INSERT_ID();"; + my $i_sql = "SELECT LAST_INSERT_ID()"; + my $i_sth = dbh->prepare($i_sql) or do { + dbh->rollback if $FS::UID::AutoCommit; + return dbh->errstr; + }; + $i_sth->execute or do { + dbh->rollback if $FS::UID::AutoCommit; + return $i_sth->errstr; + }; + $insertid = $i_sth->fetchrow_arrayref->[0]; + } + + } else { + dbh->rollback if $FS::UID::AutoCommit; + return "don't know how to retreive inserted ids from ". driver_name. + ", try using counterfiles (maybe run dbdef-create?)"; + } + $self->setfield($primary_key, $insertid); + } + + my $h_sth; + if ( defined $dbdef->table('h_'. $table) ) { + my $h_statement = $self->_h_statement('insert'); + warn "[debug]$me $h_statement\n" if $DEBUG > 2; + $h_sth = dbh->prepare($h_statement) or do { + dbh->rollback if $FS::UID::AutoCommit; + return dbh->errstr; + }; + } else { + $h_sth = ''; + } $h_sth->execute or return $h_sth->errstr if $h_sth; + dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit; ''; @@ -528,7 +582,7 @@ Depriciated (use insert instead). =cut sub add { - cluck "warning: FS::Record::add depriciated!"; + cluck "warning: FS::Record::add deprecated!"; insert @_; #call method in this scope } @@ -546,7 +600,7 @@ sub delete { map { $self->getfield($_) eq '' #? "( $_ IS NULL OR $_ = \"\" )" - ? ( driver_name =~ /^Pg$/i + ? ( driver_name eq 'Pg' ? "$_ IS NULL" : "( $_ IS NULL OR $_ = \"\" )" ) @@ -592,7 +646,7 @@ Depriciated (use delete instead). =cut sub del { - cluck "warning: FS::Record::del depriciated!"; + cluck "warning: FS::Record::del deprecated!"; &delete(@_); #call method in this scope } @@ -632,7 +686,7 @@ sub replace { map { $old->getfield($_) eq '' #? "( $_ IS NULL OR $_ = \"\" )" - ? ( driver_name =~ /^Pg$/i + ? ( driver_name eq 'Pg' ? "$_ IS NULL" : "( $_ IS NULL OR $_ = \"\" )" ) @@ -685,7 +739,7 @@ Depriciated (use replace instead). =cut sub rep { - cluck "warning: FS::Record::rep depriciated!"; + cluck "warning: FS::Record::rep deprecated!"; replace @_; #call method in this scope } @@ -718,8 +772,13 @@ sub _h_statement { =item unique COLUMN -Replaces COLUMN in record with a unique number. Called by the B method -on primary keys and single-field unique columns (see L). +B: External use is B. + +Replaces COLUMN in record with a unique number, using counters in the +filesystem. Used by the B method on single-field unique columns +(see L) and also as a fallback for primary keys +that aren't SERIAL (Pg) or AUTO_INCREMENT (mysql). + Returns the new value. =cut @@ -728,8 +787,6 @@ sub unique { my($self,$field) = @_; my($table)=$self->table; - #croak("&FS::UID::checkruid failed") unless &checkruid; - croak "Unique called on field $field, but it is ", $self->getfield($field), ", not null!" @@ -745,9 +802,8 @@ sub unique { # my($counter) = new File::CounterFile "$user/$table.$field",0; # endhack - my($index)=$counter->inc; - $index=$counter->inc - while qsearchs($table,{$field=>$index}); #just in case + my $index = $counter->inc; + $index = $counter->inc while qsearchs($table, { $field=>$index } ); $index =~ /^(\d*)$/; $index=$1; @@ -1165,14 +1221,14 @@ sub _quote { =item hfields TABLE -This is depriciated. Don't use it. +This is deprecated. Don't use it. It returns a hash-type list with the fields of this record's table set true. =cut sub hfields { - carp "warning: hfields is depriciated"; + carp "warning: hfields is deprecated"; my($table)=@_; my(%hash); foreach (fields($table)) { @@ -1208,7 +1264,7 @@ sub DESTROY { return; } This module should probably be renamed, since much of the functionality is of general use. It is not completely unlike Adapter::DBI (see below). -Exported qsearch and qsearchs should be depriciated in favor of method calls +Exported qsearch and qsearchs should be deprecated in favor of method calls (against an FS::Record object like the old search and searchs that qsearch and qsearchs were on top of.) @@ -1216,7 +1272,7 @@ The whole fields / hfields mess should be removed. The various WHERE clauses should be subroutined. -table string should be depriciated in favor of DBIx::DBSchema::Table. +table string should be deprecated in favor of DBIx::DBSchema::Table. No doubt we could benefit from a Tied hash. Documenting how exists / defined true maps to the database (and WHERE clauses) would also help. diff --git a/bin/dbdef-create b/bin/dbdef-create index 0b297b9e6..c977f876e 100755 --- a/bin/dbdef-create +++ b/bin/dbdef-create @@ -1,10 +1,10 @@ #!/usr/bin/perl -Tw # -# $Id: dbdef-create,v 1.5 2001-08-21 02:43:18 ivan Exp $ +# $Id: dbdef-create,v 1.6 2002-09-19 13:34:52 ivan Exp $ use strict; use DBI; -use DBIx::DBSchema; +use DBIx::DBSchema 0.21; use FS::UID qw(adminsuidsetup datasrc driver_name); my $user = shift or die &usage; diff --git a/bin/fs-setup b/bin/fs-setup index 81f1c26b0..aeaacbc00 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.97 2002-09-09 23:01:36 khoff Exp $ +# $Id: fs-setup,v 1.98 2002-09-19 13:34:51 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -133,33 +133,6 @@ 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, -# )); -# } -#} - #create history tables (false laziness w/create-history-tables) foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) { my $tableobj = $dbdef->table($table) @@ -334,7 +307,7 @@ sub tables_hash_hack { 'agent' => { 'columns' => [ - 'agentnum', 'int', '', '', + 'agentnum', 'serial', '', '', 'agent', 'varchar', '', $char_d, 'typenum', 'int', '', '', 'freq', 'int', 'NULL', '', @@ -347,7 +320,7 @@ sub tables_hash_hack { 'agent_type' => { 'columns' => [ - 'typenum', 'int', '', '', + 'typenum', 'serial', '', '', 'atype', 'varchar', '', $char_d, ], 'primary_key' => 'typenum', @@ -367,7 +340,7 @@ sub tables_hash_hack { 'cust_bill' => { 'columns' => [ - 'invnum', 'int', '', '', + 'invnum', 'serial', '', '', 'custnum', 'int', '', '', '_date', @date_type, 'charged', @money_type, @@ -381,7 +354,7 @@ sub tables_hash_hack { 'cust_bill_event' => { 'columns' => [ - 'eventnum', 'int', '', '', + 'eventnum', 'serial', '', '', 'invnum', 'int', '', '', 'eventpart', 'int', '', '', '_date', @date_type, @@ -396,7 +369,7 @@ sub tables_hash_hack { 'part_bill_event' => { 'columns' => [ - 'eventpart', 'int', '', '', + 'eventpart', 'serial', '', '', 'payby', 'char', '', 4, 'event', 'varchar', '', $char_d, 'eventcode', @perl_type, @@ -427,7 +400,7 @@ sub tables_hash_hack { 'cust_credit' => { 'columns' => [ - 'crednum', 'int', '', '', + 'crednum', 'serial', '', '', 'custnum', 'int', '', '', '_date', @date_type, 'amount', @money_type, @@ -442,7 +415,7 @@ sub tables_hash_hack { 'cust_credit_bill' => { 'columns' => [ - 'creditbillnum', 'int', '', '', + 'creditbillnum', 'serial', '', '', 'crednum', 'int', '', '', 'invnum', 'int', '', '', '_date', @date_type, @@ -455,7 +428,7 @@ sub tables_hash_hack { 'cust_main' => { 'columns' => [ - 'custnum', 'int', '', '', + 'custnum', 'serial', '', '', 'agentnum', 'int', '', '', # 'titlenum', 'int', 'NULL', '', 'last', 'varchar', '', $char_d, @@ -506,7 +479,7 @@ sub tables_hash_hack { 'cust_main_invoice' => { 'columns' => [ - 'destnum', 'int', '', '', + 'destnum', 'serial', '', '', 'custnum', 'int', '', '', 'dest', 'varchar', '', $char_d, ], @@ -519,7 +492,7 @@ sub tables_hash_hack { #cust_main_county for validation and to provide # a tax rate. 'columns' => [ - 'taxnum', 'int', '', '', + 'taxnum', 'serial', '', '', 'state', 'varchar', 'NULL', $char_d, 'county', 'varchar', 'NULL', $char_d, 'country', 'char', '', 2, @@ -535,7 +508,7 @@ sub tables_hash_hack { 'cust_pay' => { 'columns' => [ - 'paynum', 'int', '', '', + 'paynum', 'serial', '', '', #now cust_bill_pay #'invnum', 'int', '', '', 'custnum', 'int', '', '', 'paid', @money_type, @@ -553,7 +526,7 @@ sub tables_hash_hack { 'cust_bill_pay' => { 'columns' => [ - 'billpaynum', 'int', '', '', + 'billpaynum', 'serial', '', '', 'invnum', 'int', '', '', 'paynum', 'int', '', '', 'amount', @money_type, @@ -567,7 +540,7 @@ sub tables_hash_hack { 'cust_pay_batch' => { #what's this used for again? list of customers #in current CARD batch? (necessarily CARD?) 'columns' => [ - 'paybatchnum', 'int', '', '', + 'paybatchnum', 'serial', '', '', 'invnum', 'int', '', '', 'custnum', 'int', '', '', 'last', 'varchar', '', $char_d, @@ -592,7 +565,7 @@ sub tables_hash_hack { 'cust_pkg' => { 'columns' => [ - 'pkgnum', 'int', '', '', + 'pkgnum', 'serial', '', '', 'custnum', 'int', '', '', 'pkgpart', 'int', '', '', 'otaker', 'varchar', '', 8, @@ -610,7 +583,7 @@ sub tables_hash_hack { 'cust_refund' => { 'columns' => [ - 'refundnum', 'int', '', '', + 'refundnum', 'serial', '', '', #now cust_credit_refund #'crednum', 'int', '', '', 'custnum', 'int', '', '', '_date', @date_type, @@ -630,7 +603,7 @@ sub tables_hash_hack { 'cust_credit_refund' => { 'columns' => [ - 'creditrefundnum', 'int', '', '', + 'creditrefundnum', 'serial', '', '', 'crednum', 'int', '', '', 'refundnum', 'int', '', '', 'amount', @money_type, @@ -644,7 +617,7 @@ sub tables_hash_hack { 'cust_svc' => { 'columns' => [ - 'svcnum', 'int', '', '', + 'svcnum', 'serial', '', '', 'pkgnum', 'int', 'NULL', '', 'svcpart', 'int', '', '', ], @@ -655,7 +628,7 @@ sub tables_hash_hack { 'part_pkg' => { 'columns' => [ - 'pkgpart', 'int', '', '', + 'pkgpart', 'serial', '', '', 'pkg', 'varchar', '', $char_d, 'comment', 'varchar', '', $char_d, 'setup', @perl_type, @@ -696,7 +669,7 @@ sub tables_hash_hack { 'part_referral' => { 'columns' => [ - 'refnum', 'int', '', '', + 'refnum', 'serial', '', '', 'referral', 'varchar', '', $char_d, ], 'primary_key' => 'refnum', @@ -706,7 +679,7 @@ sub tables_hash_hack { 'part_svc' => { 'columns' => [ - 'svcpart', 'int', '', '', + 'svcpart', 'serial', '', '', 'svc', 'varchar', '', $char_d, 'svcdb', 'varchar', '', $char_d, 'disabled', 'char', 'NULL', 1, @@ -718,7 +691,7 @@ sub tables_hash_hack { 'part_svc_column' => { 'columns' => [ - 'columnnum', 'int', '', '', + 'columnnum', 'serial', '', '', 'svcpart', 'int', '', '', 'columnname', 'varchar', '', 64, 'columnvalue', 'varchar', 'NULL', $char_d, @@ -732,7 +705,7 @@ sub tables_hash_hack { #(this should be renamed to part_pop) 'svc_acct_pop' => { 'columns' => [ - 'popnum', 'int', '', '', + 'popnum', 'serial', '', '', 'city', 'varchar', '', $char_d, 'state', 'varchar', '', $char_d, 'ac', 'char', '', 3, @@ -746,7 +719,7 @@ sub tables_hash_hack { 'part_pop_local' => { 'columns' => [ - 'localnum', 'int', '', '', + 'localnum', 'serial', '', '', 'popnum', 'int', '', '', 'city', 'varchar', 'NULL', $char_d, 'state', 'char', 'NULL', 2, @@ -781,18 +754,6 @@ sub tables_hash_hack { 'index' => [ ['username'], ['domsvc'] ], }, -# 'svc_acct_sm' => { -# 'columns' => [ -# 'svcnum', 'int', '', '', -# 'domsvc', 'int', '', '', -# 'domuid', 'int', '', '', -# 'domuser', 'varchar', '', $char_d, -# ], -# 'primary_key' => 'svcnum', -# 'unique' => [ [] ], -# 'index' => [ ['domsvc'], ['domuid'] ], -# }, - #'svc_charge' => { # 'columns' => [ # 'svcnum', 'int', '', '', @@ -816,7 +777,7 @@ sub tables_hash_hack { 'domain_record' => { 'columns' => [ - 'recnum', 'int', '', '', + 'recnum', 'serial', '', '', 'svcnum', 'int', '', '', 'reczone', 'varchar', '', $char_d, 'recaf', 'char', '', 2, @@ -866,7 +827,7 @@ sub tables_hash_hack { 'prepay_credit' => { 'columns' => [ - 'prepaynum', 'int', '', '', + 'prepaynum', 'serial', '', '', 'identifier', 'varchar', '', $char_d, 'amount', @money_type, 'seconds', 'int', 'NULL', '', @@ -878,7 +839,7 @@ sub tables_hash_hack { 'port' => { 'columns' => [ - 'portnum', 'int', '', '', + 'portnum', 'serial', '', '', 'ip', 'varchar', 'NULL', 15, 'nasport', 'int', 'NULL', '', 'nasnum', 'int', '', '', @@ -890,7 +851,7 @@ sub tables_hash_hack { 'nas' => { 'columns' => [ - 'nasnum', 'int', '', '', + 'nasnum', 'serial', '', '', 'nas', 'varchar', '', $char_d, 'nasip', 'varchar', '', 15, 'nasfqdn', 'varchar', '', $char_d, @@ -903,7 +864,7 @@ sub tables_hash_hack { 'session' => { 'columns' => [ - 'sessionnum', 'int', '', '', + 'sessionnum', 'serial', '', '', 'portnum', 'int', '', '', 'svcnum', 'int', '', '', 'login', @date_type, @@ -916,7 +877,7 @@ sub tables_hash_hack { 'queue' => { 'columns' => [ - 'jobnum', 'int', '', '', + 'jobnum', 'serial', '', '', 'job', 'text', '', '', '_date', 'int', '', '', 'status', 'varchar', '', $char_d, @@ -930,7 +891,7 @@ sub tables_hash_hack { 'queue_arg' => { 'columns' => [ - 'argnum', 'int', '', '', + 'argnum', 'serial', '', '', 'jobnum', 'int', '', '', 'arg', 'text', 'NULL', '', ], @@ -941,7 +902,7 @@ sub tables_hash_hack { 'queue_depend' => { 'columns' => [ - 'dependnum', 'int', '', '', + 'dependnum', 'serial', '', '', 'jobnum', 'int', '', '', 'depend_jobnum', 'int', '', '', ], @@ -952,7 +913,7 @@ sub tables_hash_hack { 'export_svc' => { 'columns' => [ - 'exportsvcnum' => 'int', '', '', + 'exportsvcnum' => 'serial', '', '', 'exportnum' => 'int', '', '', 'svcpart' => 'int', '', '', ], @@ -963,7 +924,7 @@ sub tables_hash_hack { 'part_export' => { 'columns' => [ - 'exportnum', 'int', '', '', + 'exportnum', 'serial', '', '', #'svcpart', 'int', '', '', 'machine', 'varchar', '', $char_d, 'exporttype', 'varchar', '', $char_d, @@ -976,7 +937,7 @@ sub tables_hash_hack { 'part_export_option' => { 'columns' => [ - 'optionnum', 'int', '', '', + 'optionnum', 'serial', '', '', 'exportnum', 'int', '', '', 'optionname', 'varchar', '', $char_d, 'optionvalue', 'text', 'NULL', '', @@ -988,7 +949,7 @@ sub tables_hash_hack { 'radius_usergroup' => { 'columns' => [ - 'usergroupnum', 'int', '', '', + 'usergroupnum', 'serial', '', '', 'svcnum', 'int', '', '', 'groupname', 'varchar', '', $char_d, ], @@ -999,7 +960,7 @@ sub tables_hash_hack { 'msgcat' => { 'columns' => [ - 'msgnum', 'int', '', '', + 'msgnum', 'serial', '', '', 'msgcode', 'varchar', '', $char_d, 'locale', 'varchar', '', 16, 'msg', 'text', '', '', @@ -1011,7 +972,7 @@ sub tables_hash_hack { 'cust_tax_exempt' => { 'columns' => [ - 'exemptnum', 'int', '', '', + 'exemptnum', 'serial', '', '', 'custnum', 'int', '', '', 'taxnum', 'int', '', '', 'year', 'int', '', '', @@ -1025,7 +986,7 @@ sub tables_hash_hack { 'ac_type' => { 'columns' => [ - 'actypenum', 'int', '', '', + 'actypenum', 'serial', '', '', 'actypename', 'varchar', '', 15, ], 'primary_key' => 'actypenum', @@ -1035,7 +996,7 @@ sub tables_hash_hack { 'ac' => { 'columns' => [ - 'acnum', 'int', '', '', + 'acnum', 'serial', '', '', 'actypenum', 'int', '', '', 'acname', 'varchar', '', 15, ], @@ -1046,7 +1007,7 @@ sub tables_hash_hack { 'part_ac_field' => { 'columns' => [ - 'acfieldpart', 'int', '', '', + 'acfieldpart', 'serial', '', '', 'actypenum', 'int', '', '', 'name', 'varchar', '', 15, 'ut_type', 'varchar', '', 15, @@ -1080,7 +1041,7 @@ sub tables_hash_hack { 'svc_broadband' => { 'columns' => [ - 'svcnum', 'int', '', '', + 'svcnum', 'serial', '', '', 'actypenum', 'int', '', '', 'speed_up', 'int', '', '', 'speed_down', 'int', '', '', -- cgit v1.2.1 From 0ff15e0670be23954e18d9abbf992993a0fe1b3e Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 20 Sep 2002 10:16:28 +0000 Subject: change otaker fields to 32 chars --- FS/FS/UID.pm | 6 ++---- README.1.5.0pre1 | 2 +- bin/fs-setup | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm index 8934d49fc..6962b2768 100644 --- a/FS/FS/UID.pm +++ b/FS/FS/UID.pm @@ -171,9 +171,7 @@ Returns the current Freeside user. =cut sub getotaker { - #$user; - #stupid kludge until schema otaker fields are not 8 chars - substr($user,0,8); + $user; } =item cgisetotaker @@ -258,7 +256,7 @@ coderef into the hash %FS::UID::callback : =head1 VERSION -$Id: UID.pm,v 1.19 2002-08-29 06:02:52 ivan Exp $ +$Id: UID.pm,v 1.20 2002-09-20 10:16:28 ivan Exp $ =head1 BUGS diff --git a/README.1.5.0pre1 b/README.1.5.0pre1 index 776899e31..ab2f3ab53 100644 --- a/README.1.5.0pre1 +++ b/README.1.5.0pre1 @@ -2,7 +2,7 @@ preliminary upgrade instructions schema changes: *** get svc_broadband changes from pc-intouch - *** otaker changes + *** otaker changes s/8/32 all otkaer fields *** optional: sequence changes install DBIx::DBSchema 0.21 diff --git a/bin/fs-setup b/bin/fs-setup index aeaacbc00..c17c936e7 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.98 2002-09-19 13:34:51 ivan Exp $ +# $Id: fs-setup,v 1.99 2002-09-20 10:16:28 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -404,7 +404,7 @@ sub tables_hash_hack { 'custnum', 'int', '', '', '_date', @date_type, 'amount', @money_type, - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'reason', 'text', 'NULL', '', 'closed', 'char', 'NULL', 1, ], @@ -466,7 +466,7 @@ sub tables_hash_hack { 'paydate', 'varchar', 'NULL', 10, 'payname', 'varchar', 'NULL', $char_d, 'tax', 'char', 'NULL', 1, - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'refnum', 'int', '', '', 'referral_custnum', 'int', 'NULL', '', 'comments', 'text', 'NULL', '', @@ -568,7 +568,7 @@ sub tables_hash_hack { 'pkgnum', 'serial', '', '', 'custnum', 'int', '', '', 'pkgpart', 'int', '', '', - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'setup', @date_type, 'bill', @date_type, 'susp', @date_type, @@ -588,7 +588,7 @@ sub tables_hash_hack { 'custnum', 'int', '', '', '_date', @date_type, 'refund', @money_type, - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'reason', 'varchar', '', $char_d, 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index # into payment type table. -- cgit v1.2.1 From 5dc522149a7ad8363ce46f8ff6b3133b2d3d3cdf Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 20 Sep 2002 12:04:17 +0000 Subject: doc NetAddr::IP dependancy --- README.1.5.0pre1 | 1 + httemplate/docs/install.html | 1 + 2 files changed, 2 insertions(+) diff --git a/README.1.5.0pre1 b/README.1.5.0pre1 index ab2f3ab53..ff3e5a6cc 100644 --- a/README.1.5.0pre1 +++ b/README.1.5.0pre1 @@ -6,6 +6,7 @@ schema changes: *** optional: sequence changes install DBIx::DBSchema 0.21 +install NetAddr::IP Run dbdef-create something about history tables diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 75f039dd1..e6f6f59de 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -53,6 +53,7 @@ Before installing, you need:
            • HTML-Widgets-SelectLayers
            • Storable +
            • NetAddr-IP
            • Apache::DBI (optional but recommended for better webinterface performance)
          -- cgit v1.2.1 From eb0d04842631ae16247c6246cc6a1d8896169ff9 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 20 Sep 2002 12:50:30 +0000 Subject: move from bin/fs-setup to FS/bin/freeside-setup --- FS/bin/freeside-setup | 191 ++++---- bin/fs-setup | 1064 ------------------------------------------ httemplate/docs/install.html | 6 +- 3 files changed, 114 insertions(+), 1147 deletions(-) delete mode 100755 bin/fs-setup diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index 78a03385c..cb74e64c8 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -138,33 +138,6 @@ 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, -# )); -# } -#} - #create history tables (false laziness w/create-history-tables) foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) { my $tableobj = $dbdef->table($table) @@ -339,7 +312,7 @@ sub tables_hash_hack { 'agent' => { 'columns' => [ - 'agentnum', 'int', '', '', + 'agentnum', 'serial', '', '', 'agent', 'varchar', '', $char_d, 'typenum', 'int', '', '', 'freq', 'int', 'NULL', '', @@ -352,7 +325,7 @@ sub tables_hash_hack { 'agent_type' => { 'columns' => [ - 'typenum', 'int', '', '', + 'typenum', 'serial', '', '', 'atype', 'varchar', '', $char_d, ], 'primary_key' => 'typenum', @@ -372,7 +345,7 @@ sub tables_hash_hack { 'cust_bill' => { 'columns' => [ - 'invnum', 'int', '', '', + 'invnum', 'serial', '', '', 'custnum', 'int', '', '', '_date', @date_type, 'charged', @money_type, @@ -386,7 +359,7 @@ sub tables_hash_hack { 'cust_bill_event' => { 'columns' => [ - 'eventnum', 'int', '', '', + 'eventnum', 'serial', '', '', 'invnum', 'int', '', '', 'eventpart', 'int', '', '', '_date', @date_type, @@ -401,7 +374,7 @@ sub tables_hash_hack { 'part_bill_event' => { 'columns' => [ - 'eventpart', 'int', '', '', + 'eventpart', 'serial', '', '', 'payby', 'char', '', 4, 'event', 'varchar', '', $char_d, 'eventcode', @perl_type, @@ -432,11 +405,11 @@ sub tables_hash_hack { 'cust_credit' => { 'columns' => [ - 'crednum', 'int', '', '', + 'crednum', 'serial', '', '', 'custnum', 'int', '', '', '_date', @date_type, 'amount', @money_type, - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'reason', 'text', 'NULL', '', 'closed', 'char', 'NULL', 1, ], @@ -447,7 +420,7 @@ sub tables_hash_hack { 'cust_credit_bill' => { 'columns' => [ - 'creditbillnum', 'int', '', '', + 'creditbillnum', 'serial', '', '', 'crednum', 'int', '', '', 'invnum', 'int', '', '', '_date', @date_type, @@ -460,7 +433,7 @@ sub tables_hash_hack { 'cust_main' => { 'columns' => [ - 'custnum', 'int', '', '', + 'custnum', 'serial', '', '', 'agentnum', 'int', '', '', # 'titlenum', 'int', 'NULL', '', 'last', 'varchar', '', $char_d, @@ -498,7 +471,7 @@ sub tables_hash_hack { 'paydate', 'varchar', 'NULL', 10, 'payname', 'varchar', 'NULL', $char_d, 'tax', 'char', 'NULL', 1, - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'refnum', 'int', '', '', 'referral_custnum', 'int', 'NULL', '', 'comments', 'text', 'NULL', '', @@ -511,7 +484,7 @@ sub tables_hash_hack { 'cust_main_invoice' => { 'columns' => [ - 'destnum', 'int', '', '', + 'destnum', 'serial', '', '', 'custnum', 'int', '', '', 'dest', 'varchar', '', $char_d, ], @@ -524,7 +497,7 @@ sub tables_hash_hack { #cust_main_county for validation and to provide # a tax rate. 'columns' => [ - 'taxnum', 'int', '', '', + 'taxnum', 'serial', '', '', 'state', 'varchar', 'NULL', $char_d, 'county', 'varchar', 'NULL', $char_d, 'country', 'char', '', 2, @@ -540,7 +513,7 @@ sub tables_hash_hack { 'cust_pay' => { 'columns' => [ - 'paynum', 'int', '', '', + 'paynum', 'serial', '', '', #now cust_bill_pay #'invnum', 'int', '', '', 'custnum', 'int', '', '', 'paid', @money_type, @@ -558,7 +531,7 @@ sub tables_hash_hack { 'cust_bill_pay' => { 'columns' => [ - 'billpaynum', 'int', '', '', + 'billpaynum', 'serial', '', '', 'invnum', 'int', '', '', 'paynum', 'int', '', '', 'amount', @money_type, @@ -572,7 +545,7 @@ sub tables_hash_hack { 'cust_pay_batch' => { #what's this used for again? list of customers #in current CARD batch? (necessarily CARD?) 'columns' => [ - 'paybatchnum', 'int', '', '', + 'paybatchnum', 'serial', '', '', 'invnum', 'int', '', '', 'custnum', 'int', '', '', 'last', 'varchar', '', $char_d, @@ -597,10 +570,10 @@ sub tables_hash_hack { 'cust_pkg' => { 'columns' => [ - 'pkgnum', 'int', '', '', + 'pkgnum', 'serial', '', '', 'custnum', 'int', '', '', 'pkgpart', 'int', '', '', - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'setup', @date_type, 'bill', @date_type, 'susp', @date_type, @@ -615,12 +588,12 @@ sub tables_hash_hack { 'cust_refund' => { 'columns' => [ - 'refundnum', 'int', '', '', + 'refundnum', 'serial', '', '', #now cust_credit_refund #'crednum', 'int', '', '', 'custnum', 'int', '', '', '_date', @date_type, 'refund', @money_type, - 'otaker', 'varchar', '', 8, + 'otaker', 'varchar', '', 32, 'reason', 'varchar', '', $char_d, 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index # into payment type table. @@ -635,7 +608,7 @@ sub tables_hash_hack { 'cust_credit_refund' => { 'columns' => [ - 'creditrefundnum', 'int', '', '', + 'creditrefundnum', 'serial', '', '', 'crednum', 'int', '', '', 'refundnum', 'int', '', '', 'amount', @money_type, @@ -649,7 +622,7 @@ sub tables_hash_hack { 'cust_svc' => { 'columns' => [ - 'svcnum', 'int', '', '', + 'svcnum', 'serial', '', '', 'pkgnum', 'int', 'NULL', '', 'svcpart', 'int', '', '', ], @@ -660,7 +633,7 @@ sub tables_hash_hack { 'part_pkg' => { 'columns' => [ - 'pkgpart', 'int', '', '', + 'pkgpart', 'serial', '', '', 'pkg', 'varchar', '', $char_d, 'comment', 'varchar', '', $char_d, 'setup', @perl_type, @@ -701,7 +674,7 @@ sub tables_hash_hack { 'part_referral' => { 'columns' => [ - 'refnum', 'int', '', '', + 'refnum', 'serial', '', '', 'referral', 'varchar', '', $char_d, ], 'primary_key' => 'refnum', @@ -711,7 +684,7 @@ sub tables_hash_hack { 'part_svc' => { 'columns' => [ - 'svcpart', 'int', '', '', + 'svcpart', 'serial', '', '', 'svc', 'varchar', '', $char_d, 'svcdb', 'varchar', '', $char_d, 'disabled', 'char', 'NULL', 1, @@ -723,7 +696,7 @@ sub tables_hash_hack { 'part_svc_column' => { 'columns' => [ - 'columnnum', 'int', '', '', + 'columnnum', 'serial', '', '', 'svcpart', 'int', '', '', 'columnname', 'varchar', '', 64, 'columnvalue', 'varchar', 'NULL', $char_d, @@ -737,7 +710,7 @@ sub tables_hash_hack { #(this should be renamed to part_pop) 'svc_acct_pop' => { 'columns' => [ - 'popnum', 'int', '', '', + 'popnum', 'serial', '', '', 'city', 'varchar', '', $char_d, 'state', 'varchar', '', $char_d, 'ac', 'char', '', 3, @@ -751,7 +724,7 @@ sub tables_hash_hack { 'part_pop_local' => { 'columns' => [ - 'localnum', 'int', '', '', + 'localnum', 'serial', '', '', 'popnum', 'int', '', '', 'city', 'varchar', 'NULL', $char_d, 'state', 'char', 'NULL', 2, @@ -786,18 +759,6 @@ sub tables_hash_hack { 'index' => [ ['username'], ['domsvc'] ], }, -# 'svc_acct_sm' => { -# 'columns' => [ -# 'svcnum', 'int', '', '', -# 'domsvc', 'int', '', '', -# 'domuid', 'int', '', '', -# 'domuser', 'varchar', '', $char_d, -# ], -# 'primary_key' => 'svcnum', -# 'unique' => [ [] ], -# 'index' => [ ['domsvc'], ['domuid'] ], -# }, - #'svc_charge' => { # 'columns' => [ # 'svcnum', 'int', '', '', @@ -821,7 +782,7 @@ sub tables_hash_hack { 'domain_record' => { 'columns' => [ - 'recnum', 'int', '', '', + 'recnum', 'serial', '', '', 'svcnum', 'int', '', '', 'reczone', 'varchar', '', $char_d, 'recaf', 'char', '', 2, @@ -871,7 +832,7 @@ sub tables_hash_hack { 'prepay_credit' => { 'columns' => [ - 'prepaynum', 'int', '', '', + 'prepaynum', 'serial', '', '', 'identifier', 'varchar', '', $char_d, 'amount', @money_type, 'seconds', 'int', 'NULL', '', @@ -883,7 +844,7 @@ sub tables_hash_hack { 'port' => { 'columns' => [ - 'portnum', 'int', '', '', + 'portnum', 'serial', '', '', 'ip', 'varchar', 'NULL', 15, 'nasport', 'int', 'NULL', '', 'nasnum', 'int', '', '', @@ -895,7 +856,7 @@ sub tables_hash_hack { 'nas' => { 'columns' => [ - 'nasnum', 'int', '', '', + 'nasnum', 'serial', '', '', 'nas', 'varchar', '', $char_d, 'nasip', 'varchar', '', 15, 'nasfqdn', 'varchar', '', $char_d, @@ -908,7 +869,7 @@ sub tables_hash_hack { 'session' => { 'columns' => [ - 'sessionnum', 'int', '', '', + 'sessionnum', 'serial', '', '', 'portnum', 'int', '', '', 'svcnum', 'int', '', '', 'login', @date_type, @@ -921,7 +882,7 @@ sub tables_hash_hack { 'queue' => { 'columns' => [ - 'jobnum', 'int', '', '', + 'jobnum', 'serial', '', '', 'job', 'text', '', '', '_date', 'int', '', '', 'status', 'varchar', '', $char_d, @@ -935,7 +896,7 @@ sub tables_hash_hack { 'queue_arg' => { 'columns' => [ - 'argnum', 'int', '', '', + 'argnum', 'serial', '', '', 'jobnum', 'int', '', '', 'arg', 'text', 'NULL', '', ], @@ -946,7 +907,7 @@ sub tables_hash_hack { 'queue_depend' => { 'columns' => [ - 'dependnum', 'int', '', '', + 'dependnum', 'serial', '', '', 'jobnum', 'int', '', '', 'depend_jobnum', 'int', '', '', ], @@ -957,7 +918,7 @@ sub tables_hash_hack { 'export_svc' => { 'columns' => [ - 'exportsvcnum' => 'int', '', '', + 'exportsvcnum' => 'serial', '', '', 'exportnum' => 'int', '', '', 'svcpart' => 'int', '', '', ], @@ -968,7 +929,7 @@ sub tables_hash_hack { 'part_export' => { 'columns' => [ - 'exportnum', 'int', '', '', + 'exportnum', 'serial', '', '', #'svcpart', 'int', '', '', 'machine', 'varchar', '', $char_d, 'exporttype', 'varchar', '', $char_d, @@ -981,7 +942,7 @@ sub tables_hash_hack { 'part_export_option' => { 'columns' => [ - 'optionnum', 'int', '', '', + 'optionnum', 'serial', '', '', 'exportnum', 'int', '', '', 'optionname', 'varchar', '', $char_d, 'optionvalue', 'text', 'NULL', '', @@ -993,7 +954,7 @@ sub tables_hash_hack { 'radius_usergroup' => { 'columns' => [ - 'usergroupnum', 'int', '', '', + 'usergroupnum', 'serial', '', '', 'svcnum', 'int', '', '', 'groupname', 'varchar', '', $char_d, ], @@ -1004,7 +965,7 @@ sub tables_hash_hack { 'msgcat' => { 'columns' => [ - 'msgnum', 'int', '', '', + 'msgnum', 'serial', '', '', 'msgcode', 'varchar', '', $char_d, 'locale', 'varchar', '', 16, 'msg', 'text', '', '', @@ -1016,7 +977,7 @@ sub tables_hash_hack { 'cust_tax_exempt' => { 'columns' => [ - 'exemptnum', 'int', '', '', + 'exemptnum', 'serial', '', '', 'custnum', 'int', '', '', 'taxnum', 'int', '', '', 'year', 'int', '', '', @@ -1028,7 +989,77 @@ sub tables_hash_hack { 'index' => [], }, + 'ac_type' => { + 'columns' => [ + 'actypenum', 'serial', '', '', + 'actypename', 'varchar', '', $char_d, + ], + 'primary_key' => 'actypenum', + 'unique' => [], + 'index' => [], + }, + + 'ac' => { + 'columns' => [ + 'acnum', 'serial', '', '', + 'actypenum', 'int', '', '', + 'acname', 'varchar', '', $char_d, + ], + 'primary_key' => 'acnum', + 'unique' => [], + 'index' => [ [ 'actypenum' ] ], + }, + + 'part_ac_field' => { + 'columns' => [ + 'acfieldpart', 'serial', '', '', + 'actypenum', 'int', '', '', + 'name', 'varchar', '', $char_d, + 'ut_type', 'varchar', '', $char_d, + ], + 'primary_key' => 'acfieldpart', + 'unique' => [], + 'index' => [ [ 'actypenum' ] ], + }, + + 'ac_field' => { + 'columns' => [ + 'acfieldpart', 'int', '', '', + 'acnum', 'int', '', '', + 'value', 'text', '', '', + ], + 'primary_key' => '', + 'unique' => [ [ 'acfieldpart', 'acnum' ] ], + 'index' => [ [ 'acnum' ] ], + }, + + 'ac_block' => { + 'columns' => [ + 'acnum', 'int', '', '', + 'ip_gateway', 'varchar', '', 15, + 'ip_netmask', 'int', '', '', + ], + 'primary_key' => '', + 'unique' => [], + 'index' => [ [ 'acnum' ] ], + }, + 'svc_broadband' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'actypenum', 'int', '', '', + 'speed_up', 'int', '', '', + 'speed_down', 'int', '', '', + 'acnum', 'int', '', '', + 'ip_addr', 'varchar', '', 15, + 'ip_netmask', 'int', '', '', + 'mac_addr', 'char', '', 17, + 'location', 'varchar', '', $char_d, + ], + 'primary_key' => 'svcnum', + 'unique' => [], + 'index' => [ [ 'actypenum' ] ], + }, ); diff --git a/bin/fs-setup b/bin/fs-setup deleted file mode 100755 index c17c936e7..000000000 --- a/bin/fs-setup +++ /dev/null @@ -1,1064 +0,0 @@ -#!/usr/bin/perl -Tw -# -# $Id: fs-setup,v 1.99 2002-09-20 10:16:28 ivan Exp $ - -#to delay loading dbdef until we're ready -BEGIN { $FS::Record::setup_hack = 1; } - -use strict; -use DBI; -use DBIx::DBSchema 0.20; -use DBIx::DBSchema::Table; -use DBIx::DBSchema::Column; -use DBIx::DBSchema::ColGroup::Unique; -use DBIx::DBSchema::ColGroup::Index; -use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); -use FS::Record; -use FS::cust_main_county; -use FS::raddb; -use FS::part_bill_event; - -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); - -#needs to match FS::Record -my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; - -### - -#print "\nEnter the maximum username length: "; -#my($username_len)=&getvalue; -my $username_len = 32; #usernamemax config file - -print "\n\n", <); - chop $x; - $x; -} - -sub _yesno { - print " [y/N]:"; - my $x = scalar(); - $x =~ /^y/i; -} - -### - -my($char_d) = 80; #default maxlength for text fields - -#my(@date_type) = ( 'timestamp', '', '' ); -my(@date_type) = ( 'int', 'NULL', '' ); -my(@perl_type) = ( 'text', 'NULL', '' ); -my @money_type = ( 'decimal', '', '10,2' ); - -### -# create a dbdef object from the old data structure -### - -my(%tables)=&tables_hash_hack; - -#turn it into objects -my($dbdef) = new DBIx::DBSchema ( map { - my(@columns); - while (@{$tables{$_}{'columns'}}) { - my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4; - push @columns, new DBIx::DBSchema::Column ( $name,$type,$null,$length ); - } - DBIx::DBSchema::Table->new( - $_, - $tables{$_}{'primary_key'}, - DBIx::DBSchema::ColGroup::Unique->new($tables{$_}{'unique'}), - DBIx::DBSchema::ColGroup::Index->new($tables{$_}{'index'}), - @columns, - ); -} (keys %tables) ); - -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 - -my($svc_acct)=$dbdef->table('svc_acct'); - -my($attribute); -foreach $attribute (@attributes) { - $svc_acct->addcolumn ( new DBIx::DBSchema::Column ( - 'radius_'. $attribute, - 'varchar', - 'NULL', - $char_d, - )); -} - -foreach $attribute (@check_attributes) { - $svc_acct->addcolumn( new DBIx::DBSchema::Column ( - 'rc_'. $attribute, - 'varchar', - 'NULL', - $char_d, - )); -} - -#create history tables (false laziness w/create-history-tables) -foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) { - my $tableobj = $dbdef->table($table) - or die "unknown table $table"; - - die "unique->lol_ref undefined for $table" - unless defined $tableobj->unique->lol_ref; - die "index->lol_ref undefined for $table" - unless defined $tableobj->index->lol_ref; - - my $h_tableobj = DBIx::DBSchema::Table->new( { - name => "h_$table", - primary_key => 'historynum', - unique => DBIx::DBSchema::ColGroup::Unique->new( [] ), - 'index' => DBIx::DBSchema::ColGroup::Index->new( [ - @{$tableobj->unique->lol_ref}, - @{$tableobj->index->lol_ref} - ] ), - columns => [ - DBIx::DBSchema::Column->new( { - 'name' => 'historynum', - 'type' => 'serial', - 'null' => 'NOT NULL', - 'length' => '', - 'default' => '', - 'local' => '', - } ), - DBIx::DBSchema::Column->new( { - 'name' => 'history_date', - 'type' => 'int', - 'null' => 'NULL', - 'length' => '', - 'default' => '', - 'local' => '', - } ), - DBIx::DBSchema::Column->new( { - 'name' => 'history_user', - 'type' => 'varchar', - 'null' => 'NOT NULL', - 'length' => '80', - 'default' => '', - 'local' => '', - } ), - DBIx::DBSchema::Column->new( { - 'name' => 'history_action', - 'type' => 'varchar', - 'null' => 'NOT NULL', - 'length' => '80', - 'default' => '', - 'local' => '', - } ), - map { $tableobj->column($_) } $tableobj->columns - ], - } ); - $dbdef->addtable($h_tableobj); -} - -#important -$dbdef->save($dbdef_file); -&FS::Record::reload_dbdef($dbdef_file); - -### -# create 'em -### - -my($dbh)=adminsuidsetup $user; - -#create tables -$|=1; - -foreach my $statement ( $dbdef->sql($dbh) ) { - $dbh->do( $statement ) - or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement"; -} - -#not really sample data (and shouldn't default to US) - -#cust_main_county - -#USPS state codes -foreach ( qw( -AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA -ME MH MD MA MI MN MS MO MT NC ND NE NH NJ NM NV NY MP OH OK OR PA PW PR RI -SC SD TN TX UT VT VI VA WA WV WI WY AE AA AP -) ) { - my($cust_main_county)=new FS::cust_main_county({ - 'state' => $_, - 'tax' => 0, - 'country' => 'US', - }); - my($error); - $error=$cust_main_county->insert; - die $error if $error; -} - -#AU "offical" state codes ala mark.williamson@ebbs.com.au (Mark Williamson) -foreach ( qw( -VIC NSW NT QLD TAS ACT WA SA -) ) { - my($cust_main_county)=new FS::cust_main_county({ - 'state' => $_, - 'tax' => 0, - 'country' => 'AU', - }); - my($error); - $error=$cust_main_county->insert; - die $error if $error; -} - -#ISO 2-letter country codes (same as country TLDs) except US and AU -foreach ( qw( -AF AL DZ AS AD AO AI AQ AG AR AM AW AT AZ BS BH BD BB BY BE BZ BJ BM BT BO -BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CK CR CI -HR CU CY CZ DK DJ DM DO TP EC EG SV GQ ER EE ET FK FO FJ FI FR FX GF PF TF GA -GM GE DE GH GI GR GL GD GP GU GT GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IL -IT JM JP JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV -ML MT MH MQ MR MU YT MX FM MD MC MN MS MA MZ MM NA NR NP NL AN NC NZ NI NE NG -NU NF MP NO OM PK PW PA PG PY PE PH PN PL PT PR QA RE RO RU RW KN LC VC WS SM -ST SA SN SC SL SG SK SI SB SO ZA GS ES LK SH PM SD SR SJ SZ SE CH SY TW TJ TZ -TH TG TK TO TT TN TR TM TC TV UG UA AE GB UM UY UZ VU VA VE VN VG VI WF EH -YE YU ZR ZM ZW -) ) { - my($cust_main_county)=new FS::cust_main_county({ - 'tax' => 0, - 'country' => $_, - }); - my($error); - $error=$cust_main_county->insert; - die $error if $error; -} - -#billing events -foreach my $aref ( - [ 'COMP', 'Comp invoice', '$cust_bill->comp();', 30, 'comp' ], - [ 'CARD', 'Batch card', '$cust_bill->batch_card();', 40, 'batch-card' ], - [ 'BILL', 'Send invoice', '$cust_bill->send();', 50, 'send' ], -) { - - my $part_bill_event = new FS::part_bill_event({ - 'payby' => $aref->[0], - 'event' => $aref->[1], - 'eventcode' => $aref->[2], - 'seconds' => 0, - 'weight' => $aref->[3], - 'plan' => $aref->[4], - }); - my($error); - $error=$part_bill_event->insert; - die $error if $error; - -} - -$dbh->commit or die $dbh->errstr; -$dbh->disconnect or die $dbh->errstr; - -print "Freeside database initialized sucessfully\n"; - -sub usage { - die "Usage:\n fs-setup user\n"; -} - -### -# Now it becomes an object. much better. -### -sub tables_hash_hack { - - #note that s/(date|change)/_$1/; to avoid keyword conflict. - #put a kludge in FS::Record to catch this or? (pry need some date-handling - #stuff anyway also) - - my(%tables)=( #yech.} - - 'agent' => { - 'columns' => [ - 'agentnum', 'serial', '', '', - 'agent', 'varchar', '', $char_d, - 'typenum', 'int', '', '', - 'freq', 'int', 'NULL', '', - 'prog', @perl_type, - ], - 'primary_key' => 'agentnum', - 'unique' => [], - 'index' => [ ['typenum'] ], - }, - - 'agent_type' => { - 'columns' => [ - 'typenum', 'serial', '', '', - 'atype', 'varchar', '', $char_d, - ], - 'primary_key' => 'typenum', - 'unique' => [], - 'index' => [], - }, - - 'type_pkgs' => { - 'columns' => [ - 'typenum', 'int', '', '', - 'pkgpart', 'int', '', '', - ], - 'primary_key' => '', - 'unique' => [ ['typenum', 'pkgpart'] ], - 'index' => [ ['typenum'] ], - }, - - 'cust_bill' => { - 'columns' => [ - 'invnum', 'serial', '', '', - 'custnum', 'int', '', '', - '_date', @date_type, - 'charged', @money_type, - 'printed', 'int', '', '', - 'closed', 'char', 'NULL', 1, - ], - 'primary_key' => 'invnum', - 'unique' => [], - 'index' => [ ['custnum'] ], - }, - - 'cust_bill_event' => { - 'columns' => [ - 'eventnum', 'serial', '', '', - 'invnum', 'int', '', '', - 'eventpart', 'int', '', '', - '_date', @date_type, - 'status', 'varchar', '', $char_d, - 'statustext', 'text', 'NULL', '', - ], - 'primary_key' => 'eventnum', - #no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ], - 'unique' => [], - 'index' => [ ['invnum'], ['status'] ], - }, - - 'part_bill_event' => { - 'columns' => [ - 'eventpart', 'serial', '', '', - 'payby', 'char', '', 4, - 'event', 'varchar', '', $char_d, - 'eventcode', @perl_type, - 'seconds', 'int', 'NULL', '', - 'weight', 'int', '', '', - 'plan', 'varchar', 'NULL', $char_d, - 'plandata', 'text', 'NULL', '', - 'disabled', 'char', 'NULL', 1, - ], - 'primary_key' => 'eventpart', - 'unique' => [], - 'index' => [ ['payby'] ], - }, - - 'cust_bill_pkg' => { - 'columns' => [ - 'pkgnum', 'int', '', '', - 'invnum', 'int', '', '', - 'setup', @money_type, - 'recur', @money_type, - 'sdate', @date_type, - 'edate', @date_type, - ], - 'primary_key' => '', - 'unique' => [ ['pkgnum', 'invnum'] ], - 'index' => [ ['invnum'] ], - }, - - 'cust_credit' => { - 'columns' => [ - 'crednum', 'serial', '', '', - 'custnum', 'int', '', '', - '_date', @date_type, - 'amount', @money_type, - 'otaker', 'varchar', '', 32, - 'reason', 'text', 'NULL', '', - 'closed', 'char', 'NULL', 1, - ], - 'primary_key' => 'crednum', - 'unique' => [], - 'index' => [ ['custnum'] ], - }, - - 'cust_credit_bill' => { - 'columns' => [ - 'creditbillnum', 'serial', '', '', - 'crednum', 'int', '', '', - 'invnum', 'int', '', '', - '_date', @date_type, - 'amount', @money_type, - ], - 'primary_key' => 'creditbillnum', - 'unique' => [], - 'index' => [ ['crednum'], ['invnum'] ], - }, - - 'cust_main' => { - 'columns' => [ - 'custnum', 'serial', '', '', - 'agentnum', 'int', '', '', -# 'titlenum', 'int', 'NULL', '', - 'last', 'varchar', '', $char_d, -# 'middle', 'varchar', 'NULL', $char_d, - 'first', 'varchar', '', $char_d, - 'ss', 'char', 'NULL', 11, - 'company', 'varchar', 'NULL', $char_d, - 'address1', 'varchar', '', $char_d, - 'address2', 'varchar', 'NULL', $char_d, - 'city', 'varchar', '', $char_d, - 'county', 'varchar', 'NULL', $char_d, - 'state', 'varchar', 'NULL', $char_d, - 'zip', 'varchar', '', 10, - 'country', 'char', '', 2, - 'daytime', 'varchar', 'NULL', 20, - 'night', 'varchar', 'NULL', 20, - 'fax', 'varchar', 'NULL', 12, - 'ship_last', 'varchar', 'NULL', $char_d, -# 'ship_middle', 'varchar', 'NULL', $char_d, - 'ship_first', 'varchar', 'NULL', $char_d, - 'ship_company', 'varchar', 'NULL', $char_d, - 'ship_address1', 'varchar', 'NULL', $char_d, - 'ship_address2', 'varchar', 'NULL', $char_d, - 'ship_city', 'varchar', 'NULL', $char_d, - 'ship_county', 'varchar', 'NULL', $char_d, - 'ship_state', 'varchar', 'NULL', $char_d, - 'ship_zip', 'varchar', 'NULL', 10, - 'ship_country', 'char', 'NULL', 2, - 'ship_daytime', 'varchar', 'NULL', 20, - 'ship_night', 'varchar', 'NULL', 20, - 'ship_fax', 'varchar', 'NULL', 12, - 'payby', 'char', '', 4, - 'payinfo', 'varchar', 'NULL', $char_d, - #'paydate', @date_type, - 'paydate', 'varchar', 'NULL', 10, - 'payname', 'varchar', 'NULL', $char_d, - 'tax', 'char', 'NULL', 1, - 'otaker', 'varchar', '', 32, - 'refnum', 'int', '', '', - 'referral_custnum', 'int', 'NULL', '', - 'comments', 'text', 'NULL', '', - ], - 'primary_key' => 'custnum', - 'unique' => [], - #'index' => [ ['last'], ['company'] ], - 'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ] ], - }, - - 'cust_main_invoice' => { - 'columns' => [ - 'destnum', 'serial', '', '', - 'custnum', 'int', '', '', - 'dest', 'varchar', '', $char_d, - ], - 'primary_key' => 'destnum', - 'unique' => [], - 'index' => [ ['custnum'], ], - }, - - 'cust_main_county' => { #county+state+country are checked off the - #cust_main_county for validation and to provide - # a tax rate. - 'columns' => [ - 'taxnum', 'serial', '', '', - 'state', 'varchar', 'NULL', $char_d, - 'county', 'varchar', 'NULL', $char_d, - 'country', 'char', '', 2, - 'taxclass', 'varchar', 'NULL', $char_d, - 'exempt_amount', @money_type, - 'tax', 'real', '', '', #tax % - ], - 'primary_key' => 'taxnum', - 'unique' => [], - # 'unique' => [ ['taxnum'], ['state', 'county'] ], - 'index' => [], - }, - - 'cust_pay' => { - 'columns' => [ - 'paynum', 'serial', '', '', - #now cust_bill_pay #'invnum', 'int', '', '', - 'custnum', 'int', '', '', - 'paid', @money_type, - '_date', @date_type, - '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, #for auditing purposes. - 'closed', 'char', 'NULL', 1, - ], - 'primary_key' => 'paynum', - 'unique' => [], - 'index' => [ [ 'custnum' ], [ 'paybatch' ] ], - }, - - 'cust_bill_pay' => { - 'columns' => [ - 'billpaynum', 'serial', '', '', - '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 - #in current CARD batch? (necessarily CARD?) - 'columns' => [ - 'paybatchnum', 'serial', '', '', - 'invnum', 'int', '', '', - 'custnum', 'int', '', '', - 'last', 'varchar', '', $char_d, - 'first', 'varchar', '', $char_d, - 'address1', 'varchar', '', $char_d, - 'address2', 'varchar', 'NULL', $char_d, - 'city', 'varchar', '', $char_d, - 'state', 'varchar', 'NULL', $char_d, - 'zip', 'varchar', '', 10, - 'country', 'char', '', 2, -# 'trancode', 'int', '', '', - 'cardnum', 'varchar', '', 16, - #'exp', @date_type, - 'exp', 'varchar', '', 11, - 'payname', 'varchar', 'NULL', $char_d, - 'amount', @money_type, - ], - 'primary_key' => 'paybatchnum', - 'unique' => [], - 'index' => [ ['invnum'], ['custnum'] ], - }, - - 'cust_pkg' => { - 'columns' => [ - 'pkgnum', 'serial', '', '', - 'custnum', 'int', '', '', - 'pkgpart', 'int', '', '', - 'otaker', 'varchar', '', 32, - 'setup', @date_type, - 'bill', @date_type, - 'susp', @date_type, - 'cancel', @date_type, - 'expire', @date_type, - 'manual_flag', 'char', 'NULL', 1, - ], - 'primary_key' => 'pkgnum', - 'unique' => [], - 'index' => [ ['custnum'] ], - }, - - 'cust_refund' => { - 'columns' => [ - 'refundnum', 'serial', '', '', - #now cust_credit_refund #'crednum', 'int', '', '', - 'custnum', 'int', '', '', - '_date', @date_type, - 'refund', @money_type, - 'otaker', 'varchar', '', 32, - 'reason', 'varchar', '', $char_d, - '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, - 'closed', 'char', 'NULL', 1, - ], - 'primary_key' => 'refundnum', - 'unique' => [], - 'index' => [], - }, - - 'cust_credit_refund' => { - 'columns' => [ - 'creditrefundnum', 'serial', '', '', - 'crednum', 'int', '', '', - 'refundnum', 'int', '', '', - 'amount', @money_type, - '_date', @date_type - ], - 'primary_key' => 'creditrefundnum', - 'unique' => [], - 'index' => [ [ 'crednum', 'refundnum' ] ], - }, - - - 'cust_svc' => { - 'columns' => [ - 'svcnum', 'serial', '', '', - 'pkgnum', 'int', 'NULL', '', - 'svcpart', 'int', '', '', - ], - 'primary_key' => 'svcnum', - 'unique' => [], - 'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ], - }, - - 'part_pkg' => { - 'columns' => [ - 'pkgpart', 'serial', '', '', - 'pkg', 'varchar', '', $char_d, - 'comment', 'varchar', '', $char_d, - 'setup', @perl_type, - 'freq', 'int', '', '', #billing frequency (months) - 'recur', @perl_type, - 'setuptax', 'char', 'NULL', 1, - 'recurtax', 'char', 'NULL', 1, - 'plan', 'varchar', 'NULL', $char_d, - 'plandata', 'text', 'NULL', '', - 'disabled', 'char', 'NULL', 1, - 'taxclass', 'varchar', 'NULL', $char_d, - ], - 'primary_key' => 'pkgpart', - 'unique' => [], - 'index' => [], - }, - -# 'part_title' => { -# 'columns' => [ -# 'titlenum', 'int', '', '', -# 'title', 'varchar', '', $char_d, -# ], -# 'primary_key' => 'titlenum', -# 'unique' => [ [] ], -# 'index' => [ [] ], -# }, - - 'pkg_svc' => { - 'columns' => [ - 'pkgpart', 'int', '', '', - 'svcpart', 'int', '', '', - 'quantity', 'int', '', '', - ], - 'primary_key' => '', - 'unique' => [ ['pkgpart', 'svcpart'] ], - 'index' => [ ['pkgpart'] ], - }, - - 'part_referral' => { - 'columns' => [ - 'refnum', 'serial', '', '', - 'referral', 'varchar', '', $char_d, - ], - 'primary_key' => 'refnum', - 'unique' => [], - 'index' => [], - }, - - 'part_svc' => { - 'columns' => [ - 'svcpart', 'serial', '', '', - 'svc', 'varchar', '', $char_d, - 'svcdb', 'varchar', '', $char_d, - 'disabled', 'char', 'NULL', 1, - ], - 'primary_key' => 'svcpart', - 'unique' => [], - 'index' => [], - }, - - 'part_svc_column' => { - 'columns' => [ - 'columnnum', 'serial', '', '', - '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' => [ - 'popnum', 'serial', '', '', - 'city', 'varchar', '', $char_d, - 'state', 'varchar', '', $char_d, - 'ac', 'char', '', 3, - 'exch', 'char', '', 3, - 'loc', 'char', 'NULL', 4, #NULL for legacy purposes - ], - 'primary_key' => 'popnum', - 'unique' => [], - 'index' => [ [ 'state' ] ], - }, - - 'part_pop_local' => { - 'columns' => [ - 'localnum', 'serial', '', '', - 'popnum', 'int', '', '', - 'city', 'varchar', 'NULL', $char_d, - 'state', 'char', 'NULL', 2, - 'npa', 'char', '', 3, - 'nxx', 'char', '', 3, - ], - 'primary_key' => 'localnum', - 'unique' => [], - 'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ], - }, - - 'svc_acct' => { - 'columns' => [ - 'svcnum', 'int', '', '', - 'username', 'varchar', '', $username_len, #unique (& remove dup code) - '_password', 'varchar', '', 50, #13 for encryped pw's plus ' *SUSPENDED* (mp5 passwords can be 34) - 'sec_phrase', 'varchar', 'NULL', $char_d, - 'popnum', 'int', 'NULL', '', - 'uid', 'int', 'NULL', '', - 'gid', 'int', 'NULL', '', - 'finger', 'varchar', 'NULL', $char_d, - 'dir', 'varchar', 'NULL', $char_d, - 'shell', 'varchar', 'NULL', $char_d, - 'quota', 'varchar', 'NULL', $char_d, - 'slipip', 'varchar', 'NULL', 15, #four TINYINTs, bah. - 'seconds', 'int', 'NULL', '', #uhhhh - 'domsvc', 'int', '', '', - ], - 'primary_key' => 'svcnum', - #'unique' => [ [ 'username', 'domsvc' ] ], - 'unique' => [], - 'index' => [ ['username'], ['domsvc'] ], - }, - - #'svc_charge' => { - # 'columns' => [ - # 'svcnum', 'int', '', '', - # 'amount', @money_type, - # ], - # 'primary_key' => 'svcnum', - # 'unique' => [ [] ], - # 'index' => [ [] ], - #}, - - 'svc_domain' => { - 'columns' => [ - 'svcnum', 'int', '', '', - 'domain', 'varchar', '', $char_d, - 'catchall', 'int', 'NULL', '', - ], - 'primary_key' => 'svcnum', - 'unique' => [ ['domain'] ], - 'index' => [], - }, - - 'domain_record' => { - 'columns' => [ - 'recnum', 'serial', '', '', - 'svcnum', 'int', '', '', - 'reczone', 'varchar', '', $char_d, - 'recaf', 'char', '', 2, - 'rectype', 'char', '', 5, - 'recdata', 'varchar', '', $char_d, - ], - 'primary_key' => 'recnum', - 'unique' => [], - 'index' => [ ['svcnum'] ], - }, - - 'svc_forward' => { - 'columns' => [ - 'svcnum', 'int', '', '', - 'srcsvc', 'int', '', '', - 'dstsvc', 'int', '', '', - 'dst', 'varchar', 'NULL', $char_d, - ], - 'primary_key' => 'svcnum', - 'unique' => [], - 'index' => [ ['srcsvc'], ['dstsvc'] ], - }, - - 'svc_www' => { - 'columns' => [ - 'svcnum', 'int', '', '', - 'recnum', 'int', '', '', - 'usersvc', 'int', '', '', - ], - 'primary_key' => 'svcnum', - 'unique' => [], - 'index' => [], - }, - - #'svc_wo' => { - # 'columns' => [ - # 'svcnum', 'int', '', '', - # 'svcnum', 'int', '', '', - # 'svcnum', 'int', '', '', - # 'worker', 'varchar', '', $char_d, - # '_date', @date_type, - # ], - # 'primary_key' => 'svcnum', - # 'unique' => [ [] ], - # 'index' => [ [] ], - #}, - - 'prepay_credit' => { - 'columns' => [ - 'prepaynum', 'serial', '', '', - 'identifier', 'varchar', '', $char_d, - 'amount', @money_type, - 'seconds', 'int', 'NULL', '', - ], - 'primary_key' => 'prepaynum', - 'unique' => [ ['identifier'] ], - 'index' => [], - }, - - 'port' => { - 'columns' => [ - 'portnum', 'serial', '', '', - 'ip', 'varchar', 'NULL', 15, - 'nasport', 'int', 'NULL', '', - 'nasnum', 'int', '', '', - ], - 'primary_key' => 'portnum', - 'unique' => [], - 'index' => [], - }, - - 'nas' => { - 'columns' => [ - 'nasnum', 'serial', '', '', - 'nas', 'varchar', '', $char_d, - 'nasip', 'varchar', '', 15, - 'nasfqdn', 'varchar', '', $char_d, - 'last', 'int', '', '', - ], - 'primary_key' => 'nasnum', - 'unique' => [ [ 'nas' ], [ 'nasip' ] ], - 'index' => [ [ 'last' ] ], - }, - - 'session' => { - 'columns' => [ - 'sessionnum', 'serial', '', '', - 'portnum', 'int', '', '', - 'svcnum', 'int', '', '', - 'login', @date_type, - 'logout', @date_type, - ], - 'primary_key' => 'sessionnum', - 'unique' => [], - 'index' => [ [ 'portnum' ] ], - }, - - 'queue' => { - 'columns' => [ - 'jobnum', 'serial', '', '', - 'job', 'text', '', '', - '_date', 'int', '', '', - 'status', 'varchar', '', $char_d, - 'statustext', 'text', 'NULL', '', - 'svcnum', 'int', 'NULL', '', - ], - 'primary_key' => 'jobnum', - 'unique' => [], - 'index' => [ [ 'svcnum' ], [ 'status' ] ], - }, - - 'queue_arg' => { - 'columns' => [ - 'argnum', 'serial', '', '', - 'jobnum', 'int', '', '', - 'arg', 'text', 'NULL', '', - ], - 'primary_key' => 'argnum', - 'unique' => [], - 'index' => [ [ 'jobnum' ] ], - }, - - 'queue_depend' => { - 'columns' => [ - 'dependnum', 'serial', '', '', - 'jobnum', 'int', '', '', - 'depend_jobnum', 'int', '', '', - ], - 'primary_key' => 'dependnum', - 'unique' => [], - 'index' => [ [ 'jobnum' ], [ 'depend_jobnum' ] ], - }, - - 'export_svc' => { - 'columns' => [ - 'exportsvcnum' => 'serial', '', '', - 'exportnum' => 'int', '', '', - 'svcpart' => 'int', '', '', - ], - 'primary_key' => 'exportsvcnum', - 'unique' => [ [ 'exportnum', 'svcpart' ] ], - 'index' => [ [ 'exportnum' ], [ 'svcpart' ] ], - }, - - 'part_export' => { - 'columns' => [ - 'exportnum', 'serial', '', '', - #'svcpart', 'int', '', '', - 'machine', 'varchar', '', $char_d, - 'exporttype', 'varchar', '', $char_d, - 'nodomain', 'char', 'NULL', 1, - ], - 'primary_key' => 'exportnum', - 'unique' => [], - 'index' => [ [ 'machine' ], [ 'exporttype' ] ], - }, - - 'part_export_option' => { - 'columns' => [ - 'optionnum', 'serial', '', '', - 'exportnum', 'int', '', '', - 'optionname', 'varchar', '', $char_d, - 'optionvalue', 'text', 'NULL', '', - ], - 'primary_key' => 'optionnum', - 'unique' => [], - 'index' => [ [ 'exportnum' ], [ 'optionname' ] ], - }, - - 'radius_usergroup' => { - 'columns' => [ - 'usergroupnum', 'serial', '', '', - 'svcnum', 'int', '', '', - 'groupname', 'varchar', '', $char_d, - ], - 'primary_key' => 'usergroupnum', - 'unique' => [], - 'index' => [ [ 'svcnum' ], [ 'groupname' ] ], - }, - - 'msgcat' => { - 'columns' => [ - 'msgnum', 'serial', '', '', - 'msgcode', 'varchar', '', $char_d, - 'locale', 'varchar', '', 16, - 'msg', 'text', '', '', - ], - 'primary_key' => 'msgnum', - 'unique' => [ [ 'msgcode', 'locale' ] ], - 'index' => [], - }, - - 'cust_tax_exempt' => { - 'columns' => [ - 'exemptnum', 'serial', '', '', - 'custnum', 'int', '', '', - 'taxnum', 'int', '', '', - 'year', 'int', '', '', - 'month', 'int', '', '', - 'amount', @money_type, - ], - 'primary_key' => 'exemptnum', - 'unique' => [ [ 'custnum', 'taxnum', 'year', 'month' ] ], - 'index' => [], - }, - - 'ac_type' => { - 'columns' => [ - 'actypenum', 'serial', '', '', - 'actypename', 'varchar', '', 15, - ], - 'primary_key' => 'actypenum', - 'unique' => [], - 'index' => [], - }, - - 'ac' => { - 'columns' => [ - 'acnum', 'serial', '', '', - 'actypenum', 'int', '', '', - 'acname', 'varchar', '', 15, - ], - 'primary_key' => 'acnum', - 'unique' => [], - 'index' => [], - }, - - 'part_ac_field' => { - 'columns' => [ - 'acfieldpart', 'serial', '', '', - 'actypenum', 'int', '', '', - 'name', 'varchar', '', 15, - 'ut_type', 'varchar', '', 15, - ], - 'primary_key' => 'acfieldpart', - 'unique' => [], - 'index' => [], - }, - - 'ac_field' => { - 'columns' => [ - 'acfieldpart', 'int', '', '', - 'acnum', 'int', '', '', - 'value', 'varchar', '', 127, - ], - 'primary_key' => '', - 'unique' => [ [ 'acfieldpart', 'acnum' ] ], - 'index' => [], - }, - - 'ac_block' => { - 'columns' => [ - 'acnum', 'int', '', '', - 'ip_gateway', 'char', '', 15, - 'ip_netmask', 'int', '', '', - ], - 'primary_key' => '', - 'unique' => [], - 'index' => [], - }, - - 'svc_broadband' => { - 'columns' => [ - 'svcnum', 'serial', '', '', - 'actypenum', 'int', '', '', - 'speed_up', 'int', '', '', - 'speed_down', 'int', '', '', - 'acnum', 'int', '', '', - 'ip_addr', 'char', '', 15, - 'ip_netmask', 'int', '', '', - 'mac_addr', 'char', '', 17, - 'location', 'varchar', '', 127, - ], - 'primary_key' => 'svcnum', - 'unique' => [], - 'index' => [], - }, - - ); - - %tables; - -} - diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index e6f6f59de..e6f4edbbc 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -181,12 +181,12 @@ $ freeside-adduser -c -h /usr/local/ $ freeside-adduser -h /usr/local/etc/freeside/htpasswd username
        (using other auth types, add each user to your Apache authentication and then run: freeside-adduser username -
      • As the freeside UNIX user, run bin/fs-setup username (in the untar'ed freeside directory) to create the database tables, passing the username of a Freeside user you created above: +
      • As the freeside UNIX user, run freeside--setup username (in the untar'ed freeside directory) to create the database tables, passing the username of a Freeside user you created above:
         $ su freeside
        -$ cd /path/to/freeside-1.4.0/
        -$ bin/fs-setup username
        +$ freeside-setup username
         
        + Alternately, use the -s option to enable shipping addresses: freeside-setup -s username
      • As the freeside UNIX user, run bin/populate-msgcat username (in the untar'ed freeside directory) to populate the message catalog, passing the username of a Freeside user you created above:
         $ su freeside
        -- 
        cgit v1.2.1
        
        
        From 9c3fb2a84c655cbbaafed99586f1431e08c218d5 Mon Sep 17 00:00:00 2001
        From: ivan 
        Date: Fri, 20 Sep 2002 14:48:35 +0000
        Subject: extraneous warn
        
        ---
         FS/FS/part_export.pm | 2 --
         1 file changed, 2 deletions(-)
        
        diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm
        index 647666b86..1b402e014 100644
        --- a/FS/FS/part_export.pm
        +++ b/FS/FS/part_export.pm
        @@ -274,8 +274,6 @@ sub check {
           ;
           return $error if $error;
         
        -  warn $self->machine. "!!!\n";
        -
           $self->machine =~ /^([\w\-\.]*)$/
             or return "Illegal machine: ". $self->machine;
           $self->machine($1);
        -- 
        cgit v1.2.1
        
        
        From b59cf43f0814ea4d484d4b09833dd3c2d493455f Mon Sep 17 00:00:00 2001
        From: ivan 
        Date: Fri, 20 Sep 2002 15:46:29 +0000
        Subject: fix database sequence code, closes: Bug#69
        
        ---
         FS/FS/Record.pm | 16 ++++++++++++----
         1 file changed, 12 insertions(+), 4 deletions(-)
        
        diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
        index 8778dee79..a23f37a62 100644
        --- a/FS/FS/Record.pm
        +++ b/FS/FS/Record.pm
        @@ -480,10 +480,17 @@ sub insert {
           my $db_seq = 0;
           if ( $primary_key ) {
             my $col = $self->dbdef_table->column($primary_key);
        -    my $db_seq =
        +    
        +    $db_seq =
               uc($col->type) eq 'SERIAL'
        -      || ( driver_name eq 'Pg'    && $col->default =~ /^nextval\(/i     )
        -      || ( driver_name eq 'mysql' && $col->local   =~ /AUTO_INCREMENT/i );
        +      || ( driver_name eq 'Pg'
        +             && defined($col->default)
        +             && $col->default =~ /^nextval\(/i
        +         )
        +      || ( driver_name eq 'mysql'
        +             && defined($col->local)
        +             && $col->local =~ /AUTO_INCREMENT/i
        +         );
             $self->unique($primary_key) unless $self->getfield($primary_key) || $db_seq;
           }
         
        @@ -515,11 +522,12 @@ sub insert {
           $sth->execute or return $sth->errstr;
         
           if ( $db_seq ) { # get inserted id from the database, if applicable
        +    warn "[debug]$me retreiving sequence from database\n" if $DEBUG;
             my $insertid = '';
             if ( driver_name eq 'Pg' ) {
         
               my $oid = $sth->{'pg_oid_status'};
        -      my $i_sql = "SELECT id FROM $table WHERE oid = ?";
        +      my $i_sql = "SELECT $primary_key FROM $table WHERE oid = ?";
               my $i_sth = dbh->prepare($i_sql) or do {
                 dbh->rollback if $FS::UID::AutoCommit;
                 return dbh->errstr;
        -- 
        cgit v1.2.1
        
        
        From 70a4b5227943108ce91c68e1c4e7509a9a6c33f9 Mon Sep 17 00:00:00 2001
        From: ivan 
        Date: Fri, 20 Sep 2002 15:47:58 +0000
        Subject: add freeside-deluser, freeside-deloutsource and
         freeside-deloutsourceuser
        
        ---
         FS/MANIFEST                      |  3 ++
         FS/bin/freeside-addoutsourceuser |  2 +-
         FS/bin/freeside-deloutsource     | 11 +++++++
         FS/bin/freeside-deloutsourceuser |  6 ++++
         FS/bin/freeside-deluser          | 64 ++++++++++++++++++++++++++++++++++++++++
         FS/bin/freeside-setup            |  2 +-
         bin/populate-msgcat              |  2 +-
         7 files changed, 87 insertions(+), 3 deletions(-)
         create mode 100644 FS/bin/freeside-deloutsource
         create mode 100644 FS/bin/freeside-deloutsourceuser
         create mode 100644 FS/bin/freeside-deluser
        
        diff --git a/FS/MANIFEST b/FS/MANIFEST
        index 3cf4c2ba3..24fef1748 100644
        --- a/FS/MANIFEST
        +++ b/FS/MANIFEST
        @@ -9,8 +9,11 @@ bin/freeside-email
         bin/freeside-queued
         bin/freeside-addoutsource
         bin/freeside-addoutsourceuser
        +bin/freeside-deloutsource
        +bin/freeside-deloutsourceuser
         bin/freeside-apply-credits
         bin/freeside-adduser
        +bin/freeside-deluser
         bin/freeside-setup
         bin/freeside-setinvoice
         bin/freeside-overdue
        diff --git a/FS/bin/freeside-addoutsourceuser b/FS/bin/freeside-addoutsourceuser
        index bbad8aa3f..180cd9399 100644
        --- a/FS/bin/freeside-addoutsourceuser
        +++ b/FS/bin/freeside-addoutsourceuser
        @@ -11,5 +11,5 @@ freeside-adduser -h /usr/local/etc/freeside/htpasswd \
         
         [ -e /usr/local/etc/freeside/dbdef.DBI:Pg:host=localhost\;dbname=$domain ] \
          || ( freeside-setup $username 2>/dev/null; \
        -      /home/ivan/freeside/bin/populate-msgcat $username; 2>/dev/null )
        +      /home/ivan/freeside/bin/populate-msgcat $username )
         
        diff --git a/FS/bin/freeside-deloutsource b/FS/bin/freeside-deloutsource
        new file mode 100644
        index 000000000..561853539
        --- /dev/null
        +++ b/FS/bin/freeside-deloutsource
        @@ -0,0 +1,11 @@
        +#!/bin/sh
        +
        +domain=$1
        +
        +dropdb $domain && \
        +rm -rf /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain && \
        +rm -rf /usr/local/etc/freeside/counters.DBI:Pg:host=localhost\;dbname=$domain && \
        +rm -rf /usr/local/etc/freeside/cache.DBI:Pg:host=localhost\;dbname=$domain && \
        +rm -rf /usr/local/etc/freeside/export.DBI:Pg:host=localhost\;dbname=$domain && \
        +rm /usr/local/etc/freeside/dbdef.DBI:Pg:host=localhost\;dbname=$domain
        +
        diff --git a/FS/bin/freeside-deloutsourceuser b/FS/bin/freeside-deloutsourceuser
        new file mode 100644
        index 000000000..96871e50c
        --- /dev/null
        +++ b/FS/bin/freeside-deloutsourceuser
        @@ -0,0 +1,6 @@
        +#!/bin/sh
        +
        +username=$1
        +
        +freeside-deluser -h /usr/local/etc/freeside/htpasswd $username 2>/dev/null
        +
        diff --git a/FS/bin/freeside-deluser b/FS/bin/freeside-deluser
        new file mode 100644
        index 000000000..57d6ce165
        --- /dev/null
        +++ b/FS/bin/freeside-deluser
        @@ -0,0 +1,64 @@
        +#!/usr/bin/perl -w
        +
        +use strict;
        +use vars qw($opt_h);
        +use Fcntl qw(:flock);
        +use Getopt::Std;
        +
        +my $FREESIDE_CONF = "/usr/local/etc/freeside";
        +
        +getopts("h:");
        +my $user = shift or die &usage;
        +
        +if ( $opt_h ) {
        +  open(HTPASSWD,"<$opt_h")
        +    and flock(HTPASSWD,LOCK_EX)
        +      or die "can't open $opt_h: $!";
        +  open(HTPASSWD_TMP,">$opt_h.tmp") or die "can't open $opt_h.tmp: $!";
        +  while () {
        +    print HTPASSWD_TMP $_ unless /^$user:/;
        +  }
        +  close HTPASSWD_TMP;
        +  rename "$opt_h.tmp", "$opt_h" or die $!;
        +  flock(HTPASSWD,LOCK_UN);
        +  close HTPASSWD;
        +}
        +
        +open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
        +  and flock(MAPSECRETS,LOCK_EX)
        +    or die "can't open $FREESIDE_CONF/mapsecrets: $!";
        +open(MAPSECRETS_TMP,">>$FREESIDE_CONF/mapsecrets.tmp")
        +  or die "can't open $FREESIDE_CONF/mapsecrets.tmp: $!";
        +while () {
        +  print MAPSECRETS_TMP $_ unless /^$user\s/;
        +}
        +close MAPSECRETS_TMP;
        +rename "$FREESIDE_CONF/mapsecrets.tmp", "$FREESIDE_CONF/mapsecrets" or die $!;
        +flock(MAPSECRETS,LOCK_UN);
        +close MAPSECRETS;
        +
        +sub usage {
        +  die "Usage:\n\n  freeside-deluser [ -h htpasswd_file ] username"
        +}
        +
        +=head1 NAME
        +
        +freeside-deluser - Command line interface to add (freeside) users.
        +
        +=head1 SYNOPSIS
        +
        +  freeside-deluser [ -h htpasswd_file ] username
        +
        +=head1 DESCRIPTION
        +
        +Adds a user to the Freeside billing system.  This is for adding users (internal
        +sales/tech folks) to the web interface, not for adding customer accounts.
        +
        +  -h: Also delete from the given htpasswd filename
        +
        +=head1 SEE ALSO
        +
        +L, L(1), base Freeside documentation
        +
        +=cut
        +
        diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup
        index cb74e64c8..e8bb7ec62 100755
        --- a/FS/bin/freeside-setup
        +++ b/FS/bin/freeside-setup
        @@ -7,7 +7,7 @@ use strict;
         use vars qw($opt_s);
         use Getopt::Std;
         use DBI;
        -use DBIx::DBSchema 0.20;
        +use DBIx::DBSchema 0.21;
         use DBIx::DBSchema::Table;
         use DBIx::DBSchema::Column;
         use DBIx::DBSchema::ColGroup::Unique;
        diff --git a/bin/populate-msgcat b/bin/populate-msgcat
        index f8e23cfa0..3b198f718 100755
        --- a/bin/populate-msgcat
        +++ b/bin/populate-msgcat
        @@ -27,7 +27,7 @@ foreach my $msgcode ( keys %messages ) {
           }
         }
         
        -print "Message catalog initialized sucessfully\n";
        +#print "Message catalog initialized sucessfully\n";
         
         sub messages {
         
        -- 
        cgit v1.2.1