[freeside-commits] freeside/httemplate/search cust_main_ADV.cgi, 1.1.2.2, 1.1.2.3 report_cust_main.html, 1.1.2.1, 1.1.2.2

Jeff Finucane,420,, jeff at wavetail.420.am
Wed Nov 28 10:49:08 PST 2007


Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail:/tmp/cvs-serv5198/httemplate/search

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	cust_main_ADV.cgi report_cust_main.html 
Log Message:
advanced customer report rearrangement

Index: cust_main_ADV.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_main_ADV.cgi,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- cust_main_ADV.cgi	4 Nov 2007 18:23:23 -0000	1.1.2.2
+++ cust_main_ADV.cgi	28 Nov 2007 18:49:05 -0000	1.1.2.3
@@ -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 $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 @@
   '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>

Index: report_cust_main.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cust_main.html,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- report_cust_main.html	3 Nov 2007 00:55:24 -0000	1.1.2.1
+++ report_cust_main.html	28 Nov 2007 18:49:05 -0000	1.1.2.2
@@ -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>



More information about the freeside-commits mailing list