X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_svc.pm;h=2d6224c923966860d64eb9cb69d41de03f9ef6b5;hb=106d0163556c31a3b2cf9c065ec6d9d6ded0ce64;hp=8eecda3ad39150657f30da19adb7dd798231f086;hpb=5e05724a635a22776f1b973f5d7e77989da4e048;p=freeside.git diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 8eecda3ad..2d6224c92 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -3,6 +3,7 @@ package FS::cust_svc; use strict; use vars qw( @ISA $DEBUG $me $ignore_quantity ); use Carp; +#use Scalar::Util qw( blessed ); use FS::Conf; use FS::Record qw( qsearch qsearchs dbh str2time_sql ); use FS::cust_pkg; @@ -16,7 +17,7 @@ use FS::cdr; #most FS::svc_ classes are autoloaded in svc_x emthod use FS::svc_acct; #this one is used in the cache stuff -@ISA = qw( FS::cust_main_Mixin FS::Record ); +@ISA = qw( FS::cust_main_Mixin FS::option_Common ); #FS::Record ); $DEBUG = 0; $me = '[cust_svc]'; @@ -220,7 +221,13 @@ returns the error, otherwise returns false. =cut sub replace { +# my $new = shift; +# +# my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') ) +# ? shift +# : $new->replace_old; my ( $new, $old ) = ( shift, shift ); + $old = $new->replace_old unless defined($old); local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -233,8 +240,6 @@ sub replace { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - $old = $new->replace_old unless defined($old); - if ( $new->svcpart != $old->svcpart ) { my $svc_x = $new->svc_x; my $new_svc_x = ref($svc_x)->new({$svc_x->hash, svcpart=>$new->svcpart }); @@ -246,6 +251,7 @@ sub replace { } } + #my $error = $new->SUPER::replace($old, @_); my $error = $new->SUPER::replace($old); if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -392,6 +398,20 @@ sub _svc_label { } +=item export_links + +Returns a list of html elements associated with this services exports. + +=cut + +sub export_links { + my $self = shift; + my $svc_x = $self->svc_x + or return "can't find ". $self->part_svc->svcdb. '.svcnum '. $self->svcnum; + + $svc_x->export_links; +} + =item svc_x Returns the FS::svc_XXX object for this service (i.e. an FS::svc_acct object or @@ -628,53 +648,31 @@ CDRs are associated with svc_phone services via svc_phone.phonenum sub get_cdrs_for_update { my($self, %options) = @_; - my $default_prefix = $options{'default_prefix'}; + my @fields = ( 'charged_party' ); + push @fields, 'src' unless $options{'disable_src'}; #CDRs are now associated with svc_phone services via svc_phone.phonenum #return () unless $self->svc_x->isa('FS::svc_phone'); return () unless $self->part_svc->svcdb eq 'svc_phone'; my $number = $self->svc_x->phonenum; - my @cdrs = - qsearch( { - 'table' => 'cdr', - 'hashref' => { 'freesidestatus' => '', - 'charged_party' => $number - }, - 'extra_sql' => 'FOR UPDATE', - } ); + my $prefix = $options{'default_prefix'}; - if ( length($default_prefix) ) { - push @cdrs, - qsearch( { - 'table' => 'cdr', - 'hashref' => { 'freesidestatus' => '', - 'charged_party' => "$default_prefix$number", - }, - 'extra_sql' => 'FOR UPDATE', - } ); + my @where = map " $_ = '$number' ", @fields; + push @where, map " $_ = '$prefix$number' ", @fields + if length($prefix); + if ( $prefix =~ /^\+(\d+)$/ ) { + push @where, map " $_ = '$1$number' ", @fields } - #astricon hack? config option? - push @cdrs, + my $extra_sql = ' AND ( '. join(' OR ', @where ). ' ) '; + + my @cdrs = qsearch( { - 'table' => 'cdr', - 'hashref' => { 'freesidestatus' => '', - 'src' => $number, - }, - 'extra_sql' => 'FOR UPDATE', - } ); - - if ( length($default_prefix) ) { - push @cdrs, - qsearch( { - 'table' => 'cdr', - 'hashref' => { 'freesidestatus' => '', - 'src' => "$default_prefix$number", - }, - 'extra_sql' => 'FOR UPDATE', - } ); - } + 'table' => 'cdr', + 'hashref' => { 'freesidestatus' => '', }, + 'extra_sql' => "$extra_sql FOR UPDATE", + } ); @cdrs; }