add artera turbo handling to self-service and reseller interfaces
authorivan <ivan>
Sun, 17 Oct 2004 14:01:47 +0000 (14:01 +0000)
committerivan <ivan>
Sun, 17 Oct 2004 14:01:47 +0000 (14:01 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/part_export/artera_turbo.pm
fs_selfservice/FS-SelfService/SelfService.pm
fs_selfservice/FS-SelfService/cgi/agent.cgi
fs_selfservice/FS-SelfService/cgi/process_svc_external.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/provision_list.html
fs_selfservice/FS-SelfService/cgi/selfservice.cgi

index 34dad38..fe2e1c2 100644 (file)
@@ -21,22 +21,23 @@ use FS::cust_pkg;
 
 use FS::ClientAPI; #hmm
 FS::ClientAPI->register_handlers(
 
 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,
-  'MyAccount/list_invoices'    => \&list_invoices,
-  'MyAccount/cancel'           => \&cancel,
-  'MyAccount/payment_info'     => \&payment_info,
-  'MyAccount/process_payment'  => \&process_payment,
-  'MyAccount/list_pkgs'        => \&list_pkgs,
-  '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,
+  'MyAccount/login'              => \&login,
+  'MyAccount/logout'             => \&logout,
+  'MyAccount/customer_info'      => \&customer_info,
+  'MyAccount/edit_info'          => \&edit_info,
+  'MyAccount/invoice'            => \&invoice,
+  'MyAccount/list_invoices'      => \&list_invoices,
+  'MyAccount/cancel'             => \&cancel,
+  'MyAccount/payment_info'       => \&payment_info,
+  'MyAccount/process_payment'    => \&process_payment,
+  'MyAccount/list_pkgs'          => \&list_pkgs,
+  '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/provision_external' => \&provision_external,
+  'MyAccount/unprovision_svc'    => \&unprovision_svc,
 );
 
 use vars qw( @cust_main_editable_fields );
 );
 
 use vars qw( @cust_main_editable_fields );
@@ -48,6 +49,8 @@ use vars qw( @cust_main_editable_fields );
   payby payinfo payname
 );
 
   payby payinfo payname
 );
 
