summaryrefslogtreecommitdiff
path: root/httemplate/search
diff options
context:
space:
mode:
authorjeff <jeff>2007-11-28 18:49:20 +0000
committerjeff <jeff>2007-11-28 18:49:20 +0000
commitd5967ae3ecfdb0bb1ead8176cfb2760a65c51f2d (patch)
tree55068e68f1107ce5e731a883b79cd370696a5587 /httemplate/search
parentb0810e3538c41c723ae47b982a2e87944be828e0 (diff)
advanced customer report rearrangement
Diffstat (limited to 'httemplate/search')
-rwxr-xr-xhttemplate/search/cust_main_ADV.cgi85
-rwxr-xr-xhttemplate/search/report_cust_main.html9
2 files changed, 47 insertions, 47 deletions
diff --git a/httemplate/search/cust_main_ADV.cgi b/httemplate/search/cust_main_ADV.cgi
index 17b17488b..1889b6c82 100755
--- a/httemplate/search/cust_main_ADV.cgi
+++ b/httemplate/search/cust_main_ADV.cgi
@@ -3,32 +3,13 @@
'name' => 'customers',
'query' => $sql_query,
'count_query' => $count_query,
- 'header' => [ '#',
- 'Name',
- 'Address',
- 'Phone',
- 'Night',
- 'Fax',
- 'Email',
- 'Payment Type',
+ 'header' => [ FS::UI::Web::cust_header(
+ $cgi->param('cust_fields')
+ ),
@extra_headers,
],
'fields' => [
- 'custnum',
- 'name',
- sub { my $c = shift;
- $c->address1 .
- ($c->address2 ? ' '.$c->address2 : '').
- $c->city. ', '. $c->state. ' '. $c->zip.
- ($c->country ne $countrydefault ? ' '. $c->country
- : ''
- );
- },
- 'daytime',
- 'night',
- 'fax',
- 'email',
- 'payby',
+ \&FS::UI::Web::cust_fields,
@extra_fields,
],
)
@@ -102,15 +83,41 @@ my $addl_from = 'LEFT JOIN cust_pkg USING ( custnum ) ';
my $count_query = "SELECT COUNT(*) FROM cust_main $extra_sql";
-my $select;
-if ($dbh->{Driver}->{Name} eq 'Pg') {
- $select = "*, array_to_string(array(select pkg from cust_pkg left join part_pkg using ( pkgpart ) where cust_main.custnum = cust_pkg.custnum $pkgwhere),'|') as magic";
-}elsif ($dbh->{Driver}->{Name} =~ /^mysql/i) {
- $select = "*, GROUP_CONCAT(pkg SEPARATOR '|') as magic";
-}else{
- warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
- "omitting packing information from report.";
+my $select = '*';
+my (@extra_headers) = ();
+my (@extra_fields) = ();
+
+if ($cgi->param('flattened_pkgs')) {
+
+ if ($dbh->{Driver}->{Name} eq 'Pg') {
+
+ $select .= ", array_to_string(array(select pkg from cust_pkg left join part_pkg using ( pkgpart ) where cust_main.custnum = cust_pkg.custnum $pkgwhere),'|') as magic";
+
+ }elsif ($dbh->{Driver}->{Name} =~ /^mysql/i) {
+ $select .= ", GROUP_CONCAT(pkg SEPARATOR '|') as magic";
+ $addl_from .= " LEFT JOIN part_pkg using ( pkgpart )";
+ }else{
+ warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
+ "omitting packing information from report.";
+ }
+
+ my $header_query = "SELECT COUNT(cust_pkg.custnum = cust_main.custnum) AS count FROM cust_main $addl_from $extra_sql $pkgwhere group by cust_main.custnum order by count desc limit 1";
+
+ my $sth = dbh->prepare($header_query) or die dbh->errstr;
+ $sth->execute() or die $sth->errstr;
+ my $headerrow = $sth->fetchrow_arrayref;
+ my $headercount = $headerrow ? $headerrow->[0] : 0;
+ while($headercount) {
+ unshift @extra_headers, "Package ". $headercount;
+ unshift @extra_fields, eval q!sub {my $c = shift;
+ my @a = split '\|', $c->magic;
+ my $p = $a[!.--$headercount. q!];
+ $p;
+ };!;
+ }
+
}
+
my $sql_query = {
'table' => 'cust_main',
'select' => $select,
@@ -118,21 +125,5 @@ my $sql_query = {
'extra_sql' => "$extra_sql $orderby",
};
-my $header_query = "SELECT COUNT(cust_pkg.custnum = cust_main.custnum) AS count FROM cust_main $addl_from $extra_sql $pkgwhere group by cust_main.custnum order by count desc limit 1";
-
-my $sth = dbh->prepare($header_query) or die dbh->errstr;
-$sth->execute() or die $sth->errstr;
-my $headerrow = $sth->fetchrow_arrayref;
-my $headercount = $headerrow ? $headerrow->[0] : 0;
-my (@extra_headers) = ();
-my (@extra_fields) = ();
-while($headercount) {
- unshift @extra_headers, "Package ". $headercount;
- unshift @extra_fields, eval q!sub {my $c = shift;
- my @a = split '\|', $c->magic;
- my $p = $a[!.--$headercount. q!];
- $p;
- };!;
-}
</%init>
diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html
index f32c3aa18..57b84cb37 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -35,6 +35,15 @@
<TD><INPUT TYPE="checkbox" NAME="cancelled_pkgs"></TD>
</TR>
+ <TR>
+ <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
+ </TR>
+ <% include( '/elements/tr-select-cust-fields.html' ) %>
+
+ <TR>
+ <TD ALIGN="right" VALIGN="center">Add package columns</TD>
+ <TD><INPUT TYPE="checkbox" NAME="flattened_pkgs"></TD>
+ </TR>
</TABLE>
<BR>