diff options
author | jeff <jeff> | 2006-11-27 07:11:53 +0000 |
---|---|---|
committer | jeff <jeff> | 2006-11-27 07:11:53 +0000 |
commit | b5bd90f5ee35af1ca7989bf92dc50ada7c2cbcb8 (patch) | |
tree | 83f002ad9c43424027b7f9aff9c0b541a0eabbe8 | |
parent | d1688630a1f43fcd0e780d98556282de3e756f6a (diff) |
order package from self-service
-rw-r--r-- | FS/FS/ClientAPI/Signup.pm | 15 | ||||
-rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/customer_order_pkg.html | 10 | ||||
-rw-r--r-- | fs_selfservice/FS-SelfService/cgi/myaccount_menu.html | 3 | ||||
-rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/process_order_pkg.html | 13 | ||||
-rw-r--r-- | fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 61 |
5 files changed, 96 insertions, 6 deletions
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 3daab9d81..8eeab1a47 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -119,6 +119,19 @@ sub signup_info { } else { return { 'error' => "Can't resume session" }; #better error message } + }elsif( exists $packet->{'customer_session_id'} ) { + my $cache = new FS::ClientAPI_SessionCache( { + 'namespace' => 'FS::ClientAPI::MyAccount', + } ); + $session = $cache->get($packet->{'customer_session_id'}); + if ( $session ) { + my $custnum = $session->{'custnum'}; + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum }); + return { 'error' => "Can't find your customer record" } unless $cust_main; + $agentnum = $cust_main->agentnum; + } else { + return { 'error' => "Can't resume session" }; #better error message + } } $signup_info->{'part_pkg'} = []; @@ -159,7 +172,7 @@ sub signup_info { # delete $signup_info->{'part_pkg'}; #} - if ( $session ) { + if ( exists $packet->{'session_id'} ) { my $agent_signup_info = { %$signup_info }; delete $agent_signup_info->{agentnum2part_pkg}; $agent_signup_info->{'agent'} = $session->{'agent'}; diff --git a/fs_selfservice/FS-SelfService/cgi/customer_order_pkg.html b/fs_selfservice/FS-SelfService/cgi/customer_order_pkg.html new file mode 100755 index 000000000..c01b6b384 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/customer_order_pkg.html @@ -0,0 +1,10 @@ +<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD> +<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR> +<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> +<TD VALIGN="top"> +<%= include('order_pkg') %> +</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/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html index 6dacc3ef4..aa24f5d8f 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html @@ -12,7 +12,8 @@ my @menu = ( { title=>' ' }, { title=>'Purchase', size=>'+1', }, -# { title=>'Purchase additional package*', url=>'order', 'indent'=>2 }, + { title=>'Purchase additional package*', + url=>'customer_order_pkg', 'indent'=>2 }, ); if ( 1 ) { #XXXFIXME "enable selfservice prepay features" flag or something, eventually per-pkg or something really fancy diff --git a/fs_selfservice/FS-SelfService/cgi/process_order_pkg.html b/fs_selfservice/FS-SelfService/cgi/process_order_pkg.html new file mode 100755 index 000000000..79be5eba5 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_order_pkg.html @@ -0,0 +1,13 @@ +<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD> +<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR> +<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> +<TD VALIGN="top"> + +<FONT SIZE=4>Package order successful.</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/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index ed6d623d9..0f8979cd8 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -1,4 +1,3 @@ -#!/usr/bin/perl -T #!/usr/bin/perl -Tw use strict; @@ -11,7 +10,7 @@ use HTML::Entities; use FS::SelfService qw( login customer_info invoice payment_info process_payment process_prepay - list_pkgs + list_pkgs order_pkg signup_info part_svc_info provision_acct provision_external unprovision_svc list_svcs myaccount_passwd @@ -66,7 +65,7 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|change_password|process_change_password)$/ + /^(myaccount|view_invoice|make_payment|payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|customer_order_pkg|process_order_pkg|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|change_password|process_change_password)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -76,7 +75,9 @@ $FS::SelfService::DEBUG = $DEBUG; my $result = eval "&$action();"; die $@ if $@; -if ( $result->{error} eq "Can't resume session" ) { #ick +if ( $result->{error} eq "Can't resume session" + || $result->{error} eq "Expired session" ) { #ick + do_template('login',{}); exit; } @@ -107,6 +108,58 @@ sub view_invoice { } +sub customer_order_pkg { + my $init_data = signup_info( 'customer_session_id' => $session_id ); + return $init_data if ( $init_data->{'error'} ); + + my $customer_info = customer_info( 'session_id' => $session_id ); + return $customer_info if ( $customer_info->{'error'} ); + + return { + ( map { $_ => $init_data->{$_} } + qw( part_pkg security_phrase svc_acct_pop ), + ), + %$customer_info, + }; +} + +sub process_order_pkg { + + my $results = ''; + + unless ( length($cgi->param('_password')) ) { + my $init_data = signup_info( 'customer_session_id' => $session_id ); + $results = { 'error' => $init_data->{msgcat}{empty_password} }; + $results = { 'error' => $init_data->{error} } if($init_data->{error}); + } + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { + my $init_data = signup_info( 'customer_session_id' => $session_id ); + $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} }; + $results = { 'error' => $init_data->{error} } if($init_data->{error}); + $cgi->param('_password', ''); + $cgi->param('_password2', ''); + } + + $results ||= order_pkg ( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } + qw( custnum pkgpart username _password _password2 sec_phrase popnum ) + ); + + + if ( $results->{'error'} ) { + $action = 'customer_order_pkg'; + return { + $cgi->Vars, + %{customer_order_pkg()}, + 'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>', + }; + } else { + return $results; + } + +} + sub make_payment { payment_info( 'session_id' => $session_id ); } |