package FS::SignupClient;
use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket);
+use vars qw($VERSION @ISA @EXPORT_OK $init_data); # $fs_signupd_socket);
use Exporter;
-use Socket;
-use FileHandle;
-use IO::Handle;
-use Storable qw(nstore_fd fd_retrieve);
+#use Socket;
+#use FileHandle;
+#use IO::Handle;
+#use Storable qw(nstore_fd fd_retrieve);
+use FS::SelfService; # qw( new_customer signup_info );
-$VERSION = '0.03';
+$VERSION = '0.04';
@ISA = qw( Exporter );
-@EXPORT_OK = qw( signup_info new_customer );
-
-$fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket";
-
-$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
-$ENV{'SHELL'} = '/bin/sh';
-$ENV{'IFS'} = " \t\n";
-$ENV{'CDPATH'} = '';
-$ENV{'ENV'} = '';
-$ENV{'BASH_ENV'} = '';
-
-my $freeside_uid = scalar(getpwnam('freeside'));
-die "not running as the freeside user\n" if $> != $freeside_uid;
+@EXPORT_OK = qw( signup_info new_customer regionselector expselect popselector);
=head1 NAME
use FS::SignupClient qw( signup_info new_customer );
- ( $locales, $packages, $pops ) = signup_info;
+ #this is the backwards-compatibility bit
+ ( $locales, $packages, $pops, $real_signup_info ) = signup_info;
+ #this is compatible with FS::SelfService::new_customer
$error = new_customer ( {
'first' => $first,
'last' => $last,
'fax' => $fax,
'payby' => $payby,
'payinfo' => $payinfo,
+ 'paycvv' => $paycvv,
'paydate' => $paydate,
'payname' => $payname,
'invoicing_list' => $invoicing_list,
=cut
+#compatibility bit
sub signup_info {
- socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
- connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
- print SOCK "signup_info\n";
- SOCK->flush;
- my $init_data = fd_retrieve(\*SOCK);
- close SOCK;
+ $init_data = FS::SelfService::signup_info();
(map { $init_data->{$_} } qw( cust_main_county part_pkg svc_acct_pop ) ),
$init_data;
fax
payby
payinfo
+ paycvv
paydate
payname
invoicing_list
=cut
-sub new_customer {
- my $hashref = shift;
+#compatibility bit
+sub new_customer {
+ my $hash = FS::SelfService::new_customer(@_);
+ $hash->{'error'};
+}
+
+=item regionselector SELECTED_COUNTY, SELECTED_STATE, SELECTED_COUNTRY, PREFIX, ONCHANGE
+
+=cut
+
+sub regionselector {
+ my ( $selected_county, $selected_state, $selected_country,
+ $prefix, $onchange ) = @_;
+ signup_info() unless $init_data;
+ FS::SelfService::regionselector({
+ selected_county => $selected_county,
+ selected_state => $selected_state,
+ selected_country => $selected_country,
+ prefix => $prefix,
+ onchange => $onchange,
+ default_country => $init_data->{countrydefault},
+ locales => $init_data->{cust_main_county},
+ });
+ #default_state => $init_data->{statedefault},
+}
- socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
- connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
- print SOCK "new_customer\n";
+=item expselect PREFIX, DATE
- my $signup_data = { map { $_ => $hashref->{$_} } qw(
- first last ss company address1 address2 city county state zip country
- daytime night fax payby payinfo paydate payname invoicing_list
- referral_custnum comments pkgpart username _password sec_phrase popnum
- ) };
+=cut
- $signup_data->{agentnum} = $hashref->{agentnum} if $hashref->{agentnum};
+sub expselect {
+ FS::SelfService::expselect(@_);
+}
- nstore_fd($signup_data, \*SOCK) or die "can't send customer signup: $!";
- SOCK->flush;
+=item popselector
- chop( my $error = <SOCK> );
- $error;
+=cut
+
+sub popselector {
+ my( $popnum ) = @_;
+ signup_info() unless $init_data;
+ FS::SelfService::popselector({
+ popnum => $popnum,
+ pops => $init_data->{svc_acct_pop},
+ });
+ #popac =>
+ #acstate =>
}
=back
=head1 BUGS
+This is just a wrapper around FS::SelfService functions for backwards
+compatibility. It is only necessary if you're using a signup.cgi from before
+1.5.0pre7.
+
=head1 SEE ALSO
L<fs_signupd>, L<FS::cust_main>