summaryrefslogtreecommitdiff
path: root/httemplate/misc/part_pkg_fcc_options.html
blob: f74328446034c1f7c62d899543312772214a81b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<& /elements/header-popup.html &>

<STYLE>
  fieldset {
    border: 1px solid #7e0079;
    border-radius: 8px;
    background-color: #fff;
  }
  fieldset.inv {
    border: none;
  }
  fieldset:disabled {
    display: none;
  } 
</STYLE>

<%def .checkbox>
% my $field = shift;
% my $extra = shift || '';
<INPUT TYPE="checkbox" NAME="<% $field %>" ID="<% $field %>" VALUE="1" <%$extra%>>
</%def>

<FORM NAME="fcc_option_form">
% # The option structure is hardcoded.  The FCC rules changed enough from 
% # the original 477 report to the 2013 revision that any data-driven 
% # mechanism for expressing the original rules would likely fail to 
% # accommodate the new ones.  Therefore, we assume that whatever the FCC
% # does NEXT will also require a rewrite of this form, and we'll deal with
% # that when it arrives.
  <P>
    <LABEL FOR="media">Media type</LABEL>
    <SELECT NAME="media" ID="media">
      <OPTION VALUE=""></OPTION>
% foreach (keys(%$media_types)) {
      <OPTION VALUE="<% $_ %>"><% $_ %></OPTION>
% }
    </SELECT>
  </P>
  <P>
    <& .checkbox, 'is_consumer' &>
    <LABEL FOR="is_consumer">This is a consumer-grade package</LABEL>
  </P>
  <P>
    <& .checkbox, 'is_broadband' &>
    <LABEL FOR="is_broadband">This package provides broadband service</LABEL>
    <FIELDSET ID="broadband">
      <LABEL FOR="technology">Technology of transmission</LABEL>
      <SELECT NAME="technology" ID="technology"> </SELECT>
      <BR>
      <LABEL FOR="broadband_downstream">Downstream speed (Mbps)</LABEL>
      <INPUT NAME="broadband_downstream" ID="broadband_downstream">
      <BR>
      <LABEL FOR="broadband_upstream">Upstream speed (Mbps)</LABEL>
      <INPUT NAME="broadband_upstream" ID="broadband_upstream">
    </FIELDSET>
  </P>
  <P>
    <& .checkbox, 'is_phone' &>
    <LABEL FOR="is_phone">This package provides local telephone service</LABEL>
    <FIELDSET ID="phone">
      <LABEL FOR="phone_wholesale">Marketed as</LABEL>
      <SELECT NAME="phone_wholesale" ID="phone_wholesale">
        <OPTION VALUE="">end user</OPTION>
        <OPTION VALUE="1">wholesale</OPTION>
      </SELECT>
      <FIELDSET CLASS="inv" ID="phone0" DISABLED="1">
        <LABEL FOR="phone_lines">Number of voice-grade equivalents</LABEL>
        <INPUT NAME="phone_lines" ID="phone_lines">
        <BR>
        <LABEL FOR="phone_longdistance">Are you the presubscribed long-distance carrier?</LABEL>
        <& .checkbox, 'phone_longdistance' &>
        <BR>
        <LABEL FOR="phone_localloop">Local loop arrangement</LABEL>
        <SELECT NAME="phone_localloop" ID="phone_localloop">
          <OPTION VALUE="owned">You own the local loop</OPTION>
          <OPTION VALUE="leased">You lease UNE-L from another carrier</OPTION>
          <OPTION VALUE="resale">You resell another carrier's service</OPTION>
        </SELECT>
      </FIELDSET>
      <FIELDSET CLASS="inv" ID="phone1" DISABLED="1">
        <LABEL FOR="phone_vges">Number of voice-grade equivalents (if any)</LABEL>
        <INPUT NAME="phone_vges" ID="phone_vges">
        <BR>
        <LABEL FOR="phone_circuits">Number of unswitched circuits (if any)</LABEL>
        <INPUT NAME="phone_circuits" ID="phone_circuits">
      </FIELDSET>
    </FIELDSET>
  </P>
  <P>
    <& .checkbox, 'is_voip' &>
    <LABEL FOR="is_voip">This package provides VoIP telephone service</LABEL>
    <FIELDSET ID="voip">
      <& .checkbox, 'voip_lastmile' &>
      <LABEL FOR="voip_lastmile">Do you also provide last-mile connectivity?</LABEL>
    </FIELDSET>
  </P>
  <DIV WIDTH="100%" STYLE="text-align:center">
    <INPUT TYPE="submit" VALUE="Save changes">
  </DIV>
