X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMasonComponent.pm;h=d615c271c52a2906b8e141bf54ee11e6c3fa2bab;hp=d158ce842fcba215332a4fb202427d38a328c4f5;hb=01c9143a54bf5e1513537547fd362822f58d1e2a;hpb=d6b6f81e383f9d876e67e9704914e887a331012e diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm index d158ce842..d615c271c 100644 --- a/FS/FS/ClientAPI/MasonComponent.pm +++ b/FS/FS/ClientAPI/MasonComponent.pm @@ -6,35 +6,131 @@ 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]'; my %allowed_comps = map { $_=>1 } qw( + /elements/customer-statement.html /elements/select-did.html /misc/areacodes.cgi /misc/exchanges.cgi /misc/phonenums.cgi /misc/states.cgi /misc/counties.cgi + /misc/cities.cgi + /misc/svc_acct-domains.cgi + /misc/part_svc-columns.cgi + /edit/elements/svc_forward.html ); my %session_comps = map { $_=>1 } qw( /elements/location.html + /elements/tr-amount_fee.html + /elements/select-part_pkg.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 } ) or return "unknown custnum $custnum"; my %args = @$argsref; - $args{object} = $cust_main; + $args{object} = $cust_main->bill_location; + @$argsref = ( %args ); + return ''; #no error + }, + + '/elements/tr-amount_fee.html' => sub { + my( $custnum, $argsref ) = @_; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return "unknown custnum $custnum"; + + my $conf = new FS::Conf; + + my %args = @$argsref; + %args = ( + %args, + 'process-pkgpart' => + scalar($conf->config('selfservice_process-pkgpart', $cust_main->agentnum)), + 'process-display' => scalar($conf->config('selfservice_process-display')), + 'process-skip_first' => $conf->exists('selfservice_process-skip_first'), + 'num_payments' => scalar($cust_main->cust_pay), + 'surcharge_percentage' => scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum)), + 'surcharge_flatfee' => scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum)), + ); @$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 $conf = new FS::Conf; + if ( $conf->exists('pkg-addon_classnum') ) { + + my %classnum = map { ( $_->addon_classnum => 1 ) } + grep { $_->freq !~ /^0/ } + map { $_->part_pkg } + $cust_main->ncancelled_pkgs; + + unless ( $classnum{''} || ! keys %classnum ) { + @part_pkg = grep $classnum{ $_->classnum }, @part_pkg; + } + } + + my %args = @$argsref; + $args{part_pkg} = \@part_pkg; + $args{first_svc} = \@first_svc; + $args{no_comment} = 1; + $args{label_callback} = sub { shift->pkg_comment }; + @$argsref = ( %args ); + return ''; #no error + + }, + + '/elements/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 { $pkgpart->{ $_->pkgpart } + || ( $_->agentnum && $_->agentnum == $cust_main->agentnum ) + } + qsearch( 'part_pkg', { 'disabled' => '' }, '', 'ORDER BY pkg' ); # case? + + push @$argsref, 'part_pkg' => \@part_pkg; + ''; + }, + ); my $outbuf; @@ -65,6 +161,7 @@ sub mason_comp { my $conf = new FS::Conf; $FS::Mason::Request::FSURL = $conf->config('selfservice_server-base_url'); + $FS::Mason::Request::FSURL .= '/' unless $FS::Mason::Request::FSURL =~ /\/$/; $FS::Mason::Request::QUERY_STRING = $packet->{'query_string'} || ''; $outbuf = '';