[freeside-commits] freeside/FS/FS Conf.pm, 1.356, 1.357 Schema.pm, 1.196, 1.197 svc_phone.pm, 1.22, 1.23 svc_Domain_Mixin.pm, NONE, 1.1 svc_acct.pm, 1.287, 1.288
Ivan,,,
ivan at wavetail.420.am
Sun Mar 7 23:03:00 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv12478/FS/FS
Modified Files:
Conf.pm Schema.pm svc_phone.pm svc_acct.pm
Added Files:
svc_Domain_Mixin.pm
Log Message:
domain names in netsapiens export (domain name association w/svc_phone), RT#5864
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -w -d -r1.196 -r1.197
--- Schema.pm 22 Feb 2010 09:14:03 -0000 1.196
+++ Schema.pm 8 Mar 2010 07:02:57 -0000 1.197
@@ -2594,10 +2594,11 @@
'sip_password', 'varchar', 'NULL', $char_d, '', '',
'phone_name', 'varchar', 'NULL', $char_d, '', '',
'pbxsvc', 'int', 'NULL', '', '', '',
+ 'domsvc', 'int', 'NULL', '', '', '',
],
'primary_key' => 'svcnum',
'unique' => [],
- 'index' => [ [ 'countrycode', 'phonenum' ], ['pbxsvc'] ],
+ 'index' => [ [ 'countrycode', 'phonenum' ], ['pbxsvc'], ['domsvc'] ],
},
'phone_device' => {
Index: svc_phone.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_phone.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -w -d -r1.22 -r1.23
--- svc_phone.pm 25 Jan 2010 22:17:14 -0000 1.22
+++ svc_phone.pm 8 Mar 2010 07:02:57 -0000 1.23
@@ -1,16 +1,15 @@
package FS::svc_phone;
use strict;
-use vars qw( @ISA @pw_set $conf );
+use base qw( FS::svc_Domain_Mixin FS::svc_Common );
+use vars qw( @pw_set $conf );
use FS::Conf;
use FS::Record qw( qsearch qsearchs dbh );
use FS::Msgcat qw(gettext);
-use FS::svc_Common;
use FS::part_svc;
use FS::phone_device;
use FS::svc_pbx;
-
- at ISA = qw( FS::svc_Common );
+use FS::svc_domain;
#avoid l 1 and o O 0
@pw_set = ( 'a'..'k', 'm','n', 'p-z', 'A'..'N', 'P'..'Z' , '2'..'9' );
@@ -114,6 +113,14 @@
disable_inventory => 1,
disable_select => 1, #UI wonky, pry works otherwise
},
+ 'domsvc' => {
+ label => 'Domain',
+ type => 'select',
+ select_table => 'svc_domain',
+ select_key => 'svcnum',
+ select_label => 'domain',
+ disable_inventory => 1,
+ },
},
};
}
@@ -159,6 +166,7 @@
my $self = shift;
my $phonenum = $self->phonenum; #XXX format it better
my $label = $phonenum;
+ $label .= '@'.$self->domain if $self->domsvc;
$label .= ' ('.$self->phone_name.')' if $self->phone_name;
$label;
}
@@ -269,6 +277,7 @@
|| $self->ut_numbern('pin')
|| $self->ut_textn('phone_name')
|| $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' )
+ || $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' )
;
return $error if $error;
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.356
retrieving revision 1.357
diff -u -w -d -r1.356 -r1.357
--- Conf.pm 21 Feb 2010 22:54:10 -0000 1.356
+++ Conf.pm 8 Mar 2010 07:02:57 -0000 1.357
@@ -3297,6 +3297,13 @@
},
{
+ 'key' => 'svc_phone-domain',
+ 'section' => '',
+ 'description' => 'Track an optional domain association with each phone service.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'default_phone_countrycode',
'section' => '',
'description' => 'Default countrcode',
Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -w -d -r1.287 -r1.288
--- svc_acct.pm 22 Feb 2010 09:14:03 -0000 1.287
+++ svc_acct.pm 8 Mar 2010 07:02:57 -0000 1.288
@@ -1,7 +1,8 @@
package FS::svc_acct;
use strict;
-use vars qw( @ISA $DEBUG $me $conf $skip_fuzzyfiles
+use base qw( FS::svc_Domain_Mixin FS::svc_Common );
+use vars qw( $DEBUG $me $conf $skip_fuzzyfiles
$dir_prefix @shells $usernamemin
$usernamemax $passwordmin $passwordmax
$username_ampersand $username_letter $username_letterfirst
@@ -32,8 +33,6 @@
use FS::UI::bytecount;
use FS::UI::Web;
use FS::part_pkg;
-use FS::svc_Common;
-use FS::cust_svc;
use FS::part_svc;
use FS::svc_acct_pop;
use FS::cust_main_invoice;
@@ -48,8 +47,6 @@
use FS::svc_www;
use FS::cdr;
- at ISA = qw( FS::svc_Common );
-
$DEBUG = 0;
$me = '[FS::svc_acct]';
@@ -356,16 +353,6 @@
select_key => 'svcnum',
select_label => 'domain',
disable_inventory => 1,
-
- },
- 'domsvc' => {
- label => 'Domain',
- type => 'select',
- select_table => 'svc_domain',
- select_key => 'svcnum',
- select_label => 'domain',
- disable_inventory => 1,
-
},
'pbxsvc' => { label => 'PBX',
type => 'select-svc_pbx.html',
@@ -1810,22 +1797,6 @@
$svc_domain->domain;
}
-=item svc_domain
-
-Returns the FS::svc_domain record for this account's domain (see
-L<FS::svc_domain>).
-
-=cut
-
-# FS::h_svc_acct has a history-aware svc_domain override
-
-sub svc_domain {
- my $self = shift;
- $self->{'_domsvc'}
- ? $self->{'_domsvc'}
- : qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } );
-}
-
=item cust_svc
Returns the FS::cust_svc record for this account (see L<FS::cust_svc>).
@@ -3147,61 +3118,4 @@
=cut
-=item domain_select_hash %OPTIONS
-
-Returns a hash SVCNUM => DOMAIN ... representing the domains this customer
-may at present purchase.
-
-Currently available options are: I<pkgnum> I<svcpart>
-
-=cut
-
-sub domain_select_hash {
- my ($self, %options) = @_;
- my %domains = ();
- my $part_svc;
- my $cust_pkg;
-
- if (ref($self)) {
- $part_svc = $self->part_svc;
- $cust_pkg = $self->cust_svc->cust_pkg
- if $self->cust_svc;
- }
-
- $part_svc = qsearchs('part_svc', { 'svcpart' => $options{svcpart} })
- if $options{'svcpart'};
-
- $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $options{pkgnum} })
- if $options{'pkgnum'};
-
- if ($part_svc && ( $part_svc->part_svc_column('domsvc')->columnflag eq 'S'
- || $part_svc->part_svc_column('domsvc')->columnflag eq 'F')) {
- %domains = map { $_->svcnum => $_->domain }
- map { qsearchs('svc_domain', { 'svcnum' => $_ }) }
- split(',', $part_svc->part_svc_column('domsvc')->columnvalue);
- }elsif ($cust_pkg && !$conf->exists('svc_acct-alldomains') ) {
- %domains = map { $_->svcnum => $_->domain }
- map { qsearchs('svc_domain', { 'svcnum' => $_->svcnum }) }
- map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) }
- qsearch('cust_pkg', { 'custnum' => $cust_pkg->custnum });
- }else{
- %domains = map { $_->svcnum => $_->domain } qsearch('svc_domain', {} );
- }
-
- if ($part_svc && $part_svc->part_svc_column('domsvc')->columnflag eq 'D') {
- my $svc_domain = qsearchs('svc_domain',
- { 'svcnum' => $part_svc->part_svc_column('domsvc')->columnvalue } );
- if ( $svc_domain ) {
- $domains{$svc_domain->svcnum} = $svc_domain->domain;
- }else{
- warn "unknown svc_domain.svcnum for part_svc_column domsvc: ".
- $part_svc->part_svc_column('domsvc')->columnvalue;
-
- }
- }
-
- (%domains);
-}
-
1;
-
--- NEW FILE: svc_Domain_Mixin.pm ---
package FS::svc_Domain_Mixin;
use strict;
use FS::Conf;
use FS::Record qw(qsearch qsearchs);
use FS::part_svc;
use FS::cust_pkg;
use FS::cust_svc;
use FS::svc_domain;
=head1 NAME
FS::svc_Domain_Mixin - Mixin class for svc_classes with a domsvc field
=head1 SYNOPSIS
package FS::svc_table;
use base qw( FS::svc_Domain_Mixin FS::svc_Common );
=head1 DESCRIPTION
This is a mixin class for svc_ classes that contain a domsvc field linking to
a domain (see L<FS::svc_domain>).
=head1 METHODS
=over 4
=item domain [ END_TIMESTAMP [ START_TIMESTAMP ] ]
Returns the domain associated with this account.
END_TIMESTAMP and START_TIMESTAMP can optionally be passed when dealing with
history records.
=cut
sub domain {
my $self = shift;
#die "svc_acct.domsvc is null for svcnum ". $self->svcnum unless $self->domsvc;
return '' unless $self->domsvc;
my $svc_domain = $self->svc_domain(@_)
or die "no svc_domain.svcnum for domsvc ". $self->domsvc;
$svc_domain->domain;
}
=item svc_domain
Returns the FS::svc_domain record for this account's domain (see
L<FS::svc_domain>).
=cut
# FS::h_svc_acct has a history-aware svc_domain override
sub svc_domain {
my $self = shift;
$self->{'_domsvc'}
? $self->{'_domsvc'}
: qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } );
}
=item domain_select_hash %OPTIONS
Object or class method.
Returns a hash SVCNUM => DOMAIN ... representing the domains this customer
may at present purchase.
Currently available options are: I<pkgnum> and I<svcpart>.
=cut
sub domain_select_hash {
my ($self, %options) = @_;
my %domains = ();
my $conf = new FS::Conf;
my $part_svc;
my $cust_pkg;
if (ref($self)) {
$part_svc = $self->part_svc;
$cust_pkg = $self->cust_svc->cust_pkg
if $self->cust_svc;
}
$part_svc = qsearchs('part_svc', { 'svcpart' => $options{svcpart} })
if $options{'svcpart'};
$cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $options{pkgnum} })
if $options{'pkgnum'};
if ($part_svc && ( $part_svc->part_svc_column('domsvc')->columnflag eq 'S'
|| $part_svc->part_svc_column('domsvc')->columnflag eq 'F')) {
%domains = map { $_->svcnum => $_->domain }
map { qsearchs('svc_domain', { 'svcnum' => $_ }) }
split(',', $part_svc->part_svc_column('domsvc')->columnvalue);
}elsif ($cust_pkg && !$conf->exists('svc_acct-alldomains') ) {
%domains = map { $_->svcnum => $_->domain }
map { qsearchs('svc_domain', { 'svcnum' => $_->svcnum }) }
map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) }
qsearch('cust_pkg', { 'custnum' => $cust_pkg->custnum });
}else{
%domains = map { $_->svcnum => $_->domain } qsearch('svc_domain', {} );
}
if ($part_svc && $part_svc->part_svc_column('domsvc')->columnflag eq 'D') {
my $svc_domain = qsearchs('svc_domain',
{ 'svcnum' => $part_svc->part_svc_column('domsvc')->columnvalue } );
if ( $svc_domain ) {
$domains{$svc_domain->svcnum} = $svc_domain->domain;
}else{
warn "unknown svc_domain.svcnum for part_svc_column domsvc: ".
$part_svc->part_svc_column('domsvc')->columnvalue;
}
}
(%domains);
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::svc_Common>, L<FS::Record>
=cut
1;
More information about the freeside-commits
mailing list