477 report tweaks
[freeside.git] / httemplate / elements / input-fcc_options.html
1 % unless ($opt{js_only}) {
2 <& hidden.html, 'field' => $id, @_ &>
3 %#    <& input-text.html, 'id' => $id, @_ &> # XXX debugging
4 <UL ID="<%$id%>_display_fcc_options" CLASS="fcc_options">
5 </UL>
6 <button type="button" class="edit_fcc_button" data-target="<% $id %>">
7   Edit
8 </button>
9 % }
10 % unless ($opt{html_only}) {
11 %   my $popup = $fsurl.'misc/part_pkg_fcc_options.html?id=';
12 %   my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32;
13 <SCRIPT TYPE="text/javascript">
14 function edit_fcc_options() {
15   var id = this.dataset['target'];
16   overlib(
17     OLiframeContent( '<% $popup %>' + id,
18       760, 600, '<% $popup_name %>', 0, 'auto' ),
19     CAPTION, 'FCC Form 477 options', 
20     STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0,
21     DRAGGABLE, CLOSECLICK,
22     BGCOLOR, '#333399', CGCOLOR, '#333399',
23     CLOSETEXT, 'Close'
24   );
25 }
26
27 var technology_labels = <% encode_json(FS::part_pkg_fcc_option->technology_labels) %>;
28 function show_fcc_options(id) {
29   var curr_values = JSON.parse(document.getElementById(id).value);
30   // hardcoded for the same reasons as misc/part_pkg_fcc_options
31   var out = '';
32   var tech = curr_values['technology'];
33   if ( tech ) {
34     if (technology_labels[tech]) {
35       tech = technology_labels[tech];
36     } else {
37       tech = 'Technology '+tech; // unknown?
38     }
39   }
40   var media = String.toLowerCase(curr_values['media'] || 'unknown media');
41   if ( curr_values['is_consumer'] ) {
42     out += '<li><strong>Consumer-grade</strong> service</li>';
43   } else {
44     out += '<li><strong>Business-grade</strong> service</li>';
45   }
46   if ( curr_values['is_broadband'] ) {
47     out += '<li>Broadband via <strong>' + tech + '</strong>'
48         +  '<li><strong>' + curr_values['broadband_downstream']
49         +  'Mbps </strong> down / '
50         +  '<strong>' + curr_values['broadband_upstream']
51         +  'Mbps </strong> up</li>';
52   }
53   if ( curr_values['is_phone'] ) {
54     if ( curr_values['phone_wholesale'] ) {
55       out += '<li>Wholesale telephone</li>';
56       if ( curr_values['phone_vges'] ) {
57         out += '<li><strong>' + curr_values['phone_vges'] + '</strong>'
58             +  ' switched voice-grade lines</li>';
59       }
60       if ( curr_values['phone_circuits'] ) {
61         out += '<li><strong>' + curr_values['phone_circuits'] + '</strong>'
62             +  ' unswitched circuits</li>';
63       }
64     } else {
65       // enduser service
66       out += '<li>Local telephone over <strong>' + media + '</strong></li>'
67           +  '<li><strong>' + curr_values['phone_lines']
68           +  '</strong> voice-grade lines</li>';
69       if ( curr_values['phone_localloop'] == 'resale' ) {
70         out += '<li><strong>Resold</strong> from another carrier</li>>';
71       } else if ( curr_values['phone_localloop'] == 'leased' ) {
72         out += '<li>Using <strong>leased circuits</strong> from another carrier</li>';
73       } else if ( curr_values['phone_localloop'] == 'owned' ) {
74         out += '<li>Using <strong>our own circuits</strong></li>';
75       }
76       if ( curr_values['phone_longdistance'] ) {
77         out += '<li>Includes <strong>long-distance service</strong></li>';
78       }
79     }
80   } // is_phone
81   if ( curr_values['is_voip'] ) {
82     out += '<li><strong>VoIP</strong> telephone service</li>';
83     out += '<li><strong>' + curr_values['voip_sessions'] + 
84            '</strong> sessions allowed</li>';
85     if ( curr_values['voip_lastmile'] ) {
86       out += '<li><strong>Including</strong> last-mile connection</li>';
87     } else {
88       out += '<li>Using a <strong>separate</strong> last-mile connection</li>';
89     }
90   } // is_voip
91   if ( curr_values['is_mobile'] ) {
92     out += '<li><strong>Mobile</strong> telephone service</li>';
93     if ( curr_values['mobile_direct'] ) {
94       out += '<li>Billed <strong>directly to the user</strong></li>';
95     }
96   } // is_mobile
97
98   var out_ul = document.getElementById(id + '_display_fcc_options');
99   out_ul.innerHTML = out;
100 }
101 <&| onload.js &>
102   var edit_fcc_buttons = document.getElementsByClassName('edit_fcc_button');
103   for(var i = 0; i < edit_fcc_buttons.length; i++) {
104     var button = edit_fcc_buttons[i];
105     show_fcc_options( button.dataset['target'] );
106     button.addEventListener('click', edit_fcc_options);
107   }
108 </&>
109 </SCRIPT>
110 % }
111 <%init>
112 my %opt = @_;
113 my $id = $opt{id} || $opt{field};
114 </%init>