1 <& /elements/header-popup.html &>
5 border: 1px solid #7e0079;
7 background-color: #fff;
19 % my $extra = shift || '';
20 <INPUT TYPE="checkbox" NAME="<% $field %>" ID="<% $field %>" VALUE="1" <%$extra%>>
23 <FORM NAME="fcc_option_form">
24 % # The option structure is hardcoded. The FCC rules changed enough from
25 % # the original 477 report to the 2013 revision that any data-driven
26 % # mechanism for expressing the original rules would likely fail to
27 % # accommodate the new ones. Therefore, we assume that whatever the FCC
28 % # does NEXT will also require a rewrite of this form, and we'll deal with
29 % # that when it arrives.
31 <LABEL FOR="media">Media type</LABEL>
32 <SELECT NAME="media" ID="media">
33 <OPTION VALUE=""></OPTION>
34 % foreach (keys(%$media_types)) {
35 <OPTION VALUE="<% $_ %>"><% $_ %></OPTION>
40 <& .checkbox, 'is_consumer' &>
41 <LABEL FOR="is_consumer">This is a consumer-grade package</LABEL>
44 <& .checkbox, 'is_broadband' &>
45 <LABEL FOR="is_broadband">This package provides broadband service</LABEL>
46 <FIELDSET ID="broadband">
47 <LABEL FOR="technology">Technology of transmission</LABEL>
48 <SELECT NAME="technology" ID="technology"> </SELECT>
50 <LABEL FOR="broadband_downstream">Downstream speed (Mbps)</LABEL>
51 <INPUT NAME="broadband_downstream" ID="broadband_downstream">
53 <LABEL FOR="broadband_upstream">Upstream speed (Mbps)</LABEL>
54 <INPUT NAME="broadband_upstream" ID="broadband_upstream">
58 <& .checkbox, 'is_phone' &>
59 <LABEL FOR="is_phone">This package provides local telephone service</LABEL>
61 <LABEL FOR="phone_wholesale">Marketed as</LABEL>
62 <SELECT NAME="phone_wholesale" ID="phone_wholesale">
63 <OPTION VALUE="">end user</OPTION>
64 <OPTION VALUE="1">wholesale</OPTION>
66 <FIELDSET CLASS="inv" ID="phone0" DISABLED="1">
67 <LABEL FOR="phone_lines">Number of voice-grade equivalents</LABEL>
68 <INPUT NAME="phone_lines" ID="phone_lines">
70 <LABEL FOR="phone_longdistance">Are you the presubscribed long-distance carrier?</LABEL>
71 <& .checkbox, 'phone_longdistance' &>
73 <LABEL FOR="phone_localloop">Local loop arrangement</LABEL>
74 <SELECT NAME="phone_localloop" ID="phone_localloop">
75 <OPTION VALUE="owned">You own the local loop</OPTION>
76 <OPTION VALUE="leased">You lease UNE-L from another carrier</OPTION>
77 <OPTION VALUE="resale">You resell another carrier's service</OPTION>
80 <FIELDSET CLASS="inv" ID="phone1" DISABLED="1">
81 <LABEL FOR="phone_vges">Number of voice-grade equivalents (if any)</LABEL>
82 <INPUT NAME="phone_vges" ID="phone_vges">
84 <LABEL FOR="phone_circuits">Number of unswitched circuits (if any)</LABEL>
85 <INPUT NAME="phone_circuits" ID="phone_circuits">
90 <& .checkbox, 'is_voip' &>
91 <LABEL FOR="is_voip">This package provides VoIP telephone service</LABEL>
93 <LABEL FOR="voip_sessions">Number of simultaneous calls possible</LABEL>
94 <INPUT NAME="voip_sessions" ID="voip_sessions">
96 <& .checkbox, 'voip_lastmile' &>
97 <LABEL FOR="voip_lastmile">Do you also provide last-mile connectivity?</LABEL>
101 <& .checkbox, 'is_mobile' &>
102 <LABEL FOR="is_mobile">This package provides mobile telephone service</LABEL>
103 <FIELDSET ID="mobile">
104 <LABEL FOR="mobile_direct">Do you bill the customer directly?</LABEL>
105 <& .checkbox, 'mobile_direct' &>
108 <DIV WIDTH="100%" STYLE="text-align:center">
109 <INPUT TYPE="submit" VALUE="Save changes">
113 <SCRIPT TYPE="text/javascript">
114 // this form is invoked as a popup; the current values of the parent
115 // object are in the form field ID passed as the 'id' param
117 var parent_input = window.parent.document.getElementById('<% $parent_id %>');
118 var curr_values = JSON.parse(window.parent_input.value);
119 var form = document.forms['fcc_option_form'];
120 var media_types = <% encode_json($media_types) %>
121 var technology_labels = <% encode_json($technology_labels) %>
123 function set_tech_options() {
124 var form = document.forms['fcc_option_form'];
125 var curr_type = form.elements['media'].value;
126 var technology_obj = form.elements['technology'];
127 technology_obj.options.length = 0;
128 if (media_types[curr_type]) {
129 for( var i = 0; i < media_types[curr_type].length; i++ ) {
130 var value = media_types[curr_type][i];
131 var o = document.createElement('OPTION');
132 o.text = technology_labels[value]
134 technology_obj.add(o);
139 function save_changes() {
140 var form = document.forms['fcc_option_form'];
142 for (var i = 0; i < form.elements.length; i++) {
143 if (form.elements[i].type == 'submit')
146 // quick and dirty test for whether the element is displayed
147 if (form.elements[i].clientHeight > 0) {
148 if (form.elements[i].type == 'checkbox') {
149 if (form.elements[i].checked) {
150 data[ form.elements[i].name ] = 1;
153 data[ form.elements[i].name ] = form.elements[i].value;
157 parent_input.value = JSON.stringify(data);
158 // update the display
159 parent.finish_edit_fcc(parent_input.id);
162 function enable_fieldset(fieldset_id) {
163 var fieldset = document.getElementById(fieldset_id);
164 return function () { fieldset.disabled = !this.checked; };
167 <&| /elements/onload.js &>
168 function addEventListener(target, action, listener) {
169 if (target.addEventListener) {
170 target.addEventListener(action, listener);
171 } else if (target.attachEvent) { // IE 8 fails at everything
172 target.attachEvent('on'+action, listener);
176 // set up all event handlers
177 addEventListener(form, 'submit', save_changes);
179 var sections = [ 'broadband', 'phone', 'voip', 'mobile' ];
180 for(var i = 0; i < sections.length; i++) {
181 var toggle = form.elements['is_'+sections[i]];
182 addEventListener(toggle, 'change', enable_fieldset(sections[i]));
185 addEventListener(form.elements['media'], 'change', set_tech_options);
186 addEventListener(form.elements['phone_wholesale'], 'change',
188 form.elements['phone0'].disabled = (this.value == 1);
189 form.elements['phone1'].disabled = (this.value == '');
192 addEventListener(form.elements['is_phone'], 'change',
194 form.elements['phone_wholesale'].dispatchEvent( new Event('change') );
198 // load data from the parent form and trigger handlers
199 for(var i = 0; i < form.elements.length; i++) {
200 var input_obj = form.elements[i];
201 if (input_obj.type == 'submit') {
203 } else if (input_obj.type == 'checkbox') {
204 input_obj.checked = (curr_values[input_obj.name] > 0);
206 input_obj.value = curr_values[input_obj.name] || '';
208 input_obj.dispatchEvent( new Event('change') );
214 <& /elements/footer.html &>
216 my $media_types = FS::part_pkg_fcc_option->media_types;
217 my $technology_labels = FS::part_pkg_fcc_option->technology_labels;
219 my $parent_id = $cgi->param('id');