summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-08-22 00:22:08 +0000
committerivan <ivan>2009-08-22 00:22:08 +0000
commitbeb9681db0ee4c0912c82849267a82dd434784b3 (patch)
treed1ed900e3b2319d5bfa8e16006c082c2f83b1faf
parenta22b55437cb9c2da2670c33b28dd521a1ef1a190 (diff)
order svc_phone services from self-service too, RT#5085
-rw-r--r--FS/FS/ClientAPI/MasonComponent.pm33
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm2
-rw-r--r--FS/FS/Conf.pm7
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/misc/part_svc-columns.cgi18
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/misc/svc_acct-domains.cgi18
-rw-r--r--fs_selfservice/FS-SelfService/cgi/order_pkg.html46
-rw-r--r--fs_selfservice/FS-SelfService/cgi/selfservice.cgi61
-rw-r--r--httemplate/edit/cust_main/first_pkg/select-part_pkg.html14
-rw-r--r--httemplate/edit/cust_main/first_pkg/svc_acct.html40
9 files changed, 180 insertions, 59 deletions
diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm
index d158ce842..88baf0764 100644
--- a/FS/FS/ClientAPI/MasonComponent.pm
+++ b/FS/FS/ClientAPI/MasonComponent.pm
@@ -6,8 +6,9 @@ use subs qw( _cache );
use FS::Mason qw( mason_interps );
use FS::Conf;
use FS::ClientAPI_SessionCache;
-use FS::Record qw(qsearchs);
+use FS::Record qw( qsearch qsearchs );
use FS::cust_main;
+use FS::part_pkg;
$DEBUG = 0;
$me = '[FS::ClientAPI::MasonComponent]';
@@ -19,13 +20,17 @@ my %allowed_comps = map { $_=>1 } qw(
/misc/phonenums.cgi
/misc/states.cgi
/misc/counties.cgi
+ /misc/svc_acct-domains.cgi
+ /misc/part_svc-columns.cgi
);
my %session_comps = map { $_=>1 } qw(
/elements/location.html
+ /edit/cust_main/first_pkg/select-part_pkg.html
);
my %session_callbacks = (
+
'/elements/location.html' => sub {
my( $custnum, $argsref ) = @_;
my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
@@ -35,6 +40,32 @@ my %session_callbacks = (
@$argsref = ( %args );
return ''; #no error
},
+
+ '/edit/cust_main/first_pkg/select-part_pkg.html' => sub {
+ my( $custnum, $argsref ) = @_;
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return "unknown custnum $custnum";
+
+ my $pkgpart = $cust_main->agent->pkgpart_hashref;
+
+ #false laziness w/ edit/cust_main/first_pkg.html
+ my @first_svc = ( 'svc_acct', 'svc_phone' );
+
+ my @part_pkg =
+ grep { $_->svcpart(\@first_svc)
+ && ( $pkgpart->{ $_->pkgpart }
+ || ( $_->agentnum && $_->agentnum == $cust_main->agentnum )
+ )
+ }
+ qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case?
+
+ my %args = @$argsref;
+ $args{part_pkg} = \@part_pkg;
+ @$argsref = ( %args );
+ return ''; #no error
+
+ },
+
);
my $outbuf;
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index b6934f8bd..e1d4c9225 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1110,7 +1110,7 @@ sub order_pkg {
my %fields = (
'svc_acct' => [ qw( username domsvc _password sec_phrase popnum ) ],
'svc_domain' => [ qw( domain ) ],
- 'svc_phone' => [ qw( phonenum pin sip_password ) ],
+ 'svc_phone' => [ qw( phonenum pin sip_password phone_name ) ],
'svc_external' => [ qw( id title ) ],
);
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 1ee0214c2..d8e111b35 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3079,6 +3079,13 @@ worry that config_items is freeside-specific and icky.
'type' => 'checkbox',
},
+ {
+ 'key' => 'svc_acct-disable_access_number',
+ 'section' => 'UI',
+ 'descritpion' => 'Disable access number selection.',
+ 'type' => 'checkbox',
+ },
+
{ key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
{ key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
{ key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/fs_selfservice/FS-SelfService/cgi/misc/part_svc-columns.cgi b/fs_selfservice/FS-SelfService/cgi/misc/part_svc-columns.cgi
new file mode 100755
index 000000000..4ee83ca96
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/misc/part_svc-columns.cgi
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -w
+
+use strict;
+use CGI;
+use FS::SelfService qw( mason_comp );
+
+my $cgi = new CGI;
+
+my $rv = mason_comp( 'comp' => '/misc/part_svc-columns.cgi',
+ 'query_string' => $cgi->query_string, #pass CGI params...
+ );
+
+#hmm.
+my $output = $rv->{'error'} || $rv->{'output'};
+
+print $cgi->header( '-expires' => 'now' ).
+ $output;
+
diff --git a/fs_selfservice/FS-SelfService/cgi/misc/svc_acct-domains.cgi b/fs_selfservice/FS-SelfService/cgi/misc/svc_acct-domains.cgi
new file mode 100755
index 000000000..c5413bac6
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/misc/svc_acct-domains.cgi
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -w
+
+use strict;
+use CGI;
+use FS::SelfService qw( mason_comp );
+
+my $cgi = new CGI;
+
+my $rv = mason_comp( 'comp' => '/misc/svc_acct-domains.cgi',
+ 'query_string' => $cgi->query_string, #pass CGI params...
+ );
+
+#hmm.
+my $output = $rv->{'error'} || $rv->{'output'};
+
+print $cgi->header( '-expires' => 'now' ).
+ $output;
+
diff --git a/fs_selfservice/FS-SelfService/cgi/order_pkg.html b/fs_selfservice/FS-SelfService/cgi/order_pkg.html
index 9cdd4cd6c..4abfd8440 100644
--- a/fs_selfservice/FS-SelfService/cgi/order_pkg.html
+++ b/fs_selfservice/FS-SelfService/cgi/order_pkg.html
@@ -1,6 +1,6 @@
<SCRIPT TYPE="text/javascript">
function enable_order_pkg () {
- if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
+ if ( document.OrderPkgForm.pkgpart_svcpart.selectedIndex > 0 ) {
document.OrderPkgForm.submit.disabled = false;
} else {
document.OrderPkgForm.submit.disabled = true;
@@ -16,46 +16,16 @@ function enable_order_pkg () {
<INPUT TYPE="hidden" NAME="action" VALUE="process_order_pkg">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
-<TR>
- <TD COLSPAN=2><SELECT NAME="pkgpart" onChange="enable_order_pkg()">
- <OPTION VALUE="">
-
- <%=
- foreach my $part_pkg ( @part_pkg ) {
- $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
- $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
- $OUT .= '>'. $part_pkg->{'pkg'};
- }
- %>
- </SELECT></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Username</TD>
- <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Password</TD>
- <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $_password %>"></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Re-enter Password</TD>
- <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $_password2 %>"></TD>
-</TR>
-<%=
- if ( $security_phrase ) {
- $OUT .= <<ENDOUT;
<TR>
- <TD ALIGN="right">Security Phrase</TD>
- <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
+ <TD COLSPAN=2>
+ <TABLE><TR><TD> <%= $pkg_selector %>
+
</TD>
</TR>
-ENDOUT
- } else {
- $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
- }
-%>
+
<%=
+ if ( 0 ) {
if ( @svc_acct_pop ) {
$OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
popselector( 'popnum' => $popnum,
@@ -68,8 +38,10 @@ ENDOUT
} else {
$OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
}
+ }
+ '';
%>
</TABLE>
-<INPUT NAME="submit" TYPE="submit" VALUE="Purchase" disabled>
+<INPUT NAME="submit" TYPE="submit" VALUE="Purchase" DISABLED>
</FORM>
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
index a5a7d1844..2ace027a4 100644
--- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
@@ -17,6 +17,7 @@ use FS::SelfService qw(
unprovision_svc change_pkg domainselector
list_svcs list_svc_usage list_cdr_usage list_support_usage
myaccount_passwd
+ mason_comp
);
$template_dir = '.';
@@ -199,11 +200,24 @@ sub customer_order_pkg {
my $customer_info = customer_info( 'session_id' => $session_id );
return $customer_info if ( $customer_info->{'error'} );
+ my $pkgselect = mason_comp(
+ 'session_id' => $session_id,
+ 'comp' => '/edit/cust_main/first_pkg/select-part_pkg.html',
+ 'args' => [ 'password_verify' => 1,
+ 'onchange' => 'enable_order_pkg()',
+ 'relurls' => 1,
+ 'empty_label' => 'Select package',
+ ],
+ );
+
+ $pkgselect = $pkgselect->{'error'} || $pkgselect->{'output'};
+
return {
( map { $_ => $init_data->{$_} }
qw( part_pkg security_phrase svc_acct_pop ),
),
%$customer_info,
+ 'pkg_selector' => $pkgselect,
};
}
@@ -229,23 +243,46 @@ sub process_order_pkg {
my $results = '';
- unless ( length($cgi->param('_password')) ) {
- my $init_data = signup_info( 'customer_session_id' => $session_id );
- $results = { 'error' => $init_data->{msgcat}{empty_password} };
- $results = { 'error' => $init_data->{error} } if($init_data->{error});
+ my @params = (qw( custnum pkgpart ));
+ my $svcdb = '';
+ if ( $cgi->param('pkgpart_svcpart') =~ /^(\d+)_(\d+)$/ ) {
+ $cgi->param('pkgpart', $1);
+ $cgi->param('svcpart', $2);
+ push @params, 'svcpart';
+ $svcdb = $cgi->param('svcdb');
+ push @params, 'domsvc' if $svcdb eq 'svc_acct';
+ } else {
+ $svcdb = 'svc_acct';
}
- if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
- my $init_data = signup_info( 'customer_session_id' => $session_id );
- $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} };
- $results = { 'error' => $init_data->{error} } if($init_data->{error});
- $cgi->param('_password', '');
- $cgi->param('_password2', '');
+
+ if ( $svcdb eq 'svc_acct' ) {
+
+ push @params, qw( username _password _password2 sec_phrase popnum );
+
+ unless ( length($cgi->param('_password')) ) {
+ my $init_data = signup_info( 'customer_session_id' => $session_id );
+ $results = { 'error' => $init_data->{msgcat}{empty_password} };
+ $results = { 'error' => $init_data->{error} } if($init_data->{error});
+ }
+ if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
+ my $init_data = signup_info( 'customer_session_id' => $session_id );
+ $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} };
+ $results = { 'error' => $init_data->{error} } if($init_data->{error});
+ $cgi->param('_password', '');
+ $cgi->param('_password2', '');
+ }
+
+ } elsif ( $svcdb eq 'svc_phone' ) {
+
+ push @params, qw( phonenum sip_password pin phone_name );
+
+ } else {
+ die "$svcdb not handled on process_order_pkg yet";
}
$results ||= order_pkg (
'session_id' => $session_id,
- map { $_ => $cgi->param($_) }
- qw( custnum pkgpart username _password _password2 sec_phrase popnum )
+ map { $_ => $cgi->param($_) } @params
);
diff --git a/httemplate/edit/cust_main/first_pkg/select-part_pkg.html b/httemplate/edit/cust_main/first_pkg/select-part_pkg.html
index d2d862bea..871e1cdee 100644
--- a/httemplate/edit/cust_main/first_pkg/select-part_pkg.html
+++ b/httemplate/edit/cust_main/first_pkg/select-part_pkg.html
@@ -1,15 +1,17 @@
<% include('/elements/xmlhttp.html',
- 'url' => $p.'misc/svc_acct-domains.cgi',
+ 'url' => $url_prefix.'misc/svc_acct-domains.cgi',
'subs' => [ $opt{'prefix'}. 'get_domains' ],
)
%>
<% include('/elements/xmlhttp.html',
- 'url' => $p.'misc/part_svc-columns.cgi',
+ 'url' => $url_prefix.'misc/part_svc-columns.cgi',
'subs' => [ $opt{'prefix'}. 'get_part_svc' ],
)
%>
+<INPUT TYPE="hidden" NAME="svcdb" VALUE="">
+
<SCRIPT TYPE="text/javascript">
function selopt(what,value,text,selected) {
@@ -27,10 +29,14 @@
function <% $opt{'prefix'} %>pkgpart_svcpart_changed_too(what,selected) {
+ <% $opt{'onchange'} %>;
+
pkgpart_svcpart = what.options[what.selectedIndex].value;
var svcdb = pkgpart_svcpart2svcdb[pkgpart_svcpart];
+ what.form.svcdb.value = svcdb;
+
if ( svcdb == 'svc_acct' ) {
// go get the new domains
@@ -124,6 +130,8 @@ foreach my $opt (qw( svc_part pkgparts saved_pkgpart saved_domsvc prefix)) {
}
$opt{saved_domsvc} = 0 unless $opt{saved_domsvc};
+my $url_prefix = $opt{'relurls'} ? '' : $p;
+
my @part_pkg = @{$opt{'part_pkg'}};
my @first_svc = ( 'svc_acct', 'svc_phone' );
@@ -140,7 +148,7 @@ foreach my $part_pkg ( @part_pkg ) {
}
my @options = ( '', map $pkgpart_svcpart{ $_->pkgpart }, @part_pkg );
-my %labels = ( '' => '(none)',
+my %labels = ( '' => ( $opt{'empty_label'} || '(none)' ),
map { $pkgpart_svcpart{ $_->pkgpart } => $_->pkg_comment }
@part_pkg
);
diff --git a/httemplate/edit/cust_main/first_pkg/svc_acct.html b/httemplate/edit/cust_main/first_pkg/svc_acct.html
index 91ee7a56c..150d4c043 100644
--- a/httemplate/edit/cust_main/first_pkg/svc_acct.html
+++ b/httemplate/edit/cust_main/first_pkg/svc_acct.html
@@ -29,14 +29,44 @@
VALUE = "<% $opt{'password'} %>"
SIZE = <% $pmax2 %>
MAXLENGTH = <% $passwordmax %>>
- (blank to generate)
+% unless ( $opt{'password_verify'} ) {
+ (blank to generate)
+% }
</TD>
</TR>
- <TR>
- <TD ALIGN="right">Access number</TD>
- <TD><% FS::svc_acct_pop::popselector($opt{'popnum'}) %></TD>
- </TR>
+% if ( $opt{'password_verify'} ) {
+ <TR>
+ <TD ALIGN="right">Re-enter Password</TD>
+ <TD>
+ <INPUT TYPE = "text"
+ NAME = "_password2"
+ VALUE = "<% $opt{'password2'} %>"
+ SIZE = <% $pmax2 %>
+ MAXLENGTH = <% $passwordmax %>>
+ </TD>
+ </TR>
+% }
+
+% if ( $conf->exists('security_phrase') ) {
+ <TR>
+ <TD ALIGN="right">Security Phrase</TD>
+ <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $opt{'sec_phrase'} %>">
+ </TD>
+ </TR>
+% } else {
+ <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">
+% }
+
+% if ( $conf->exists('svc_acct-disable_access_number') ) {
+ <INPUT TYPE="hidden" NAME="popnum" VALUE="">
+% } else {
+ <TR>
+ <TD ALIGN="right">Access number</TD>
+%# XXX should gain "area code" selection and labels on the dropdowns
+ <TD><% FS::svc_acct_pop::popselector($opt{'popnum'}) %></TD>
+ </TR>
+% }
</TABLE>