>
<% $cust_main->display_custnum %>
|
>
- <% ucfirst($status) %>
+ <% $status_label %>
|
>
- <% "$last, $first" %>
+ <% "$last, $first" |h %>
|
>
<% $pcompany %>
|
-% if ( defined dbdef->table('cust_main')->column('ship_last') ) {
-% my($ship_last,$ship_first,$ship_company)=(
-% $cust_main->ship_last || $cust_main->getfield('last'),
-% $cust_main->ship_last ? $cust_main->ship_first : $cust_main->first,
-% $cust_main->ship_last ? $cust_main->ship_company : $cust_main->company,
-% );
-% my $pship_company = $ship_company
-% ? qq!$ship_company!
-% : ' ';
-%
-
- >
- <% "$ship_last, $ship_first" %>
- |
- >
- <% $pship_company %>
- |
-% }
-%
% foreach my $addl_col ( @addl_cols ) {
% if ( $addl_col eq 'tickets' ) {
% if ( @custom_priorities ) {
@@ -257,7 +235,7 @@
% my $pkgnum = $_->pkgnum;
% my $part_pkg = $_->part_pkg;
%
-% my $pkg_comment = $part_pkg->pkg_comment(nopkgpart => 1);
+% my $pkg_comment = $part_pkg->pkg_comment( cust_pkg=>$_, nopkgpart=>1 );
% my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
% ? ''
% : ';show=packages';
@@ -268,7 +246,7 @@
% my $pkg_rowspan = shift @pkg_rowspans;
<% $n1 %>
- <% $pkg_comment %>
+ <% $pkg_comment |h %>
|
% my $n2 = '';
@@ -321,7 +299,7 @@
% }
%
% unless ( @{$all_pkgs{$custnum}} ) {
- | !;
+ |
% }
%
@@ -334,7 +312,7 @@
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $curuser->access_right('List customers');
+ unless $curuser->access_right('List all customers');
my $conf = new FS::Conf;
my $maxrecords = $conf->config('maxsearchrecordsperpage');
@@ -365,7 +343,12 @@ if ( $cgi->param('browse')
if ( $query eq 'custnum' ) {
if ( $conf->exists('cust_main-default_agent_custid') ) {
$sortby=\*display_custnum_sort;
- $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL AND agent_custid != '' THEN CAST(agent_custid AS BIGINT) ELSE custnum END";
+ $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL
+ AND agent_custid != ''
+ AND agent_custid ". regexp_sql. " '^[0-9]+\$'
+ THEN CAST(agent_custid AS BIGINT)
+ ELSE custnum
+ END";
} else {
$sortby=\*custnum_sort;
$orderby = "ORDER BY custnum";
@@ -417,6 +400,7 @@ if ( $cgi->param('browse')
push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled');
push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect');
+ push @qual, FS::cust_main->ordered_sql if $cgi->param('ordered');
push @qual, FS::cust_main->active_sql if $cgi->param('active');
push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive');
push @qual, FS::cust_main->susp_sql if $cgi->param('suspended');
@@ -492,12 +476,12 @@ if ( $cgi->param('browse')
if ( $cgi->param('search_cust') ) {
$sortby = \*company_sort;
$orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )";
- push @cust_main, smart_search( 'search' => scalar($cgi->param('search_cust')),
- 'no_fuzzy_on_exact' => 1, #pref?
- );
+ push @cust_main, smart_search(
+ 'search' => scalar($cgi->param('search_cust')),
+ );
}
- @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
+ @cust_main = grep { $_->num_ncancelled_pkgs || ! $_->num_pkgs } @cust_main
if ! $cgi->param('cancelled')
&& (
$cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
@@ -509,12 +493,30 @@ if ( $cgi->param('browse')
@cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
}
-my %all_pkgs;
-if ( $conf->exists('hidecancelledpackages' ) ) {
- %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main;
-} else {
- %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main;
-}
+my $pkgs_method = $conf->exists('hidecancelledpackages')
+ ? 'ncancelled_pkgs'
+ : 'all_pkgs';
+
+#false laziness w/httemplate/view/cust_main/packages.html
+my $select = '*, setup_option.optionvalue AS _opt_setup_fee, '.
+ 'recur_option.optionvalue AS _opt_recur_fee',
+my $addl_from = qq{
+ LEFT JOIN part_pkg USING ( pkgpart )
+ LEFT JOIN part_pkg_option AS setup_option
+ ON ( cust_pkg.pkgpart = setup_option.pkgpart
+ AND setup_option.optionname = 'setup_fee' )
+ LEFT JOIN part_pkg_option AS recur_option
+ ON ( cust_pkg.pkgpart = recur_option.pkgpart
+ AND recur_option.optionname = 'recur_fee' )
+};
+
+my %all_pkgs = map { $_->custnum =>
+ [ $_->$pkgs_method({ select => $select,
+ addl_from => $addl_from,
+ })
+ ];
+ }
+ @cust_main;
sub last_sort {
lc($a->getfield('last')) cmp lc($b->getfield('last'))