RT# 82137 - default payment amount now has processing fee in total if processing...
[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-'.random_id();
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 = curr_values['media'] || 'unknown media';
41   media = media.toLowerCase();
42   if ( curr_values['is_consumer'] ) {
43     out += '<li><strong>Consumer-grade</strong> service</li>';
44   } else {
45     out += '<li><strong>Business-grade</strong> service</li>';
46   }
47   if ( curr_values['is_broadband'] ) {
48     out += '<li>Broadband via <strong>' + tech + '</strong>'
49         +  '<li><strong>' + curr_values['broadband_downstream']
50         +  'Mbps </strong> down / '
51         +  '<strong>' + curr_values['broadband_upstream']
52         +  'Mbps </strong> up</li>';
53   }
54   if ( curr_values['is_phone'] ) {
55     if ( curr_values['phone_wholesale'] ) {
56       out += '<li>Wholesale telephone</li>';
57       if ( curr_values['phone_vges'] ) {
58         out += '<li><strong>' + curr_values['phone_vges'] + '</strong>'
59             +  ' switched voice-grade lines</li>';
60       }
61       if ( curr_values['phone_circuits'] ) {
62         out += '<li><strong>' + curr_values['phone_circuits'] + '</strong>'
63             +  ' unswitched circuits</li>';
64       }
65     } else {
66       // enduser service
67       out += '<li>Local telephone over <strong>' + media + '</strong></li>'
68           +  '<li><strong>' + curr_values['phone_lines']
69           +  '</strong> voice-grade lines</li>';
70       if ( curr_values['phone_localloop'] == 'resale' ) {
71         out += '<li><strong>Resold</strong> from another carrier</li>>';
72       } else if ( curr_values['phone_localloop'] == 'leased' ) {
73         out += '<li>Using <strong>leased circuits</strong> from another carrier</li>';
74       } else if ( curr_values['phone_localloop'] == 'owned' ) {
75         out += '<li>Using <strong>our own circuits</strong></li>';
76       }
77       if ( curr_values['phone_longdistance'] ) {
78         out += '<li>Includes <strong>long-distance service</strong></li>';
79       }
80     }
81   } // is_phone
82   if ( curr_values['is_voip'] ) {
83     out += '<li><strong>VoIP</strong> telephone service over <strong>' 
84             + media + '</strong></li>';
85     out += '<li><strong>' + curr_values['voip_sessions'] + 
86            '</strong> sessions allowed</li>';
87     if ( curr_values['voip_lastmile'] ) {
88       out += '<li><strong>Including</strong> last-mile connection</li>';
89     } else {
90       out += '<li>Using a <strong>separate</strong> last-mile connection</li>';
91     }
92   } // is_voip
93   if ( curr_values['is_mobile'] ) {
94     out += '<li><strong>Mobile</strong> telephone service</li>';
95     if ( curr_values['mobile_direct'] ) {
96       out += '<li>Billed <strong>directly to the user</strong></li>';
97     }
98   } // is_mobile
99
100   var out_ul = document.getElementById(id + '_display_fcc_options');
101   out_ul.innerHTML = out;
102 }
103 <&| onload.js &>
104   var edit_fcc_buttons = document.getElementsByClassName('edit_fcc_button');
105   for(var i = 0; i < edit_fcc_buttons.length; i++) {
106     var button = edit_fcc_buttons[i];
107     show_fcc_options( button.dataset['target'] );
108     button.addEventListener('click', edit_fcc_options);
109   }
110 </&>
111 </SCRIPT>
112 % }
113 <%init>
114 my %opt = @_;
115 my $id = $opt{id} || $opt{field};
116 </%init>