From 6ced9264b8ec79e4b460be90ede25ec72a7dfc16 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 15 Jul 2004 22:40:01 +0000 Subject: big update for customer self-service: add provisioning/unprovisioning of purchased services, like fs_selfadmin --- fs_selfservice/FS-SelfService/cgi/agent.cgi | 4 + fs_selfservice/FS-SelfService/cgi/delete_svc.html | 18 +++++ fs_selfservice/FS-SelfService/cgi/logout.html | 5 ++ .../FS-SelfService/cgi/make_payment.html | 7 +- fs_selfservice/FS-SelfService/cgi/myaccount.html | 9 +-- .../FS-SelfService/cgi/myaccount_menu.html | 13 +++ .../FS-SelfService/cgi/payment_results.html | 7 +- .../FS-SelfService/cgi/process_svc_acct.html | 14 ++++ fs_selfservice/FS-SelfService/cgi/provision.html | 77 ++++++++++++++++++ .../FS-SelfService/cgi/provision_svc_acct.html | 66 ++++++++++++++++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 92 +++++++++++++++++++++- .../FS-SelfService/cgi/view_invoice.html | 9 +-- 12 files changed, 298 insertions(+), 23 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/delete_svc.html create mode 100644 fs_selfservice/FS-SelfService/cgi/logout.html create mode 100644 fs_selfservice/FS-SelfService/cgi/myaccount_menu.html create mode 100644 fs_selfservice/FS-SelfService/cgi/process_svc_acct.html create mode 100644 fs_selfservice/FS-SelfService/cgi/provision.html create mode 100644 fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html (limited to 'fs_selfservice/FS-SelfService/cgi') diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index 2d948e790..6d2fd5840 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -221,6 +221,10 @@ sub process_order_pkg { my $results = ''; + unless ( length($cgi->param('_password')) ) { + my $init_data = signup_info( 'session_id' => $session_id ); + $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} }; diff --git a/fs_selfservice/FS-SelfService/cgi/delete_svc.html b/fs_selfservice/FS-SelfService/cgi/delete_svc.html new file mode 100644 index 000000000..16054a77c --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/delete_svc.html @@ -0,0 +1,18 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+ +<%= if ( $error ) { + $OUT .= qq!Error: $error!; +} else { + $OUT .= "$svc removed."; +} %> + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/logout.html b/fs_selfservice/FS-SelfService/cgi/logout.html new file mode 100644 index 000000000..0e774e9eb --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/logout.html @@ -0,0 +1,5 @@ +MyAccount +MyAccount

+You have been logged out. + + diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index cf6d62e22..3522c0867 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -1,10 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
+ +<%= include('myaccount_menu') %> +
Make a payment

diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index f48fdedea..9997d7059 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -1,10 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
+ +<%= include('myaccount_menu') %> +
Hello <%= $name %>!

<%= $small_custview %> @@ -15,7 +14,7 @@ Hello <%= $name %>!

<%= if ( @open_invoices ) { $OUT .= ''. - ''; my $link = qq! + diff --git a/fs_selfservice/FS-SelfService/cgi/payment_results.html b/fs_selfservice/FS-SelfService/cgi/payment_results.html index 92c8cf51b..44289deba 100644 --- a/fs_selfservice/FS-SelfService/cgi/payment_results.html +++ b/fs_selfservice/FS-SelfService/cgi/payment_results.html @@ -1,10 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
Open Invoices'; + '
Open Invoices
+ +Overview

+Change payment info *

+Change service address *

+Setup my services

+Purchase additional package *

+ +Change password(s)

+Logout

+* coming soon +
-MyAccount
- -
+ +<%= include('myaccount_menu') %> +
Payment results

<%= if ( $error ) { $OUT .= qq!Error processing your payment: $error!; diff --git a/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html new file mode 100644 index 000000000..7052059c4 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html @@ -0,0 +1,14 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+ +<%= $svc %> setup sucessfully. + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/provision.html b/fs_selfservice/FS-SelfService/cgi/provision.html new file mode 100644 index 000000000..326f90229 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/provision.html @@ -0,0 +1,77 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= 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)'. + '

'; + +} %> + +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html new file mode 100644 index 000000000..d18375c82 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html @@ -0,0 +1,66 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+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, + ). + '
+ + + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 6d6716ddc..d8e044a96 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -6,8 +6,11 @@ use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); use Text::Template; -use FS::SelfService qw( login customer_info invoice payment_info - process_payment ); +use FS::SelfService qw( login customer_info invoice + payment_info process_payment + list_pkgs + part_svc_info provision_acct unprovision_svc + ); $template_dir = '.'; @@ -54,8 +57,9 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); +#order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|payment_results)$/ + /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|delete_svc)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -167,6 +171,63 @@ sub payment_results { } +sub logout { + FS::SelfService::logout( 'session_id' => $session_id ); +} + +sub provision { + list_pkgs( 'session_id' => $session_id ); +} + +sub provision_svc { + + my $result = part_svc_info( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( pkgnum svcpart ), + ); + 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"; + + $result; +} + +sub process_svc_acct { + + my $result = provision_acct ( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( + pkgnum svcpart username _password _password2 sec_phrase popnum ) + ); + + if ( exists $result->{'error'} && $result->{'error'} ) { + warn "$result $result->{'error'}"; + $action = 'provision_svc_acct'; + return { + $cgi->Vars, + %{ part_svc_info( 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( pkgnum svcpart ) + ) + }, + 'error' => $result->{'error'}, + }; + } else { + warn "$result $result->{'error'}"; + return $result; + } + +} + +sub delete_svc { + unprovision_svc( + 'session_id' => $session_id, + 'svcnum' => $cgi->param('svcnum'), + ); +} + #-- sub do_template { @@ -175,6 +236,7 @@ sub do_template { $cgi->delete_all(); $fill_in->{'selfurl'} = $cgi->self_url; + $fill_in->{'cgi'} = \$cgi; my $template = new Text::Template( TYPE => 'FILE', SOURCE => "$template_dir/$name.html", @@ -183,6 +245,28 @@ sub do_template { or die $Text::Template::ERROR; print $cgi->header( '-expires' => 'now' ), - $template->fill_in( HASH => $fill_in ); + $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi', + HASH => $fill_in + ); +} + +#*FS::SelfService::_selfservicecgi::include = \&Text::Template::fill_in_file; + +package FS::SelfService::_selfservicecgi; + +#use FS::SelfService qw(regionselector expselect popselector); +use FS::SelfService qw(popselector); + +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(); + } diff --git a/fs_selfservice/FS-SelfService/cgi/view_invoice.html b/fs_selfservice/FS-SelfService/cgi/view_invoice.html index d2b012b5d..46f731890 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_invoice.html +++ b/fs_selfservice/FS-SelfService/cgi/view_invoice.html @@ -1,12 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
- -<-- back to MyAccount

+ +<%= include('myaccount_menu') %> +
 <%= $invoice_text %>
-- 
cgit v1.2.1