4 my $conf = new FS::Conf;
6 my($query) = $cgi->keywords;
9 my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum});
10 die "Unknown svcnum" unless $svc_acct;
12 #false laziness w/all svc_*.cgi
13 my $cust_svc = qsearchs( 'cust_svc' , { 'svcnum' => $svcnum } );
14 my $pkgnum = $cust_svc->getfield('pkgnum');
15 my($cust_pkg, $custnum);
17 $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } );
18 $custnum = $cust_pkg->custnum;
25 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
26 die "Unknown svcpart" unless $part_svc;
29 if ( $svc_acct->domsvc ) {
30 my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } );
31 die "Unknown domain" unless $svc_domain;
32 $domain = $svc_domain->domain;
34 die "No svc_domain.svcnum record for svc_acct.domsvc: ". $cust_svc->domsvc;
40 function areyousure(href) {
41 if (confirm("Permanently delete this account?") == true)
42 window.location.href = href;
46 <%= header('Account View', menubar(
47 ( ( $pkgnum || $custnum )
48 ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
50 : ( "Cancel this (unaudited) account" =>
51 "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')" )
58 #if ( $cust_pkg && $cust_pkg->part_pkg->plan eq 'sqlradacct_hour' ) {
59 if ( $part_svc->part_export('sqlradius')
60 || $part_svc->part_export('sqlradius_withdomain')
66 #false laziness w/httemplate/edit/part_pkg... this stuff doesn't really
68 %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
69 split("\n", $cust_pkg->part_pkg->plandata );
71 $last_bill = $cust_pkg->last_bill;
77 my $seconds = $svc_acct->seconds_since_sqlradacct( $last_bill, time );
78 my $hour = int($seconds/3600);
79 my $min = int( ($seconds%3600) / 60 );
80 my $sec = $seconds%60;
82 my $input = $svc_acct->attribute_since_sqlradacct(
83 $last_bill, time, 'AcctInputOctets'
85 my $output = $svc_acct->attribute_since_sqlradacct(
86 $last_bill, time, 'AcctOutputOctets'
91 RADIUS session information<BR>
92 <%= ntable('#cccccc',2) %>
93 <TR><TD BGCOLOR="#ffffff">
95 <% if ( $seconds ) { %>
96 Online <B><%= $hour %></B>h <B><%= $min %></B>m <B><%= $sec %></B>s
101 <% if ( $cust_pkg ) { %>
102 since last bill (<%= time2str('%a %b %o %Y', $last_bill) %>)
103 <% if ( length($plandata{recur_included_hours}) ) { %>
104 - <%= $plandata{recur_included_hours} %> total hours in plan
108 (no billing cycle available for unaudited account)<BR>
111 Upload: <B><%= sprintf("%.3f", $input) %></B> megabytes<BR>
112 Download: <B><%= sprintf("%.3f", $output) %></B> megabytes<BR>
114 <% my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=$svcnum!; %>
116 <%= $href %>;begin=<%= $last_bill %>">this billing cycle</A>
117 | <%= $href %>;begin=<%= time-15552000 %>">past six months</A>
118 | <%= $href %>">all sessions</A>
120 </TD></TR></TABLE><BR>
124 <SCRIPT TYPE="text/javascript">
125 function enable_change () {
126 if ( document.OneTrueForm.svcpart.selectedIndex > 1 ) {
127 document.OneTrueForm.submit.disabled = false;
129 document.OneTrueForm.submit.disabled = true;
133 <FORM NAME="OneTrueForm" ACTION="<%=$p%>edit/process/cust_svc.cgi">
134 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>">
135 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>">
137 <% #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!; %>
142 @part_svc = grep { $_->svcdb eq 'svc_acct'
143 && $_->svcpart != $part_svc->svcpart }
144 $cust_pkg->available_part_svc;
146 @part_svc = qsearch('part_svc', {
149 svcpart => { op=>'!=', value=>$part_svc->svcpart },
155 | <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this information</A>
157 <% if ( @part_svc ) { %>
158 | <SELECT NAME="svcpart" onChange="enable_change()">
159 <OPTION VALUE="">Change service</OPTION>
160 <OPTION VALUE="">--------------</OPTION>
161 <% foreach my $part_svc ( @part_svc ) { %>
162 <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $part_svc->svc %></OPTION>
165 <INPUT NAME="submit" TYPE="submit" VALUE="Change" disabled>
168 <%= &ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %>
169 <TR><TD ALIGN="right">Service number</TD>
170 <TD BGCOLOR="#ffffff"><%= $svcnum %></TD></TR>
171 <TR><TD ALIGN="right">Service</TD>
172 <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD></TR>
173 <TR><TD ALIGN="right">Username</TD>
174 <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD></TR>
175 <TR><TD ALIGN="right">Domain</TD>
176 <TD BGCOLOR="#ffffff"><%= $domain %></TD></TR>
178 <TR><TD ALIGN="right">Password</TD>
179 <TD BGCOLOR="#ffffff"><%
181 my $password = $svc_acct->_password;
182 if ( $password =~ /^\*\w+\* (.*)$/ ) {
184 print "<I>(login disabled)</I> ";
186 if ( $conf->exists('showpasswords') ) {
187 print '<PRE>'. encode_entities($password). '</PRE>';
189 print "<I>(hidden)</I>";
194 if ( $conf->exists('security_phrase') ) {
195 my $sec_phrase = $svc_acct->sec_phrase;
196 print '<TR><TD ALIGN="right">Security phrase</TD><TD BGCOLOR="#ffffff">'.
197 $svc_acct->sec_phrase. '</TD></TR>';
200 my $svc_acct_pop = $svc_acct->popnum
201 ? qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum})
203 print "<TR><TD ALIGN=\"right\">Access number</TD>".
204 "<TD BGCOLOR=\"#ffffff\">". $svc_acct_pop->text. '</TD></TR>'
207 if ($svc_acct->uid ne '') {
208 print "<TR><TD ALIGN=\"right\">Uid</TD>".
209 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->uid. "</TD></TR>",
210 "<TR><TD ALIGN=\"right\">Gid</TD>".
211 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->gid. "</TD></TR>",
212 "<TR><TD ALIGN=\"right\">GECOS</TD>".
213 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->finger. "</TD></TR>",
214 "<TR><TD ALIGN=\"right\">Home directory</TD>".
215 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->dir. "</TD></TR>",
216 "<TR><TD ALIGN=\"right\">Shell</TD>".
217 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->shell. "</TD></TR>",
218 "<TR><TD ALIGN=\"right\">Quota</TD>".
219 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->quota. "</TD></TR>"
222 print "<TR><TH COLSPAN=2>(No shell account)</TH></TR>";
225 if ($svc_acct->slipip) {
226 print "<TR><TD ALIGN=\"right\">IP address</TD><TD BGCOLOR=\"#ffffff\">".
227 ( ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' )
232 foreach $attribute ( grep /^radius_/, $svc_acct->fields ) {
234 $attribute =~ /^radius_(.*)$/;
235 my $pattribute = $FS::raddb::attrib{$1};
236 print "<TR><TD ALIGN=\"right\">Radius (reply) $pattribute</TD>".
237 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute).
240 foreach $attribute ( grep /^rc_/, $svc_acct->fields ) {
242 $attribute =~ /^rc_(.*)$/;
243 my $pattribute = $FS::raddb::attrib{$1};
244 print "<TR><TD ALIGN=\"right\">Radius (check) $pattribute: </TD>".
245 "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute).
249 print "<TR><TH COLSPAN=2>(No SLIP/PPP account)</TH></TR>";
252 print '<TR><TD ALIGN="right">RADIUS groups</TD><TD BGCOLOR="#ffffff">'.
253 join('<BR>', $svc_acct->radius_groups). '</TD></TR>';
255 # Can this be abstracted further? Maybe a library function like
256 # widget('HTML', 'view', $svc_acct) ? It would definitely make UI
257 # style management easier.
259 foreach (sort { $a cmp $b } $svc_acct->virtual_fields) {
260 print $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)),
264 </TABLE></TD></TR></TABLE></FORM>
269 print join("\n", $conf->config('svc_acct-notes') ). '<BR><BR>'.
270 joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>';