IP address management for svc_acct, #19567
[freeside.git] / httemplate / view / svc_acct / basics.html
1 <% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %>
2
3 <& /view/elements/tr.html, label=>mt('Service'),  value=>$part_svc->svc &>
4 % if ( $opt{cust_svc}->agent_svcid ) {
5   <& /view/elements/tr.html, label=>mt('Legacy ID'),  value=>$opt{cust_svc}->agent_svcid &>
6 % }
7 <& /view/elements/tr.html, label=>mt('Username'), value=>$svc_acct->username &>
8 <& /view/elements/tr.html, label=>mt('Domain'),   value=>$domain &>
9
10 % if ( $opt{'communigate'} ) {
11   <& /view/elements/tr.html, label=>mt('Aliases'), value=>$svc_acct->cgp_aliases &>
12 %}
13
14 % if ( $svc_acct->pbxsvc ) {
15   <& /view/elements/tr.html, label=>mt('PBX'), value=>$svc_acct->pbx_title &>
16 %}
17
18 % my $show_pw = '';
19 % my $password = $svc_acct->get_cleartext_password; 
20 % if ( $password =~ /^\*\w+\* (.*)$/ ) {
21 %   $password = $1;
22 %   $show_pw .= '<I>('. mt('login disabled') .')</I> ';
23 % } 
24 % if ( ! $password
25 %      && $svc_acct->_password_encryption ne 'plain'
26 %      && $svc_acct->_password
27 %    )
28 % {
29 %   $show_pw .= '<I>('. uc($svc_acct->_password_encryption). ' '.mt('encrypted').')</I>';
30 % } elsif ( $conf->exists('showpasswords') ) { 
31 %   $show_pw .= '<PRE>'. encode_entities($password). '</PRE>';
32 % } else { 
33 %   $show_pw .= '<I>('. mt('hidden') .')</I>';
34 % } 
35 % $password = ''; 
36 <& /view/elements/tr.html, label=>mt('Password'), value=>$show_pw &>
37
38
39 % if ( $conf->exists('security_phrase') ) {
40   <& /view/elements/tr.html, label=>mt('Security phrase'), value=>$svc_acct->sec_phrase &>
41 % } 
42
43 % if ( $svc_acct->popnum ) {
44 %   my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
45     <& /view/elements/tr.html, label=>mt('Access number'), value=>$svc_acct_pop->text &>
46 % } 
47
48 % if ( $svc_acct->sectornum && $conf->exists('svc_acct-tower_sector') ) {
49 %   my $tower_sector = $svc_acct->tower_sector;
50 %   my $link = $tower_sector->ip_addr
51 %                ? '<A HREF="http://'. $tower_sector->ip_addr. '">'
52 %                : '';
53     <& /view/elements/tr.html,
54         label => mt('Tower sector'),
55         value => $link. $tower_sector->description. ($link ? '</A>' : ''),
56     &>
57 % }
58
59 <& /view/elements/tr-svc_export_machine.html,
60      'svc'      => $svc_acct,
61      'part_svc' => $part_svc,
62 &>
63
64 % if ($svc_acct->uid ne '') { 
65   <& /view/elements/tr.html, label=>mt('UID'), value=>$svc_acct->uid &>
66 % } 
67
68 % if ($svc_acct->gid ne '') { 
69   <& /view/elements/tr.html, label=>mt('GID'), value=>$svc_acct->gid &>
70 % } 
71
72 % if ($svc_acct->finger ne '') { 
73   <& /view/elements/tr.html, label=>mt('Real Name'), value=>$svc_acct->finger &>
74 % } 
75
76 % if ($svc_acct->dir ne '') { 
77   <& /view/elements/tr.html, label=>mt('Home directory'), value=>$svc_acct->dir &>
78 % } 
79
80 % if ($svc_acct->shell ne '') { 
81   <& /view/elements/tr.html, label=>mt('Shell'), value=>$svc_acct->shell &>
82 % } 
83
84 % if ($svc_acct->quota ne '' && ! $opt{'communigate'} ) { 
85
86   <& /view/elements/tr.html, label=>mt('Quota'), value=>$svc_acct->quota &>
87
88 % } elsif ( $opt{'communigate'} ) {
89
90   <& communigate.html, %opt &>
91
92 % }
93
94 <%perl>
95 # minor false laziness w/ view/svc_broadband.cgi
96 sub slipip {
97   my $svc_acct = shift;
98   my $out = $svc_acct->slipip or return '';
99   if ( $out eq '0.0.0.0' or $out eq '0e0' ) {
100     return '<I>('.mt('Dynamic').'</I>';
101   }
102   $out .= ' ('.
103           include('/elements/popup_link-ping.html', ip => $svc_acct->slipip).
104           ')';
105   if ( my $addr_block = $svc_acct->addr_block ) {
106     $out .= '<br>Netmask: ' . $addr_block->NetAddr->mask .
107             '<br>Gateway: ' . $addr_block->ip_gateway;
108   }
109   $out;
110 }
111 </%perl>
112
113 % if ($svc_acct->slipip) { 
114   <& /view/elements/tr.html,
115        label=>mt('IP address'),
116        value=> slipip($svc_acct)
117   &>
118 % } 
119
120 <& usage.html, 'svc_acct' => $svc_acct &>
121
122 % foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) {
123 %   $attribute =~ /^radius_(.*)$/;
124 %   my $pattribute = $FS::raddb::attrib{$1};
125     <& /view/elements/tr.html, label=>mt("Radius (reply) [_1]",$pattribute),
126                           value=>$svc_acct->getfield($attribute)
127     &>
128 % } 
129
130 % foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) {
131 %   $attribute =~ /^rc_(.*)$/;
132 %   my $pattribute = $FS::raddb::attrib{$1};
133     <& /view/elements/tr.html, label=>mt("Radius (check) [_1]",$pattribute),
134                           value=>$svc_acct->getfield($attribute)
135     &>
136 % } 
137
138 <& /view/elements/tr.html, label=>mt('RADIUS groups'),
139     value=>join('<BR>', $svc_acct->radius_groups('long_description')) &>
140
141 %# Can this be abstracted further?  Maybe a library function like
142 %# widget('HTML', 'view', $svc_acct) ?  It would definitely make UI 
143 %# style management easier.
144 % foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { 
145   <% $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)) %>
146 % } 
147
148 </TABLE></TD></TR></TABLE>
149 <%init>
150
151 my %opt = @_;
152
153 my $conf = new FS::Conf;
154
155 my $svc_acct = $opt{'svc_acct'};
156 my $part_svc = $opt{'part_svc'};
157
158 die 'Empty domsvc for svc_acct.svcnum '. $svc_acct->svcnum
159   unless $svc_acct->domsvc;
160 my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } );
161 die 'Unknown domain (domsvc '. $svc_acct->domsvc.
162     ' for svc_acct.svcnum '. $svc_acct->svcnum. ')'
163   unless $svc_domain;
164 my $domain = $svc_domain->domain;
165
166 </%init>