freeside/FS/FS/ClientAPI MyAccount.pm,1.27,1.28 Signup.pm,1.14,1.15
ivan
ivan at pouncequick.420.am
Thu Jul 15 15:40:04 PDT 2004
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory pouncequick:/tmp/cvs-serv27096/FS/FS/ClientAPI
Modified Files:
MyAccount.pm Signup.pm
Log Message:
big update for customer self-service: add provisioning/unprovisioning of purchased services, like fs_selfadmin
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- MyAccount.pm 10 Jul 2004 14:46:17 -0000 1.27
+++ MyAccount.pm 15 Jul 2004 22:40:00 -0000 1.28
@@ -22,6 +22,7 @@
use FS::ClientAPI; #hmm
FS::ClientAPI->register_handlers(
'MyAccount/login' => \&login,
+ 'MyAccount/logout' => \&logout,
'MyAccount/customer_info' => \&customer_info,
'MyAccount/edit_info' => \&edit_info,
'MyAccount/invoice' => \&invoice,
@@ -33,6 +34,9 @@
'MyAccount/order_pkg' => \&order_pkg,
'MyAccount/cancel_pkg' => \&cancel_pkg,
'MyAccount/charge' => \&charge,
+ 'MyAccount/part_svc_info' => \&part_svc_info,
+ 'MyAccount/provision_acct' => \&provision_acct,
+ 'MyAccount/unprovision_svc' => \&unprovision_svc,
);
use vars qw( @cust_main_editable_fields );
@@ -92,6 +96,16 @@
};
}
+sub 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 customer_info {
my $p = shift;
@@ -445,7 +459,24 @@
my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
or return { 'error' => "unknown custnum $custnum" };
- return { 'cust_pkg' => [ map { $_->hashref } $cust_main->ncancelled_pkgs ] };
+ #return { 'cust_pkg' => [ map { $_->hashref } $cust_main->ncancelled_pkgs ] };
+
+ { 'svcnum' => $session->{'svcnum'},
+ 'cust_pkg' => [ map {
+ { $_->hash,
+ $_->part_pkg->hash,
+ part_svc =>
+ [ map $_->hashref, $_->available_part_svc ],
+ cust_svc =>
+ [ map { { $_->hash,
+ label => [ $_->label ],
+ }
+ } $_->cust_svc
+ ],
+ };
+ } $cust_main->ncancelled_pkgs
+ ],
+ };
}
@@ -595,6 +626,111 @@
my $error = $cust_pkg->cancel( 'quiet'=>1 );
return { 'error' => $error };
+
+}
+
+sub provision_acct {
+ 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 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my $pkgnum = $p->{'pkgnum'};
+
+ my $cust_pkg = qsearchs('cust_pkg', { 'custnum' => $custnum,
+ 'pkgnum' => $pkgnum,
+ } )
+ or return { 'error' => "unknown pkgnum $pkgnum" };
+
+ my $part_svc = qsearchs('part_svc', { 'svcpart' => $p->{'svcpart'} } )
+ or return { 'error' => "unknown svcpart $p->{'svcpart'}" };
+
+ return { 'error' => gettext('passwords_dont_match') }
+ if $p->{'_password'} ne $p->{'_password2'};
+ return { 'error' => gettext('empty_password') }
+ unless length($p->{'_password'});
+
+ my $svc_acct = new FS::svc_acct( {
+ 'pkgnum' => $p->{'pkgnum'},
+ 'svcpart' => $p->{'svcpart'},
+ 'username' => $p->{'username'},
+ '_password' => $p->{'_password'},
+ } );
+
+ return { 'svc' => $part_svc->svc,
+ 'error' => $svc_acct->insert
+ };
+
+}
+
+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 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my $pkgnum = $p->{'pkgnum'};
+
+ my $cust_pkg = qsearchs('cust_pkg', { 'custnum' => $custnum,
+ 'pkgnum' => $pkgnum,
+ } )
+ or return { 'error' => "unknown pkgnum $pkgnum" };
+
+ my $svcpart = $p->{'svcpart'};
+
+ my $pkg_svc = qsearchs('pkg_svc', { 'pkgpart' => $cust_pkg->pkgpart,
+ 'svcpart' => $svcpart, } )
+ or return { 'error' => "unknown svcpart $svcpart for pkgnum $pkgnum" };
+ my $part_svc = $pkg_svc->part_svc;
+
+ return {
+ 'svc' => $part_svc->svc,
+ 'svcdb' => $part_svc->svcdb,
+ 'pkgnum' => $pkgnum,
+ 'svcpart' => $svcpart,
+
+ 'security_phrase' => 0, #XXX !
+ 'svc_acct_pop' => [], #XXX !
+ 'popnum' => '',
+ 'init_popstate' => '',
+ 'popac' => '',
+ 'acstate' => '',
+ };
+
+}
+
+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 $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my $svcnum = $p->{'svcnum'};
+
+ my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svcnum, } )
+ or return { 'error' => "unknown svcnum $svcnum" };
+
+ return { 'error' => "Service $svcnum does not belong to customer $custnum" }
+ unless $cust_svc->cust_pkg->custnum == $custnum;
+
+ return { 'svc' => $cust_svc->part_svc->svc,
+ 'error' => $cust_svc->cancel
+ };
}
Index: Signup.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/Signup.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Signup.pm 10 Jun 2004 12:31:31 -0000 1.14
+++ Signup.pm 15 Jul 2004 22:40:00 -0000 1.15
@@ -128,7 +128,7 @@
#return "Passwords don't match"
# if $hashref->{'_password'} ne $hashref->{'_password2'}
return { 'error' => gettext('empty_password') }
- unless $packet->{'_password'};
+ unless length($packet->{'_password'});
# a bit inefficient for large numbers of pops
return { 'error' => gettext('no_access_number_selected') }
unless $packet->{'popnum'} || !scalar(qsearch('svc_acct_pop',{} ));
More information about the freeside-commits
mailing list