add less than and greater than amounts to credit and payment searches
authorivan <ivan>
Fri, 24 Nov 2006 08:49:09 +0000 (08:49 +0000)
committerivan <ivan>
Fri, 24 Nov 2006 08:49:09 +0000 (08:49 +0000)
FS/FS/UI/Web.pm
httemplate/elements/tr-input-beginning_ending.html
httemplate/elements/tr-input-lessthan_greaterthan.html [new file with mode: 0644]
httemplate/search/cust_credit.html
httemplate/search/cust_pay.cgi
httemplate/search/report_cust_credit.html
httemplate/search/report_cust_pay.html

index 080ac6e..c9eaf50 100644 (file)
@@ -32,6 +32,38 @@ sub parse_beginning_ending {
   ( $beginning, $ending );
 }
 
   ( $beginning, $ending );
 }
 
+sub parse_lt_gt {
+  my($cgi, $field) = @_;
+
+  my @search = ();
+
+  my %op = ( 
+    'lt' => '<',
+    'gt' => '>',
+  );
+
+  foreach my $op (keys %op) {
+
+    warn "checking for ${field}_$op field\n"
+      if $DEBUG;
+
+    if ( $cgi->param($field."_$op") =~ /^\s*\$?\s*([\d\,\s]+(\.\d\d)?)\s*$/ ) {
+
+      my $num = $1;
+      $num =~ s/[\,\s]+//g;
+      my $search = "$field $op{$op} $num";
+      push @search, $search;
+
+      warn "found ${field}_$op field; adding search element $search\n"
+        if $DEBUG;
+    }
+
+  }
+
+  @search;
+
+}
+
 ###
 # cust_main report subroutines
 ###
 ###
 # cust_main report subroutines
 ###
index a8ab6ed..397f749 100644 (file)
@@ -5,7 +5,7 @@
 
 
 <TR>
 
 
 <TR>
