[freeside-commits] freeside/httemplate/search report_h_cust_pay.html, 1.2, 1.3 report_cust_pkg_discount.html, 1.1, 1.2 cust_pkg_discount.html, 1.1, 1.2 cust_bill_pkg_discount.html, 1.1, 1.2 report_cust_bill_pkg_discount.html, 1.1, 1.2 cust_credit.html, 1.14, 1.15 report_cust_credit.html, 1.14, 1.15

Ivan,,, ivan at wavetail.420.am
Sun Aug 15 00:00:23 PDT 2010


Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv21093/search

Modified Files:
	report_h_cust_pay.html report_cust_pkg_discount.html 
	cust_pkg_discount.html cust_bill_pkg_discount.html 
	report_cust_bill_pkg_discount.html cust_credit.html 
	report_cust_credit.html 
Log Message:
additional by-otaker searches fixed for the brave new world of usernum, RT#9555

Index: report_cust_credit.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cust_credit.html,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -d -r1.14 -r1.15
--- report_cust_credit.html	10 Dec 2008 21:43:43 -0000	1.14
+++ report_cust_credit.html	15 Aug 2010 07:00:21 -0000	1.15
@@ -5,9 +5,9 @@
 
 <TABLE>
 
-  <% include( '/elements/tr-select-otaker.html',
+  <% include( '/elements/tr-select-user.html',
                 'label'   => 'Credits by employee: ',
-                'otakers' => \@otakers,
+                'access_user' => \%access_user,
             )
   %>
 
@@ -40,9 +40,13 @@
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
 
-my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit")
+my $sth = dbh->prepare("SELECT DISTINCT usernum FROM cust_credit")
   or die dbh->errstr;
 $sth->execute or die $sth->errstr;
-my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref};
+my @usernum = map $_->[0], @{$sth->fetchall_arrayref};
+my %access_user =
+  map { $_ => qsearchs('access_user',{'usernum'=>$_})->username }
+      @usernum;
+
 
 </%init>

Index: cust_bill_pkg_discount.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_bill_pkg_discount.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- cust_bill_pkg_discount.html	6 Feb 2010 02:54:10 -0000	1.1
+++ cust_bill_pkg_discount.html	15 Aug 2010 07:00:21 -0000	1.2
@@ -85,6 +85,11 @@
   push @where, "cust_main.agentnum = $1";
 }
 
+#usernum
+if ( $cgi->param('usernum') =~ /^(\d+)$/ ) {
+  push @where, "cust_pkg_discount.usernum = $1";
+}
+
 # #classnum
 # # not specified: all classes
 # # 0: empty class
@@ -110,18 +115,25 @@
 
 my $count_query = "SELECT COUNT(*), SUM(amount)";
 
-my $join_cust =  '      JOIN cust_bill_pkg USING ( billpkgnum )
+my $join_cust_pkg_discount =
+  'LEFT JOIN cust_pkg_discount USING (pkgdiscountnum)';
+
+my $join_cust =
+  '      JOIN cust_bill_pkg USING ( billpkgnum )
                         JOIN cust_bill USING ( invnum ) 
                    LEFT JOIN cust_main USING ( custnum ) ';
 
-my $join_pkg = ' LEFT JOIN cust_pkg USING ( pkgnum )
+my $join_pkg =
+  ' LEFT JOIN cust_pkg ON ( cust_bill_pkg.pkgnum = cust_pkg.pkgnum )
                  LEFT JOIN part_pkg USING ( pkgpart ) ';
                  #LEFT JOIN part_pkg AS override
                  #  ON pkgpart_override = override.pkgpart ';
 
 my $where = ' WHERE '. join(' AND ', @where);
 
