1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<%
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;
@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',{});
} 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});
@svc_external = qsearchs('svc_external',{'id'=>$id});
}
if ( scalar(@svc_external) == 1 ) {
print $cgi->redirect(popurl(2). "view/svc_external.cgi?". $svc_external[0]->svcnum);
#exit;
} elsif ( scalar(@svc_external) == 0 ) {
%>
<!-- mason kludge -->
<%
eidiot "No matching external services found!\n";
} else {
%>
<!-- mason kludge -->
<%= header("External Search Results",'') %>
<%= scalar(@svc_external) %> matching external services found
<TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
<TR>
<TH>Service #</TH>
<TH><%= FS::Msgcat::_gettext('svc_external-id') || 'External ID' %></TH>
<TH><%= FS::Msgcat::_gettext('svc_external-title') || 'Title' %></TH>
</TR>
<%
foreach my $svc_external (
sort $sortby (@svc_external)
) {
my($svcnum, $id, $title)=(
$svc_external->svcnum,
$svc_external->id,
$svc_external->title,
);
my $rowspan = 1;
print <<END;
<TR>
<TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$svcnum</A></TD>
<TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$id</A></TD>
<TD ROWSPAN=$rowspan><A HREF="${p}view/svc_external.cgi?$svcnum">$title</A></TD>
END
#print @rows;
print "</TR>";
}
print <<END;
</TABLE>
</BODY>
</HTML>
END
}
sub svcnum_sort {
$a->getfield('svcnum') <=> $b->getfield('svcnum');
}
sub id_sort {
$a->getfield('id') <=> $b->getfield('id');
}
%>
|