[freeside-commits] freeside/httemplate/search cust_main.cgi, 1.70,
1.71 cust_svc.html, NONE, 1.1 svc_acct.cgi, 1.38,
1.39 svc_broadband.cgi, 1.2, 1.3 svc_domain.cgi, 1.21,
1.22 svc_external.cgi, 1.4, 1.5 svc_forward.cgi, 1.10,
1.11 svc_phone.cgi, 1.2, 1.3 svc_www.cgi, 1.7, 1.8
Ivan,,,
ivan at wavetail.420.am
Fri Dec 29 00:51:35 PST 2006
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail:/tmp/cvs-serv4384/httemplate/search
Modified Files:
cust_main.cgi svc_acct.cgi svc_broadband.cgi svc_domain.cgi
svc_external.cgi svc_forward.cgi svc_phone.cgi svc_www.cgi
Added Files:
cust_svc.html
Log Message:
service refactor!
Index: cust_main.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_main.cgi,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- cust_main.cgi 25 Oct 2006 17:36:28 -0000 1.70
+++ cust_main.cgi 29 Dec 2006 08:51:33 -0000 1.71
@@ -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;
%}
-%
-%
-
Index: svc_domain.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_domain.cgi,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- svc_domain.cgi 23 Aug 2006 22:25:38 -0000 1.21
+++ svc_domain.cgi 29 Dec 2006 08:51:33 -0000 1.22
@@ -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\-\.]+)$/;
Index: svc_www.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_www.cgi,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- svc_www.cgi 23 Aug 2006 22:25:38 -0000 1.7
+++ svc_www.cgi 29 Dec 2006 08:51:33 -0000 1.8
@@ -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', ];
--- NEW FILE: cust_svc.html ---
<% 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=',
);
Index: svc_phone.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_phone.cgi,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- svc_phone.cgi 23 Aug 2006 22:25:38 -0000 1.2
+++ svc_phone.cgi 29 Dec 2006 08:51:33 -0000 1.3
@@ -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\- ]+)$/;
Index: svc_acct.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_acct.cgi,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- svc_acct.cgi 26 Sep 2006 18:55:59 -0000 1.38
+++ svc_acct.cgi 29 Dec 2006 08:51:33 -0000 1.39
@@ -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)";
Index: svc_external.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_external.cgi,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- svc_external.cgi 23 Aug 2006 22:25:38 -0000 1.4
+++ svc_external.cgi 29 Dec 2006 08:51:33 -0000 1.5
@@ -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>
Index: svc_broadband.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_broadband.cgi,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- svc_broadband.cgi 23 Aug 2006 22:25:38 -0000 1.2
+++ svc_broadband.cgi 29 Dec 2006 08:51:33 -0000 1.3
@@ -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});
%}
%
Index: svc_forward.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_forward.cgi,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- svc_forward.cgi 23 Aug 2006 22:25:38 -0000 1.10
+++ svc_forward.cgi 29 Dec 2006 08:51:33 -0000 1.11
@@ -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 ) '.
More information about the freeside-commits
mailing list