summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/ClientAPI/Signup.pm156
-rw-r--r--FS/FS/ClientAPI_XMLRPC.pm1
-rw-r--r--FS/FS/cust_main.pm15
-rw-r--r--FS/FS/cust_main/Location.pm6
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm1
-rw-r--r--httemplate/view/cust_main/contacts.html6
6 files changed, 175 insertions, 10 deletions
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index 57091c4..593c426 100644
--- a/FS/FS/ClientAPI/Signup.pm
+++ b/FS/FS/ClientAPI/Signup.pm
@@ -24,7 +24,7 @@ use FS::reg_code;
use FS::payby;
use FS::banned_pay;
-$DEBUG = 0;
+$DEBUG = 1;
$me = '[FS::ClientAPI::Signup]';
sub clear_cache {
@@ -869,6 +869,160 @@ sub new_customer {
}
+#false laziness w/ above
+# fresh restart to support "free account" portals with 3.x/4.x-style
+# addressless accounts
+sub new_customer_minimal {
+ my $packet = shift;
+
+ my $conf = new FS::Conf;
+ my $svc_x = $conf->config('signup_server-service') || 'svc_acct';
+
+ if ( $svc_x eq 'svc_acct' ) {
+
+ #things that aren't necessary in base class, but are for signup server
+ #return "Passwords don't match"
+ # if $hashref->{'_password'} ne $hashref->{'_password2'}
+ return { 'error' => gettext('empty_password') }
+ unless length($packet->{'_password'});
+ # a bit inefficient for large numbers of pops
+ return { 'error' => gettext('no_access_number_selected') }
+ unless $packet->{'popnum'} || !scalar(qsearch('svc_acct_pop',{} ));
+
+ }
+ elsif ( $svc_x eq 'svc_pbx' ) {
+ #possibly some validation will be needed
+ }
+
+ my $agentnum;
+ if ( exists $packet->{'session_id'} ) {
+ my $cache = new FS::ClientAPI_SessionCache( {
+ 'namespace' => 'FS::ClientAPI::Agent',
+ } );
+ my $session = $cache->get($packet->{'session_id'});
+ if ( $session ) {
+ $agentnum = $session->{'agentnum'};
+ } else {
+ return { 'error' => "Can't resume session" }; #better error message
+ }
+ } else {
+ $agentnum = $packet->{agentnum}
+ || $conf->config('signup_server-default_agentnum');
+ }
+
+ #shares some stuff with htdocs/edit/process/cust_main.cgi... take any
+ # common that are still here and library them.
+
+ my $cust_main = new FS::cust_main ( {
+ #'custnum' => '',
+ 'agentnum' => $agentnum,
+ 'refnum' => $packet->{refnum}
+ || $conf->config('signup_server-default_refnum'),
+ 'payby' => 'BILL',
+
+ map { $_ => $packet->{$_} } qw(
+ last first ss company
+ daytime night fax
+ ),
+
+ } );
+
+ my @invoicing_list = $packet->{'invoicing_list'}
+ ? split( /\s*\,\s*/, $packet->{'invoicing_list'} )
+ : ();
+
+ $packet->{'pkgpart'} =~ /^(\d+)$/ or '' =~ /^()$/;
+ my $pkgpart = $1;
+ return { 'error' => 'Please select a package' } unless $pkgpart; #msgcat
+
+ my $part_pkg =
+ qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } )
+ or return { 'error' => "WARNING: unknown pkgpart: $pkgpart" };
+ my $svcpart = $part_pkg->svcpart($svc_x);
+
+ my $cust_pkg = new FS::cust_pkg ( {
+ #later#'custnum' => $custnum,
+ 'pkgpart' => $packet->{'pkgpart'},
+ } );
+ #my $error = $cust_pkg->check;
+ #return { 'error' => $error } if $error;
+
+ #should be all auto-magic and shit
+ my @svc = ();
+ if ( $svc_x eq 'svc_acct' ) {
+
+ my $svc = new FS::svc_acct {
+ 'svcpart' => $svcpart,
+ map { $_ => $packet->{$_} }
+ qw( username _password sec_phrase popnum domsvc ),
+ };
+
+ push @svc, $svc;
+
+ } elsif ( $svc_x eq 'svc_phone' ) {
+
+ push @svc, new FS::svc_phone ( {
+ 'svcpart' => $svcpart,
+ map { $_ => $packet->{$_} }
+ qw( countrycode phonenum sip_password pin ),
+ } );
+
+ } elsif ( $svc_x eq 'svc_pbx' ) {
+
+ push @svc, new FS::svc_pbx ( {
+ 'svcpart' => $svcpart,
+ map { $_ => $packet->{$_} }
+ qw( id title ),
+ } );
+
+ } else {
+ die "unknown signup service $svc_x";
+ }
+
+ foreach my $svc ( @svc ) {
+ my $y = $svc->setdefault; # arguably should be in new method
+ return { 'error' => $y } if $y && !ref($y);
+ #$error = $svc->check;
+ #return { 'error' => $error } if $error;
+ }
+
+ use Tie::RefHash;
+ tie my %hash, 'Tie::RefHash';
+ %hash = ( $cust_pkg => \@svc );
+ #msgcat
+ my $error = $cust_main->insert(
+ \%hash,
+ \@invoicing_list,
+ );
+ return { 'error' => $error } if $error;
+
+ my %return = ( 'error' => '',
+ 'signup_service' => $svc_x,
+ 'custnum' => $cust_main->custnum,
+ );
+
+ if ( $svc[0] ) {
+
+ $return{'svcnum'} = $svc[0]->svcnum;
+
+ if ( $svc_x eq 'svc_acct' ) {
+ $return{$_} = $svc[0]->$_() for qw( username _password );
+ } elsif ( $svc_x eq 'svc_phone' ) {
+ $return{$_} = $svc[0]->$_() for qw(countrycode phonenum sip_password pin);
+ } elsif ( $svc_x eq 'svc_pbx' ) {
+ #$return{$_} = $svc[0]->$_() for qw( ) #nothing yet
+ } else {
+ return {'error' => "configuration error: unknown signup service $svc_x"};
+ #die "unknown signup service $svc_x";
+ # return an error that's visible to someone somewhere
+ }
+
+ }
+
+ return \%return;
+
+}
+
sub capture_payment {
my $packet = shift;
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 6f37ce8..6ebdcec 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -170,6 +170,7 @@ sub ss2clientapi {
'access_info' => 'MyAccount/access_info',
'domain_select_hash' => 'Signup/domain_select_hash', # expose?
'new_customer' => 'Signup/new_customer',
+ 'new_customer_minimal' => 'Signup/new_customer_minimal',
'capture_payment' => 'Signup/capture_payment',
'clear_signup_cache' => 'Signup/clear_cache',
'new_agent' => 'Agent/new_agent',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 5126fea..a1d7d87 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -411,7 +411,9 @@ sub insert {
my $loc = delete $self->hashref->{$l};
# XXX if we're moving a prospect's locations, do that here
if ( !$loc ) {
- return "$l not set";
+ #return "$l not set";
+ #location-less customer records are now permitted
+ next;
}
if ( !$loc->locationnum ) {
@@ -461,7 +463,7 @@ sub insert {
foreach my $l (qw(bill_location ship_location)) {
warn " setting $l.custnum\n"
if $DEBUG > 1;
- my $loc = $self->$l;
+ my $loc = $self->$l or next;
unless ( $loc->custnum ) {
$loc->set(custnum => $self->custnum);
$error ||= $loc->replace;
@@ -1674,8 +1676,9 @@ sub queue_fuzzyfiles_update {
}
}
- my @locations = $self->bill_location;
- push @locations, $self->ship_location if $self->has_ship_address;
+ my @locations = ();
+ push @locations, $self->bill_location if $self->bill_locationnum;
+ push @locations, $self->ship_location if @locations && $self->has_ship_address;
foreach my $location (@locations) {
my $queue = new FS::queue {
'job' => 'FS::cust_main::Search::append_fuzzyfiles_fuzzyfield'
@@ -1712,8 +1715,8 @@ sub check {
|| $self->ut_number('agentnum')
|| $self->ut_textn('agent_custid')
|| $self->ut_number('refnum')
- || $self->ut_foreign_key('bill_locationnum', 'cust_location','locationnum')
- || $self->ut_foreign_key('ship_locationnum', 'cust_location','locationnum')
+ || $self->ut_foreign_keyn('bill_locationnum', 'cust_location','locationnum')
+ || $self->ut_foreign_keyn('ship_locationnum', 'cust_location','locationnum')
|| $self->ut_foreign_keyn('classnum', 'cust_class', 'classnum')
|| $self->ut_foreign_keyn('salesnum', 'sales', 'salesnum')
|| $self->ut_textn('custbatch')
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index 52fe313..4bcffab 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -24,11 +24,13 @@ BEGIN {
foreach my $f (@location_fields) {
*{"FS::cust_main::Location::$f"} = sub {
carp "WARNING: tried to set cust_main.$f with accessor" if (@_ > 1);
- shift->bill_location->$f
+ my $l = shift->bill_location;
+ $l ? $l->$f : '';
};
*{"FS::cust_main::Location::ship_$f"} = sub {
carp "WARNING: tried to set cust_main.ship_$f with accessor" if (@_ > 1);
- shift->ship_location->$f
+ my $l = shift->ship_location;
+ $l ? $l->$f : '';
};
}
$init++;
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 8227e57..567c710 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -96,6 +96,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
'access_info' => 'MyAccount/access_info',
'domain_select_hash' => 'Signup/domain_select_hash', # expose?
'new_customer' => 'Signup/new_customer',
+ 'new_customer_minimal' => 'Signup/new_customer_minimal',
'capture_payment' => 'Signup/capture_payment',
#N/A 'clear_signup_cache' => 'Signup/clear_cache',
'new_agent' => 'Agent/new_agent',
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 294b7ba..4444535 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -49,7 +49,9 @@
</TR>
% }
% }
-% # now the actual address
+
+
+% if ( $location ) { # now the actual address
<TR>
<TD ALIGN="right"><% mt('Address') |h %></TD>
<TD COLSPAN=7 BGCOLOR="#ffffff"><% $location->address1 |h %></TD>
@@ -92,6 +94,8 @@
&>
% }
<& /elements/tr-censustract.html, $location &>
+
+% }
% if ( $this eq 'bill' ) {
% # billing contact phone numbers