X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FUI%2FWeb.pm;h=9eb49c430be42b9028605dd73e808732570afe65;hb=a98de57aee063b3ff737c283336f83b2e50e14a8;hp=f460904634efb65f9059591e18816dbd3d0e4b59;hpb=cf2014ff0946351fd7bd4bc134ae2535543b63da;p=freeside.git
diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index f46090463..9eb49c430 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -7,7 +7,7 @@ use Carp qw( confess );
use HTML::Entities;
use FS::Conf;
use FS::Misc::DateTime qw( parse_datetime day_end );
-use FS::Record qw(dbdef);
+use FS::Record qw(dbdef qsearch);
use FS::cust_main; # are sql_balance and sql_date_balance in the right module?
#use vars qw(@ISA);
@@ -300,7 +300,7 @@ sub cust_header {
my %header2method = (
'Customer' => 'name',
'Cust. Status' => 'cust_status_label',
- 'Cust#' => 'custnum',
+ 'Cust#' => 'display_custnum',
'Name' => 'contact',
'Company' => 'company',
@@ -343,14 +343,39 @@ sub cust_header {
'(service) Latitude' => 'ship_latitude',
'(service) Longitude' => 'ship_longitude',
'Invoicing email(s)' => 'invoicing_list_emailonly_scalar',
- 'Payment Type' => 'cust_payby',
+ 'Contact email(s)' => 'contact_list_emailonly',
+ 'Invoices' => 'contact_list_cust_invoice_only',
+ 'Messages' => 'contact_list_cust_message_only',
+# FS::Upgrade::upgrade_config removes this from existing cust-fields settings
+# 'Payment Type' => 'cust_payby',
'Current Balance' => 'current_balance',
'Agent Cust#' => 'agent_custid',
+ 'Agent' => 'agent_name',
+ 'Agent Cust# or Cust#' => 'display_custnum',
'Advertising Source' => 'referral',
);
$header2method{'Cust#'} = 'display_custnum'
if $conf->exists('cust_main-default_agent_custid');
+foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
+ $header2method{'Contact '.$phone_type->typename.' phone(s)'} = sub {
+ my $self = shift;
+ my $num = $phone_type->phonetypenum;
+
+ my @phones;
+ foreach ($self->contact_list_name_phones) {
+ my $data = [
+ {
+ 'data' => $_->first.' '.$_->last.' '.FS::contact_phone::phonenum_pretty($_),
+ },
+ ];
+ push @phones, $data if $_->phonetypenum eq $phone_type->phonetypenum;
+ }
+ return \@phones;
+ };
+
+}
+
my %header2colormethod = (
'Cust. Status' => 'cust_statuscolor',
);
@@ -408,7 +433,14 @@ sub cust_sort_fields {
cust_header(@_) if( @_ or !@cust_fields );
#inefficientish, but tiny lists and only run once per page
- map { $_ eq 'custnum' ? 'custnum' : '' } @cust_fields;
+ my @sort_fields;
+ foreach (@cust_fields) {
+ if ($_ eq "custnum") { push @sort_fields, 'custnum'; }
+ elsif ($_ eq "contact" || $_ eq "name") { push @sort_fields, '(last, first)'; }
+ elsif ($_ eq "company") { push @sort_fields, 'company'; }
+ else { push @sort_fields, ''; }
+ }
+ return @sort_fields;
}
@@ -447,16 +479,16 @@ sub cust_sql_fields {
foreach my $field (qw(daytime night mobile fax )) {
push @fields, $field if (grep { $_ eq $field } @cust_fields);
}
- push @fields, "payby AS cust_payby"
- if grep { $_ eq 'cust_payby' } @cust_fields;
push @fields, 'agent_custid';
+ push @fields, 'agentnum' if grep { $_ eq 'agent_name' } @cust_fields;
+
my @extra_fields = ();
if (grep { $_ eq 'current_balance' } @cust_fields) {
push @extra_fields, FS::cust_main->balance_sql . " AS current_balance";
}
- push @extra_fields, 'part_referral.referral AS referral'
+ push @extra_fields, 'part_referral_x.referral AS referral'
if grep { $_ eq 'referral' } @cust_fields;
map("cust_main.$_", @fields), @location_fields, @extra_fields;
@@ -465,9 +497,9 @@ sub cust_sql_fields {
=item join_cust_main [ TABLE[.CUSTNUM] ] [ LOCATION_TABLE[.LOCATIONNUM] ]
Returns an SQL join phrase for the FROM clause so that the fields listed
-in L will be available. Currently joins to cust_main
+in L will be available. Currently joins to cust_main
itself, as well as cust_location (under the aliases 'bill_location' and
-'ship_location') if address fields are needed. L should have
+'ship_location') if address fields are needed. L should have
been called already.
All of these will be left joins; if you want to exclude rows with no linked
@@ -524,7 +556,7 @@ sub join_cust_main {
}
if ( !@cust_fields or grep { $_ eq 'referral' } @cust_fields ) {
- $sql .= ' LEFT JOIN part_referral ON (cust_main.refnum = part_referral.refnum) ';
+ $sql .= ' LEFT JOIN (select refnum, referral from part_referral) AS part_referral_x ON (cust_main.refnum = part_referral_x.refnum) ';
}
$sql;
@@ -740,6 +772,7 @@ use FS::CurrentUser;
use FS::Record qw(qsearchs);
use FS::queue;
use FS::CGI qw(rooturl);
+use FS::Report::Queued::FutureAutobill;
$DEBUG = 0;