[freeside-commits] freeside/httemplate/search cust_main.cgi, 1.83.2.2, 1.83.2.3 cust_pkg.cgi, 1.69.2.1, 1.69.2.2
Mark Wells
mark at wavetail.420.am
Thu Jun 23 14:31:31 PDT 2011
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv1487/httemplate/search
Modified Files:
Tag: FREESIDE_2_1_BRANCH
cust_main.cgi cust_pkg.cgi
Log Message:
large package display in customer/package search, #13364
Index: cust_main.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_main.cgi,v
retrieving revision 1.83.2.2
retrieving revision 1.83.2.3
diff -u -w -d -r1.83.2.2 -r1.83.2.3
--- cust_main.cgi 22 May 2011 20:09:23 -0000 1.83.2.2
+++ cust_main.cgi 23 Jun 2011 21:31:29 -0000 1.83.2.3
@@ -5,6 +5,7 @@
%
%my $conf = new FS::Conf;
%my $maxrecords = $conf->config('maxsearchrecordsperpage');
+%my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size') || 0;
%
%#my $cache;
%
@@ -372,16 +373,31 @@
% $cust_main->company,
% );
%
-% my(@lol_cust_svc);
-% my($rowspan)=0;#scalar( @{$all_pkgs{$custnum}} );
-% foreach ( @{$all_pkgs{$custnum}} ) {
-% #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
-% my @cust_svc = $_->cust_svc;
-% push @lol_cust_svc, \@cust_svc;
-% $rowspan += scalar(@cust_svc) || 1;
+% my @all_cust_svc;
+% my @pkg_rowspans;
+% foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) {
+% my %cust_svc_by_svcpart;
+% foreach my $svc ( $cust_pkg->cust_svc ) {
+% push @{ $cust_svc_by_svcpart{$svc->svcpart} ||= [] }, $svc;
% }
+% push @all_cust_svc, \%cust_svc_by_svcpart;
+% if ( !keys %cust_svc_by_svcpart ) {
+% # no services
+% push @pkg_rowspans, 1;
+% }
+% else {
+% my $rows = 0;
+% foreach (values %cust_svc_by_svcpart) {
+% # summarizing takes two rows per svcpart,
+% # full display takes one per cust_svc
+% $rows += ( $large_pkg_size > 0 && $large_pkg_size <= scalar @$_ ) ?
+% 2 : scalar @$_;
+% }
+% push @pkg_rowspans, $rows;
+% }
+% }
+% my $rowspan = List::Util::sum(@pkg_rowspans) || 1;
%
-% #my($rowspan) = scalar(@{$all_pkgs{$custnum}});
% my $view;
% if ( defined $cgi->param('quickpay') && $cgi->param('quickpay') eq 'yes' ) {
% $view = $p. 'edit/cust_pay.cgi?quickpay=yes;custnum='. $custnum;
@@ -396,10 +412,10 @@
% my $statuscol = $cust_main->statuscolor;
<TR>
- <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% $cust_main->display_custnum %></FONT></A></TD>
- <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><FONT SIZE="-1" COLOR="#<% $statuscol %>"><B><% ucfirst($status) %></B></FONT></TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pcompany %></TD>
+ <TD CLASS="grid" ALIGN="right" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>><A HREF="<% $view %>"><FONT SIZE=-1><% $cust_main->display_custnum %></FONT></A></TD>
+ <TD CLASS="grid" ALIGN="center" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>><FONT SIZE="-1" COLOR="#<% $statuscol %>"><B><% ucfirst($status) %></B></FONT></TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$last, $first" %></FONT></A></TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>><% $pcompany %></TD>
%
% if ( defined dbdef->table('cust_main')->column('ship_last') ) {
% my($ship_last,$ship_first,$ship_company)=(
@@ -413,8 +429,8 @@
%
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A></TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %>><% $pship_company %></A></TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>><A HREF="<% $view %>"><FONT SIZE=-1><% "$ship_last, $ship_first" %></FONT></A></TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %>><% $pship_company %></A></TD>
% }
%
% foreach my $addl_col ( @addl_cols ) {
@@ -422,7 +438,7 @@
% if ( @custom_priorities ) {
- <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+ <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right><FONT SIZE=-1>
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
% foreach my $priority ( @custom_priorities, '' ) {
@@ -454,7 +470,7 @@
% } else {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right><FONT SIZE=-1>
% }
%
% my $ahref = '';
@@ -482,7 +498,7 @@
% } else {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN=<% $rowspan %> ALIGN=right><FONT SIZE=-1>
<% $cust_main->get($addl_col) %>
</FONT></TD>
%
@@ -501,25 +517,55 @@
% : ';show=packages';
% my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
% my $pkgview = "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag";
-% my @cust_svc = @{shift @lol_cust_svc};
-% #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } );
-% my $rowspan = scalar(@cust_svc) || 1;
-%
-% print $n1, qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ROWSPAN=$rowspan><A HREF="$pkgview"><FONT SIZE=-1>$pkg_comment</FONT></A></TD>!;
+% # cust_svc stuff, built earlier
+% my %cust_svc_by_svcpart = %{ shift @all_cust_svc };
+% my $pkg_rowspan = shift @pkg_rowspans;
+
+ <% $n1 %><TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ROWSPAN="<% $pkg_rowspan %>">
+ <A HREF="$pkgview"><FONT SIZE=-1><% $pkg_comment %></FONT></A></TD>
+
+% my $n2 = '';
+% my $td = '<TD CLASS="grid" BGCOLOR="'.$bgcolor.'">';
%
-% my($n2)='';
-% foreach my $cust_svc ( @cust_svc ) {
-% my($label, $value, $svcdb) = $cust_svc->label;
-% my($svcnum) = $cust_svc->svcnum;
-% my($sview) = $p.'view';
-% print $n2,
-% qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !.
-% qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !;
+% foreach my $svcpart ( sort keys %cust_svc_by_svcpart ) { #sort order?
+% my $these = $cust_svc_by_svcpart{$svcpart};
+% my $num_cust_svc = scalar @$these; # always at least 1
+% if ( $large_pkg_size > 0 && $num_cust_svc >= $large_pkg_size ) {
+ <% $n2 %>
+% # summarize
+% # link opens a new search for this pkgnum/svcnum combo
+% my $href = $p.'search/cust_pkg_svc.html?svcpart='.$svcpart.
+% ';pkgnum='.$pkgnum;
+ <% $td %>
+ <A HREF="<% $href %>"><% $these->[0]->part_svc->svc %></A>
+ </TD>
+ <% $td %>
+ <A HREF="<% $href %>"><B>(view all <% $num_cust_svc %>)</B></A>
+ </TD>
+ </TR><TR>
+ <% $td %></TD>
+ <% $td %><& /elements/search-cust_svc.html,
+ 'svcpart' => $svcpart,
+ 'pkgnum' => $pkgnum,
+ &></TD>
% $n2="</TR><TR>";
% }
+% else { # do not summarize
+% foreach my $cust_svc ( @$these ) {
+ <% $n2 %>
+ <% $td %>
+ <% FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) %>
+ </TD>
+ <% $td %>
+ <% FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) %>
+ </TD>
+% $n2 = "</TR><TR>";
+% } # foreach $cust_svc
+% }
+% } # foreach $svcpart
%
-% unless ( @cust_svc ) {
-% print qq!<TD CLASS="grid" BGCOLOR="$bgcolor" COLSPAN=2> </TD>!;
+% unless ( %cust_svc_by_svcpart ) {
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=2> </TD>
% }
%
% #print qq!</TR><TR>\n!;
Index: cust_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_pkg.cgi,v
retrieving revision 1.69.2.1
retrieving revision 1.69.2.2
diff -u -w -d -r1.69.2.1 -r1.69.2.2
--- cust_pkg.cgi 10 Feb 2011 17:11:48 -0000 1.69.2.1
+++ cust_pkg.cgi 23 Jun 2011 21:31:29 -0000 1.69.2.2
@@ -93,19 +93,7 @@
}
}
else {
- [ map {
- [
- { 'data' => $_->[0]. ':',
- 'align'=> 'right',
- },
- { 'data' => $_->[1],
- 'align'=> 'left',
- 'link' => $p. 'view/' .
- $_->[2]. '.cgi?'. $_->[3],
- },
- ];
- } $cust_pkg->labels
- ];
+ [ $process_svc_labels->( $cust_pkg ) ]
}
}
],
@@ -301,4 +289,50 @@
return $text;
};
+my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size');
+
+my $process_svc_labels = sub {
+ my $cust_pkg = shift;
+ my @out;
+ foreach my $part_svc ( $cust_pkg->part_svc) {
+ # some false laziness with view/cust_main/packages/services.html
+
+ my $num_cust_svc = $cust_pkg->num_cust_svc( $part_svc->svcpart );
+
+ if ( $large_pkg_size > 0 and $large_pkg_size <= $num_cust_svc ) {
+ my $href = $p.'search/cust_pkg_svc.html?svcpart='.$part_svc->svcpart.
+ ';pkgnum='.$cust_pkg->pkgnum;
+ push @out, [
+ { 'data' => $part_svc->svc . ':',
+ 'align' => 'right',
+ 'rowspan' => 2 },
+ { 'data' => '(view all '. $num_cust_svc .')',
+ 'data_style' => 'b',
+ 'align' => 'left',
+ 'link' => $href, },
+ ],
+ [
+ { 'data' => include('/elements/search-cust_svc.html',
+ 'svcpart' => $part_svc->svcpart,
+ 'pkgnum' => $cust_pkg->pkgnum,
+ ),
+ 'align' => 'left' },
+ ];
+ }
+ else {
+ foreach ( map { [ $_->label ] } @{ $part_svc->cust_pkg_svc } ) {
+ push @out, [
+ { 'data' => $_->[0]. ':',
+ 'align'=> 'right', },
+ { 'data' => $_->[1],
+ 'align'=> 'left',
+ 'link' => $p. 'view/' .
+ $_->[2]. '.cgi?'. $_->[3], },
+ ];
+ }
+ }
+ } #foreach $cust_pkg
+ return @out;
+};
+
</%init>
More information about the freeside-commits
mailing list