From: ivan Date: Tue, 24 Aug 2004 11:16:57 +0000 (+0000) Subject: big update for reseller interface X-Git-Tag: BEFORE_FINAL_MASONIZE~963 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=0cbeb01df08457b056a7ae775b4924c266b4228b big update for reseller interface --- 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 or I 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'} + ? ''. $result->{'error'}. '' + : $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'} - ? ''. $results->{'error'}. '' - : 'Package order sucessful.' - }; + if ( $results->{'error'} ) { + $action = 'agent_order_pkg'; + return { + $cgi->Vars, + %{agent_order_pkg()}, + #'message' => ''. $results->{'error'}. '', + 'error' => ''. $results->{'error'}. '', + }; + } 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="; ''; %> + +Setup services

+Purchase additional package

+ + + 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 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+<%= $small_custview %> +
+<%= if ( $error ) { + + $OUT .= qq!Error: $error!; +} else { + $OUT .= "$svc removed."; +} %> + +
+
+powered by freeside + + 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 @@ +Reseller +Reseller

+You have been logged out. + + 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 @@ -Reseller Main -Reseller Main

+Reseller +Reseller

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-Reseller Main
- -
+ +<%= include('agent_menu') %> +
<%= $message ? "$message" @@ -16,21 +15,19 @@
<%= $num_prospect %> - prospects + <%= $num_prospect ? qq!! : '' %>prospects
<%= $num_active %> - active + <%= $num_active ? qq!! : '' %>active
<%= $num_susp %> - suspended + <%= $num_susp ? qq!! : '' %>suspended
<%= $num_cancel %> - cancelled + <%= $num_cancel ? qq!! : '' %>cancelled
-
New customer -

powered by freeside 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="; ''; %> + + +Overview

+New customer

+
+ + +
+cust #, last name, or company
+
+
+Logout

+ + 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 @@ +Reseller +Reseller

+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> + +<%= include('agent_menu') %> +
+<%= $small_custview %> +
+ + +<%= include('agent_customer_menu') %> +
+<%= include('order_pkg') %> +
+ +
+
+powered by freeside + 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 @@ +Reseller +Reseller

+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> + +<%= include('agent_menu') %> +
+ +<%= $message + ? "$message

" + : '' +%> + +<%= $small_custview %> +
+ + +<%= include('agent_customer_menu') %> +
+<%= include('provision_list') %> +
+ +
+
+powered by freeside + 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 @@ +Reseller +Reseller

+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> + +<%= include('agent_menu') %> +
+<%= $small_custview %> +
+ +<%= include('agent_customer_menu') %> +
+<%= include('svc_acct') %> +
+ +
+
+powered by freeside + + 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 @@ -Reseller Main -Reseller Main

+Reseller +Reseller

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-Reseller Main
- -
+ +<%= include('agent_menu') %> +'; + +} %> + +
<%= if ( @customers ) { @@ -38,4 +37,3 @@ powered by freeside - 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 @@ + +Purchase additional package

+<%= if ( $error ) { + $OUT .= qq!$error

!; +} ''; %> +
+ + + + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+ +
+ 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 @@ <%= include('myaccount_menu') %>
-Setup services

- - - -<%= foreach my $pkg ( - grep { scalar(@{$_->{part_svc}}) - || scalar(@{$_->{cust_svc}}) - } @cust_pkg - ) { - - $OUT .= ''. - ''; - - my $col1 = "ffffff"; - my $col2 = "dddddd"; - my $col = $col1; - - foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) { - my $td = qq!'. - "$td>". $cust_svc->{label}[1]. ''. - "$td>"; - - #if ( $cust_svc->{label}[2] eq 'svc_acct' ) { - # $OUT .= qq!(!. - # 'change pw) '; - #} - - unless ( $cust_svc->{'svcnum'} == $svcnum ) { - $OUT .= qq!(!. - 'delete)'; - - } - $OUT .= ''; - $col = $col eq $col1 ? $col2 : $col1; - } - - $OUT .= '' - if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}}); - - my $col = $col1; - - foreach my $part_svc ( @{ $pkg->{part_svc} } ) { - - my $td = qq!'; - $col = $col eq $col1 ? $col2 : $col1; - } - - $OUT .= '
'. - $pkg->{'pkg'}. - '
". $cust_svc->{label}[0]. ':
!. - 'Setup '. $part_svc->{'svc'}. ' '. - '('. $part_svc->{'num_avail'}. ' available)'. - '

'; - -} %> - +<%= include('provision_list') %>

powered by freeside 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 @@ +Setup services

+ + + + + +<%= foreach my $pkg ( + grep { scalar(@{$_->{part_svc}}) + || scalar(@{$_->{cust_svc}}) + } @cust_pkg + ) { + + $OUT .= #'
'. + ''; + + my $col1 = "ffffff"; + my $col2 = "dddddd"; + my $col = $col1; + + foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) { + my $td = qq!'. + "$td>". $cust_svc->{label}[1]. ''; + $OUT .= '
password: '. encode_entities($cust_svc->{_password}). '' + if exists($cust_svc->{_password}); + $OUT .= ''. + "$td>"; + + #if ( $cust_svc->{label}[2] eq 'svc_acct' ) { + # $OUT .= qq!(!. + # 'change pw) '; + #} + + unless ( $cust_svc->{'svcnum'} == $svcnum ) { + $OUT .= qq!(!. + 'delete)'; + + } + $OUT .= ''; + $col = $col eq $col1 ? $col2 : $col1; + } + + $OUT .= '' + if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}}); + + $col = $col1; + + foreach my $part_svc ( @{ $pkg->{part_svc} } ) { + + my $td = qq!'; + $col = $col eq $col1 ? $col2 : $col1; + } + + #$OUT .= '
'. + $pkg->{'pkg'}. + '
". $cust_svc->{label}[0]. ':
!. + 'Setup '. $part_svc->{'svc'}. ' '. + '('. $part_svc->{'num_avail'}. ' available)'. + '

'; + $OUT .= '
 
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 @@ +Setup <%= $svc %>

+ +<%= if ( $error ) { + $OUT .= qq!Error setting up $svc: $error!. + '

'; +} ''; %> +
+ + + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+ +
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 @@ -View Customer -View Customer

+Reseller +Reseller

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-Reseller Main
- -
+ +<%= include('agent_menu') %> +
<%= $message ? "$message

" @@ -13,67 +12,13 @@ <%= $small_custview %> -
Purchase additional package -
- - - - - -
+<%= include('agent_customer_menu') %> + - - - - - - - - - - - - - -<%= - if ( $security_phrase ) { - $OUT .= < - - - -ENDOUT - } else { - $OUT .= ''; - } -%> -<%= - if ( @svc_acct_pop ) { - $OUT .= ''; - } else { - $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); - } -%> -
-
Username
Password
Re-enter Password
Security Phrase -
Access number'. - popselector( 'popnum' => $popnum, - 'pops' => \@svc_acct_pop, - 'init_popstate' => $init_popstate, - 'popac' => $popac, - 'acstate' => $acstate, - ). - '
- - +

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;