[freeside-commits] freeside/FS/FS cust_pkg.pm, 1.124, 1.125 cust_main.pm, 1.414, 1.415
Ivan,,,
ivan at wavetail.420.am
Sun Mar 29 23:10:21 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv21892/FS/FS
Modified Files:
cust_pkg.pm cust_main.pm
Log Message:
okay. counts are needed for the package sort, so push the embedded counting into cust_main.pm. sure hope this does it. RT#5083
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- cust_pkg.pm 30 Mar 2009 05:08:53 -0000 1.124
+++ cust_pkg.pm 30 Mar 2009 06:10:18 -0000 1.125
@@ -1500,6 +1500,9 @@
&& exists($self->{'_num_cust_svc'})
&& $self->{'_num_cust_svc'} =~ /\d/;
+ cluck "cust_pkg->num_cust_svc called, _num_cust_svc:".$self->{'_num_cust_svc'}
+ if $DEBUG > 2;
+
my $sql = 'SELECT COUNT(*) FROM cust_svc WHERE pkgnum = ?';
$sql .= ' AND svcpart = ?' if @_;
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.414
retrieving revision 1.415
diff -u -d -r1.414 -r1.415
--- cust_main.pm 30 Mar 2009 03:47:13 -0000 1.414
+++ cust_main.pm 30 Mar 2009 06:10:18 -0000 1.415
@@ -1819,17 +1819,13 @@
my $self = shift;
my $extra_qsearch = ref($_[0]) ? shift : {};
- return $self->num_pkgs unless wantarray; #XXX doesn't work w/$extra_qsearch
+ return $self->num_pkgs unless wantarray || keys(%$extra_qsearch);
my @cust_pkg = ();
if ( $self->{'_pkgnum'} ) {
@cust_pkg = values %{ $self->{'_pkgnum'}->cache };
} else {
- @cust_pkg = qsearch({
- %$extra_qsearch,
- 'table' => 'cust_pkg',
- 'hashref' => { 'custnum' => $self->custnum },
- });
+ @cust_pkg = $self->_cust_pkg($extra_qsearch);
}
sort sort_packages @cust_pkg;
@@ -1885,11 +1881,7 @@
$extra_qsearch->{'extra_sql'} .= ' AND ( cancel IS NULL OR cancel = 0 ) ';
- @cust_pkg = qsearch({
- %$extra_qsearch,
- 'table' => 'cust_pkg',
- 'hashref' => { 'custnum' => $self->custnum },
- });
+ @cust_pkg = $self->_cust_pkg($extra_qsearch);
}
@@ -1897,6 +1889,27 @@
}
+sub _cust_pkg {
+ my $self = shift;
+ my $extra_qsearch = ref($_[0]) ? shift : {};
+
+ $extra_qsearch->{'select'} ||= '*';
+ $extra_qsearch->{'select'} .=
+ ',( SELECT COUNT(*) FROM cust_svc WHERE cust_pkg.pkgnum = cust_svc.pkgnum )
+ AS _num_cust_svc';
+
+ map {
+ $_->{'_num_cust_svc'} = $_->get('_num_cust_svc');
+ $_;
+ }
+ qsearch({
+ %$extra_qsearch,
+ 'table' => 'cust_pkg',
+ 'hashref' => { 'custnum' => $self->custnum },
+ });
+
+}
+
# This should be generalized to use config options to determine order.
sub sort_packages {
@@ -1906,11 +1919,13 @@
#shouldn't get here...
return 0;
} else {
+ my $a_num_cust_svc = $a->num_cust_svc;
+ my $b_num_cust_svc = $b->num_cust_svc;
+ return 0 if !$a_num_cust_svc && !$b_num_cust_svc;
+ return -1 if $a_num_cust_svc && !$b_num_cust_svc;
+ return 1 if !$a_num_cust_svc && $b_num_cust_svc;
my @a_cust_svc = $a->cust_svc;
my @b_cust_svc = $b->cust_svc;
- return 0 if !scalar(@a_cust_svc) && !scalar(@b_cust_svc);
- return -1 if scalar(@a_cust_svc) && !scalar(@b_cust_svc);
- return 1 if !scalar(@a_cust_svc) && scalar(@b_cust_svc);
$a_cust_svc[0]->svc_x->label cmp $b_cust_svc[0]->svc_x->label;
}
More information about the freeside-commits
mailing list