[freeside-commits] freeside/FS/FS cust_main_Mixin.pm, 1.3,
1.4 ConfDefaults.pm, 1.1, 1.2 cust_main.pm, 1.269,
1.270 AccessRight.pm, 1.16, 1.17
Ivan,,,
ivan at wavetail.420.am
Sat Feb 3 03:36:32 PST 2007
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv7660/FS/FS
Modified Files:
cust_main_Mixin.pm ConfDefaults.pm cust_main.pm AccessRight.pm
Log Message:
add customer status column to customer & most other reports. also put the C in ACL in the search/ and graph/ directories.
Index: cust_main_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main_Mixin.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cust_main_Mixin.pm 29 Jan 2007 16:01:22 -0000 1.3
+++ cust_main_Mixin.pm 3 Feb 2007 11:36:29 -0000 1.4
@@ -2,9 +2,10 @@
use strict;
use vars qw( $DEBUG );
+use FS::UID qw(dbh);
use FS::cust_main;
-$DEBUG = 0;
+$DEBUG = 1;
=head1 NAME
@@ -138,7 +139,7 @@
sub invoicing_list_emailonly_scalar {
my $self = shift;
- warn "invoicing_list_email only called on $self, ".
+ warn "invoicing_list_emailonly called on $self, ".
"custnum ". $self->custnum. "\n"
if $DEBUG;
$self->cust_linked
@@ -165,8 +166,95 @@
: ();
}
+=item status
+
+Given an object that contains fields from cust_main (say, from a JOINed
+search; see httemplate/search/ for examples), returns the equivalent of the
+FS::cust_main I<status> method, or "(unlinked)" if this object is not linked to
+a customer.
+
+=cut
+
+sub cust_status {
+ my $self = shift;
+ return $self->cust_unlinked_msg unless $self->cust_linked;
+
+ #FS::cust_main::status($self)
+ #false laziness w/actual cust_main::status
+ # (make sure FS::cust_main methods are called)
+ for my $status (qw( prospect active inactive suspended cancelled )) {
+ my $method = $status.'_sql';
+ my $sql = FS::cust_main->$method();;
+ my $numnum = ( $sql =~ s/cust_main\.custnum/?/g );
+ my $sth = dbh->prepare("SELECT $sql") or die dbh->errstr;
+ $sth->execute( ($self->custnum) x $numnum )
+ or die "Error executing 'SELECT $sql': ". $sth->errstr;
+ return $status if $sth->fetchrow_arrayref->[0];
+ }
+}
+
+=item ucfirst_cust_status
+
+Given an object that contains fields from cust_main (say, from a JOINed
+search; see httemplate/search/ for examples), returns the equivalent of the
+FS::cust_main I<ucfirst_status> method, or "(unlinked)" if this object is not
+linked to a customer.
+
+=cut
+
+sub ucfirst_cust_status {
+ my $self = shift;
+ $self->cust_linked
+ ? ucfirst( $self->cust_status(@_) )
+ : $self->cust_unlinked_msg;
+}
+
+=item cust_statuscolor
+
+Given an object that contains fields from cust_main (say, from a JOINed
+search; see httemplate/search/ for examples), returns the equivalent of the
+FS::cust_main I<statuscol> method, or "000000" if this object is not linked to
+a customer.
+
+=cut
+
+sub cust_statuscolor {
+ my $self = shift;
+
+ $self->cust_linked
+ ? FS::cust_main::cust_statuscolor($self)
+ : '000000';
+}
+
+=item prospect_sql
+
+=item active_sql
+
+=item inactive_sql
+
+=item suspended_sql
+
+=item cancelled_sql
+
+Given an object that contains fields from cust_main (say, from a JOINed
+search; see httemplate/search/ for examples), returns the equivalent of the
+corresponding FS::cust_main method, or "0" if this object is not linked to
+a customer.
+
=cut
+foreach my $sub (qw( prospect active inactive suspended cancelled )) {
+ eval "
+ sub ${sub}_sql {
+ my \$self = shift;
+ \$self->cust_linked
+ ? FS::cust_main::${sub}_sql(\$self)
+ : '0';
+ }
+ ";
+ die $@ if $@;
+}
+
=back
=head1 BUGS
Index: ConfDefaults.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ConfDefaults.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ConfDefaults.pm 19 Jun 2006 08:05:28 -0000 1.1
+++ ConfDefaults.pm 3 Feb 2007 11:36:29 -0000 1.2
@@ -28,28 +28,28 @@
# XXX should use msgcat for "Day phone" and "Night phone", but how?
sub cust_fields_avail { (
- 'Customer' =>
- 'Last, First or Company (Last, First)',
- 'Cust# | Customer' =>
- 'custnum | Last, First or Company (Last, First)',
+ 'Cust. Status | Customer' =>
+ 'Status | Last, First or Company (Last, First)',
+ 'Cust# | Cust. Status | Customer' =>
+ 'custnum | Status | Last, First or Company (Last, First)',
- 'Name | Company' =>
- 'Last, First | Company',
- 'Cust# | Name | Company' =>
- 'custnum | Last, First | Company',
+ 'Cust. Status | Name | Company' =>
+ 'Status | Last, First | Company',
+ 'Cust# | Cust. Status | Name | Company' =>
+ 'custnum | Status | Last, First | Company',
- '(bill) Customer | (service) Customer' =>
- 'Last, First or Company (Last, First) | (same for service contact if present)',
- 'Cust# | (bill) Customer | (service) Customer' =>
- 'custnum | Last, First or Company (Last, First) | (same for service contact if present)',
+ 'Cust. Status | (bill) Customer | (service) Customer' =>
+ 'Status | Last, First or Company (Last, First) | (same for service contact if present)',
+ 'Cust# | Cust. Status | (bill) Customer | (service) Customer' =>
+ 'custnum | Status | Last, First or Company (Last, First) | (same for service contact if present)',
- '(bill) Name | (bill) Company | (service) Name | (service) Company' =>
- 'Last, First | Company | (same for service address if present)',
- 'Cust# | (bill) Name | (bill) Company | (service) Name | (service) Company' =>
- 'custnum | Last, First | Company | (same for service address if present)',
+ 'Cust. Status | (bill) Name | (bill) Company | (service) Name | (service) Company' =>
+ 'Status | Last, First | Company | (same for service address if present)',
+ 'Cust# | Cust. Status | (bill) Name | (bill) Company | (service) Name | (service) Company' =>
+ 'custnum | Status | Last, First | Company | (same for service address if present)',
- 'Cust# | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Invoicing email(s)' =>
- 'custnum | Last, First | Company | (all address fields ) | Day phone | Night phone | Invoicing email(s)',
+ 'Cust# | Cust. Status | Name | Company | Address 1 | Address 2 | City | State | Zip | Country | Day phone | Night phone | Invoicing email(s)' =>
+ 'custnum | Status | Last, First | Company | (all address fields ) | Day phone | Night phone | Invoicing email(s)',
); }
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- AccessRight.pm 8 Jan 2007 17:36:52 -0000 1.16
+++ AccessRight.pm 3 Feb 2007 11:36:29 -0000 1.17
@@ -160,7 +160,7 @@
# report/listing rights...
###
'List customers',
- #'List zip codes',
+ 'List zip codes',
'List invoices',
'List packages',
'List services',
@@ -179,6 +179,11 @@
'Export', #
###
+# misc misc rights
+###
+ 'Raw SQL',
+
+###
# setup/config rights
###
'Edit advertising sources',
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.269
retrieving revision 1.270
diff -u -d -r1.269 -r1.270
--- cust_main.pm 31 Jan 2007 05:23:18 -0000 1.269
+++ cust_main.pm 3 Feb 2007 11:36:29 -0000 1.270
@@ -3886,6 +3886,8 @@
code2country($self->country);
}
+=item cust_status
+
=item status
Returns a status string for this customer, currently:
@@ -3906,17 +3908,35 @@
=cut
-sub status {
+sub status { shift->cust_status(@_); }
+
+sub cust_status {
my $self = shift;
for my $status (qw( prospect active inactive suspended cancelled )) {
my $method = $status.'_sql';
my $numnum = ( my $sql = $self->$method() ) =~ s/cust_main\.custnum/?/g;
my $sth = dbh->prepare("SELECT $sql") or die dbh->errstr;
- $sth->execute( ($self->custnum) x $numnum ) or die $sth->errstr;
+ $sth->execute( ($self->custnum) x $numnum )
+ or die "Error executing 'SELECT $sql': ". $sth->errstr;
return $status if $sth->fetchrow_arrayref->[0];
}
}
+=item ucfirst_cust_status
+
+=item ucfirst_status
+
+Returns the status with the first character capitalized.
+
+=cut
+
+sub ucfirst_status { shift->ucfirst_cust_status(@_); }
+
+sub ucfirst_cust_status {
+ my $self = shift;
+ ucfirst($self->cust_status);
+}
+
=item statuscolor
Returns a hex triplet color string for this customer's status.
@@ -3932,9 +3952,11 @@
'cancelled' => 'FF0000', #red
);
-sub statuscolor {
+sub statuscolor { shift->cust_statuscolor(@_); }
+
+sub cust_statuscolor {
my $self = shift;
- $statuscolor{$self->status};
+ $statuscolor{$self->cust_status};
}
=back
More information about the freeside-commits
mailing list