fix js quirk, #30643, #24047
[freeside.git] / httemplate / elements / tr-input-fcc_options.html
1 <STYLE>
2   ul.fcc_options {
3     font-weight: normal;
4     text-align: left;
5     padding: 0em 1em 0em 2em;
6   }
7 </STYLE>
8 <TR>
9   <TH COLSPAN=2>
10     <& hidden.html, 'id' => $id, @_ &>
11 %#    <& input-text.html, 'id' => $id, @_ &> # XXX debugging
12     <UL ID="<%$id%>_display_fcc_options" CLASS="fcc_options">
13     </UL>
14     <BUTTON TYPE="button" onclick="edit_fcc_options()">
15       Edit
16     </BUTTON>
17 % # show some kind of useful summary of the FCC options here
18   </TH>
19 </TR>
20 <SCRIPT TYPE="text/javascript">
21 function edit_fcc_options() {
22   <& popup_link_onclick.html,
23   'action'      => $fsurl.'misc/part_pkg_fcc_options.html?id=' . $id,
24   'actionlabel' => 'FCC Form 477 options',
25   'width'       => 760,
26   'height'      => 600,
27   &>
28 }
29 var technology_labels = <% encode_json(FS::part_pkg_fcc_option->technology_labels) %>;
30 function show_fcc_options() {
31   var curr_values = JSON.parse(document.getElementById('<% $id %>').value);
32   // hardcoded for the same reasons as misc/part_pkg_fcc_options
33   var out = '';
34   var tech = curr_values['technology'];
35   if ( tech ) {
36     if (technology_labels[tech]) {
37       tech = technology_labels[tech];
38     } else {
39       tech = 'Technology '+tech; // unknown?
40     }
41   }
42   var media = curr_values['media'] || 'unknown media';
43   media = media.toLowerCase();
44   if ( curr_values['is_consumer'] ) {
45     out += '<li><strong>Consumer-grade</strong></li>>';
46   } else {
47     out += '<li><strong>Business-grade</strong></li>';
48   }
49   if ( curr_values['is_broadband'] ) {
50     out += '<li>Broadband via <strong>' + tech + '</strong>'
51         +  '<li><strong>' + curr_values['broadband_downstream']
52         +  'Mbps </strong> down / '
53         +  '<strong>' + curr_values['broadband_upstream']
54         +  'Mbps </strong> up</li>';
55   }
56   if ( curr_values['is_phone'] ) {
57     if ( curr_values['phone_wholesale'] ) {
58       out += '<li>Wholesale telephone</li>';
59       if ( curr_values['phone_vges'] ) {
60         out += '<li><strong>' + curr_values['phone_vges'] + '</strong>'
61             +  ' switched voice-grade lines</li>';
62       }
63       if ( curr_values['phone_circuits'] ) {
64         out += '<li><strong>' + curr_values['phone_circuits'] + '</strong>'
65             +  ' unswitched circuits</li>';
66       }
67     } else {
68       // enduser service
69       out += '<li>Local telephone over <strong>' + media + '</strong></li>'
70           +  '<li><strong>' + curr_values['phone_lines']
71           +  '</strong> voice-grade lines</li>';
72       if ( curr_values['phone_localloop'] == 'resale' ) {
73         out += '<li><strong>Resold</strong> from another carrier</li>>';
74       } else if ( curr_values['phone_localloop'] == 'leased' ) {
75         out += '<li>Using <strong>leased circuits</strong> from another carrier</li>';
76       } else if ( curr_values['phone_localloop'] == 'owned' ) {
77         out += '<li>Using <strong>our own circuits</strong></li>';
78       }
79       if ( curr_values['phone_longdistance'] ) {
80         out += '<li>Includes <strong>long-distance service</strong></li>';
81       }
82     }
83   } // is_phone
84   if ( curr_values['is_voip'] ) {
85     out += '<li><strong>VoIP</strong> telephone service</li>';
86     if ( curr_values['voip_ott'] ) {
87       out += '<li>Using a <strong>separate</strong> last-mile connection</li>';
88     } else {
89       out += '<li><strong>Including</strong> last-mile connection</li>';
90     }
91   } // is_voip
92
93   var out_ul = document.getElementById('<% $id %>_display_fcc_options');
94   out_ul.innerHTML = out;
95 }
96 <&| onload.js &>
97   show_fcc_options();
98 </&>
99 </SCRIPT>
100 <%init>
101 my %opt = @_;
102 my $id = $opt{id} || $opt{field};
103 </%init>