Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / search / elements / cust_pay_or_refund.html
index d691aeb..187fc83 100755 (executable)
@@ -226,7 +226,7 @@ push @links, '';
 push @fields, sub { time2str('%b %d %Y', shift->_date ) };
 push @sort_fields, '_date';
 
-if ($opt{'show_order_number'}) {
+if ($cgi->param('show_order_number')) {
   push @header, emt('Order Number');
   $align .= 'r';
   push @links, '';
@@ -348,6 +348,13 @@ if ( $cgi->param('magic') ) {
 
     }
 
+    if ( $cgi->param('paymask') ) {
+      $cgi->param('paymask') =~ /^\s*(\d+)\s*$/
+        or die "illegal paymask ". $cgi->param('paymask');
+      my $regexp = regexp_sql();
+      push @search, "$table.paymask $regexp '$1\$'";
+    } 
+
     if ( $cgi->param('payinfo') ) {
       $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/
         or die "illegal payinfo ". $cgi->param('payinfo');
@@ -455,6 +462,19 @@ if ( $cgi->param('magic') ) {
     }
   }
 
+  #check for customer tags
+  my @tags;
+  foreach my $p (keys $cgi->Vars) {
+    if ($p =~ /^tagnum(\d+)/ && $1) {
+      $addl_from .= " LEFT JOIN cust_tag ON (cust_tag.custnum = cust_pay.custnum)" unless @tags;
+      push @tags, $1;
+    }
+  }
+  if (@tags) {
+    my $tags = join(',',@tags);
+    push @search, "cust_tag.tagnum in ($tags)";
+  }
+
   if ( $cgi->param('tax_names') ) {
     if ( dbh->{Driver}->{Name} =~ /^Pg/i ) {