diff options
Diffstat (limited to 'httemplate/search')
-rwxr-xr-x | httemplate/search/cust_main.cgi | 10 | ||||
-rw-r--r-- | httemplate/search/cust_svc.html | 110 | ||||
-rwxr-xr-x | httemplate/search/svc_acct.cgi | 33 | ||||
-rwxr-xr-x | httemplate/search/svc_broadband.cgi | 45 | ||||
-rwxr-xr-x | httemplate/search/svc_domain.cgi | 28 | ||||
-rwxr-xr-x | httemplate/search/svc_external.cgi | 101 | ||||
-rwxr-xr-x | httemplate/search/svc_forward.cgi | 26 | ||||
-rw-r--r-- | httemplate/search/svc_phone.cgi | 20 | ||||
-rwxr-xr-x | httemplate/search/svc_www.cgi | 39 |
9 files changed, 292 insertions, 120 deletions
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 1b6b52675..e15447ae0 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -1,5 +1,3 @@ -% -% %my $conf = new FS::Conf; %my $maxrecords = $conf->config('maxsearchrecordsperpage'); % @@ -486,8 +484,9 @@ % my($label, $value, $svcdb) = $cust_svc->label; % my($svcnum) = $cust_svc->svcnum; % my($sview) = $p.'view'; -% print $n2,qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, -% qq!<TD CLASS="grid" BGCOLOR="$bgcolor" ><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; +% print $n2, +% qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !. +% qq!<TD CLASS="grid" BGCOLOR="$bgcolor" >!. FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) . qq!</TD> !; % $n2="</TR><TR>"; % } % @@ -719,6 +718,3 @@ % % \@cust_main; %} -% -% - diff --git a/httemplate/search/cust_svc.html b/httemplate/search/cust_svc.html new file mode 100644 index 000000000..568b43b18 --- /dev/null +++ b/httemplate/search/cust_svc.html @@ -0,0 +1,110 @@ +<% include( 'elements/search.html', + 'title' => 'Service search results', + 'name' => 'services', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Service', + # package? + FS::UI::Web::cust_header(), + ], + 'fields' => [ 'svcnum', + sub { + #$_[0]->svc. ': '. $_[0]->label; + my($label, $value, $svcdb) = $_[0]->label; + "$label: $value"; + }, + # package? + \&FS::UI::Web::cust_fields, + ], + 'links' => [ $link, + $link, + # package? + ( map { $link_cust } + FS::UI::Web::cust_header() + ), + ], + ) +%> +<%init> + +my $addl_from = ' LEFT JOIN part_svc USING ( svcpart ) '. + ' LEFT JOIN cust_pkg USING ( pkgnum ) '. + ' LEFT JOIN cust_main USING ( custnum ) '; + +my @extra_sql = (); +my $orderby = 'ORDER BY svcnum'; #has to be ordered by something + #for pagination to work +if ( length( $cgi->param('search_svc') ) ) { + + my $string = $cgi->param('search_svc'); + + # implement fuzzy searching in subclasses too at some point? + # service searching maybe shouldn't be fuzzy... + + push @extra_sql, + ' ( '. join(' OR ', + map { my $table = $_; + my $search_sql = "FS::$table"->search_sql($string); + " ( svcdb = '$table' + AND 0 < ( SELECT COUNT(*) FROM $table + WHERE $table.svcnum = cust_svc.svcnum + AND $search_sql + ) + ) "; + } + FS::part_svc->svc_tables + ). ' ) '; + +} elsif ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { + + $cgi->param('svcdb') =~ /^(svc_\w+)$/ or die "unknown svcdb"; + push @extra_sql, "svcdb = '$1'"; + + push @extra_sql, 'pkgnum IS NULL' + if $cgi->param('magic') eq 'unlinked'; + + if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { + my $sortby = $1; + $orderby = "ORDER BY $sortby"; + } + +} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { + + push @extra_sql, "svcpart = $1"; + +} else { + eidiot("No search term specified"); +} + +#here is the agent virtualization +push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; + +my $extra_sql = ' WHERE '. join(' AND ', @extra_sql ); + +my $sql_query = { + 'select' => join(', ', + 'cust_svc.*', + 'part_svc.*', + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), + ), + 'table' => 'cust_svc', + 'addl_from' => $addl_from, + 'hashref' => {}, + 'extra_sql' => "$extra_sql $orderby", +}; + +my $count_query = "SELECT COUNT(*) FROM cust_svc $addl_from $extra_sql"; + +my $link = sub { + my $cust_svc = shift; + my $url = FS::UI::Web::svc_url( + 'm' => $m, + 'action' => 'view', + #'part_svc' => $cust_svc->part_svc, + 'svcdb' => $cust_svc->svcdb, #we have it from the joined search + #'svc' => $cust_svc, #redundant + 'query' => 'svcnum=', + ); diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 2a1414bea..592aa150a 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,15 +1,4 @@ -% -% -%my $orderby = 'ORDER BY svcnum'; -% -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors -% %my @extra_sql = (); -%if ( $query =~ /^UN_(.*)$/ ) { -% $query = $1; -% push @extra_sql, 'pkgnum IS NULL'; -%} % % if ( $cgi->param('domain') ) { % my $svc_domain = @@ -23,13 +12,21 @@ % } % } % -%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"; +%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'; +% $orderby = "ORDER BY $sortby"; +% } +% %} elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { % push @extra_sql, "popnum = $1"; % $orderby = "ORDER BY LOWER(username)"; diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi index ae32ccd7e..297d74c1d 100755 --- a/httemplate/search/svc_broadband.cgi +++ b/httemplate/search/svc_broadband.cgi @@ -1,19 +1,38 @@ -% -% %my $conf = new FS::Conf; % -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors -%my(@svc_broadband,$sortby); -%if ( $query eq 'svcnum' ) { -% $sortby=\*svcnum_sort; -% @svc_broadband=qsearch('svc_broadband',{}); -%} elsif ( $query eq 'blocknum' ) { -% $sortby=\*blocknum_sort; +%my @svc_broadband = (); +%my $sortby=\*svcnum_sort; +%if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { +% % @svc_broadband=qsearch('svc_broadband',{}); -%} else { -% $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; -% my($ip_addr)=$1; +% +% if ( $cgi->param('magic') eq 'unlinked' ) { +% @svc_broadband = grep { qsearchs('cust_svc', { +% 'svcnum' => $_->svcnum, +% 'pkgnum' => '', +% } +% ) +% } +% @svc_broadband; +% } +% +% if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { +% my $sortby = $1; +% if ( $sortby eq 'blocknum' ) { +% $sortby = \*blocknum_sort; +% } +% } +% +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% +% @svc_broadband = +% qsearch( 'svc_broadband', {}, '', +% " WHERE $1 = ( SELECT svcpart FROM cust_svc ". +% " WHERE cust_svc.svcnum = svc_external.svcnum ) " +% ); +% +%} elsif ( $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/ ) { +% my $ip_addr = $1; % @svc_broadband = qsearchs('svc_broadband',{'ip_addr'=>$ip_addr}); %} % diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 85ae94a80..8643ea0dc 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,27 +1,19 @@ -% -% %my $conf = new FS::Conf; % -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors -% %my $orderby = 'ORDER BY svcnum'; %my %svc_domain = (); %my @extra_sql = (); -%if ( $query eq 'svcnum' ) { -% #$orderby = 'ORDER BY svcnum'; -%} elsif ( $query eq 'domain' ) { -% $orderby = 'ORDER BY domain'; -%} elsif ( $query eq 'UN_svcnum' ) { #UN searches need to be acl'ed (and need to -% #fix $agentnums_sql -% #$orderby = 'ORDER BY svcnum'; -% push @extra_sql, 'pkgnum IS NULL'; -%} elsif ( $query eq 'UN_domain' ) { #UN searches need to be acl'ed (and need to -% #fix $agentnums_sql -% $orderby = 'ORDER BY domain'; -% push @extra_sql, 'pkgnum IS NULL'; +%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; +% $orderby = "ORDER BY $sortby"; +% } +% %} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { -% #$orderby = 'ORDER BY svcnum'; % push @extra_sql, "svcpart = $1"; %} else { % $cgi->param('domain') =~ /^([\w\-\.]+)$/; diff --git a/httemplate/search/svc_external.cgi b/httemplate/search/svc_external.cgi index e85d6d7b3..5502bfc25 100755 --- a/httemplate/search/svc_external.cgi +++ b/httemplate/search/svc_external.cgi @@ -1,39 +1,45 @@ -% -% %my $conf = new FS::Conf; % -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors -%my(@svc_external,$sortby); -%if ( $query eq 'svcnum' ) { -% $sortby=\*svcnum_sort; -% @svc_external=qsearch('svc_external',{}); -%} elsif ( $query eq 'id' ) { -% $sortby=\*id_sort; +%my @svc_external = (); +%my @h_svc_external = (); +%my $sortby=\*svcnum_sort; +%if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { +% % @svc_external=qsearch('svc_external',{}); -%} elsif ( $query eq 'UN_svcnum' ) { -% $sortby=\*svcnum_sort; -% @svc_external = grep qsearchs('cust_svc',{ -% 'svcnum' => $_->svcnum, -% 'pkgnum' => '', -% }), qsearch('svc_external',{}); -%} elsif ( $query eq 'UN_id' ) { -% $sortby=\*id_sort; -% @svc_external = grep qsearchs('cust_svc',{ -% 'svcnum' => $_->svcnum, -% 'pkgnum' => '', -% }), qsearch('svc_external',{}); +% +% if ( $cgi->param('magic') eq 'unlinked' ) { +% @svc_external = grep { qsearchs('cust_svc', { +% 'svcnum' => $_->svcnum, +% 'pkgnum' => '', +% } +% ) +% } +% @svc_external; +% } +% +% if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { +% my $sortby = $1; +% if ( $sortby eq 'id' ) { +% $sortby = \*id_sort; +% } +% } +% %} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% % @svc_external = % qsearch( 'svc_external', {}, '', % " WHERE $1 = ( SELECT svcpart FROM cust_svc ". % " WHERE cust_svc.svcnum = svc_external.svcnum ) " % ); -% $sortby=\*svcnum_sort; -%} else { -% $cgi->param('id') =~ /^([\w\-\.]+)$/; -% my($id)=$1; -% #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain}); +% +%} elsif ( $cgi->param('title') =~ /^(.*)$/ ) { +% $sortby=\*id_sort; +% @svc_external=qsearch('svc_external',{ title => $1 }); +% if( $cgi->param('history') == 1 ) { +% @h_svc_external=qsearch('h_svc_external',{ title => $1 }); +% } +%} elsif ( $cgi->param('id') =~ /^([\w\-\.]+)$/ ) { +% my $id = $1; % @svc_external = qsearchs('svc_external',{'id'=>$id}); %} % @@ -84,7 +90,46 @@ % print "</TR>"; % % } -% +% if( scalar(@h_svc_external) > 0 ) { +% print <<HTML; +% </TABLE> +% <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0> +% <TR> +% <TH>Freeside ID</TH> +% <TH>Service #</TH> +% <TH>Title</TH> +% <TH>Date</TH> +% </TR> +%HTML +% +% foreach my $h_svc ( @h_svc_external ) { +% my($svcnum, $id, $title, $user, $date)=( +% $h_svc->svcnum, +% $h_svc->id, +% $h_svc->title, +% $h_svc->history_user, +% $h_svc->history_date, +% ); +% my $rowspan = 1; +% my ($h_cust_svc) = qsearchs( 'h_cust_svc', { +% svcnum => $svcnum, +% }); +% my $cust_pkg = qsearchs( 'cust_pkg', { +% pkgnum => $h_cust_svc->pkgnum, +% }); +% my $custnum = $cust_pkg->custnum; +% +% print <<END; +% <TR> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/cust_main.cgi?$custnum">$custnum</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/cust_main.cgi?$custnum">$svcnum</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/cust_main.cgi?$custnum">$title</A></TD> +% <TD ROWSPAN=$rowspan><A HREF="${p}view/cust_main.cgi?$custnum">$date</A></TD> +% </TR> +%END +% } +% } +% % print <<END; % </TABLE> % </BODY> diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index dc002d96a..4d44c9ca6 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -1,23 +1,19 @@ -% -% %my $conf = new FS::Conf; % -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors +%my $orderby = 'ORDER BY svcnum'; +%my @extra_sql = (); +%if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { % -%my $orderby; +% push @extra_sql, 'pkgnum IS NULL' +% if $cgi->param('magic') eq 'unlinked'; % -%my @extra_sql = (); -%if ( $query =~ /^UN_(.*)$/ ) { #UN searches need to be acl'ed (and need to -% #fix $agentnums_sql -% $query = $1; -% push @extra_sql, 'pkgnum IS NULL'; -%} +% if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { +% my $sortby = $1; +% $orderby = "ORDER BY $sortby"; +% } % -%if ( $query eq 'svcnum' ) { -% $orderby = 'ORDER BY svcnum'; -%} else { -% eidiot('unimplemented'); +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% push @extra_sql, "svcpart = $1"; %} % %my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. diff --git a/httemplate/search/svc_phone.cgi b/httemplate/search/svc_phone.cgi index 26e2090e6..229dd5d89 100644 --- a/httemplate/search/svc_phone.cgi +++ b/httemplate/search/svc_phone.cgi @@ -1,19 +1,19 @@ -% -% %my $conf = new FS::Conf; % -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors -% %my $orderby = 'ORDER BY svcnum'; %my %svc_phone = (); %my @extra_sql = (); -%if ( $query eq 'svcnum' ) { -% #$orderby = 'ORDER BY svcnum'; -%} elsif ( $query eq 'phonenum' ) { -% $orderby = 'ORDER BY phonenum'; +%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; +% $orderby = "ORDER BY $sortby"; +% } +% %} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { -% #$orderby = 'ORDER BY svcnum'; % push @extra_sql, "svcpart = $1"; %} else { % $cgi->param('phonenum') =~ /^([\d\- ]+)$/; diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index b0f1d5c80..ae1482b9f 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -1,16 +1,35 @@ +%#my $conf = new FS::Conf; % +%my $orderby = 'ORDER BY svcnum'; +%my @extra_sql = (); +%if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { % -%#my $conf = new FS::Conf; +% push @extra_sql, 'pkgnum IS NULL' +% if $cgi->param('magic') eq 'unlinked'; % -%my($query)=$cgi->keywords; -%$query ||= ''; #to avoid use of unitialized value errors -%my $orderby; -%if ( $query eq 'svcnum' ) { -% $orderby = 'ORDER BY svcnum'; -%} else { -% eidiot('unimplemented'); +% if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { +% my $sortby = $1; +% $orderby = "ORDER BY $sortby"; +% } +% +%} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { +% push @extra_sql, "svcpart = $1"; %} % +%my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. +% ' LEFT JOIN part_svc USING ( svcpart ) '. +% ' LEFT JOIN cust_pkg USING ( pkgnum ) '. +% ' LEFT JOIN cust_main USING ( custnum ) '; +% +%#here is the agent virtualization +%push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; +% +%my $extra_sql = +% scalar(@extra_sql) +% ? ' WHERE '. join(' AND ', @extra_sql ) +% : ''; +% +% %my $count_query = 'SELECT COUNT(*) FROM svc_www'; %my $sql_query = { % 'table' => 'svc_www', @@ -22,9 +41,7 @@ % FS::UI::Web::cust_sql_fields(), % ), % 'extra_sql' => $orderby, -% 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum )'. -% 'LEFT JOIN cust_pkg USING ( pkgnum )'. -% 'LEFT JOIN cust_main USING ( custnum )', +% 'addl_from' => $addl_from, %}; % %my $link = [ "${p}view/svc_www.cgi?", 'svcnum', ]; |