-  <TD ALIGN="right">From: </TD>
+  <TD ALIGN="right">From date: </TD>
   <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=<%$size%> MAXLENGTH=<%$maxlength%>> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y<% $time_hint %></i></TD>
 <SCRIPT TYPE="text/javascript">
   Calendar.setup({
   <TD><INPUT TYPE="text" NAME="beginning" ID="beginning_text" VALUE="" SIZE=<%$size%> MAXLENGTH=<%$maxlength%>> <IMG SRC="../images/calendar.png" ID="beginning_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y<% $time_hint %></i></TD>
 <SCRIPT TYPE="text/javascript">
   Calendar.setup({
@@ -19,7 +19,7 @@
 </TR>
 
 <TR>
 </TR>
 
 <TR>
-  <TD ALIGN="right">To: </TD>
+  <TD ALIGN="right">To date: </TD>
   <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=<%$size%> MAXLENGTH=<%$maxlength%>> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y<% $time_hint %></i></TD>
 <SCRIPT TYPE="text/javascript">
   Calendar.setup({
   <TD><INPUT TYPE="text" NAME="ending" ID="ending_text" VALUE="" SIZE=<%$size%> MAXLENGTH=<%$maxlength%>> <IMG SRC="../images/calendar.png" ID="ending_button" STYLE="cursor: pointer" TITLE="Select date"><BR><i>m/d/y<% $time_hint %></i></TD>
 <SCRIPT TYPE="text/javascript">
   Calendar.setup({
diff --git a/httemplate/elements/tr-input-lessthan_greaterthan.html b/httemplate/elements/tr-input-lessthan_greaterthan.html
new file mode 100644 (file)
index 0000000..16c2ed9
--- /dev/null
@@ -0,0 +1,13 @@
+<TR>
+  <TD ALIGN="right"><% $opt{label} %> less than: </TD>
+  <TD><INPUT TYPE="text" NAME="<% $opt{field} %>_lt" SIZE=7></TD>
+</TR>
+
+<TR>
+  <TD ALIGN="right"><% $opt{label} %> greater than: </TD>
+  <TD><INPUT TYPE="text" NAME="<% $opt{field} %>_gt" SIZE=7></TD>
+</TR>
+
+<%init>
+  my %opt = @_;
+</%init>
index 80cfc45..c52394a 100755 (executable)
 %     $title = $agent->agent. " $title";
 %   }
 %
 %     $title = $agent->agent. " $title";
 %   }
 %
-%   #false laziness with cust_pkg.cgi and cust_pay.cgi
-%   if ( $cgi->param('beginning')
-%        && $cgi->param('beginning') =~ /^([ 0-9\-\/]{1,10})$/ ) {
-%     my $beginning = str2time($1);
-%     push @search, "_date >= $beginning ";
-%   }
-%   if ( $cgi->param('ending')
-%             && $cgi->param('ending') =~ /^([ 0-9\-\/]{1,10})$/ ) {
-%     my $ending = str2time($1) + 86399;
-%     push @search, " _date <= $ending ";
-%   }
+%   my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
+%   push @search, "_date >= $beginning ",
+%                 "_date <= $ending";
 %
 %
-%   if ( $cgi->param('begin')
-%        && $cgi->param('begin') =~ /^(\d+)$/ ) {
-%     push @search, "_date >= $1 ";
-%   }
-%   if ( $cgi->param('end')
-%             && $cgi->param('end') =~ /^(\d+)$/ ) {
-%     push @search, " _date < $1 ";
-%   }
+%   push @search, FS::UI::Web::parse_lt_gt($cgi, 'amount' );
 %
 %   #here is the agent virtualization
 %   push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
 %
 %   #here is the agent virtualization
 %   push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
index 0664bf7..87da179 100755 (executable)
@@ -80,6 +80,8 @@
 %       my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
 %       push @search, "_date >= $beginning ",
 %                     "_date <= $ending";
 %       my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
 %       push @search, "_date >= $beginning ",
 %                     "_date <= $ending";
+%
+%       push @search, FS::UI::Web::parse_lt_gt($cgi, 'paid' );
 %  
 %       $orderby = '_date';
 %   
 %  
 %       $orderby = '_date';
 %   
index 96c0b5a..ab48102 100644 (file)
@@ -6,30 +6,31 @@
 <TABLE>
   <TR>
     <TD ALIGN="right">Credits by employee: </TD>
 <TABLE>
   <TR>
     <TD ALIGN="right">Credits by employee: </TD>
-%
-%  my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit")
-%    or die dbh->errstr;
-%  $sth->execute or die $sth->errstr;
-%  my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref};
-%
 
 
-
-    <TD><SELECT NAME="otaker">
-          <OPTION VALUE="">all</OPTION>
-% foreach my $otaker ( @otakers ) { 
-
-            <OPTION VALUE="<% $otaker %>"><% $otaker %></OPTION>
-% } 
-
-        </SELECT>
+    <TD>
+      <SELECT NAME="otaker">
+        <OPTION VALUE="">all</OPTION>
+%       foreach my $otaker ( @otakers ) { 
+          <OPTION VALUE="<% $otaker %>"><% $otaker %></OPTION>
+%       } 
+      </SELECT>
     </TD>
   </TR>
     </TD>
   </TR>
+
   <% include( '/elements/tr-select-agent.html',
                  $cgi->param('agentnum'),
                  'label' => 'for agent: ',
              )
   %>
   <% include( '/elements/tr-select-agent.html',
                  $cgi->param('agentnum'),
                  'label' => 'for agent: ',
              )
   %>
+
   <% include( '/elements/tr-input-beginning_ending.html' ) %>
   <% include( '/elements/tr-input-beginning_ending.html' ) %>
+
+  <% include( '/elements/tr-input-lessthan_greaterthan.html',
+                'label' => 'Amount',
+               'field' => 'amount',
+            )
+  %>
+
 </TABLE>
 
 <BR>
 </TABLE>
 
 <BR>
 </FORM>
 
 <% include('/elements/footer.html') %>
 </FORM>
 
 <% include('/elements/footer.html') %>
+
+<%init>
+
+my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit")
+  or die dbh->errstr;
+$sth->execute or die $sth->errstr;
+my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref};
+
+</%init>
index a3e43f8..90c5d25 100644 (file)
 
   <% include( '/elements/tr-input-beginning_ending.html' ) %>
 
 
   <% include( '/elements/tr-input-beginning_ending.html' ) %>
 
+  <% include( '/elements/tr-input-lessthan_greaterthan.html',
+                'label' => 'Amount',
+               'field' => 'paid',
+            )
+  %>
+
 </TABLE>
 
 <BR>
 </TABLE>
 
 <BR>