remove extraneous "
[freeside.git] / httemplate / search / cust_pay.cgi
index 2106a64..0247b0b 100755 (executable)
@@ -17,7 +17,7 @@
      
        if ( $cgi->param('payby') ) {
          $cgi->param('payby') =~
-           /^(CARD|CHEK|BILL|PREP|CASH|WEST)(-(VisaMC|Amex|Discover|Maestro))?$/
+           /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/
              or die "illegal payby ". $cgi->param('payby');
          push @search, "cust_pay.payby = '$1'";
          if ( $3 ) {
                " ) ";
            } elsif ( $3 eq 'Discover' ) {
              push @search,
-               "    substring(cust_pay.payinfo from 1 for 4 ) = '6011'  ".
-               " OR substring(cust_pay.payinfo from 1 for 3 ) = '650'   ";
+               " (    substring(cust_pay.payinfo from 1 for 4 ) = '6011'  ".
+               "   OR substring(cust_pay.payinfo from 1 for 3 ) = '650'   ".
+               " ) ";
            } elsif ( $3 eq 'Maestro' ) { 
              push @search,
                " (    substring(cust_pay.payinfo from 1 for 2 ) = '63'     ".
-               '   OR substring(cust_pay.payinfo from 1 for 2 ) = '67'     ".
-               '   OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ".
+               "   OR substring(cust_pay.payinfo from 1 for 2 ) = '67'     ".
+               "   OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ".
                "   OR substring(cust_pay.payinfo from 1 for 4 ) = '4936'   ".
                "   OR substring(cust_pay.payinfo from 1 for 6 )            ".
                "      SIMILAR TO '49030[2-9]'                             ".
        die "unknown search magic: ". $cgi->param('magic');
      }
 
-     my $search = '';
-     if ( @search ) {
-       $search = ' WHERE '. join(' AND ', @search);
-     }
+     #here is the agent virtualization
+     push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
+
+     my $search = ' WHERE '. join(' AND ', @search);
   
      $count_query = "SELECT COUNT(*), SUM(paid) ".
                     "FROM cust_pay LEFT JOIN cust_main USING ( custnum )".
      $cgi->param('payby') =~ /^(\w+)$/ or die "illegal payby";
      my $payby = $1;
    
-     $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay ".
-                    "WHERE payinfo = '$payinfo' AND payby = '$payby'";
+     $count_query = "SELECT COUNT(*), SUM(paid) FROM cust_pay".
+                    "  WHERE payinfo = '$payinfo' AND payby = '$payby'".
+                    "  AND ". $FS::CurrentUser::CurrentUser->agentnums_sql;
    
      $sql_query = {
        'table'     => 'cust_pay',
        'hashref'   => { 'payinfo' => $payinfo,
                         'payby'   => $payby    },
-       'extra_sql' => "ORDER BY _date",
+       'extra_sql' => $FS::CurrentUser::CurrentUser->agentnums_sql.
+                      " ORDER BY _date",
      };
    
    }
                        'Cash '. $cust_pay->payinfo;
                      } elsif ( $cust_pay->payby eq 'WEST' ) {
                        'Western Union'; #. $cust_pay->payinfo;
+                     } elsif ( $cust_pay->payby eq 'MCRD' ) {
+                       'Manual credit card'; #. $cust_pay->payinfo;
                      } else {
                        $cust_pay->payby. ' '. $cust_pay->payinfo;
                      }