From: ivan Date: Wed, 25 Feb 2004 10:37:22 +0000 (+0000) Subject: fix up forward editing for new svc_forward.src field X-Git-Tag: NET_WHOIS_RAW_0_31~125 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=395e0a932b6728326f8f5242f7f0a82e2dac919d fix up forward editing for new svc_forward.src field --- diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index b74cfd685..0d8a12114 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -281,10 +281,15 @@ sub label { if ( $svcdb eq 'svc_acct' ) { $tag = $svc_x->email; } elsif ( $svcdb eq 'svc_forward' ) { - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_x->srcsvc } ); - $tag = $svc_acct->email. '->'; + if ( $svc_x->srcsvc ) { + my $svc_acct = $svc_x->srcsvc_acct; + $tag = $svc_acct->email; + } else { + $tag = $svc_x->src; + } + $tag .= '->'; if ( $svc_x->dstsvc ) { - $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_x->dstsvc } ); + my $svc_acct = $svc_x->dstsvc_acct; $tag .= $svc_acct->email; } else { $tag .= $svc_x->dst; diff --git a/httemplate/edit/svc_forward.cgi b/httemplate/edit/svc_forward.cgi index 0d815b9e5..c323fa29e 100755 --- a/httemplate/edit/svc_forward.cgi +++ b/httemplate/edit/svc_forward.cgi @@ -58,20 +58,17 @@ if ( $cgi->param('error') ) { my $action = $svc_forward->svcnum ? 'Edit' : 'Add'; my %email; + +#starting with those currently attached +foreach my $method (qw( srcsvc_acct dstsvc_acct )) { + my $svc_acct = $svc_forward->$method(); + $email{$svc_acct->svcnum} = $svc_acct->email if $svc_acct; +} + if ($pkgnum) { #find all possible user svcnums (and emails) - #starting with those currently attached - if ( $svc_forward->srcsvc ) { - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_forward->srcsvc } ); - $email{$svc_forward->srcsvc} = $svc_acct->email; - } - if ( $svc_forward->dstsvc ) { - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_forward->dstsvc } ); - $email{$svc_forward->dstsvc} = $svc_acct->email; - } - #and including the rest for this customer my($u_part_svc,@u_acct_svcparts); foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { @@ -98,15 +95,7 @@ if ($pkgnum) { } } -} elsif ( $action eq 'Edit' ) { - - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_forward->srcsvc}); - $email{$svc_forward->srcsvc} = $svc_acct->email; - - $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svc_forward->dstsvc}); - $email{$svc_forward->dstsvc} = $svc_acct->email; - -} else { +} elsif ( $action eq 'Add' ) { die "\$action eq Add, but \$pkgnum is null!\n"; } @@ -115,6 +104,7 @@ my($srcsvc,$dstsvc,$dst)=( $svc_forward->dstsvc, $svc_forward->dst, ); +my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : ''; #display @@ -130,46 +120,54 @@ my($srcsvc,$dstsvc,$dst)=( Service #<%= $svcnum ? "$svcnum" : " (NEW)" %>
Service: <%= $part_svc->svc %>

-
+ + + + + + <%= ntable("#cccccc",2) %> -Email to <% foreach $_ (keys %email) { %> VALUE="<%= $_ %>"><%= $email{$_} %> <% } %> - - -<% - tie my %tied_email, 'Tie::IxHash', - '' => 'SELECT DESTINATION', - %email, - '0' => '(other email address)'; - my $widget = new HTML::Widgets::SelectLayers( - 'selected_layer' => $dstsvc, - 'options' => \%tied_email, - 'form_name' => 'dummy', - 'form_action' => 'process/svc_forward.cgi', - 'form_select' => ['srcsvc'], - 'html_between' => '', - 'layer_callback' => sub { - my $layer = shift; - my $html = qq!!. - qq!!. - qq!!. - qq!!; - if ( $layer eq '0' ) { - $html .= ntable("#cccccc",2). - 'Destination email'. - qq!!. - ''; - } - $html .= '
'; - $html; - }, - ); -%> +<% if ( $svc_forward->dbdef_table->column('src') ) { %> + +<% } %> + +<% if ( $svc_forward->dbdef_table->column('src') ) { %> +> +<% } %> + Forwards to -<%= $widget->html %> + +> + + +
+