-$count_query .= " FROM cust_bill_pkg_discount $join_cust $join_pkg $where";
+$count_query .=
+  " FROM cust_bill_pkg_discount $join_cust_pkg_discount $join_cust $join_pkg ".
+  $where;
 
 my @select = (
                'cust_bill_pkg_discount.*',
@@ -135,7 +147,7 @@
 
 my $query = {
   'table'     => 'cust_bill_pkg_discount',
-  'addl_from' => "$join_cust $join_pkg",
+  'addl_from' => "$join_cust_pkg_discount $join_cust $join_pkg",
   'hashref'   => {},
   'select'    => join(', ', @select ),
   'extra_sql' => $where,

Index: report_cust_pkg_discount.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cust_pkg_discount.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- report_cust_pkg_discount.html	6 Feb 2010 02:54:10 -0000	1.1
+++ report_cust_pkg_discount.html	15 Aug 2010 07:00:21 -0000	1.2
@@ -16,9 +16,9 @@
     </TD>
   </TR>
 
-  <% include( '/elements/tr-select-otaker.html',
+  <% include( '/elements/tr-select-user.html',
                 'label'   => 'Discounts by employee: ',
-                'otakers' => \@otakers,
+                'access_user' => \%access_user,
             )
   %>
 
@@ -42,9 +42,12 @@
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
 
-my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_pkg_discount")
+my $sth = dbh->prepare("SELECT DISTINCT usernum FROM cust_pkg_discount")
   or die dbh->errstr;
 $sth->execute or die $sth->errstr;
-my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref};
+my @usernum = map $_->[0], @{$sth->fetchall_arrayref};
+my %access_user =
+  map { $_ => qsearchs('access_user',{'usernum'=>$_})->username }
+      @usernum;
 
 </%init>

Index: report_cust_bill_pkg_discount.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cust_bill_pkg_discount.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- report_cust_bill_pkg_discount.html	6 Feb 2010 02:54:10 -0000	1.1
+++ report_cust_bill_pkg_discount.html	15 Aug 2010 07:00:21 -0000	1.2
@@ -5,9 +5,9 @@
 
 <TABLE>
 
-  <% include( '/elements/tr-select-otaker.html',
+  <% include( '/elements/tr-select-user.html',
                 'label'   => 'Discounts by employee: ',
-                'otakers' => \@otakers,
+                'access_user' => \%access_user,
             )
   %>
 
@@ -39,9 +39,12 @@
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
 
-my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_pkg_discount")
+my $sth = dbh->prepare("SELECT DISTINCT usernum FROM cust_pkg_discount")
   or die dbh->errstr;
 $sth->execute or die $sth->errstr;
-my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref};
+my @usernum = map $_->[0], @{$sth->fetchall_arrayref};
+my %access_user =
+  map { $_ => qsearchs('access_user',{'usernum'=>$_})->username }
+      @usernum;
 
 </%init>

Index: cust_pkg_discount.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_pkg_discount.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- cust_pkg_discount.html	6 Feb 2010 02:54:10 -0000	1.1
+++ cust_pkg_discount.html	15 Aug 2010 07:00:21 -0000	1.2
@@ -78,9 +78,9 @@
                ";     #XXX also end date
 }
 
-#otaker
-if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) {
-  push @where, "cust_pkg_discount.otaker = '$1'";
+#usernum
+if ( $cgi->param('usernum') =~ /^(\d+)$/ ) {
+  push @where, "cust_pkg_discount.usernum = $1";
 }
 
 #agent

Index: cust_credit.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_credit.html,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -d -r1.14 -r1.15
--- cust_credit.html	19 May 2008 04:07:02 -0000	1.14
+++ cust_credit.html	15 Aug 2010 07:00:21 -0000	1.15
@@ -56,8 +56,8 @@
 
 my @search = ();
 
-if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) {
-  push @search, "cust_credit.otaker = '$1'";
+if ( $cgi->param('usernum') =~ /^(\d+)$/ ) {
+  push @search, "cust_credit.usernum = $1";
 }
 
 if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) {

Index: report_h_cust_pay.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_h_cust_pay.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- report_h_cust_pay.html	20 May 2010 08:48:51 -0000	1.2
+++ report_h_cust_pay.html	15 Aug 2010 07:00:21 -0000	1.3
@@ -88,7 +88,7 @@
              )
   %>
 
-  <% include( '/elements/tr-select-otaker.html' ) %>
+  <% include( '/elements/tr-select-user.html' ) %>
 
   <TR>
     <TD ALIGN="right" VALIGN="center">Payment</TD>



More information about the freeside-commits mailing list