X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fgraph%2Fsignupdate.cgi;h=823ddb89f27b4e2aefea752538ffd71529b45bb9;hp=5b70758682af41ba107e1f94eeada55470fd8aeb;hb=f822e27a1e00594332ffa487a1c284234c5580a6;hpb=624b2d44625f69d71175c3348cae635d580c890b diff --git a/httemplate/graph/signupdate.cgi b/httemplate/graph/signupdate.cgi index 5b7075868..823ddb89f 100644 --- a/httemplate/graph/signupdate.cgi +++ b/httemplate/graph/signupdate.cgi @@ -32,22 +32,24 @@ my @count = (0) x 24; my %where; $where{'agentnum'} = $agentnum if $agentnum; $where{'usernum'} = $usernum if $usernum; -my $sdate = $cgi->param('start_year'). - '-'. - $cgi->param('start_month'). - '-01'; -my $edate = ($cgi->param('end_year') + - ($cgi->param('end_month')==12)). - '-'. - ($cgi->param('end_month') % 12 + 1). - '-01'; # first day of the next month - -my $sql = "AND signupdate >= ".str2time($sdate). - " AND signupdate < ".str2time($edate); - -foreach my $cust (qsearch({ table => 'cust_main', + +my $sdate = DateTime->new( + year => scalar($cgi->param('start_year')), + month => scalar($cgi->param('start_month')), +)->epoch(); + +my $edate = DateTime->new( + year => scalar($cgi->param('end_year')), + month => scalar($cgi->param('end_month')), +)->add( months => 1 )->epoch(); + +my $where = (%where ? ' AND ' : ' WHERE '); +$where .= " signupdate >= $sdate ". + " AND signupdate < $edate "; + +foreach my $cust (qsearch({ table => 'cust_main', hashref => \%where, - extra_sql => $sql } )) { + extra_sql => $where } )) { next if !$cust->signupdate; my $hour = time2str('%H',$cust->signupdate); $count[$hour]++;