X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_main.cgi;h=c72ab44df191ea25753689ef968bb1a19424bf20;hb=a0732f52fdcc2bca7c399d1249ccceb191de51cd;hp=10746e7e3da78dc29bafba1fb38763af66863780;hpb=2bb260ad6df6a86dc24d0678cf42181fe25e07e7;p=freeside.git diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 10746e7e3..c72ab44df 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -57,6 +57,7 @@ if ( $cgi->param('browse') ) { my %search = (); + if ( $cgi->param('browse') ) { my $query = $cgi->param('browse'); if ( $query eq 'custnum' ) { @@ -80,15 +81,16 @@ if ( $cgi->param('browse') } else { $sortby = \*last_sort; #?? $orderby = "ORDER BY LOWER(last || ' ' || first)"; #?? - if ( $cgi->param('otaker_on') ) { - $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; - $search{otaker} = $1; - } elsif ( $cgi->param('agentnum_on') ) { - $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; - $search{agentnum} = $1; - } else { - die "unknown query..."; - } + } + + if ( $cgi->param('otaker_on') ) { + $cgi->param('otaker') =~ /^(\w{1,32})$/ or eidiot "Illegal otaker\n"; + $search{otaker} = $1; + } elsif ( $cgi->param('agentnum_on') ) { + $cgi->param('agentnum') =~ /^(\d+)$/ or eidiot "Illegal agentnum\n"; + $search{agentnum} = $1; +# } else { +# die "unknown query..."; } my @qual = (); @@ -100,23 +102,14 @@ if ( $cgi->param('browse') && ! $cgi->param('showcancelledcustomers') ) ) { #grep { $_->ncancelled_pkgs || ! $_->all_pkgs } - push @qual, " - ( 0 < ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 - ) - ) - OR 0 = ( SELECT COUNT(*) FROM cust_pkg - WHERE cust_pkg.custnum = cust_main.custnum - ) - ) - "; + push @qual, FS::cust_main->uncancel_sql; + } push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled'); push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect'); push @qual, FS::cust_main->active_sql if $cgi->param('active'); + push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive'); push @qual, FS::cust_main->susp_sql if $cgi->param('suspended'); #EWWWWWW @@ -125,6 +118,10 @@ if ( $cgi->param('browse') my $addl_qual = join(' AND ', @qual); + #here is the agent virtualization + $addl_qual .= ( $addl_qual ? ' AND ' : '' ). + $FS::CurrentUser::CurrentUser->agentnums_sql; + if ( $addl_qual ) { $qual .= ' AND ' if $qual; $qual .= $addl_qual; @@ -194,6 +191,13 @@ if ( $cgi->param('browse') push @cust_main, @{&companysearch}; } + if ( $cgi->param('search_cust') ) { + $sortby = \*company_sort; + $orderby = "ORDER BY LOWER(company || ' ' || last || ' ' || first )"; + warn "smart searching for: ". $cgi->param('search_cust'); + push @cust_main, smart_search( 'search' => $cgi->param('search_cust') ); + } + @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main if ! $cgi->param('cancelled') && ( @@ -228,14 +232,13 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { eidiot "No matching customers found!\n"; } else { %> - -<% +<%= include('/elements/header.html', "Customer Search Results", '' ) %> + + <% $total ||= scalar(@cust_main); %> - $total ||= scalar(@cust_main); - print header("Customer Search Results",menubar( - 'Main Menu', popurl(2) - )), "$total matching customers found "; + <%= $total %> matching customers found + <% #begin pager my $pager = ''; if ( $total != scalar(@cust_main) && $maxrecords ) { @@ -285,7 +288,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { or eidiot "Illegal referral_custnum\n"; my $referral_custnum = $1; my $cust_main = qsearchs('cust_main', { custnum => $referral_custnum } ); - print '
'. + print ''. qq!!. 'referrals of $referral_custnum: ". @@ -322,34 +325,45 @@ END $conf->config('ticket_system-custom_priority_field-values'); } - print "

". $pager. &table(). <
". $pager. include('/elements/table-grid.html'). < - - (bill) name - company + + (bill) name + company END if ( defined dbdef->table('cust_main')->column('ship_last') ) { print <(service) name - company + (service) name + company END } foreach my $addl_header ( @addl_headers ) { - print "$addl_header"; + print ''. "$addl_header"; } print <Packages - Services + Packages + Services END + my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor; + my(%saw,$cust_main); foreach $cust_main ( sort $sortby grep(!$saw{$_->custnum}++, @cust_main) ) { + + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + my($custnum,$last,$first,$company)=( $cust_main->custnum, $cust_main->getfield('last'), @@ -376,12 +390,14 @@ END my $pcompany = $company ? qq!
$company! : ' '; - print < + - $custnum - $last, $first - $pcompany -END + ><%= $custnum %> + ><%= "$last, $first" %> + ><%= $pcompany %> + + <% if ( defined dbdef->table('cust_main')->column('ship_last') ) { my($ship_last,$ship_first,$ship_company)=( $cust_main->ship_last || $cust_main->getfield('last'), @@ -391,54 +407,87 @@ END my $pship_company = $ship_company ? qq!$ship_company! : ' '; - print <$ship_last, $ship_first - $pship_company -END - } + %> - foreach my $addl_col ( @addl_cols ) { - print ""; - if ( $addl_col eq 'tickets' ) { - if ( @custom_priorities ) { - print &itable('', 0); - foreach my $priority ( @custom_priorities, '' ) { - - my $num = - FS::TicketSystem->num_customer_tickets($custnum,$priority); - my $ahref = ''; - $ahref= '' - if $num; - - print ''. - " $ahref$num". - "$ahref". - ( $priority || '(none)' ). - ""; - - } - print ''. - ''; - } - - my $ahref = ''; - my $ahref = '' - if $cust_main->get($addl_col); - - print $ahref. $cust_main->get($addl_col). ''; - print "". - "${ahref}Total". - "" - if @custom_priorities; + ><%= "$ship_last, $ship_first" %> + ><%= $pship_company %> - } else { - print $cust_main->get($addl_col); + <% } + + foreach my $addl_col ( @addl_cols ) { %> + + <% if ( $addl_col eq 'tickets' ) { %> + + <% if ( @custom_priorities ) { %> + + ALIGN=right> + + + + <% foreach my $priority ( @custom_priorities, '' ) { %> + + <% + my $num = + FS::TicketSystem->num_customer_tickets($custnum,$priority); + my $ahref = ''; + $ahref= '' + if $num; + %> + + + + + + + <% } %> + + + + +
+ <%= $ahref.$num %> + + <%= $ahref %><%= $priority || '(none)' %> +
+ + + <% } else { %> + + ALIGN=right> + + <% } %> + + <% + my $ahref = ''; + $ahref = '' + if $cust_main->get($addl_col); + %> + + <%= $ahref %><%= $cust_main->get($addl_col) %> + + <% if ( @custom_priorities ) { %> + + + + <%= ${ahref} %>Total +
+ + <% } %> + +
+ + } else { %> + + ALIGN=right> + <%= $cust_main->get($addl_col) %> + + +<% } - print "
"; } my($n1)=''; @@ -454,25 +503,40 @@ END #my(@cust_svc) = qsearch( 'cust_svc', { 'pkgnum' => $_->pkgnum } ); my $rowspan = scalar(@cust_svc) || 1; - print $n1, qq!$pkg - $comment!; + print $n1, qq!$pkg - $comment!; + my($n2)=''; foreach my $cust_svc ( @cust_svc ) { my($label, $value, $svcdb) = $cust_svc->label; my($svcnum) = $cust_svc->svcnum; my($sview) = $p.'view'; - print $n2,qq!$label!, - qq!$value!; + print $n2,qq!$label!, + qq!$value!; $n2=""; } + + unless ( @cust_svc ) { + print qq! !; + } + #print qq!\n!; $n1=""; } + + unless ( @{$all_pkgs{$custnum}} ) { + print qq! !; + } + print ""; } + + %> - print "$pager"; + <%= $pager %> -} + <%= include('/elements/footer.html') %> + +<% } #undef $cache; #does this help?