X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fsvc_acct.cgi;h=9ccac5dd76d47f3fed0d6149eb88fb5dc9f24335;hb=4ddf9e2e9a5552306c3d95cb85a44586367f58c4;hp=ef68ba05e1f7352411c83e10ba014f40c6520dbd;hpb=c0e8da2f1e89729efa1032241e4239765a296514;p=freeside.git diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index ef68ba05e..9ccac5dd7 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,23 +1,80 @@ -<% - -my $orderby = 'ORDER BY svcnum'; +<% include( 'elements/search.html', + 'title' => 'Account Search Results', + 'name' => 'accounts', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Service', + 'Account', + 'UID', + FS::UI::Web::cust_header(), + ], + 'fields' => [ 'svcnum', + 'svc', + 'email', + 'uid', + \&FS::UI::Web::cust_fields, + ], + 'links' => [ $link, + $link, + $link, + $link, + ( map { $_ ne 'Cust. Status' ? $link_cust : '' } + FS::UI::Web::cust_header() + ), + ], + 'align' => 'rlll'. FS::UI::Web::cust_aligns(), + 'color' => [ + '', + '', + '', + '', + FS::UI::Web::cust_colors(), + ], + 'style' => [ + '', + '', + '', + '', + FS::UI::Web::cust_styles(), + ], + ) +%> +<%init> -my($query)=$cgi->keywords; -$query ||= ''; #to avoid use of unitialized value errors +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List services'); my @extra_sql = (); -if ( $query =~ /^UN_(.*)$/ ) { - $query = $1; - push @extra_sql, 'pkgnum IS NULL'; -} -if ( $query eq 'svcnum' ) { - #$orderby = "ORDER BY svcnum"; -} elsif ( $query eq 'username' ) { - $orderby = "ORDER BY LOWER(username)"; -} elsif ( $query eq 'uid' ) { - $orderby = "ORDER BY uid"; - push @extra_sql, "uid IS NOT NULL"; + if ( $cgi->param('domain') ) { + my $svc_domain = + qsearchs('svc_domain', { 'domain' => $cgi->param('domain') } ); + unless ( $svc_domain ) { + #it would be nice if this looked more like the other "not found" + #errors, but this will do for now. + eidiot "Domain ". $cgi->param('domain'). " not found at all"; + } else { + push @extra_sql, 'domsvc = '. $svc_domain->svcnum; + } + } + +my $orderby = 'ORDER BY svcnum'; +if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { + + push @extra_sql, 'pkgnum IS NULL' + if $cgi->param('magic') eq 'unlinked'; + + if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { + my $sortby = $1; + $sortby = "LOWER($sortby)" + if $sortby eq 'username'; + push @extra_sql, "$sortby IS NOT NULL" + if $sortby eq 'uid' || $sortby eq 'seconds'; + $orderby = "ORDER BY $sortby"; + } + } elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { push @extra_sql, "popnum = $1"; $orderby = "ORDER BY LOWER(username)"; @@ -75,7 +132,9 @@ my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. ' LEFT JOIN cust_main USING ( custnum ) '; #here is the agent virtualization -push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; +push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'View/link unlinked services' + ); my $extra_sql = scalar(@extra_sql) @@ -95,6 +154,7 @@ my $sql_query = { 'hashref' => {}, # \%svc_acct, 'select' => join(', ', 'svc_acct.*', + 'part_svc.svc', 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), @@ -112,31 +172,5 @@ my $link_cust = sub { } }; -%><%= include( 'elements/search.html', - 'title' => 'Account Search Results', - 'name' => 'accounts', - 'query' => $sql_query, - 'count_query' => $count_query, - 'redirect' => $link, - 'header' => [ '#', - 'Service', - 'Account', - 'UID', - FS::UI::Web::cust_header(), - ], - 'fields' => [ 'svcnum', - 'svc', - 'email', - 'uid', - \&FS::UI::Web::cust_fields, - ], - 'links' => [ $link, - $link, - $link, - $link, - ( map { $link_cust } - FS::UI::Web::cust_header() - ), - ], - ) -%> + +