X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=ba7d4e368bd4b95ce551edfd9bb6f03d81a68071;hb=16c3fc46b67dc42c0404fc93aa54ce61be5f08f9;hp=509fb294dc52882a6e0f99c6ed6cdcc70a8b3e48;hpb=56ce4169e37654f4f1a8784b7125954d81828c2d;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 509fb294d..ba7d4e368 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,4 +1,7 @@ +%my $curuser = $FS::CurrentUser::CurrentUser; % +%die "access denied" +% unless $curuser->access_right('List customers'); % %my $conf = new FS::Conf; %my $maxrecords = $conf->config('maxsearchrecordsperpage'); @@ -61,8 +64,13 @@ % if ( $cgi->param('browse') ) { % my $query = $cgi->param('browse'); % if ( $query eq 'custnum' ) { -% $sortby=\*custnum_sort; -% $orderby = "ORDER BY custnum"; +% if ( $conf->exists('cust_main-default_agent_custid') ) { +% $sortby=\*display_custnum_sort; +% $orderby = "ORDER BY CASE WHEN agent_custid IS NOT NULL AND agent_custid != '' THEN CAST(agent_custid AS BIGINT) ELSE custnum END"; +% } else { +% $sortby=\*custnum_sort; +% $orderby = "ORDER BY custnum"; +% } % } elsif ( $query eq 'last' ) { % $sortby=\*last_sort; % $orderby = "ORDER BY LOWER(last || ' ' || first)"; @@ -75,6 +83,10 @@ % push @select, FS::TicketSystem->sql_num_customer_tickets. " as tickets"; % push @addl_headers, 'Tickets'; % push @addl_cols, 'tickets'; +% } elsif ( $query eq 'uspsunvalid' ) { +% $search{'country'} = 'US'; +% $sortby=\*custnum_sort; +% $orderby = "ORDER BY custnum"; % } else { % die "unknown browse field $query"; % } @@ -84,10 +96,12 @@ % } % % if ( $cgi->param('otaker_on') ) { -% $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; +% die "access denied" +% unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +% $cgi->param('otaker') =~ /^(\w{1,32})$/ or errorpage("Illegal otaker"); % $search{otaker} = $1; % } elsif ( $cgi->param('agentnum_on') ) { -% $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; +% $cgi->param('agentnum') =~ /^(\d+)$/ or errorpage("Illegal agentnum"); % $search{agentnum} = $1; %# } else { %# die "unknown query..."; @@ -122,6 +136,10 @@ % $addl_qual .= ( $addl_qual ? ' AND ' : '' ). % $FS::CurrentUser::CurrentUser->agentnums_sql; % +% if ( $cgi->param('browse') && $cgi->param('browse') eq 'uspsunvalid' ) { +% $addl_qual .= ' AND ( length(zip) < 9 OR upper(address1) != address1 OR upper(city) != city ) '; +% } +% % if ( $addl_qual ) { % $qual .= ' AND ' if $qual; % $qual .= $addl_qual; @@ -194,7 +212,9 @@ % if ( $cgi->param('search_cust') ) { % $sortby = \*company_sort; % $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; -% push @cust_main, smart_search( 'search' => $cgi->param('search_cust') ); +% push @cust_main, smart_search( 'search' => $cgi->param('search_cust'), +% 'no_fuzzy_on_exact' => 1, #pref? +% ); % } % % @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main @@ -229,7 +249,7 @@ % -% eidiot "No matching customers found!\n"; +% errorpage("No matching customers found!"); %} else { % @@ -238,33 +258,13 @@ <% $total %> matching customers found -% -% #begin pager -% my $pager = ''; -% if ( $total != scalar(@cust_main) && $maxrecords ) { -% unless ( $offset == 0 ) { -% $cgi->param('offset', $offset - $maxrecords); -% $pager .= 'Previous '; -% } -% my $poff; -% my $page; -% for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { -% $page++; -% if ( $offset == $poff ) { -% $pager .= qq!$page !; -% } else { -% $cgi->param('offset', $poff); -% $pager .= qq!$page !; -% } -% } -% unless ( $offset + $maxrecords > $total ) { -% $cgi->param('offset', $offset + $maxrecords); -% $pager .= 'Next '; -% } -% } -% #end pager + +% my $pager = include( '/elements/pager.html', +% 'offset' => $offset, +% 'num_rows' => scalar(@cust_main), +% 'total' => $total, +% 'maxrecords' => $maxrecords, +% ); % % unless ( $cgi->param('cancelled') ) { % if ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me @@ -280,12 +280,12 @@ % $cgi->param('offset', 0); % print qq!( hide!; % } -% print ' cancelled customers )'; +% print ' canceled customers )'; % } % % if ( $cgi->param('referral_custnum') ) { % $cgi->param('referral_custnum') =~ /^(\d+)$/ -% or eidiot "Illegal referral_custnum\n"; +% or errorpage("Illegal referral_custnum"); % my $referral_custnum = $1; % my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); % print '
'. @@ -305,7 +305,7 @@ % print '