default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / graph / signupdate.cgi
index 23e4596..823ddb8 100644 (file)
@@ -34,19 +34,20 @@ $where{'agentnum'} = $agentnum if $agentnum;
 $where{'usernum'}   = $usernum if $usernum;
 
 my $sdate = DateTime->new(
-    year       => $cgi->param('start_year'),
-    month      => $cgi->param('start_month'),
+    year       => scalar($cgi->param('start_year')),
+    month      => scalar($cgi->param('start_month')),
 )->epoch();
 
 my $edate = DateTime->new(
-    year       => $cgi->param('end_year'),
-    month      => ($cgi->param('end_month') % 12 + 1) # first day of the next month
-)->epoch();
+    year       => scalar($cgi->param('end_year')),
+    month      => scalar($cgi->param('end_month')),
+)->add( months => 1 )->epoch();
 
-my $where .= " AND signupdate >= $sdate ".
-             " AND signupdate <= $edate ";
+my $where = (%where ? ' AND ' : ' WHERE ');
+$where .= " signupdate >= $sdate ".
+          " AND signupdate < $edate ";
 
-foreach my $cust (qsearch({ table   => 'cust_main', 
+foreach my $cust (qsearch({ table   => 'cust_main',
                             hashref => \%where,
                             extra_sql => $where } )) {
   next if !$cust->signupdate;