'phone_name', 'varchar', 'NULL', $char_d, '', '',
'pbxsvc', 'int', 'NULL', '', '', '',
'domsvc', 'int', 'NULL', '', '', '',
+ 'locationnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'svcnum',
'unique' => [],
- 'index' => [ [ 'countrycode', 'phonenum' ], ['pbxsvc'], ['domsvc'] ],
+ 'index' => [ ['countrycode', 'phonenum'], ['pbxsvc'], ['domsvc'],
+ ['locationnum'],
+ ],
},
'phone_device' => {
package FS::cust_pkg;
use strict;
+use base qw( FS::cust_main_Mixin FS::location_Mixin
+ FS::m2m_Common FS::option_Common FS::Record
+ );
use vars qw(@ISA $disable_agentcheck $DEBUG $me);
use Carp qw(cluck);
use Scalar::Util qw( blessed );
use FS::UID qw( getotaker dbh );
use FS::Misc qw( send_email );
use FS::Record qw( qsearch qsearchs );
-use FS::m2m_Common;
-use FS::cust_main_Mixin;
use FS::cust_svc;
use FS::part_pkg;
use FS::cust_main;
# for sending cancel emails in sub cancel
use FS::Conf;
-@ISA = qw( FS::m2m_Common FS::cust_main_Mixin FS::option_Common FS::Record );
-
$DEBUG = 0;
$me = '[FS::cust_pkg]';
qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
}
+#these subs are in location_Mixin.pm now... unfortunately the POD doesn't mixin
+
=item cust_location
Returns the location object, if any (see L<FS::cust_location>).
-=cut
-
-sub cust_location {
- my $self = shift;
- return '' unless $self->locationnum;
- qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } );
-}
-
=item cust_location_or_main
If this package is associated with a location, returns the locaiton (see
L<FS::cust_location>), otherwise returns the customer (see L<FS::cust_main>).
-=cut
-
-sub cust_location_or_main {
- my $self = shift;
- $self->cust_location || $self->cust_main;
-}
-
=item location_label [ OPTION => VALUE ... ]
Returns the label of the location object (see L<FS::cust_location>).
=cut
-sub location_label {
- my $self = shift;
- my $object = $self->cust_location_or_main;
- $object->location_label(@_);
-}
+#end of subs in location_Mixin.pm now... unfortunately the POD doesn't mixin
=item seconds_since TIMESTAMP
--- /dev/null
+package FS::location_Mixin;
+
+use strict;
+use FS::Record qw( qsearchs );
+use FS::cust_location;
+
+=item cust_location
+
+Returns the location object, if any (see L<FS::cust_location>).
+
+=cut
+
+sub cust_location {
+ my $self = shift;
+ return '' unless $self->locationnum;
+ qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } );
+}
+
+=item cust_location_or_main
+
+If this package is associated with a location, returns the locaiton (see
+L<FS::cust_location>), otherwise returns the customer (see L<FS::cust_main>).
+
+=cut
+
+sub cust_location_or_main {
+ my $self = shift;
+ $self->cust_location || $self->cust_main;
+}
+
+=item location_label [ OPTION => VALUE ... ]
+
+Returns the label of the location object (see L<FS::cust_location>).
+
+=cut
+
+sub location_label {
+ my $self = shift;
+ my $object = $self->cust_location_or_main;
+ $object->location_label(@_);
+}
+
+1;
package FS::svc_phone;
use strict;
-use base qw( FS::svc_Domain_Mixin FS::svc_Common );
+use base qw( FS::svc_Domain_Mixin FS::location_Mixin FS::svc_Common );
use vars qw( @pw_set $conf );
use FS::Conf;
use FS::Record qw( qsearch qsearchs dbh );
use FS::phone_device;
use FS::svc_pbx;
use FS::svc_domain;
+use FS::cust_location;
#avoid l 1 and o O 0
@pw_set = ( 'a'..'k', 'm','n', 'p-z', 'A'..'N', 'P'..'Z' , '2'..'9' );
select_label => 'domain',
disable_inventory => 1,
},
+ 'locationnum' => {
+ label => 'E911 location',
+ disable_inventory => 1,
+ disable_select => 1,
+ },
},
};
}
|| $self->ut_textn('phone_name')
|| $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' )
|| $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' )
+ || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
;
return $error if $error;
--- /dev/null
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::location_Mixin;
+$loaded=1;
+print "ok 1\n";
'disabled' => 0,
'onchange' => 'javascript_function',
- 'include_opt_callback' => sub { #my $ = @_;
+ 'include_opt_callback' => sub { my $object = @_;
( 'option' => 'value', );
},
%
% 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 = '';
'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;
#$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;
},
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 ];
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*$/;
}
}
<% include( 'elements/svc_Common.html',
- 'name' => 'Phone number',
'table' => 'svc_phone',
'fields' => \@fields,
'labels' => {
+ 'svcnum' => 'Service',
'countrycode' => 'Country code',
'phonenum' => 'Phone number',
'domsvc' => 'Domain',
'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>
'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>
</%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"
</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"
</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>
<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>
'style' => \@style,
);
+my $th = $opt{'no_bold'} ? 'TD' : 'TH';
+
</%init>
</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 %>
#'onchange' ? probably not
'disabled' => $disabled,
'no_asterisks' => 1,
+ 'no_bold' => $opt{'no_bold'},
)
%>
? ''
: 'DISABLED';
+my $th = $opt{'no_bold'} ? 'TD' : 'TH';
+
</%init>
<%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');
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
###
# concatenate & return
###
+ $e911.
$devices.
join(' | ', @links ). '<BR>'.
join(' | ', @ilinks). '<BR>';