RT#38597: OQM - svc Circuit use and setup [v3 only]
[freeside.git] / httemplate / elements / tr-cust_svc.html
1 <%doc>
2 tr-cust_svc - Short display of a customer service for use in view/cust_main.
3
4 Formerly part of view/cust_main/packages/services.html
5
6 Usage:
7
8   <% include('/elements/tr-cust_svc.html',
9                 #required
10                 'part_svc' => $part_svc,
11                 'cust_svc' => $cust_svc,
12                 'cust_pkg' => $cust_pkg,
13                 #optional
14                 'cust_pkg-display_times'    => '', #bool
15                 'manage_link'               => '', #for svc_broadband
16                 'manage_link_text'          => '', #default 'Manage Device'
17                 'manage_link_loc'           => '', #default 'bottom', or 'right'
18             )
19   %>
20
21 </%doc>
22 <TR>
23   <TD ALIGN="right" VALIGN="top">
24 %   if ( $opt{no_links} ) {
25       <% $part_svc->svc |h %>:
26 %   } else {
27       <% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %>
28 %   }
29   </TD>
30   <TD STYLE="padding-bottom:0px" VALIGN="top">
31 %   if ( $opt{before_svc_callback} ) {
32       <% &{ $opt{before_svc_callback} }( $cust_svc ) %>
33 %   }
34     <B><% $cust_svc->agent_svcid ? $cust_svc->agent_svcid.': ' : '' %>
35 %   if ( $opt{no_links} ) {
36       <% ($cust_svc->label)[1] |h %>
37 %   } else {
38       <% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %>
39 %   }
40     </B>
41 %   if ($part_svc->svcdb eq 'svc_circuit') {
42 %     my $provider = qsearchs('circuit_provider', { 'providernum' => $svc_x->providernum });
43 %     my $ctype    = qsearchs('circuit_type', { 'typenum' => $svc_x->typenum });
44 %     if ($provider) {
45       <BR>Provider:&nbsp;<% $provider->provider %>
46 %     }
47 %     if ($ctype) {
48       <BR>Type:&nbsp;<% $ctype->typename %>
49 %     }
50 %   }
51 %   if ( $opt{after_svc_callback} ) {
52       <% &{ $opt{after_svc_callback} }( $cust_svc ) %>
53 %   }
54   </TD>
55 <TD ALIGN="right"><% FS::UI::Web::svc_export_links($m, $part_svc, $cust_svc) %>
56 %   if ( $opt{'manage_link_loc'} eq 'right' && ! $opt{no_links} ) {
57 <& /elements/manage_device_link.html, 
58         'svc' => $svc_x,
59         'part_svc' => $opt{'part_svc'} || $cust_svc->part_svc,
60         'manage_link' => $opt{'manage_link'},
61         'manage_link_text' => $opt{'manage_link_text'},
62         'manage_link-new_window' => $opt{'manage_link-new_window'}
63 &>
64 % }
65 </TD>
66 </TR>
67 % if ( $cust_svc->overlimit ) {
68 <TR>
69   <TD ALIGN="right" COLSPAN="3" VALIGN="top"
70       STYLE="padding-bottom:1px; padding-top:0px">
71     <FONT SIZE="-2" COLOR="#FFD000">Overlimit: <%
72 time2str('%b %o %Y' . $opt{'cust_pkg-display_times'} ? ' %l:%M %P' : '',
73 $cust_svc->overlimit )
74     %></FONT>
75   </TD>
76 </TR>
77 % }
78 <TR>
79 % # first column: (optional external balance and) recharge link
80   <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px; padding-top:0px">
81 % if ( $part_svc->svcdb eq 'svc_phone'
82 %        && ! $opt{no_links}
83 %    )
84 % {
85 %   my( $html, $hashref ) = $svc_x->export_getstatus;
86 %   if ( length($hashref->{'Balance'}) ) { #quelle hack
87       <FONT SIZE="-1">Balance:&nbsp;<b><% $hashref->{'Balance'} %></b>&nbsp;</FONT>
88 %   }
89 % }
90 % if ( $curuser->access_right('Recharge customer service') 
91 %     && $part_svc->svcdb eq 'svc_acct'
92 %     && ! $opt{no_links}
93 %     && ( $svc_x->seconds ne '' 
94 %       || $svc_x->upbytes ne ''
95 %       || $svc_x->downbytes ne ''
96 %       || $svc_x->totalbytes ne ''
97 %     )
98 % ) {
99     <FONT SIZE="-2">(&nbsp;<% svc_recharge_link($cust_svc)%>&nbsp;)</FONT>
100 % }
101   </TD>
102 % # second column: all other action links
103   <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px; padding-top:0px">
104 % if ( $part_svc->svcdb eq 'svc_broadband' && ! $opt{no_links} ) {
105     <FONT SIZE="-2">(&nbsp;<%
106       include('/elements/popup_link-ping.html',
107               'ip' => $svc_x->ip_addr
108       ) %>&nbsp;)</FONT>
109 %   if ( $opt{'manage_link_loc'} eq 'bottom' && ! $opt{no_links} ) {
110 <& /elements/manage_device_link.html, 
111         'svc' => $svc_x,
112         'part_svc' => $opt{'part_svc'} || $cust_svc->part_svc,
113         'manage_link' => $opt{'manage_link'},
114         'manage_link_text' => $opt{'manage_link_text'},
115         'manage_link-new_window' => $opt{'manage_link-new_window'},
116         'prepend' => '<FONT SIZE="-2">(&nbsp;',
117         'append' => '&nbsp;)</FONT>'
118 &>
119 %   }
120 % } #svc_broadband
121 % if ( $curuser->access_right('Unprovision customer service') && ! $opt{no_links} ) {
122     <FONT SIZE="-2">(&nbsp;<% $svc_unprovision_link %>&nbsp;)</FONT>
123 % }
124   </TD>
125 </TR>
126
127 <%init>
128 my %opt = @_;
129 my $curuser = $FS::CurrentUser::CurrentUser;
130
131 my $cust_svc = $opt{'cust_svc'};
132 my $part_svc = $opt{'part_svc'} || $cust_svc->part_svc;
133 my $cust_pkg = $opt{'cust_pkg'} || $cust_svc->cust_pkg;
134 my $svc_x = $cust_svc->svc_x;
135
136 my $svc_unprovision_link = 
137   qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?! .
138   $cust_svc->svcnum .
139   qq!', '!.emt('Permanently unprovision and delete this service?').qq!')">!.emt('Unprovision').'</A>';
140
141 $opt{'manage_link_loc'}  ||= 'bottom';
142
143 </%init>