package FS::SelfService;
use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $DEBUG $dir $socket %autoload $tag);
+use vars qw( $VERSION @ISA @EXPORT_OK $DEBUG
+ $skip_uid_check $dir $socket %autoload $tag );
use Exporter;
use Socket;
use FileHandle;
'agent_logout' => 'Agent/agent_logout',
'agent_info' => 'Agent/agent_info',
'agent_list_customers' => 'Agent/agent_list_customers',
+ 'mason_comp' => 'MasonComponent/mason_comp',
+ 'call_time' => 'PrepaidPhone/call_time',
+ 'call_time_nanpa' => 'PrepaidPhone/call_time_nanpa',
+ 'phonenum_balance' => 'PrepaidPhone/phonenum_balance',
);
-@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector) );
+@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector didselector) );
$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
$ENV{'SHELL'} = '/bin/sh';
$ENV{'ENV'} = '';
$ENV{'BASH_ENV'} = '';
+#you can add BEGIN { $FS::SelfService::skip_uid_check = 1; }
+#if you grant appropriate permissions to whatever user
my $freeside_uid = scalar(getpwnam('freeside'));
-die "not running as the freeside user\n" if $> != $freeside_uid;
+die "not running as the freeside user\n"
+ if $> != $freeside_uid && ! $skip_uid_check;
-e $dir or die "FATAL: $dir doesn't exist!";
-d $dir or die "FATAL: $dir isn't a directory!";
'payname' => $payname,
'invoicing_list' => $invoicing_list,
'referral_custnum' => $referral_custnum,
+ 'agentnum' => $agentnum,
'pkgpart' => $pkgpart,
+
'username' => $username,
'_password' => $password,
'popnum' => $popnum,
- 'agentnum' => $agentnum,
+ #OR
+ 'countrycode' => 1,
+ 'phonenum' => $phonenum,
+ 'pin' => $pin,
}
);
=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>
=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
=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
=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
=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
=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.
referring customer number
+=item agentnum
+
+Agent number
+
=item pkgpart
pkgpart of initial package
Access number (index, not the literal number)
-=item agentnum
+=item countrycode
-Agent number
+Country code (to be provisioned as a service)
+
+=item phonenum
+
+Phone number (to be provisioned as a service)
+
+=item pin
+
+Voicemail PIN
=back
return '<INPUT TYPE="hidden" NAME="domsvc" VALUE="">'
unless scalar(keys %$domains);
-
+
if (scalar(keys %$domains) == 1) {
my $key;
foreach(keys %$domains) {
}
+=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