+use subs qw(_provision);
+
 #store in db?
 my $cache = new Cache::SharedMemoryCache( {
    'namespace' => 'FS::ClientAPI::MyAccount',
 #store in db?
 my $cache = new Cache::SharedMemoryCache( {
    'namespace' => 'FS::ClientAPI::MyAccount',
@@ -611,6 +614,33 @@ sub cancel_pkg {
 sub provision_acct {
   my $p = shift;
 
 sub provision_acct {
   my $p = shift;
 
+  return { 'error' => gettext('passwords_dont_match') }
+    if $p->{'_password'} ne $p->{'_password2'};
+  return { 'error' => gettext('empty_password') }
+    unless length($p->{'_password'});
+
+  _provision( 'FS::svc_acct',
+              [qw(username _password)],
+              [qw(username _password)],
+              $p,
+              @_
+            );
+}
+
+sub provision_external {
+  my $p = shift;
+  #_provision( 'FS::svc_external', [qw(id title)], [qw(id title)], $p, @_ );
+  _provision( 'FS::svc_external',
+              [],
+              [qw(id title)],
+              $p,
+              @_
+            );
+}
+
+sub _provision {
+  my( $class, $fields, $return_fields, $p ) = splice(@_, 0, 4);
+
   my($context, $session, $custnum) = _custoragent_session_custnum($p);
   return { 'error' => $session } if $context eq 'error';
 
   my($context, $session, $custnum) = _custoragent_session_custnum($p);
   return { 'error' => $session } if $context eq 'error';
 
@@ -629,20 +659,18 @@ sub provision_acct {
   my $part_svc = qsearchs('part_svc', { 'svcpart' => $p->{'svcpart'} } )
     or return { 'error' => "unknown svcpart $p->{'svcpart'}" };
 
   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'},
+  my $svc_x = $class->new( {
+    'pkgnum'  => $p->{'pkgnum'},
+    'svcpart' => $p->{'svcpart'},
+    map { $_ => $p->{$_} } @$fields
   } );
   } );
+  my $error = $svc_x->insert;
+  $svc_x = qsearchs($svc_x->table, { 'svcnum' => $svc_x->svcnum })
+    unless $error;
 
   return { 'svc'   => $part_svc->svc,
 
   return { 'svc'   => $part_svc->svc,
-           'error' => $svc_acct->insert
+           'error' => $error,
+           map { $_ => $svc_x->get($_) } @$return_fields
          };
 
 }
          };
 
 }
index 52ab232..1e22961 100644 (file)
@@ -61,7 +61,6 @@ sub _export_insert {
 
   eval "use Net::Artera;";
   return $@ if $@;
 
   eval "use Net::Artera;";
   return $@ if $@;
-
   my $artera = $self->_new_Artera;
 
   my $cust_pkg = $svc_external->cust_svc->cust_pkg;
   my $artera = $self->_new_Artera;
 
   my $cust_pkg = $svc_external->cust_svc->cust_pkg;
@@ -113,25 +112,27 @@ sub _export_replace {
 
 sub _export_delete {
   my( $self, $svc_external ) = (shift, shift);
 
 sub _export_delete {
   my( $self, $svc_external ) = (shift, shift);
-  $self->StatusChange(17, $svc_external);
+  $self->statusChange(17, $svc_external);
 }
 
 sub _export_suspend {
   my( $self, $svc_external ) = (shift, shift);
 }
 
 sub _export_suspend {
   my( $self, $svc_external ) = (shift, shift);
-  $self->StatusChange(16, $svc_external);
+  $self->statusChange(16, $svc_external);
 }
 
 sub _export_unsuspend {
   my( $self, $svc_external ) = (shift, shift);
 }
 
 sub _export_unsuspend {
   my( $self, $svc_external ) = (shift, shift);
-  $self->StatusChange(15, $svc_external);
+  $self->statusChange(15, $svc_external);
 }
 
 }
 
-sub StatusChange {
+sub statusChange {
   my( $self, $status, $svc_external ) = @_;
 
   my( $self, $status, $svc_external ) = @_;
 
+  eval "use Net::Artera;";
+  return $@ if $@;
   my $artera = $self->_new_Artera;
 
   my $artera = $self->_new_Artera;
 
-  my $result = $artera->StatusChange(
+  my $result = $artera->statusChange(
     'asn'      => sprintf('%010d', $svc_external->id),
     'akc'      => $svc_external->title,
     'statusid' => $status,
     'asn'      => sprintf('%010d', $svc_external->id),
     'akc'      => $svc_external->title,
     'statusid' => $status,
index de33b75..6e3ca3b 100644 (file)
@@ -36,6 +36,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'charge'               => 'MyAccount/charge',        #?
   'part_svc_info'        => 'MyAccount/part_svc_info',
   'provision_acct'       => 'MyAccount/provision_acct',
   'charge'               => 'MyAccount/charge',        #?
   'part_svc_info'        => 'MyAccount/part_svc_info',
   'provision_acct'       => 'MyAccount/provision_acct',
+  'provision_external'   => 'MyAccount/provision_external',
   'unprovision_svc'      => 'MyAccount/unprovision_svc',
   'signup_info'          => 'Signup/signup_info',
   'new_customer'         => 'Signup/new_customer',
   'unprovision_svc'      => 'MyAccount/unprovision_svc',
   'signup_info'          => 'Signup/signup_info',
   'new_customer'         => 'Signup/new_customer',
index b887098..92c76f3 100644 (file)
@@ -14,7 +14,8 @@ use FS::SelfService qw( agent_login agent_logout agent_info
                         agent_list_customers
                         signup_info new_customer
                         customer_info list_pkgs order_pkg
                         agent_list_customers
                         signup_info new_customer
                         customer_info list_pkgs order_pkg
-                        part_svc_info provision_acct unprovision_svc
+                        part_svc_info provision_acct provision_external
+                        unprovision_svc
                       );
 
 $DEBUG = 0;
                       );
 
 $DEBUG = 0;
@@ -67,7 +68,7 @@ $session_id = $cgi->param('session');
 
 warn "$me checking action\n" if $DEBUG;
 $cgi->param('action') =~
 
 warn "$me checking action\n" if $DEBUG;
 $cgi->param('action') =~
-   /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|delete_svc|agent_order_pkg|process_order_pkg|logout)$/
+   /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|agent_order_pkg|process_order_pkg|logout)$/
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
@@ -321,6 +322,26 @@ sub process_svc_acct {
 
 }
 
 
 }
 
+sub process_svc_external {
+
+  my $result = provision_external (
+    'agent_session_id' => $session_id,
+    map { $_ => $cgi->param($_) } qw( custnum pkgnum svcpart )
+  );
+
+  #warn "$result $result->{'error'}"; 
+  $action = 'agent_provision';
+  return {
+    %{agent_provision()},
+    'message' => $result->{'error'}
+                   ? '<FONT COLOR="#FF0000">'. $result->{'error'}. '</FONT>'
+                   : $result->{'svc'}. ' setup sucessfully'.
+                     ': serial number '.
+                     sprintf('%010d', $result->{'id'}). '-'. $result->{'title'}
+  };
+
+}
+
 sub delete_svc {
   my $result = unprovision_svc(
     'agent_session_id' => $session_id,
 sub delete_svc {
   my $result = unprovision_svc(
     'agent_session_id' => $session_id,
diff --git a/fs_selfservice/FS-SelfService/cgi/process_svc_external.html b/fs_selfservice/FS-SelfService/cgi/process_svc_external.html
new file mode 100644 (file)
index 0000000..772cf08
--- /dev/null
@@ -0,0 +1,16 @@
+<HTML><HEAD><TITLE><%= $error ? 'MyAccount' : sprintf("Your serial number is %010d-$title", $id) %></TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<TABLE BORDER=0 CELLPADDING=4><TR>
+<%= include('myaccount_menu') %>
+<TD VALIGN="top">
+
+<FONT SIZE=4><%= $svc %> setup sucessfully.</FONT>
+
+<BR><BR>Your serial number is <%= sprintf("%010d-$title", $id) %>
+
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
index 7e70593..0c8e050 100644 (file)
@@ -58,9 +58,22 @@ function areyousure(href, message) {
 
     my $td = qq!<TD BGCOLOR="#$col"!;
 
 
     my $td = qq!<TD BGCOLOR="#$col"!;
 
+    my $link;
+
+    if ( $part_svc->{'svcdb'} eq 'svc_external'
+         #&& $conf->exists('svc_external-skip_manual')
+    ) {
+      $link = "${url}process_svc_external;".
+              "pkgnum=$pkg->{'pkgnum'};".
+              "svcpart=$part_svc->{'svcpart'}";
+    } else {
+      $link = "${url}provision_svc;".
+              "pkgnum=$pkg->{'pkgnum'};".
+              "svcpart=$part_svc->{'svcpart'}";
+    }
+
     $OUT .= "<TR>$td COLSPAN=3 ALIGN=center>".
     $OUT .= "<TR>$td COLSPAN=3 ALIGN=center>".
-            qq!<A HREF="${url}provision_svc;pkgnum=$pkg->{'pkgnum'};svcpart=$part_svc->{'svcpart'}">!.
-            'Setup '. $part_svc->{'svc'}. '</A> '.
+            qq!<A HREF="$link">!. 'Setup '. $part_svc->{'svc'}. '</A> '.
             '('. $part_svc->{'num_avail'}. ' available)'.
             '</TD></TR>';
     $col = $col eq $col1 ? $col2 : $col1;
             '('. $part_svc->{'num_avail'}. ' available)'.
             '</TD></TR>';
     $col = $col eq $col1 ? $col2 : $col1;
index 44dd8bb..0816758 100644 (file)
@@ -10,7 +10,8 @@ use HTML::Entities;
 use FS::SelfService qw( login customer_info invoice
                         payment_info process_payment 
                         list_pkgs
 use FS::SelfService qw( login customer_info invoice
                         payment_info process_payment 
                         list_pkgs
-                        part_svc_info provision_acct unprovision_svc
+                        part_svc_info provision_acct provision_external
+                        unprovision_svc
                       );
 
 $template_dir = '.';
                       );
 
 $template_dir = '.';
@@ -60,7 +61,7 @@ $session_id = $cgi->param('session');
 
 #order|pw_list XXX ???
 $cgi->param('action') =~
 
 #order|pw_list XXX ???
 $cgi->param('action') =~
-    /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|delete_svc)$/
+    /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc)$/
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
@@ -224,6 +225,13 @@ sub process_svc_acct {
 
 }
 
 
 }
 
+sub process_svc_external {
+  provision_external (
+    'session_id' => $session_id,
+    map { $_ => $cgi->param($_) } qw( pkgnum svcpart )
+  );
+}
+
 sub delete_svc {
   unprovision_svc(
     'session_id' => $session_id,
 sub delete_svc {
   unprovision_svc(
     'session_id' => $session_id,