signup w/globalpops DID selection via mason components pass-through
[freeside.git] / fs_selfservice / FS-SelfService / SelfService.pm
index 061bdac..6867fd8 100644 (file)
@@ -21,42 +21,45 @@ $socket .= '.'.$tag if defined $tag && length($tag);
 
 #maybe should ask ClientAPI for this list
 %autoload = (
-  'passwd'               => 'passwd/passwd',
-  'chfn'                 => 'passwd/passwd',
-  'chsh'                 => 'passwd/passwd',
-  'login'                => 'MyAccount/login',
-  'logout'               => 'MyAccount/logout',
-  'customer_info'        => 'MyAccount/customer_info',
-  'edit_info'            => 'MyAccount/edit_info',     #add to ss cgi!
-  'invoice'              => 'MyAccount/invoice',
-  'invoice_logo'         => 'MyAccount/invoice_logo',
-  'list_invoices'        => 'MyAccount/list_invoices', #?
-  'cancel'               => 'MyAccount/cancel',        #add to ss cgi!
-  'payment_info'         => 'MyAccount/payment_info',
-  'process_payment'      => 'MyAccount/process_payment',
-  'process_prepay'       => 'MyAccount/process_prepay',
-  'list_pkgs'            => 'MyAccount/list_pkgs',     #add to ss cgi (added?)
-  'list_svcs'            => 'MyAccount/list_svcs',     #add to ss cgi (added?)
-  'list_svc_usage'       => 'MyAccount/list_svc_usage',   
-  'list_support_usage'   => 'MyAccount/list_support_usage',   
-  'order_pkg'            => 'MyAccount/order_pkg',     #add to ss cgi!
-  'change_pkg'           => 'MyAccount/change_pkg', 
-  'order_recharge'       => 'MyAccount/order_recharge',
-  'cancel_pkg'           => 'MyAccount/cancel_pkg',    #add to ss cgi!
-  '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',
-  'myaccount_passwd'     => 'MyAccount/myaccount_passwd',
-  'signup_info'          => 'Signup/signup_info',
-  'new_customer'         => 'Signup/new_customer',
-  'agent_login'          => 'Agent/agent_login',
-  'agent_logout'         => 'Agent/agent_logout',
-  'agent_info'           => 'Agent/agent_info',
-  'agent_list_customers' => 'Agent/agent_list_customers',
+  'passwd'                    => 'passwd/passwd',
+  'chfn'                      => 'passwd/passwd',
+  'chsh'                      => 'passwd/passwd',
+  'login'                     => 'MyAccount/login',
+  'logout'                    => 'MyAccount/logout',
+  'customer_info'             => 'MyAccount/customer_info',
+  'edit_info'                 => 'MyAccount/edit_info',     #add to ss cgi!
+  'invoice'                   => 'MyAccount/invoice',
+  'invoice_logo'              => 'MyAccount/invoice_logo',
+  'list_invoices'             => 'MyAccount/list_invoices', #?
+  'cancel'                    => 'MyAccount/cancel',        #add to ss cgi!
+  'payment_info'              => 'MyAccount/payment_info',
+  'process_payment'           => 'MyAccount/process_payment',
+  'process_payment_order_pkg' => 'MyAccount/process_payment_order_pkg',
+  'process_prepay'            => 'MyAccount/process_prepay',
+  'list_pkgs'                 => 'MyAccount/list_pkgs',     #add to ss (added?)
+  'list_svcs'                 => 'MyAccount/list_svcs',     #add to ss (added?)
+  'list_svc_usage'            => 'MyAccount/list_svc_usage',   
+  'list_support_usage'        => 'MyAccount/list_support_usage',   
+  'order_pkg'                 => 'MyAccount/order_pkg',     #add to ss cgi!
+  'change_pkg'                => 'MyAccount/change_pkg', 
+  'order_recharge'            => 'MyAccount/order_recharge',
+  'cancel_pkg'                => 'MyAccount/cancel_pkg',    #add to ss cgi!
+  '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',
+  'myaccount_passwd'          => 'MyAccount/myaccount_passwd',
+  'signup_info'               => 'Signup/signup_info',
+  'domain_select_hash'        => 'Signup/domain_select_hash',  # expose?
+  'new_customer'              => 'Signup/new_customer',
+  'agent_login'               => 'Agent/agent_login',
+  'agent_logout'              => 'Agent/agent_logout',
+  'agent_info'                => 'Agent/agent_info',
+  'agent_list_customers'      => 'Agent/agent_list_customers',
+  'mason_comp'                => 'MasonComponent/mason_comp',
 );
-@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector ) );
+@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector didselector) );
 
 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
 $ENV{'SHELL'} = '/bin/sh';
@@ -467,6 +470,10 @@ hash reference as parameter with the following keys:
 
 Session identifier
 
+=item amount
+
+Amount
+
 =item save
 
 If true, address and card information entered will be saved for subsequent
@@ -526,7 +533,8 @@ error message on errors
 
 =item list_pkgs
 
-Returns package information for this customer.
+Returns package information for this customer.  For more detail on services,
+see L</list_svcs>.
 
 Takes a hash reference as parameter with a single key: B<session_id>
 
@@ -534,6 +542,10 @@ Returns a hash reference containing customer package information.  The hash refe
 
 =over 4
 
+=item custnum
+
+Customer number
+
 =item cust_pkg HASHREF
 
 Array reference of hash references, each of which has the fields of a cust_pkg
@@ -544,8 +556,9 @@ the internal FS:: objects, but hash references of columns and values.
 
 =item part_pkg fields
 
