1 <% include('elements/report.html',
2 'title' => $agentname . 'Customer signups by time of day',
3 'items' => [ 'signupdate' ],
5 'row_labels' => [ 'New customers' ],
6 'colors' => [ '00cc00' ], #green
7 'col_labels' => [ map { "$_:00" } @hours ],
8 'links' => [ \@links ],
9 'graph_type' => 'Bars',
17 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
20 my( $agentnum, $agent ) = ('', '');
21 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
23 $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
24 die "agentnum $agentnum not found!" unless $agent;
27 my $agentname = $agent ? $agent->agent.' ' : '';
28 my $usernum = $cgi->param('usernum');
33 $where{'agentnum'} = $agentnum if $agentnum;
34 $where{'usernum'} = $usernum if $usernum;
35 my $sdate = $cgi->param('start_year').
37 $cgi->param('start_month').
39 my $edate = ($cgi->param('end_year') +
40 ($cgi->param('end_month')==12)).
42 ($cgi->param('end_month') % 12 + 1).
43 '-01'; # first day of the next month
45 my $sql = "AND signupdate >= ".str2time($sdate).
46 " AND signupdate < ".str2time($edate);
48 foreach my $cust (qsearch({ table => 'cust_main',
50 extra_sql => $sql } )) {
51 next if !$cust->signupdate;
52 my $hour = time2str('%H',$cust->signupdate);
56 my @links = ("${p}search/cust_main.html?" .
57 join (';', map {$_.'='.$where{$_}} (keys(%where))) ).
58 ";signupdate_beginning=$sdate;signupdate_ending=$edate";
59 push @links, map { ";signuphour=$_" } @hours;