diff options
author | mark <mark> | 2010-11-23 01:40:12 +0000 |
---|---|---|
committer | mark <mark> | 2010-11-23 01:40:12 +0000 |
commit | ee03c169b91b87c93c21f768d103eb7316559214 (patch) | |
tree | 5c5896bab3d3b1fe7772af76c2170d8a78b952c3 /FS | |
parent | 6b706c66d9f4247d4ba70c59adb726f3d932643c (diff) |
selfservice command to suspend packages, RT#9989
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 17 | ||||
-rw-r--r-- | FS/FS/ClientAPI_XMLRPC.pm | 1 | ||||
-rw-r--r-- | FS/FS/Conf.pm | 26 |
3 files changed, 42 insertions, 2 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 1e1d1d3b1..377eb22d5 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -266,6 +266,9 @@ sub access_info { @{ $info->{cust_paybys} } ]; + $info->{'self_suspend_reason'} = + $conf->config('selfservice-self_suspend_reason'); + return { %$info, 'custnum' => $custnum, 'access_pkgnum' => $session->{'pkgnum'}, @@ -1453,8 +1456,18 @@ sub order_renew { } -sub cancel_pkg { +# these are basically the same +sub cancel_pkg { alter_pkg(shift, 'cancel', 'quiet' => 1) } +sub suspend_pkg { + my $conf = new FS::Conf; + my $reasonnum = $conf->config('selfservice-self_suspend_reason') + or return { 'error' => "Permission denied" }; + alter_pkg(shift, 'suspend', 'reason' => $reasonnum) +} + +sub alter_pkg { my $p = shift; + my $method = shift; my $session = _cache->get($p->{'session_id'}) or return { 'error' => "Can't resume session" }; #better error message @@ -1469,7 +1482,7 @@ sub cancel_pkg { 'pkgnum' => $pkgnum, } ) or return { 'error' => "unknown pkgnum $pkgnum" }; - my $error = $cust_pkg->cancel( 'quiet'=>1 ); + my $error = $cust_pkg->$method(@_); return { 'error' => $error }; } diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index 32e96b8e2..48b94eba2 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -91,6 +91,7 @@ sub ss2clientapi { 'renew_info' => 'MyAccount/renew_info', 'order_renew' => 'MyAccount/order_renew', 'cancel_pkg' => 'MyAccount/cancel_pkg', #add to ss cgi! + 'suspend_pkg' => 'MyAccount/suspend_pkg', #add to ss cgi! 'charge' => 'MyAccount/charge', #? 'part_svc_info' => 'MyAccount/part_svc_info', 'provision_acct' => 'MyAccount/provision_acct', diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 1d946a5e8..08bdedd6f 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2294,6 +2294,32 @@ and customer address. Include units.', }, { + 'key' => 'selfservice-self_suspend_reason', + 'section' => 'self-service', + 'description' => 'Suspend reason when customers suspend their own packages. Set to nothing to disallow self-suspension.', + 'type' => 'select-sub', + 'options_sub' => sub { require FS::Record; + require FS::reason; + my $type = qsearchs('reason_type', + { class => 'S' }) + or return (); + map { $_->reasonnum => $_->reason } + FS::Record::qsearch('reason', + { reason_type => $type->typenum } + ); + }, + 'option_sub' => sub { require FS::Record; + require FS::reason; + my $reason = FS::Record::qsearchs( + 'reason', { 'reasonnum' => shift } + ); + $reason ? $reason->reason : ''; + }, + + 'per_agent' => 1, + }, + + { 'key' => 'card_refund-days', 'section' => 'billing', 'description' => 'After a payment, the number of days a refund link will be available for that payment. Defaults to 120.', |