diff options
author | ivan <ivan> | 2010-03-12 03:36:36 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-03-12 03:36:36 +0000 |
commit | 9e570867c27b5336f4fa701c84b70fd65791f87c (patch) | |
tree | d1d495861d3dcd54457604e09eecacc813fcbcf1 /httemplate | |
parent | 1cc9a75a47a548fc8a200371c88647f34c71db14 (diff) |
add location to svc_phone, RT#7047
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/edit/elements/edit.html | 8 | ||||
-rw-r--r-- | httemplate/edit/elements/svc_Common.html | 19 | ||||
-rw-r--r-- | httemplate/edit/svc_phone.cgi | 28 | ||||
-rw-r--r-- | httemplate/elements/location.html | 16 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cust_location.html | 5 | ||||
-rw-r--r-- | httemplate/view/svc_phone.cgi | 23 |
6 files changed, 84 insertions, 15 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 88a1fe58d..0c7c02dab 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -40,7 +40,7 @@ Example: 'disabled' => 0, 'onchange' => 'javascript_function', - 'include_opt_callback' => sub { #my $ = @_; + 'include_opt_callback' => sub { my $object = @_; ( 'option' => 'value', ); }, @@ -300,11 +300,15 @@ Example: % % if ( $type eq 'tablebreak-tr-title' ) { % $include_common{'table_id'} = 'TableNumber'. $tablenum++; +% } +% if ( $type eq 'tablebreak-tr-title' || $type eq 'title' ) { % $include_common{'colspan'} = $f->{colspan} if $f->{colspan}; % } % % if ( $f->{include_opt_callback} ) { -% %include_common = ( %include_common, &{ $f->{include_opt_callback} } ); +% %include_common = ( %include_common, +% &{ $f->{include_opt_callback} }( $object ) +% ); % } % % my $layer_prefix_on = ''; diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index 2e98a1b25..1cb1659f4 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -34,12 +34,14 @@ 'new_hashref_callback' => sub { #my( $cgi, $svc_x ) = @_; - { svcpart => $svcpart }; + { pkgnum => $pkgnum, + svcpart => $svcpart, + }; }, 'new_callback' => sub { - my( $cgi, $svc_x, $fields, $opt ) = @_;; + my( $cgi, $svc_x, $fields, $opt ) = @_; $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart }); die "No part_svc entry!" unless $part_svc; @@ -48,6 +50,13 @@ #$svcnum=''; + if ( my $cb = $opt{'svc_new_callback'} ) { + my $cust_pkg = $pkgnum + ? qsearchs('cust_pkg', {pkgnum=>$pkgnum}) + : ''; #? + &{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt); + } + $svc_x->set_default_and_fixed; }, @@ -141,11 +150,13 @@ sub label_fixup { my( $part_svc, $opt ) = @_; + $opt->{'name'} ||= $part_svc->svc; + my $svcdb = $part_svc->svcdb; require "FS/$svcdb.pm"; if ( UNIVERSAL::can("FS::$svcdb", 'table_info') ) { - $opt->{'name'} ||= "FS::$svcdb"->table_info->{'name'}; + #$opt->{'name'} ||= "FS::$svcdb"->table_info->{'name'}; my $fields = "FS::$svcdb"->table_info->{'fields'}; $opt->{'fields'} ||= [ grep { $_ ne 'svcnum' } keys %$fields ]; @@ -165,7 +176,7 @@ sub label_fixup { my $labels = $opt->{labels}; # with -> here foreach my $field ( keys %{ $opt->{labels} } ) { my $col = $part_svc->part_svc_column($field); - $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\S*$/; + $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\s*$/; } } diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index 3c7b75249..779708b4e 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -1,8 +1,8 @@ <% include( 'elements/svc_Common.html', - 'name' => 'Phone number', 'table' => 'svc_phone', 'fields' => \@fields, 'labels' => { + 'svcnum' => 'Service', 'countrycode' => 'Country code', 'phonenum' => 'Phone number', 'domsvc' => 'Domain', @@ -10,7 +10,12 @@ 'pin' => 'Voicemail PIN', 'phone_name' => 'Name', 'pbxsvc' => 'PBX', + 'locationnum' => 'E911 location', }, + 'svc_new_callback' => sub { + my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_; + $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg; + }, ) %> <%init> @@ -40,6 +45,27 @@ push @fields, { field => 'pbxsvc', 'sip_password', 'pin', 'phone_name', + + { value => 'E911 Information', + type => 'tablebreak-tr-title', + colspan => 7, + }, + { field => 'locationnum', + type => 'select-cust_location', + label => 'E911 location', + include_opt_callback => sub { + my $svc_phone = shift; + my $pkgnum = $svc_phone->get('pkgnum') + || $cgi->param('pkgnum') + || $svc_phone->cust_svc->pkgnum; #hua? + #cross agent location exposure? sheesh + my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum}); + my $cust_main = $cust_pkg ? $cust_pkg->cust_main : ''; + ( 'no_bold' => 1, + 'cust_main' => $cust_main, + ); + }, + }, ; </%init> diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html index 5478e1e1e..0d2fa38c3 100644 --- a/httemplate/elements/location.html +++ b/httemplate/elements/location.html @@ -18,7 +18,7 @@ Example: </%doc> <TR> - <TH ALIGN="right"><%$r%><% $opt{'address1_label'} || 'Address' %></TH> + <<%$th%> ALIGN="right"><%$r%><% $opt{'address1_label'} || 'Address' %></<%$th%>> <TD COLSPAN=7> <INPUT TYPE = "text" NAME = "<%$pre%>address1" @@ -48,15 +48,15 @@ Example: </TR> <TR> - <TH ALIGN="right"><%$r%>City</TH> + <<%$th%> ALIGN="right"><%$r%>City</<%$th%>> <TD WIDTH="1"><% include('/elements/city.html', %select_hash) %></TD> - <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH> + <<%$th%> ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</<%$th%>> <TD><% include('/elements/select-county.html', %select_hash ) %></TD> - <TH ALIGN="right" WIDTH="1"><%$r%>State</TH> + <<%$th%> ALIGN="right" WIDTH="1"><%$r%>State</<%$th%>> <TD WIDTH="1"> <% include('/elements/select-state.html', %select_hash ) %> </TD> - <TH><%$r%>Zip</TH> + <<%$th%>><%$r%>Zip</<%$th%>> <TD> <INPUT TYPE = "text" NAME = "<%$pre%>zip" @@ -71,7 +71,7 @@ Example: </TR> <TR> - <TH ALIGN="right"><%$r%>Country</TH> + <<%$th%> ALIGN="right"><%$r%>Country</<%$th%>> <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD> </TR> @@ -79,7 +79,7 @@ Example: <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>"> % } else { % if ( $pre eq 'ship_' && $conf->exists('cust_main-require_censustract') ) { - <TR><TH ALIGN="right">Census tract<BR>(automatic)</TH> + <TR><<%$th%> ALIGN="right">Census tract<BR>(automatic)</<%$th%>> <TD> <INPUT TYPE="text" NAME="censustract" VALUE="<% $opt{censustract} %>"> </TD> @@ -153,4 +153,6 @@ my %select_hash = ( 'style' => \@style, ); +my $th = $opt{'no_bold'} ? 'TD' : 'TH'; + </%init> diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html index 5e938b53a..f26649763 100644 --- a/httemplate/elements/tr-select-cust_location.html +++ b/httemplate/elements/tr-select-cust_location.html @@ -143,7 +143,7 @@ Example: </SCRIPT> <TR> - <TH ALIGN="right">Service location</TH> + <<%$th%> ALIGN="right"><% $opt{'label'} || 'Service location' %></<%$th%>> <TD COLSPAN=7> <SELECT NAME="locationnum" onChange="locationnum_changed(this);"> <OPTION VALUE=""><% $opt{'empty_label'} || '(default service address)' |h %> @@ -169,6 +169,7 @@ Example: #'onchange' ? probably not 'disabled' => $disabled, 'no_asterisks' => 1, + 'no_bold' => $opt{'no_bold'}, ) %> @@ -221,4 +222,6 @@ my $disabled = ( $locationnum == -1 || ($editable && $locationnum) ) ? '' : 'DISABLED'; +my $th = $opt{'no_bold'} ? 'TD' : 'TH'; + </%init> diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi index 76ee7397d..ebde42228 100644 --- a/httemplate/view/svc_phone.cgi +++ b/httemplate/view/svc_phone.cgi @@ -16,6 +16,7 @@ <%init> my $conf = new FS::Conf; +my $countrydefault = $conf->config('countrydefault') || 'US'; my @fields = qw( countrycode phonenum ); push @fields, 'domain' if $conf->exists('svc_phone-domain'); @@ -25,6 +26,27 @@ my $html_foot = sub { my $svc_phone = shift; ### + # E911 Info + ### + + my $loc = $svc_phone->cust_location_or_main; + + my $e911 = + 'E911 Information'. + &ntable("#cccccc"). '<TR><TD>'. ntable("#cccccc",2). + '<TR><TD>Location</TD>'. + '<TD BGCOLOR="#FFFFFF">'. + $loc->location_label( 'join_string' => '<BR>', + 'double_space' => ' ', + 'escape_function' => \&encode_entities, + 'countrydefault' => $countrydefault, + ). + '</TD></TR>'. + '</TABLE></TD></TR></TABLE>'. + '<BR>' + ; + + ### # Devices ### @@ -123,6 +145,7 @@ my $html_foot = sub { # concatenate & return ### + $e911. $devices. join(' | ', @links ). '<BR>'. join(' | ', @ilinks). '<BR>'; |