-All fields of part_pkg (be careful with this information - it may reveal more
-about your available packages than you would like users to know in aggregate) 
+All fields of part_pkg for this specific cust_pkg (be careful with this
+information - it may reveal more about your available packages than you would
+like users to know in aggregate) 
 
 =cut
 
@@ -553,7 +566,9 @@ about your available packages than you would like users to know in aggregate)
 
 =item part_svc
 
-An array of hash references, each of which has the following keys:
+An array of hash references indicating information on unprovisioned services
+available for provisioning for this specific cust_pkg.  Each has the following
+keys:
 
 =over 4
 
@@ -568,6 +583,45 @@ about your available packages than you would like users to know in aggregate)
 
 =back
 
+=item cust_svc
+
+An array of hash references indicating information on the customer services
+already provisioned for this specific cust_pkg.  Each has the following keys:
+
+=over 4
+
+=item label
+
+Array reference with three elements:
+
+=over 4
+
+=item Name of this service
+
+=item Meaningful user-specific identifier for the service (i.e. username, domain or mail alias)
+
+=item Table name of this service
+
+=back
+
+=item svcnum
+
+Primary key for this service
+
+=item svcpart
+
+Service definition (part_pkg)
+
+=item pkgnum
+
+Customer package (cust_pkg)
+
+=item overlimit
+
+Blank if the service is not over limit, or the date the service exceeded its usage limit (as a UNIX timestamp).
+
+=back
+
 =back
 
 =item error
@@ -576,6 +630,92 @@ Empty on success, or an error message on errors.
 
 =back
 
+=item list_svcs
+
+Returns service information for this customer.
+
+Takes a hash reference as parameter with a single key: B<session_id>
+
+Returns a hash reference containing customer package information.  The hash reference contains the following keys:
+
+=over 4
+
+=item custnum
+
+Customer number
+
+=item svcs
+
+An array of hash references indicating information on all of this customer's
+services.  Each has the following keys:
+
+=over 4
+
+=item svcnum
+
+Primary key for this service
+
+=item label
+
+Name of this service
+
+=item value
+
+Meaningful user-specific identifier for the service (i.e. username, domain, or
+mail alias).
+
+=back
+
+Account (svc_acct) services also have the following keys:
+
+=item username
+
+Username
+
+=item email
+
+username@domain
+
+=item seconds
+
+Seconds remaining
+
+=item upbytes
+
+Upload bytes remaining
+
+=item downbytes
+
+Download bytes remaining
+
+=item totalbytes
+
+Total bytes remaining
+
+=item recharge_amount
+
+Cost of a recharge
+
+=item recharge_seconds
+
+Number of seconds gained by recharge
+
+=item recharge_upbytes
+
+Number of upload bytes gained by recharge
+
+=item recharge_downbytes
+
+Number of download bytes gained by recharge
+
+=item recharge_totalbytes
+
+Number of total bytes gained by recharge
+
+=back
+
+=back
+
 =item order_pkg
 
 Orders a package for this customer.
@@ -1238,6 +1378,99 @@ END
 
 }
 
+=item domainselector HASHREF | LIST
+
+Takes as input a hashref or list of key/value pairs with the following keys:
+
+=over 4
+
+=item pkgnum
+
+Package number
+
+=item domsvc
+
+Service number of the selected item.
+
+=back
+
+Returns an HTML fragment for domain selection.
+
+=cut
+
+sub domainselector {
+  my $param;
+  if ( ref($_[0]) ) {
+    $param = shift;
+  } else {
+    $param = { @_ };
+  }
+  my $domsvc= $param->{'domsvc'};
+  my $rv = 
+      domain_select_hash(map {$_ => $param->{$_}} qw(pkgnum svcpart pkgpart) );
+  my $domains = $rv->{'domains'};
+  $domsvc = $rv->{'domsvc'} unless $domsvc;
+
+  return '<INPUT TYPE="hidden" NAME="domsvc" VALUE="">'
+    unless scalar(keys %$domains);
+
+  if (scalar(keys %$domains) == 1) {
+    my $key;
+    foreach(keys %$domains) {
+      $key = $_;
+    }
+    return '<TR><TD ALIGN="right">Domain</TD><TD>'. $domains->{$key}.
+           '<INPUT TYPE="hidden" NAME="domsvc" VALUE="'. $key. '"></TD></TR>'
+  }
+
+  my $text .= qq!<TR><TD ALIGN="right">Domain</TD><TD><SELECT NAME="domsvc" SIZE=1 STYLE="width: 20em"><OPTION>(Choose Domain)!;
+
+
+  foreach my $domain ( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains ) {
+    $text .= qq!<OPTION VALUE="!. $domain. '"'.
+             ( ( $domsvc && $domain == $domsvc ) ? ' SELECTED' : '' ). ">".
+             $domains->{$domain};
+  }
+
+  $text .= qq!</SELECT></TD></TR>!;
+
+  $text;
+
+}
+
+=item didselector HASHREF | LIST
+
+Takes as input a hashref or list of key/value pairs with the following keys:
+
+=over 4
+
+=item field
+
+=item svcpart
+
+=back
+
+Returns an HTML fragment for DID selection.
+
+=cut
+
+sub didselector {
+  my $param;
+  if ( ref($_[0]) ) {
+    $param = shift;
+  } else {
+    $param = { @_ };
+  }
+
+  my $rv = mason_comp( 'comp'=>'/elements/select-did.html',
+                       'args'=>[ %$param ],
+                     );
+
+  #hmm.
+  $rv->{'error'} || $rv->{'output'};
+
+}
+
 =back
 
 =head1 RESELLER FUNCTIONS