include elements/search.html the right way to avoid problems with XLS download, ...
[freeside.git] / httemplate / search / cust_pkg_discount.html
index 233345e..23af180 100644 (file)
@@ -1,4 +1,4 @@
-<% include( 'elements/search.html',
+<& elements/search.html,
                   'title'       => 'Package discounts', 
                   'name'        => 'discounts',
                   'query'       => $query,
@@ -50,8 +50,8 @@
                                      '',
                                      FS::UI::Web::cust_styles(),
                                    ],
-           )
-%>
+           
+&>
 <%init>
 
 die "access denied"
@@ -78,9 +78,9 @@ if ( $cgi->param('status') eq 'active' ) {
                ";     #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
@@ -92,8 +92,8 @@ my $count_query = "SELECT COUNT(*), SUM(amount)";
 
 my $join = ' LEFT JOIN discount  USING ( discountnum )
              LEFT JOIN cust_pkg  USING ( pkgnum )
-             LEFT JOIN part_pkg  USING ( pkgpart )
-             LEFT JOIN cust_main USING ( custnum ) ';
+             LEFT JOIN part_pkg  USING ( pkgpart ) '.
+             FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg');
 
 my $where = ' WHERE '. join(' AND ', @where);