fix brainfart parsing end dates, closes: Bug#1248
[freeside.git] / FS / FS / UI / Web.pm
index 716fd86..18e841e 100644 (file)
@@ -1,5 +1,6 @@
 package FS::UI::Web;
 
+use vars qw($DEBUG);
 use FS::Conf;
 use FS::Record qw(dbdef);
 
@@ -11,12 +12,20 @@ use Date::Parse;
 sub parse_beginning_ending {
   my($cgi) = @_;
 
-  $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
-  my $beginning = str2time($1) || 0;
+  my $beginning = 0;
+  if ( $cgi->param('begin') =~ /^(\d+)$/ ) {
+    $beginning = $1;
+  } elsif ( $cgi->param('beginning') =~ /^([ 0-9\-\/]{1,64})$/ ) {
+    $beginning = str2time($1) || 0;
+  }
 
-  #need an option to turn off the + 86399 ???
-  $cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
-  my $ending =  ( $1 ? str2time($1) : 4294880896 ) + 86399;
+  my $ending = 4294967295; #2^32-1
+  if ( $cgi->param('end') =~ /^(\d+)$/ ) {
+    $ending = $1 - 1;
+  } elsif ( $cgi->param('ending') =~ /^([ 0-9\-\/]{1,64})$/ ) {
+    #probably need an option to turn off the + 86399
+    $ending = str2time($1) + 86399;
+  }
 
   ( $beginning, $ending );
 }
@@ -76,7 +85,7 @@ sub cust_header {
     warn "  no cust-fields configuration value found; using default 'Customer'"
       if $DEBUG;
     @cust_header = ( 'Customer' );
-    @cust_fields = ( 'cust_name' );
+    @cust_fields = ( 'name' );
   }
 
   #my $svc_x = shift;