X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fselfservice.cgi;h=4c7b1d86a010aff08d8914abed9a4b229b656096;hb=d6b6f81e383f9d876e67e9704914e887a331012e;hp=2e1da41689955e7d736394ea39bb2bea03128a21;hpb=7cdcb8d249f66efdbd5eb4efdd6e07f0f7948b49;p=freeside.git diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 2e1da4168..4c7b1d86a 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -8,13 +8,16 @@ use CGI::Carp qw(fatalsToBrowser); use Text::Template; use HTML::Entities; use Date::Format; -use FS::SelfService qw( login customer_info invoice - payment_info process_payment +use Number::Format 1.50; +use FS::SelfService qw( login_info login customer_info edit_info invoice + payment_info process_payment realtime_collect process_prepay list_pkgs order_pkg signup_info order_recharge part_svc_info provision_acct provision_external - unprovision_svc change_pkg - list_svcs list_svc_usage myaccount_passwd + unprovision_svc change_pkg domainselector + list_svcs + list_svc_usage list_cdr_usage list_support_usage + myaccount_passwd ); $template_dir = '.'; @@ -26,7 +29,9 @@ $form_max = 255; $cgi = new CGI; unless ( defined $cgi->param('session') ) { - do_template('login',{}); + my $login_info = login_info(); + + do_template('login', $login_info ); exit; } @@ -50,10 +55,12 @@ if ( $cgi->param('session') eq 'login' ) { 'password' => $password, ); if ( $rv->{error} ) { + my $login_info = login_info(); do_template('login', { 'error' => $rv->{error}, 'username' => $username, 'domain' => $domain, + %$login_info, } ); exit; } else { @@ -66,7 +73,7 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|make_ach_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|change_password|process_change_password)$/ + /^(myaccount|view_invoice|make_payment|make_ach_payment|make_thirdparty_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_cdr_details|view_support_details|change_password|process_change_password)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -79,7 +86,8 @@ die $@ if $@; if ( $result->{error} eq "Can't resume session" || $result->{error} eq "Expired session" ) { #ick - do_template('login',{}); + my $login_info = login_info(); + do_template('login', $login_info); exit; } @@ -91,6 +99,7 @@ warn "processing template $action\n" do_template($action, { 'session_id' => $session_id, 'action' => $action, #so the menu knows what tab we're on... + %{ payment_info( 'session_id' => $session_id ) }, # cust_paybys for the menu %{$result} }); @@ -98,6 +107,81 @@ do_template($action, { sub myaccount { customer_info( 'session_id' => $session_id ); } +sub change_bill { my $payment_info = + payment_info( 'session_id' => $session_id ); + return $payment_info if ( $payment_info->{'error'} ); + my $customer_info = + customer_info( 'session_id' => $session_id ); + return { + %$payment_info, + %$customer_info, + }; + } +sub change_ship { change_bill(@_); } +sub change_pay { change_bill(@_); } + +sub _process_change_info { + my ($erroraction, @fields) = @_; + + my $results = ''; + + $results ||= edit_info ( + 'session_id' => $session_id, + map { ($_ => $cgi->param($_)) } grep { defined($cgi->param($_)) } @fields, + ); + + + if ( $results->{'error'} ) { + no strict 'refs'; + $action = $erroraction; + return { + $cgi->Vars, + %{&$action()}, + 'error' => ''. $results->{'error'}. '', + }; + } else { + return $results; + } +} + +sub process_change_bill { + _process_change_info( 'change_bill', + qw( first last company address1 address2 city state + county zip country daytime night fax ) + ); +} + +sub process_change_ship { + my @list = map { "ship_$_" } + qw( first last company address1 address2 city state + county zip country daytime night fax + ); + if ($cgi->param('same') eq 'Y') { + foreach (@list) { $cgi->param($_, '') } + } + + _process_change_info( 'change_ship', @list ); +} + +sub process_change_pay { + my $postal = $cgi->param( 'postal_invoicing' ); + my @list = + qw( payby payinfo payinfo1 payinfo2 month year payname + address1 address2 city county state zip country auto paytype + paystate ss stateid stateid_state invoicing_list + ); + push @list, 'postal_invoicing' if $postal; + unless ( $postal || $cgi->param( 'invoicing_list' ) ) { + $action = 'change_pay'; + return { + %{&change_pay()}, + $cgi->Vars, + 'error' => 'Postal or email required.', + }; + } + _process_change_info( 'change_pay', @list ); +} + sub view_invoice { $cgi->param('invnum') =~ /^(\d+)$/ or die "illegal invnum"; @@ -243,7 +327,7 @@ sub payment_results { #the rest, it gives better error messages $cgi->param('amount') =~ /^\s*(\d+(\.\d{2})?)\s*$/ - or die "illegal amount"; #!!! + or die "Illegal amount: ". $cgi->param('amount'); #!!! my $amount = $1; my $payinfo = $cgi->param('payinfo'); @@ -390,6 +474,12 @@ sub ach_payment_results { } +sub make_thirdparty_payment { + $cgi->param('payby_method') =~ /^(CC|ECHECK)$/ + or die "illegal payby method"; + realtime_collect( 'session_id' => $session_id, 'method' => $1 ); +} + sub recharge_prepay { customer_info( 'session_id' => $session_id ); } @@ -437,7 +527,7 @@ sub process_svc_acct { my $result = provision_acct ( 'session_id' => $session_id, map { $_ => $cgi->param($_) } qw( - pkgnum svcpart username _password _password2 sec_phrase popnum ) + pkgnum svcpart username domsvc _password _password2 sec_phrase popnum ) ); if ( exists $result->{'error'} && $result->{'error'} ) { @@ -475,7 +565,7 @@ sub delete_svc { sub view_usage { list_svcs( 'session_id' => $session_id, - 'svcdb' => 'svc_acct', + 'svcdb' => [ 'svc_acct', 'svc_phone' ], 'ncancelled' => 1, ); } @@ -489,6 +579,24 @@ sub view_usage_details { ); } +sub view_cdr_details { + list_cdr_usage( + 'session_id' => $session_id, + 'svcnum' => $cgi->param('svcnum'), + 'beginning' => $cgi->param('beginning') || '', + 'ending' => $cgi->param('ending') || '', + ); +} + +sub view_support_details { + list_support_usage( + 'session_id' => $session_id, + 'svcnum' => $cgi->param('svcnum'), + 'beginning' => $cgi->param('beginning') || '', + 'ending' => $cgi->param('ending') || '', + ); +} + sub change_password { list_svcs( 'session_id' => $session_id, @@ -534,12 +642,16 @@ sub do_template { $fill_in->{'selfurl'} = $cgi->self_url; $fill_in->{'cgi'} = \$cgi; - my $template = new Text::Template( TYPE => 'FILE', - SOURCE => "$template_dir/$name.html", + my $source = "$template_dir/$name.html"; + #warn "creating template for $source\n"; + my $template = new Text::Template( TYPE => 'FILE', + SOURCE => $source, DELIMITERS => [ '<%=', '%>' ], - UNTAINT => 1, ) + UNTAINT => 1, + ) or die $Text::Template::ERROR; + #warn "filling in $template with $fill_in\n"; print $cgi->header( '-expires' => 'now' ), $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi', HASH => $fill_in @@ -552,7 +664,7 @@ package FS::SelfService::_selfservicecgi; #use FS::SelfService qw(regionselector expselect popselector); use HTML::Entities; -use FS::SelfService qw(popselector); +use FS::SelfService qw(regionselector popselector domainselector location_form); #false laziness w/agent.cgi sub include {