3 my $conf = new FS::Conf;
5 my($query) = $cgi->keywords;
8 my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum});
9 die "Unknown svcnum" unless $svc_acct;
11 #false laziness w/all svc_*.cgi
12 my $cust_svc = qsearchs( 'cust_svc' , { 'svcnum' => $svcnum } );
13 my $pkgnum = $cust_svc->getfield('pkgnum');
14 my($cust_pkg, $custnum);
16 $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } );
17 $custnum = $cust_pkg->custnum;
24 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
25 die "Unknown svcpart" unless $part_svc;
26 my $svc = $part_svc->svc;
28 die 'Empty domsvc for svc_acct.svcnum '. $svc_acct->svcnum
29 unless $svc_acct->domsvc;
30 my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } );
31 die 'Unknown domain (domsvc '. $svc_acct->domsvc.
32 ' for svc_acct.svcnum '. $svc_acct->svcnum. ')'
34 my $domain = $svc_domain->domain;
38 <% if ( $custnum ) { %>
40 <%= header("View $svc account", menubar(
41 "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
45 <%= include( '/elements/small_custview.html', $custnum, '', 1 ) %>
51 function areyousure(href) {
52 if (confirm("Permanently delete this account?") == true)
53 window.location.href = href;
57 <%= header('Account View', menubar(
58 "Cancel this (unaudited) account" =>
59 "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')",
65 <% if ( $part_svc->part_export_usage ) {
70 #false laziness w/httemplate/edit/part_pkg... this stuff doesn't really
72 %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
73 split("\n", $cust_pkg->part_pkg->plandata );
75 $last_bill = $cust_pkg->last_bill;
81 my $seconds = $svc_acct->seconds_since_sqlradacct( $last_bill, time );
82 my $hour = int($seconds/3600);
83 my $min = int( ($seconds%3600) / 60 );
84 my $sec = $seconds%60;
86 my $input = $svc_acct->attribute_since_sqlradacct(
87 $last_bill, time, 'AcctInputOctets'
89 my $output = $svc_acct->attribute_since_sqlradacct(
90 $last_bill, time, 'AcctOutputOctets'
95 RADIUS session information<BR>
96 <%= ntable('#cccccc',2) %>
97 <TR><TD BGCOLOR="#ffffff">
99 <% if ( $seconds ) { %>
100 Online <B><%= $hour %></B>h <B><%= $min %></B>m <B><%= $sec %></B>s
105 <% if ( $cust_pkg ) { %>
106 since last bill (<%= time2str('%a %b %o %Y', $last_bill) %>)
107 <% if ( length($plandata{recur_included_hours}) ) { %>
108 - <%= $plandata{recur_included_hours} %> total hours in plan
112 (no billing cycle available for unaudited account)<BR>
115 Upload: <B><%= sprintf("%.3f", $input) %></B> megabytes<BR>
116 Download: <B><%= sprintf("%.3f", $output) %></B> megabytes<BR>
118 <% my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=$svcnum!; %>
120 <%= $href %>;begin=<%= $last_bill %>">this billing cycle</A>
121 | <%= $href %>;begin=<%= time-15552000 %>">past six months</A>
122 | <%= $href %>">all sessions</A>
124 </TD></TR></TABLE><BR>
128 <SCRIPT TYPE="text/javascript">
129 function enable_change () {
130 if ( document.OneTrueForm.svcpart.selectedIndex > 1 ) {
131 document.OneTrueForm.submit.disabled = false;
133 document.OneTrueForm.submit.disabled = true;
137 <FORM NAME="OneTrueForm" ACTION="<%=$p%>edit/process/cust_svc.cgi">
138 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>">
139 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>">
141 <% #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!; %>
146 @part_svc = grep { $_->svcdb eq 'svc_acct'
147 && $_->svcpart != $part_svc->svcpart }
148 $cust_pkg->available_part_svc;
150 @part_svc = qsearch('part_svc', {
153 svcpart => { op=>'!=', value=>$part_svc->svcpart },
158 Service #<B><%= $svcnum %></B>
159 | <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this service</A>
161 <% if ( @part_svc ) { %>
162 | <SELECT NAME="svcpart" onChange="enable_change()">
163 <OPTION VALUE="">Change service</OPTION>
164 <OPTION VALUE="">--------------</OPTION>
165 <% foreach my $opt_part_svc ( @part_svc ) { %>
166 <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $opt_part_svc->svc %></OPTION>
169 <INPUT NAME="submit" TYPE="submit" VALUE="Change" disabled>
172 <%= &ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %>
175 <TD ALIGN="right">Service</TD>
176 <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD>
179 <TD ALIGN="right">Username</TD>
180 <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD>
183 <TD ALIGN="right">Domain</TD>
184 <TD BGCOLOR="#ffffff"><%= $domain %></TD>
188 <TD ALIGN="right">Password</TD>
189 <TD BGCOLOR="#ffffff">
191 <% my $password = $svc_acct->_password; %>
192 <% if ( $password =~ /^\*\w+\* (.*)$/ ) {
195 <I>(login disabled)</I>
198 <% if ( $conf->exists('showpasswords') ) { %>
199 <PRE><%= encode_entities($password) %></PRE>
206 <% $password = ''; %>
208 <% if ( $conf->exists('security_phrase') ) {
209 my $sec_phrase = $svc_acct->sec_phrase;
212 <TD ALIGN="right">Security phrase</TD>
213 <TD BGCOLOR="#ffffff"><%= $svc_acct->sec_phrase %></TD>
217 <% if ( $svc_acct->popnum ) {
218 my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
221 <TD ALIGN="right">Access number</TD>
222 <TD BGCOLOR="#ffffff"><%= $svc_acct_pop->text %></TD>
226 <% if ($svc_acct->uid ne '') { %>
228 <TD ALIGN="right">UID</TD>
229 <TD BGCOLOR="#ffffff"><%= $svc_acct->uid %></TD>
233 <% if ($svc_acct->gid ne '') { %>
235 <TD ALIGN="right">GID</TD>
236 <TD BGCOLOR="#ffffff"><%= $svc_acct->gid %></TD>
240 <% if ($svc_acct->finger ne '') { %>
242 <TD ALIGN="right">GECOS</TD>
243 <TD BGCOLOR="#ffffff"><%= $svc_acct->finger %></TD>
247 <% if ($svc_acct->dir ne '') { %>
249 <TD ALIGN="right">Home directory</TD>
250 <TD BGCOLOR="#ffffff"><%= $svc_acct->dir %></TD>
254 <% if ($svc_acct->shell ne '') { %>
256 <TD ALIGN="right">Shell</TD>
257 <TD BGCOLOR="#ffffff"><%= $svc_acct->shell %></TD>
261 <% if ($svc_acct->quota ne '') { %>
263 <TD ALIGN="right">Quota</TD>
264 <TD BGCOLOR="#ffffff"><%= $svc_acct->quota %></TD>
268 <% if ($svc_acct->slipip) { %>
270 <TD ALIGN="right">IP address</TD>
271 <TD BGCOLOR="#ffffff">
272 <%= ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' )
280 <% foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) {
281 $attribute =~ /^radius_(.*)$/;
282 my $pattribute = $FS::raddb::attrib{$1};
285 <TD ALIGN="right">Radius (reply) <%= $pattribute %></TD>
286 <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD>
290 <% foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) {
291 $attribute =~ /^rc_(.*)$/;
292 my $pattribute = $FS::raddb::attrib{$1};
295 <TD ALIGN="right">Radius (check) <%= $pattribute %></TD>
296 <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD>
301 <TD ALIGN="right">RADIUS groups</TD>
302 <TD BGCOLOR="#ffffff"><%= join('<BR>', $svc_acct->radius_groups) %></TD>
305 <% if ( $svc_acct->seconds =~ /^\d+$/ ) { %>
307 <TD ALIGN="right">Prepaid time</TD>
308 <TD BGCOLOR="#ffffff"><%= duration_exact($svc_acct->seconds) %></TD>
313 # Can this be abstracted further? Maybe a library function like
314 # widget('HTML', 'view', $svc_acct) ? It would definitely make UI
315 # style management easier.
318 <% foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { %>
319 <%= $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)) %>
322 </TABLE></TD></TR></TABLE>
326 <%= join("<BR>", $conf->config('svc_acct-notes') ) %>
329 <%= joblisting({'svcnum'=>$svcnum}, 1) %>