summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2004-08-24 11:16:57 +0000
committerivan <ivan>2004-08-24 11:16:57 +0000
commit0cbeb01df08457b056a7ae775b4924c266b4228b (patch)
tree24fb4d674874657d05512a48789715eb77c8c7c8
parente64990633f433dc4e27f0509a2417aea29e0fdc8 (diff)
big update for reseller interface
-rw-r--r--FS/FS/ClientAPI/Agent.pm80
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm140
-rw-r--r--FS/FS/ClientAPI/Signup.pm2
-rw-r--r--FS/FS/Conf.pm9
-rw-r--r--FS/FS/cust_main.pm37
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm1
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent.cgi192
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html7
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html20
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_logout.html5
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_main.html21
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_menu.html15
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html19
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_provision.html25
-rw-r--r--fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html19
-rw-r--r--fs_selfservice/FS-SelfService/cgi/list_customers.html12
-rw-r--r--fs_selfservice/FS-SelfService/cgi/order_pkg.html75
-rw-r--r--fs_selfservice/FS-SelfService/cgi/provision.html68
-rw-r--r--fs_selfservice/FS-SelfService/cgi/provision_list.html74
-rw-r--r--fs_selfservice/FS-SelfService/cgi/selfservice.cgi15
-rw-r--r--fs_selfservice/FS-SelfService/cgi/svc_acct.html55
-rw-r--r--fs_selfservice/FS-SelfService/cgi/view_customer.html75
-rwxr-xr-xhttemplate/search/cust_main.cgi46
23 files changed, 732 insertions, 280 deletions
diff --git a/FS/FS/ClientAPI/Agent.pm b/FS/FS/ClientAPI/Agent.pm
index 212faaa6b..1cc11d536 100644
--- a/FS/FS/ClientAPI/Agent.pm
+++ b/FS/FS/ClientAPI/Agent.pm
@@ -6,12 +6,14 @@ use strict;
use vars qw($cache);
use Digest::MD5 qw(md5_hex);
use Cache::SharedMemoryCache; #store in db?
-use FS::Record qw(qsearchs); # qsearch);
+use FS::Record qw(qsearchs qsearch dbdef dbh);
use FS::agent;
+use FS::cust_main;
use FS::ClientAPI;
FS::ClientAPI->register_handlers(
'Agent/agent_login' => \&agent_login,
+ 'Agent/agent_logout' => \&agent_logout,
'Agent/agent_info' => \&agent_info,
'Agent/agent_list_customers' => \&agent_list_customers,
);
@@ -52,6 +54,16 @@ sub agent_login {
};
}
+sub agent_logout {
+ my $p = shift;
+ if ( $p->{'session_id'} ) {
+ $cache->remove($p->{'session_id'});
+ return { 'error' => '' };
+ } else {
+ return { 'error' => "Can't resume session" }; #better error message
+ }
+}
+
sub agent_info {
my $p = shift;
@@ -92,12 +104,76 @@ sub agent_list_customers {
my @cust_main = ();
- warn $p->{'susp'};
+ #warn $p->{'search'};
+ if ( $p->{'search'} =~ /^\s*(\d+)\s*$/ ) { # customer # search
+ push @cust_main, qsearch('cust_main', { 'agentnum' => $agentnum,
+ 'custnum' => $1 } );
+ } elsif ( $p->{'search'} =~ /^\s*(\S.*\S)\s*$/ ) { #value search
+ my $value = lc($1);
+ my $q_value = dbh->quote($value);
+
+ #exact
+ my $sql = " AND ( LOWER(last) = $q_value OR LOWER(company) = $q_value";
+ $sql .= " OR LOWER(ship_last) = $q_value OR LOWER(ship_company) = $q_value"
+ if defined dbdef->table('cust_main')->column('ship_last');
+ $sql .= ' )';
+
+ push @cust_main, qsearch( 'cust_main',
+ { 'agentnum' => $agentnum },
+ '',
+ $sql
+ );
+
+ unless ( @cust_main ) {
+ warn "no exact match, trying substring/fuzzy\n";
+
+ #still some false laziness w/ search/cust_main.cgi
+
+ #substring
+ push @cust_main, qsearch( 'cust_main',
+ { 'agentnum' => $agentnum,
+ 'last' => { 'op' => 'ILIKE',
+ 'value' => "%$q_value%" } } );
+
+ push @cust_main, qsearch( 'cust_main',
+ { 'agentnum' => $agentnum,
+ 'ship_last' => { 'op' => 'ILIKE',
+ 'value' => "%$q_value%" } } )
+ if defined dbdef->table('cust_main')->column('ship_last');
+
+ push @cust_main, qsearch( 'cust_main',
+ { 'agentnum' => $agentnum,
+ 'company' => { 'op' => 'ILIKE',
+ 'value' => "%$q_value%" } } );
+
+ push @cust_main, qsearch( 'cust_main',
+ { 'agentnum' => $agentnum,
+ 'ship_company' => { 'op' => 'ILIKE',
+ 'value' => "%$q_value%" } } )
+ if defined dbdef->table('cust_main')->column('ship_last');
+
+ #fuzzy
+ push @cust_main, FS::cust_main->fuzzy_search(
+ { 'last' => $value },
+ { 'agentnum' => $agentnum }
+ );
+ push @cust_main, FS::cust_main->fuzzy_search(
+ { 'company' => $value },
+ { 'agentnum' => $agentnum }
+ );
+
+ }
+ }
+ #aggregate searches
push @cust_main,
map $agent->$_(), map $_.'_cust_main',
grep $p->{$_}, qw( prospect active susp cancel );
+ #eliminate dups?
+ my %saw = ();
+ @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
+
{ customers => [ map {
my $cust_main = $_;
my $hashref = $cust_main->hashref;
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 639cb7b9b..34dad3870 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -109,23 +109,8 @@ sub logout {
sub customer_info {
my $p = shift;
- my($session, $custnum, $context);
- if ( $p->{'session_id'} ) {
- $context = 'customer';
- $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
- $custnum = $session->{'custnum'};
- } elsif ( $p->{'agent_session_id'} ) {
- $context = 'agent';
- my $agent_cache = new Cache::SharedMemoryCache( {
- 'namespace' => 'FS::ClientAPI::Agent',
- } );
- $session = $agent_cache->get($p->{'agent_session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
- $custnum = $p->{'custnum'};
- } else {
- return { 'error' => "Can't resume session" }; #better error message
- }
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
my %return;
if ( $custnum ) { #customer record
@@ -451,31 +436,42 @@ sub cancel {
sub list_pkgs {
my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
- my $custnum = $session->{'custnum'};
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ my $search = { 'custnum' => $custnum };
+ $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
+ my $cust_main = qsearchs('cust_main', $search )
or return { 'error' => "unknown custnum $custnum" };
#return { 'cust_pkg' => [ map { $_->hashref } $cust_main->ncancelled_pkgs ] };
+ my $conf = new FS::Conf;
+
{ 'svcnum' => $session->{'svcnum'},
+ 'custnum' => $custnum,
'cust_pkg' => [ map {
{ $_->hash,
$_->part_pkg->hash,
part_svc =>
[ map $_->hashref, $_->available_part_svc ],
cust_svc =>
- [ map { { $_->hash,
- label => [ $_->label ],
- }
+ [ map { my $ref = { $_->hash,
+ label => [ $_->label ],
+ };
+ $ref->{_password} = $_->svc_x->_password
+ if $context eq 'agent'
+ && $conf->exists('agent-showpasswords')
+ && $_->part_svc->svcdb eq 'svc_acct';
+ $ref;
} $_->cust_svc
],
};
} $cust_main->ncancelled_pkgs
],
+ 'small_custview' =>
+ small_custview( $cust_main, $conf->config('defaultcountry') ),
};
}
@@ -483,28 +479,11 @@ sub list_pkgs {
sub order_pkg {
my $p = shift;
- my($session, $custnum, $context);
-
- if ( $p->{'session_id'} ) {
- $context = 'customer';
- $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
- $custnum = $session->{'custnum'};
- } elsif ( $p->{'agent_session_id'} ) {
- $context = 'agent';
- my $agent_cache = new Cache::SharedMemoryCache( {
- 'namespace' => 'FS::ClientAPI::Agent',
- } );
- $session = $agent_cache->get($p->{'agent_session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
- $custnum = $p->{'custnum'};
- } else {
- return { 'error' => "Can't resume session" }; #better error message
- }
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
my $search = { 'custnum' => $custnum };
$search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
-
my $cust_main = qsearchs('cust_main', $search )
or return { 'error' => "unknown custnum $custnum" };
@@ -632,12 +611,12 @@ sub cancel_pkg {
sub provision_acct {
my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ my $search = { 'custnum' => $custnum };
+ $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
+ my $cust_main = qsearchs('cust_main', $search )
or return { 'error' => "unknown custnum $custnum" };
my $pkgnum = $p->{'pkgnum'};
@@ -671,12 +650,12 @@ sub provision_acct {
sub part_svc_info {
my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ my $search = { 'custnum' => $custnum };
+ $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
+ my $cust_main = qsearchs('cust_main', $search )
or return { 'error' => "unknown custnum $custnum" };
my $pkgnum = $p->{'pkgnum'};
@@ -693,11 +672,14 @@ sub part_svc_info {
or return { 'error' => "unknown svcpart $svcpart for pkgnum $pkgnum" };
my $part_svc = $pkg_svc->part_svc;
+ my $conf = new FS::Conf;
+
return {
'svc' => $part_svc->svc,
'svcdb' => $part_svc->svcdb,
'pkgnum' => $pkgnum,
'svcpart' => $svcpart,
+ 'custnum' => $custnum,
'security_phrase' => 0, #XXX !
'svc_acct_pop' => [], #XXX !
@@ -705,6 +687,10 @@ sub part_svc_info {
'init_popstate' => '',
'popac' => '',
'acstate' => '',
+
+ 'small_custview' =>
+ small_custview( $cust_main, $conf->config('defaultcountry') ),
+
};
}
@@ -712,12 +698,12 @@ sub part_svc_info {
sub unprovision_svc {
my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ my $search = { 'custnum' => $custnum };
+ $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
+ my $cust_main = qsearchs('cust_main', $search )
or return { 'error' => "unknown custnum $custnum" };
my $svcnum = $p->{'svcnum'};
@@ -728,11 +714,47 @@ sub unprovision_svc {
return { 'error' => "Service $svcnum does not belong to customer $custnum" }
unless $cust_svc->cust_pkg->custnum == $custnum;
+ my $conf = new FS::Conf;
+
return { 'svc' => $cust_svc->part_svc->svc,
- 'error' => $cust_svc->cancel
+ 'error' => $cust_svc->cancel,
+ 'small_custview' =>
+ small_custview( $cust_main, $conf->config('defaultcountry') ),
};
}
+#--
+
+sub _custoragent_session_custnum {
+ my $p = shift;
+
+ my($context, $session, $custnum);
+ if ( $p->{'session_id'} ) {
+
+ $context = 'customer';
+ $session = $cache->get($p->{'session_id'})
+ or return { 'error' => "Can't resume session" }; #better error message
+ $custnum = $session->{'custnum'};
+
+ } elsif ( $p->{'agent_session_id'} ) {
+
+ $context = 'agent';
+ my $agent_cache = new Cache::SharedMemoryCache( {
+ 'namespace' => 'FS::ClientAPI::Agent',
+ } );
+ $session = $agent_cache->get($p->{'agent_session_id'})
+ or return { 'error' => "Can't resume session" }; #better error message
+ $custnum = $p->{'custnum'};
+
+ } else {
+ return { 'error' => "Can't resume session" }; #better error message
+ }
+
+ ($context, $session, $custnum);
+
+}
+
+
1;
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index 81ed5e65c..bdcd2fbf1 100644
--- a/FS/FS/ClientAPI/Signup.pm
+++ b/FS/FS/ClientAPI/Signup.pm
@@ -76,7 +76,7 @@ sub signup_info {
'cvv_enabled' => defined dbdef->table('cust_main')->column('paycvv'),
'msgcat' => { map { $_=>gettext($_) } qw(
- passwords_dont_match invalid_card unknown_card_type not_a
+ passwords_dont_match invalid_card unknown_card_type not_a empty_password
) },
'statedefault' => $conf->config('statedefault') || 'CA',
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index bfef62807..c8f0d81af 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -759,7 +759,7 @@ httemplate/docs/config.html
{
'key' => 'showpasswords',
'section' => 'UI',
- 'description' => 'Display unencrypted user passwords in the web interface',
+ 'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
'type' => 'checkbox',
},
@@ -1276,6 +1276,13 @@ httemplate/docs/config.html
'type' => 'text',
},
+ {
+ 'key' => 'agent-showpasswords',
+ 'section' => '',
+ 'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
+ 'type' => 'checkbox',
+ },
+
);
1;
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 58d1a28f5..1540b61a3 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -13,6 +13,7 @@ BEGIN {
}
use Date::Format;
#use Date::Manip;
+use String::Approx qw(amatch);
use Business::CreditCard;
use FS::UID qw( getotaker dbh );
use FS::Record qw( qsearchs qsearch dbdef );
@@ -2949,6 +2950,42 @@ sub cancel_sql { "
)
"; }
+=item fuzzy_search FUZZY_HASHREF [ HASHREF, SELECT, EXTRA_SQL, CACHE_OBJ ]
+
+Performs a fuzzy (approximate) search and returns the matching FS::cust_main
+records. Currently, only I<last> or I<company> may be specified (the
+appropriate ship_ field is also searched if applicable).
+
+Additional options are the same as FS::Record::qsearch
+
+=cut
+
+sub fuzzy_search {
+ my( $self, $fuzzy, $hash, @opt) = @_;
+ #$self
+ $hash ||= {};
+ my @cust_main = ();
+
+ check_and_rebuild_fuzzyfiles();
+ foreach my $field ( keys %$fuzzy ) {
+ my $sub = \&{"all_$field"};
+ my %match = ();
+ $match{$_}=1 foreach ( amatch($fuzzy->{$field}, ['i'], @{ &$sub() } ) );
+
+ foreach ( keys %match ) {
+ push @cust_main, qsearch('cust_main', { %$hash, $field=>$_}, @opt);
+ push @cust_main, qsearch('cust_main', { %$hash, "ship_$field"=>$_}, @opt)
+ if defined dbdef->table('cust_main')->column('ship_last');
+ }
+ }
+
+ my %saw = ();
+ @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
+
+ @cust_main;
+
+}
+
=back
=head1 SUBROUTINES
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index ae6d37671..de33b75b1 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -40,6 +40,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
'signup_info' => 'Signup/signup_info',
'new_customer' => 'Signup/new_customer',
'agent_login' => 'Agent/agent_login',
+ 'agent_logout' => 'Agent/agent_logout',
'agent_info' => 'Agent/agent_info',
'agent_list_customers' => 'Agent/agent_list_customers',
);
diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi
index 6d2fd5840..b88709862 100644
--- a/fs_selfservice/FS-SelfService/cgi/agent.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi
@@ -9,10 +9,12 @@ use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Business::CreditCard;
use Text::Template;
-use FS::SelfService qw( agent_login agent_info
+#use HTML::Entities;
+use FS::SelfService qw( agent_login agent_logout agent_info
agent_list_customers
signup_info new_customer
- customer_info order_pkg
+ customer_info list_pkgs order_pkg
+ part_svc_info provision_acct unprovision_svc
);
$DEBUG = 0;
@@ -65,7 +67,7 @@ $session_id = $cgi->param('session');
warn "$me checking action\n" if $DEBUG;
$cgi->param('action') =~
- /^(agent_main|signup|process_signup|list_customers|view_customer|process_order_pkg)$/
+ /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|delete_svc|agent_order_pkg|process_order_pkg|logout)$/
or die "unknown action ". $cgi->param('action');
my $action = $1;
@@ -87,6 +89,11 @@ warn "$me done processing template $action\n" if $DEBUG;
#--
+sub logout {
+ $action = 'agent_logout';
+ agent_logout( 'session_id' => $session_id );
+}
+
sub agent_main { agent_info( 'session_id' => $session_id ); }
sub signup { signup_info( 'session_id' => $session_id ); }
@@ -184,15 +191,55 @@ sub process_signup {
}
sub list_customers {
- agent_list_customers( 'session_id' => $session_id,
- map { $_ => $cgi->param($_) }
- grep defined($cgi->param($_)),
- qw(prospect active susp cancel)
- );
+
+ my $results =
+ agent_list_customers( 'session_id' => $session_id,
+ map { $_ => $cgi->param($_) }
+ grep defined($cgi->param($_)),
+ qw(prospect active susp cancel),
+ 'search',
+ );
+
+ if ( scalar( @{$results->{'customers'}} ) == 1 ) {
+ $action = 'view_customer';
+ customer_info (
+ 'agent_session_id' => $session_id,
+ 'custnum' => $results->{'customers'}[0]{'custnum'},
+ );
+ } else {
+ $results;
+ }
+
}
sub view_customer {
+ #my $init_data = signup_info( 'session_id' => $session_id );
+ #if ( $init_data->{'error'} ) {
+ # if ( $init_data->{'error'} eq "Can't resume session" ) { #ick
+ # do_template('agent_login',{});
+ # exit;
+ # } else { #?
+ # die $init_data->{'error'};
+ # }
+ #}
+ #
+ #my $customer_info =
+ customer_info (
+ 'agent_session_id' => $session_id,
+ 'custnum' => $cgi->param('custnum'),
+ );
+ #
+ #return {
+ # ( map { $_ => $init_data->{$_} }
+ # qw( part_pkg security_phrase svc_acct_pop ),
+ # ),
+ # %$customer_info,
+ #};
+}
+
+sub agent_order_pkg {
+
my $init_data = signup_info( 'session_id' => $session_id );
if ( $init_data->{'error'} ) {
if ( $init_data->{'error'} eq "Can't resume session" ) { #ick
@@ -205,16 +252,91 @@ sub view_customer {
my $customer_info = customer_info (
'agent_session_id' => $session_id,
- 'custnum' => $cgi->param('custnum')
+ 'custnum' => $cgi->param('custnum'),
);
-
return {
( map { $_ => $init_data->{$_} }
qw( part_pkg security_phrase svc_acct_pop ),
),
%$customer_info,
};
+
+}
+
+sub agent_provision {
+ my $result = list_pkgs(
+ 'agent_session_id' => $session_id,
+ 'custnum' => $cgi->param('custnum'),
+ );
+ die $result->{'error'} if exists $result->{'error'} && $result->{'error'};
+ $result;
+}
+
+sub provision_svc {
+
+ my $result = part_svc_info(
+ 'agent_session_id' => $session_id,
+ map { $_ => $cgi->param($_) } qw( pkgnum svcpart custnum ),
+ );
+ die $result->{'error'} if exists $result->{'error'} && $result->{'error'};
+
+ $result->{'svcdb'} =~ /^svc_(.*)$/
+ #or return { 'error' => 'Unknown svcdb '. $result->{'svcdb'} };
+ or die 'Unknown svcdb '. $result->{'svcdb'};
+ $action .= "_$1";
+ $action = "agent_$action";
+
+ $result;
+}
+
+sub process_svc_acct {
+
+ my $result = provision_acct (
+ 'agent_session_id' => $session_id,
+ map { $_ => $cgi->param($_) } qw(
+ custnum pkgnum svcpart username _password _password2 sec_phrase popnum )
+ );
+
+ if ( exists $result->{'error'} && $result->{'error'} ) {
+ #warn "$result $result->{'error'}";
+ $action = 'provision_svc_acct';
+ $action = "agent_$action";
+ return {
+ $cgi->Vars,
+ %{ part_svc_info( 'agent_session_id' => $session_id,
+ map { $_ => $cgi->param($_) } qw(pkgnum svcpart custnum)
+ )
+ },
+ 'error' => $result->{'error'},
+ };
+ } else {
+ #warn "$result $result->{'error'}";
+ $action = 'agent_provision';
+ return {
+ %{agent_provision()},
+ 'message' => $result->{'svc'}. ' setup sucessfully.',
+ };
+ }
+
+}
+
+sub delete_svc {
+ my $result = unprovision_svc(
+ 'agent_session_id' => $session_id,
+ 'custnum' => $cgi->param('custnum'),
+ 'svcnum' => $cgi->param('svcnum'),
+ );
+
+ $action = 'agent_provision';
+
+ return {
+ %{agent_provision()},
+ 'message' => $result->{'error'}
+ ? '<FONT COLOR="#FF0000">'. $result->{'error'}. '</FONT>'
+ : $result->{'svc'}. ' removed.'
+ };
+
}
sub process_order_pkg {
@@ -223,11 +345,12 @@ sub process_order_pkg {
unless ( length($cgi->param('_password')) ) {
my $init_data = signup_info( 'session_id' => $session_id );
- $results = { 'error' => $init_data->{msgcat}{empty_password} }
+ #die $init_data->{'error'} if $init_data->{'error'};
+ $results = { 'error' => $init_data->{msgcat}{empty_password} };
}
if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
my $init_data = signup_info( 'session_id' => $session_id );
- $results = { error => $init_data->{msgcat}{passwords_dont_match} };
+ $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} };
$cgi->param('_password', '');
$cgi->param('_password2', '');
}
@@ -238,17 +361,22 @@ sub process_order_pkg {
qw( custnum pkgpart username _password _password2 sec_phrase popnum )
);
- $action = 'view_customer';
- $cgi->delete( grep { $_ ne 'custnum' } $cgi->param )
- unless $results->{'error'};
-
- return {
- $cgi->Vars,
- %{view_customer()},
- 'message' => $results->{'error'}
- ? '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>'
- : 'Package order sucessful.'
- };
+ if ( $results->{'error'} ) {
+ $action = 'agent_order_pkg';
+ return {
+ $cgi->Vars,
+ %{agent_order_pkg()},
+ #'message' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+ 'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+ };
+ } else {
+ $action = 'view_customer';
+ #$cgi->delete( grep { $_ ne 'custnum' } $cgi->param );
+ return {
+ %{view_customer()},
+ 'message' => 'Package order sucessful.',
+ };
+ }
}
@@ -277,5 +405,23 @@ sub do_template {
}
package FS::SelfService::_agentcgi;
+
+use HTML::Entities;
use FS::SelfService qw(regionselector expselect popselector);
+#false laziness w/selfservice.cgi
+sub include {
+ my $name = shift;
+ my $template = new Text::Template( TYPE => 'FILE',
+ SOURCE => "$main::template_dir/$name.html",
+ DELIMITERS => [ '<%=', '%>' ],
+ UNTAINT => 1,
+ )
+ or die $Text::Template::ERROR;
+
+ $template->fill_in( PACKAGE => 'FS::SelfService::_agentcgi',
+ #HASH => $fill_in
+ );
+
+}
+
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html b/fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html
new file mode 100644
index 000000000..603fc0bd2
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html
@@ -0,0 +1,7 @@
+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
+<TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
+<A HREF="<%= $url %>agent_provision">Setup services</A><BR><BR>
+<A HREF="<%= $url %>agent_order_pkg">Purchase additional package</A><BR><BR>
+
+</TD>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html b/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html
new file mode 100644
index 000000000..e8be07ed1
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html
@@ -0,0 +1,20 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+<%= $small_custview %>
+<BR>
+<%= if ( $error ) {
+
+ $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT>!;
+} else {
+ $OUT .= "<FONT SIZE=4>$svc removed.</FONT>";
+} %>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_logout.html b/fs_selfservice/FS-SelfService/cgi/agent_logout.html
new file mode 100644
index 000000000..98094679a
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_logout.html
@@ -0,0 +1,5 @@
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
+You have been logged out.
+</BODY></HTML>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_main.html b/fs_selfservice/FS-SelfService/cgi/agent_main.html
index 629734555..9dd338382 100644
--- a/fs_selfservice/FS-SelfService/cgi/agent_main.html
+++ b/fs_selfservice/FS-SelfService/cgi/agent_main.html
@@ -1,10 +1,9 @@
-<HTML><HEAD><TITLE>Reseller Main</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller Main</FONT><BR><BR>
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>agent_main">Reseller Main</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
<%= $message
? "<FONT SIZE=\"+2\"><B>$message</B></FONT>"
@@ -16,21 +15,19 @@
<TR><TD BGCOLOR="#dddddd">
<B><%= $num_prospect %></B>
- <A HREF="<%= $url %>list_customers;prospect=1">prospects</A>
+ <%= $num_prospect ? qq!<A HREF="${url}list_customers;prospect=1">! : '' %>prospects</A>
<BR><FONT COLOR="#00CC00"><B><%= $num_active %></B></FONT>
- <A HREF="<%= $url %>list_customers;active=1">active</A>
+ <%= $num_active ? qq!<A HREF="${url}list_customers;active=1">! : '' %>active</A>
<BR><FONT COLOR="#FF9900"><B><%= $num_susp %></B></FONT>
- <A HREF="<%= $url %>list_customers;susp=1">suspended</A>
+ <%= $num_susp ? qq!<A HREF="${url}list_customers;susp=1">! : '' %>suspended</A>
<BR><FONT COLOR="#FF0000"><B><%= $num_cancel %></B></FONT>
- <A HREF="<%= $url %>list_customers;cancel=1">cancelled</A>
+ <%= $num_cancel ? qq!<A HREF="${url}list_customers;cancel=1">! : '' %>cancelled</A>
</TD></TR></TABLE>
-<BR><A HREF="<%= $url %>signup">New customer<!--/prospect--></A>
-
</TD></TR></TABLE>
<HR>
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_menu.html b/fs_selfservice/FS-SelfService/cgi/agent_menu.html
new file mode 100644
index 000000000..84a295304
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_menu.html
@@ -0,0 +1,15 @@
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
+
+<A HREF="<%= $url %>agent_main">Overview</A><BR><BR>
+<A HREF="<%= $url %>signup">New customer<!--/prospect--></A><BR><BR>
+<FORM ACTION="<%= $selfurl %>">
+<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
+<INPUT TYPE="hidden" NAME="action" VALUE="list_customers">
+<INPUT TYPE="text" NAME="search" SIZE=20><BR>
+<SMALL><I>cust&nbsp;#,&nbsp;last&nbsp;name,&nbsp;or&nbsp;company</I></SMALL><BR>
+<INPUT TYPE="submit" VALUE="Search customers"><BR>
+</FORM>
+<A HREF="<%= $url %>logout">Logout</A><BR><BR>
+
+</TD>
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html b/fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html
new file mode 100644
index 000000000..0a665c99e
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html
@@ -0,0 +1,19 @@
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
+<%= $small_custview %>
+<BR>
+
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_customer_menu') %>
+<TD VALIGN="top">
+<%= include('order_pkg') %>
+</TD></TR></TABLE>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_provision.html b/fs_selfservice/FS-SelfService/cgi/agent_provision.html
new file mode 100644
index 000000000..8770e2f9e
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_provision.html
@@ -0,0 +1,25 @@
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
+
+<%= $message
+ ? "<FONT SIZE=\"+2\"><B>$message</B></FONT><BR><BR>"
+ : ''
+%>
+
+<%= $small_custview %>
+<BR>
+
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_customer_menu') %>
+<TD VALIGN="top">
+<%= include('provision_list') %>
+</TD></TR></TABLE>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
diff --git a/fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html
new file mode 100644
index 000000000..8d299cdc5
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html
@@ -0,0 +1,19 @@
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
+<%= $small_custview %>
+<BR>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_customer_menu') %>
+<TD VALIGN="top">
+<%= include('svc_acct') %>
+</TD></TR></TABLE>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/list_customers.html b/fs_selfservice/FS-SelfService/cgi/list_customers.html
index 6d4ba564e..858e5e9ba 100644
--- a/fs_selfservice/FS-SelfService/cgi/list_customers.html
+++ b/fs_selfservice/FS-SelfService/cgi/list_customers.html
@@ -1,10 +1,9 @@
-<HTML><HEAD><TITLE>Reseller Main</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller Main</FONT><BR><BR>
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>agent_main">Reseller Main</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
<%=
if ( @customers ) {
@@ -38,4 +37,3 @@
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
</BODY></HTML>
-
diff --git a/fs_selfservice/FS-SelfService/cgi/order_pkg.html b/fs_selfservice/FS-SelfService/cgi/order_pkg.html
new file mode 100644
index 000000000..9cdd4cd6c
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/order_pkg.html
@@ -0,0 +1,75 @@
+<SCRIPT TYPE="text/javascript">
+function enable_order_pkg () {
+ if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
+ document.OrderPkgForm.submit.disabled = false;
+ } else {
+ document.OrderPkgForm.submit.disabled = true;
+ }
+}
+</SCRIPT>
+<FONT SIZE=4>Purchase additional package</FONT><BR><BR>
+<%= if ( $error ) {
+ $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">$error</FONT><BR><BR>!;
+} ''; %>
+<FORM NAME="OrderPkgForm" ACTION="<%= $selfurl %>" METHOD=POST>
+<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
+<INPUT TYPE="hidden" NAME="action" VALUE="process_order_pkg">
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
+<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
+<TR>
+ <TD COLSPAN=2><SELECT NAME="pkgpart" onChange="enable_order_pkg()">
+ <OPTION VALUE="">
+
+ <%=
+ foreach my $part_pkg ( @part_pkg ) {
+ $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
+ $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
+ $OUT .= '>'. $part_pkg->{'pkg'};
+ }
+ %>
+
+ </SELECT></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Username</TD>
+ <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Password</TD>
+ <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Re-enter Password</TD>
+ <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
+</TR>
+<%=
+ if ( $security_phrase ) {
+ $OUT .= <<ENDOUT;
+<TR>
+ <TD ALIGN="right">Security Phrase</TD>
+ <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
+ </TD>
+</TR>
+ENDOUT
+ } else {
+ $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
+ }
+%>
+<%=
+ if ( @svc_acct_pop ) {
+ $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
+ popselector( 'popnum' => $popnum,
+ 'pops' => \@svc_acct_pop,
+ 'init_popstate' => $init_popstate,
+ 'popac' => $popac,
+ 'acstate' => $acstate,
+ ).
+ '</TD></TR>';
+ } else {
+ $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
+ }
+%>
+</TABLE>
+<INPUT NAME="submit" TYPE="submit" VALUE="Purchase" disabled>
+</FORM>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/provision.html b/fs_selfservice/FS-SelfService/cgi/provision.html
index 326f90229..6d80e89db 100644
--- a/fs_selfservice/FS-SelfService/cgi/provision.html
+++ b/fs_selfservice/FS-SelfService/cgi/provision.html
@@ -4,73 +4,7 @@
<TABLE BORDER=0 CELLPADDING=4><TR>
<%= include('myaccount_menu') %>
<TD VALIGN="top">
-<FONT SIZE=4>Setup services</FONT><BR><BR>
-
-<SCRIPT>
-function areyousure(href, message) {
- if (confirm(message) == true)
- window.location.href = href;
-}
-</SCRIPT>
-
-<%= foreach my $pkg (
- grep { scalar(@{$_->{part_svc}})
- || scalar(@{$_->{cust_svc}})
- } @cust_pkg
- ) {
-
- $OUT .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#ffffff">'.
- '<TR><TH BGCOLOR="#6666ff" COLSPAN=3>'.
- $pkg->{'pkg'}.
- '</TH></TR>';
-
- my $col1 = "ffffff";
- my $col2 = "dddddd";
- my $col = $col1;
-
- foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) {
- my $td = qq!<TD BGCOLOR="#$col"!;
-
- $OUT .= '<TR>'.
- "$td ALIGN=right>". $cust_svc->{label}[0]. ': </TD>'.
- "$td><B>". $cust_svc->{label}[1]. '</B></TD>'.
- "$td><FONT SIZE=-1>";
-
- #if ( $cust_svc->{label}[2] eq 'svc_acct' ) {
- # $OUT .= qq!(<A HREF="${url}changepw;svcnum=$cust_svc->{'svcnum'}">!.
- # 'change&nbsp;pw) ';
- #}
-
- unless ( $cust_svc->{'svcnum'} == $svcnum ) {
- $OUT .= qq!(<A HREF="javascript:areyousure('${url}delete_svc;svcnum=$cust_svc->{svcnum}', 'This will perminantly delete the $cust_svc->{label}[1] $cust_svc->{label}[0]. Are you sure?')">!.
- 'delete</A>)';
-
- }
- $OUT .= '</FONT></TD></TR>';
- $col = $col eq $col1 ? $col2 : $col1;
- }
-
- $OUT .= '<TR><TD COLSPAN=3 BGCOLOR="#000000"></TD></TR>'
- if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}});
-
- my $col = $col1;
-
- foreach my $part_svc ( @{ $pkg->{part_svc} } ) {
-
- my $td = qq!<TD BGCOLOR="#$col"!;
-
- $OUT .= "<TR>$td COLSPAN=3>".
- qq!<A HREF="${url}provision_svc;pkgnum=$pkg->{'pkgnum'};svcpart=$part_svc->{'svcpart'}">!.
- 'Setup '. $part_svc->{'svc'}. '</A> '.
- '('. $part_svc->{'num_avail'}. ' available)'.
- '</TD></TR>';
- $col = $col eq $col1 ? $col2 : $col1;
- }
-
- $OUT .= '</TABLE><BR>';
-
-} %>
-
+<%= include('provision_list') %>
</TD></TR></TABLE>
<HR>
<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
diff --git a/fs_selfservice/FS-SelfService/cgi/provision_list.html b/fs_selfservice/FS-SelfService/cgi/provision_list.html
new file mode 100644
index 000000000..7e7059388
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/provision_list.html
@@ -0,0 +1,74 @@
+<FONT SIZE=4>Setup services</FONT><BR><BR>
+
+<SCRIPT>
+function areyousure(href, message) {
+ if (confirm(message) == true)
+ window.location.href = href;
+}
+</SCRIPT>
+
+<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#ffffff">
+
+<%= foreach my $pkg (
+ grep { scalar(@{$_->{part_svc}})
+ || scalar(@{$_->{cust_svc}})
+ } @cust_pkg
+ ) {
+
+ $OUT .= #'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#ffffff">'.
+ '<TR><TH BGCOLOR="#6666ff" COLSPAN=3>'.
+ $pkg->{'pkg'}.
+ '</TH></TR>';
+
+ my $col1 = "ffffff";
+ my $col2 = "dddddd";
+ my $col = $col1;
+
+ foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) {
+ my $td = qq!<TD BGCOLOR="#$col"!;
+
+ $OUT .= '<TR>'.
+ "$td ALIGN=right>". $cust_svc->{label}[0]. ': </TD>'.
+ "$td><B>". $cust_svc->{label}[1]. '</B>';
+ $OUT .= '<BR><I>password: '. encode_entities($cust_svc->{_password}). '</I>'
+ if exists($cust_svc->{_password});
+ $OUT .= '</TD>'.
+ "$td><FONT SIZE=-1>";
+
+ #if ( $cust_svc->{label}[2] eq 'svc_acct' ) {
+ # $OUT .= qq!(<A HREF="${url}changepw;svcnum=$cust_svc->{'svcnum'}">!.
+ # 'change&nbsp;pw) ';
+ #}
+
+ unless ( $cust_svc->{'svcnum'} == $svcnum ) {
+ $OUT .= qq!(<A HREF="javascript:areyousure('${url}delete_svc;svcnum=$cust_svc->{svcnum}', 'This will perminantly delete the $cust_svc->{label}[1] $cust_svc->{label}[0]. Are you sure?')">!.
+ 'delete</A>)';
+
+ }
+ $OUT .= '</FONT></TD></TR>';
+ $col = $col eq $col1 ? $col2 : $col1;
+ }
+
+ $OUT .= '<TR><TD COLSPAN=3 BGCOLOR="#000000"></TD></TR>'
+ if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}});
+
+ $col = $col1;
+
+ foreach my $part_svc ( @{ $pkg->{part_svc} } ) {
+
+ my $td = qq!<TD BGCOLOR="#$col"!;
+
+ $OUT .= "<TR>$td COLSPAN=3 ALIGN=center>".
+ qq!<A HREF="${url}provision_svc;pkgnum=$pkg->{'pkgnum'};svcpart=$part_svc->{'svcpart'}">!.
+ 'Setup '. $part_svc->{'svc'}. '</A> '.
+ '('. $part_svc->{'num_avail'}. ' available)'.
+ '</TD></TR>';
+ $col = $col eq $col1 ? $col2 : $col1;
+ }
+
+ #$OUT .= '</TABLE><BR>';
+ $OUT .= '<TR><TD BGCOLOR="#eeeeee" COLSPAN=3>&nbsp;</TD></TR>';
+
+} %>
+
+</TABLE>
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
index d8e044a96..44dd8bb3a 100644
--- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
@@ -6,6 +6,7 @@ use subs qw(do_template);
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Text::Template;
+use HTML::Entities;
use FS::SelfService qw( login customer_info invoice
payment_info process_payment
list_pkgs
@@ -176,7 +177,9 @@ sub logout {
}
sub provision {
- list_pkgs( 'session_id' => $session_id );
+ my $result = list_pkgs( 'session_id' => $session_id );
+ die $result->{'error'} if exists $result->{'error'} && $result->{'error'};
+ $result;
}
sub provision_svc {
@@ -204,7 +207,7 @@ sub process_svc_acct {
);
if ( exists $result->{'error'} && $result->{'error'} ) {
- warn "$result $result->{'error'}";
+ #warn "$result $result->{'error'}";
$action = 'provision_svc_acct';
return {
$cgi->Vars,
@@ -215,7 +218,7 @@ sub process_svc_acct {
'error' => $result->{'error'},
};
} else {
- warn "$result $result->{'error'}";
+ #warn "$result $result->{'error'}";
return $result;
}
@@ -255,8 +258,10 @@ sub do_template {
package FS::SelfService::_selfservicecgi;
#use FS::SelfService qw(regionselector expselect popselector);
+use HTML::Entities;
use FS::SelfService qw(popselector);
+#false laziness w/agent.cgi
sub include {
my $name = shift;
my $template = new Text::Template( TYPE => 'FILE',
@@ -266,7 +271,9 @@ sub include {
)
or die $Text::Template::ERROR;
- $template->fill_in();
+ $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi',
+ #HASH => $fill_in
+ );
}
diff --git a/fs_selfservice/FS-SelfService/cgi/svc_acct.html b/fs_selfservice/FS-SelfService/cgi/svc_acct.html
new file mode 100644
index 000000000..abed8786e
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/svc_acct.html
@@ -0,0 +1,55 @@
+<FONT SIZE=4>Setup <%= $svc %></FONT><BR><BR>
+
+<%= if ( $error ) {
+ $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error setting up $svc: $error!.
+ '</FONT><BR><BR>';
+} ''; %>
+<FORM ACTION="<%= $selfurl %>" METHOD=POST>
+<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
+<INPUT TYPE="hidden" NAME="action" VALUE="process_svc_acct">
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>">
+<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR="#cccccc">
+<TR>
+ <TD ALIGN="right">Username</TD>
+ <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Password</TD>
+ <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Re-enter Password</TD>
+ <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
+</TR>
+<%=
+ if ( $security_phrase ) {
+ $OUT .= <<ENDOUT;
+<TR>
+ <TD ALIGN="right">Security Phrase</TD>
+ <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
+ </TD>
+</TR>
+ENDOUT
+ } else {
+ $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
+ }
+%>
+<%=
+ if ( @svc_acct_pop ) {
+ $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
+ popselector( 'popnum' => $popnum,
+ 'pops' => \@svc_acct_pop,
+ 'init_popstate' => $init_popstate,
+ 'popac' => $popac,
+ 'acstate' => $acstate,
+ ).
+ '</TD></TR>';
+ } else {
+ $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
+ }
+%>
+</TABLE>
+<INPUT TYPE="submit" VALUE="Setup">
+</FORM>
diff --git a/fs_selfservice/FS-SelfService/cgi/view_customer.html b/fs_selfservice/FS-SelfService/cgi/view_customer.html
index e4e9be250..11e4432d0 100644
--- a/fs_selfservice/FS-SelfService/cgi/view_customer.html
+++ b/fs_selfservice/FS-SelfService/cgi/view_customer.html
@@ -1,10 +1,9 @@
-<HTML><HEAD><TITLE>View Customer</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>View Customer</FONT><BR><BR>
+<HTML><HEAD><TITLE>Reseller</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>Reseller</FONT><BR><BR>
<%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>agent_main">Reseller Main</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_menu') %>
+<TD VALIGN="top">
<%= $message
? "<FONT SIZE=\"+2\"><B>$message</B></FONT><BR><BR>"
@@ -13,67 +12,13 @@
<%= $small_custview %>
-<BR>Purchase additional package
-<FORM ACTION="<%= $selfurl %>" METHOD=POST>
-<INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
-<INPUT TYPE="hidden" NAME="action" VALUE="process_order_pkg">
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
-<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
-<TR>
- <TD COLSPAN=2><SELECT NAME="pkgpart"><OPTION VALUE="">
+<BR>
- <%=
- foreach my $part_pkg ( @part_pkg ) {
- $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
- $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
- $OUT .= '>'. $part_pkg->{'pkg'};
- }
- %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('agent_customer_menu') %>
+<TD VALIGN="top">
- </SELECT></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Username</TD>
- <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Password</TD>
- <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Re-enter Password</TD>
- <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
-</TR>
-<%=
- if ( $security_phrase ) {
- $OUT .= <<ENDOUT;
-<TR>
- <TD ALIGN="right">Security Phrase</TD>
- <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
- </TD>
-</TR>
-ENDOUT
- } else {
- $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
- }
-%>
-<%=
- if ( @svc_acct_pop ) {
- $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
- popselector( 'popnum' => $popnum,
- 'pops' => \@svc_acct_pop,
- 'init_popstate' => $init_popstate,
- 'popac' => $popac,
- 'acstate' => $acstate,
- ).
- '</TD></TR>';
- } else {
- $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
- }
-%>
-</TABLE>
-<INPUT TYPE="submit" VALUE="Purchase">
-</FORM>
+</TD></TR></TABLE>
</TD></TR></TABLE>
<HR>
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index 632d68df9..27f23de36 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -498,28 +498,12 @@ sub lastsearch {
}
if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
-
- &FS::cust_main::check_and_rebuild_fuzzyfiles;
- my $all_last = &FS::cust_main::all_last;
-
- my %last;
- if ( $last_type{'Fuzzy'} || $last_type{'All'} ) {
- foreach ( amatch($last, [ qw(i) ], @$all_last) ) {
- $last{$_}++;
- }
- }
-
- #if ($last_type{'Sound-alike'}) {
- #}
-
- foreach ( keys %last ) {
- push @cust_main, qsearch('cust_main',{'last'=>$_});
- push @cust_main, qsearch('cust_main',{'ship_last'=>$_})
- if defined dbdef->table('cust_main')->column('ship_last');
- }
-
+ push @cust_main, FS::cust_main->fuzzy_search( { 'last' => $last } );
}
+ #if ($last_type{'Sound-alike'}) {
+ #}
+
\@cust_main;
}
@@ -561,26 +545,10 @@ sub companysearch {
}
if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
+ push @cust_main, FS::cust_main->fuzzy_search( { 'company' => $company } );
+ }
- &FS::cust_main::check_and_rebuild_fuzzyfiles;
- my $all_company = &FS::cust_main::all_company;
-
- my %company;
- if ( $company_type{'Fuzzy'} || $company_type{'All'} ) {
- foreach ( amatch($company, [ qw(i) ], @$all_company ) ) {
- $company{$_}++;
- }
- }
-
- #if ($company_type{'Sound-alike'}) {
- #}
-
- foreach ( keys %company ) {
- push @cust_main, qsearch('cust_main',{'company'=>$_});
- push @cust_main, qsearch('cust_main',{'ship_company'=>$_})
- if defined dbdef->table('cust_main')->column('ship_last');
- }
-
+ if ($company_type{'Sound-alike'}) {
}
\@cust_main;