</FORM>

<SCRIPT TYPE="text/javascript">
// this form is invoked as a popup; the current values of the parent 
// object are in the form field ID passed as the 'id' param

var parent_input = window.parent.document.getElementById('<% $parent_id %>');
var curr_values = JSON.parse(window.parent_input.value);
var form = document.forms['fcc_option_form'];
var media_types = <% encode_json($media_types) %>
var technology_labels = <% encode_json($technology_labels) %>

function set_tech_options() {
  var form = document.forms['fcc_option_form'];
  var curr_type = form.elements['media'].value;
  var technology_obj = form.elements['technology'];
  technology_obj.options.length = 0;
  if (media_types[curr_type]) {
    for( var i = 0; i < media_types[curr_type].length; i++ ) {
      var value = media_types[curr_type][i];
      var o = document.createElement('OPTION');
      o.text = technology_labels[value]
      o.value = value;
      technology_obj.add(o);
    }
  }
}
  
function save_changes() {
  var form = document.forms['fcc_option_form'];
  var data = {};
  for (var i = 0; i < form.elements.length; i++) {
    if (form.elements[i].type == 'submit')
      continue;

    // quick and dirty test for whether the element is displayed
    if (form.elements[i].clientHeight > 0) {
      if (form.elements[i].type == 'checkbox') {
        if (form.elements[i].checked) {
          data[ form.elements[i].name ] = 1;
        }
      } else {
        data[ form.elements[i].name ] = form.elements[i].value;
      }
    }
  }
  parent_input.value = JSON.stringify(data);
  // update the display
  parent.show_fcc_options();
  parent.cClick(); //overlib
}

function enable_fieldset(fieldset_id) {
  var fieldset = document.getElementById(fieldset_id);
  return function () { fieldset.disabled = !this.checked; };
}

<&| /elements/onload.js &>
  function addEventListener(target, action, listener) {
    if (target.addEventListener) {
      target.addEventListener(action, listener);
    } else if (target.attachEvent) { // IE 8 fails at everything
      target.attachEvent('on'+action, listener);
    }
  }

  // set up all event handlers
  addEventListener(form, 'submit', save_changes);

  var sections = [ 'broadband', 'phone', 'voip' ];
  for(var i = 0; i < sections.length; i++) {
    var toggle = form.elements['is_'+sections[i]];
    addEventListener(toggle, 'change', enable_fieldset(sections[i]));
  }

  addEventListener(form.elements['media'], 'change', set_tech_options);
  addEventListener(form.elements['phone_wholesale'], 'change',
    function () {
      form.elements['phone0'].disabled = (this.value == 1);
      form.elements['phone1'].disabled = (this.value == '');
    }
  );

  // load data from the parent form and trigger handlers
  for(var i = 0; i < form.elements.length; i++) {
    var input_obj = form.elements[i];
    if (input_obj.type == 'submit') {
      //nothing
    } else if (input_obj.type == 'checkbox') {
      input_obj.checked = (curr_values[input_obj.name] > 0);
    } else {
      input_obj.value = curr_values[input_obj.name] || '';
    }
    input_obj.dispatchEvent( new Event('change') );
  }

</&>

</SCRIPT>
<& /elements/footer.html &>
<%init>
my $media_types = FS::part_pkg_fcc_option->media_types;
my $technology_labels = FS::part_pkg_fcc_option->technology_labels;

my $parent_id = $cgi->param('id');
</%init>