5 include('/elements/select-did.html',
6 #can't actuall change from phonenum yet# 'field' => 'phonenum',
10 'object' => $svc_phone,
14 % if ( $use_selector ) {
16 % if ( $export->option('restrict_selection') eq 'non-tollfree'
17 % || !$export->option('restrict_selection') ) {
21 % my( $phonenum_checked, $manual_checked ) = ( '', '' );
22 % if ( $export->get_dids_can_manual ) {
23 % #not 100% perfect UI on error handling, but it'll do
24 % if ( $opt{'curr_value'} ) {
25 % $phonenum_checked = '';
26 % $manual_checked = 'CHECKED';
28 % $phonenum_checked = 'CHECKED';
29 % $manual_checked = '';
34 NAME = "phonenum_which"
36 onChange = "phonenum_which_changed(this)"
37 onClick = "phonenum_which_changed(this)"
38 <% $phonenum_checked %>
43 % if ( $export->get_dids_npa_select ) {
46 <% include('/elements/select-state.html',
47 'prefix' => 'phonenum_', #$field.'_',
48 'country' => $country,
49 'svcpart' => $svcpart,
51 'empty_label' => 'Select state',
52 'disabled' => ( $manual_checked ? 1 : 0 ),
55 <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>State</FONT>
59 <% include('/elements/select-areacode.html',
60 'state_prefix' => 'phonenum_', #$field.'_',
61 'svcpart' => $svcpart,
62 'empty' => 'Select area code',
65 <BR><FONT SIZE="-1" ID="areacode_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Area code</FONT>
69 <% include('/elements/select-exchange.html',
70 'svcpart' => $svcpart,
71 'empty' => 'Select exchange',
74 <BR><FONT SIZE="-1" ID="exchange_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>City / Exchange</FONT>
79 % #this code path currently only being used by fibernetics
80 % # should change "Province" label to "State" or make it configurable
81 % # if/when other folks need an areacode-less DID selector that goes
82 % # directly from state to region
85 <% include('/elements/select.html',
86 'field' => 'phonenum_state',
87 'id' => 'phonenum_state',
88 'options' => [ '', @{ $export->get_dids } ],
89 'labels' => { '' => 'Select province' },
90 'onchange' => 'phonenum_state_changed(this);',
91 'disabled' => ( $manual_checked ? 1 : 0 ),
94 <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Province</FONT>
98 <% include('/elements/select-region.html',
99 'state_prefix' => 'phonenum_', #$field.'_',
100 'svcpart' => $svcpart,
101 'empty' => 'Select region',
104 <BR><FONT SIZE="-1" ID="region_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Region</FONT>
110 <% include('/elements/select-phonenum.html',
111 'svcpart' => $svcpart,
112 'empty' => 'Select phone number',
113 'bulknum' => $bulknum,
114 'multiple' => $multiple,
115 'region' => ! $export->get_dids_npa_select,
118 <BR><FONT SIZE="-1" ID="phonenum_phonenum_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Phone number</FONT>
123 % if ( $export->get_dids_can_manual ) {
127 <INPUT TYPE = "radio"
128 NAME = "phonenum_which"
129 VALUE = "phonenum_manual"
130 onChange = "phonenum_which_changed(this)"
131 onClick = "phonenum_which_changed(this)"
132 <% $manual_checked %>
136 <TD VALIGN="top" COLSPAN=4>
137 <& /elements/input-text.html,
139 field => 'phonenum_manual',
140 id => 'phonenum_manual',
142 disabled => ( $phonenum_checked ? 1 : 0 ),
147 <SCRIPT TYPE="text/javascript">
148 function phonenum_which_changed(what) {
150 if ( what.value == 'phonenum' && what.checked ) {
152 what.form.phonenum_manual.disabled = true;
153 what.form.phonenum_manual.style.backgroundColor = '#dddddd';
155 what.form.phonenum_state.disabled = false;
157 document.getElementById('phonenum_state_label').style.color = '#000000';
158 if ( document.getElementById('areacode_label') ) {
159 document.getElementById('areacode_label').style.color = '#000000';
161 if ( document.getElementById('exchange_label') ) {
162 document.getElementById('exchange_label').style.color = '#000000';
164 if ( document.getElementById('region_label') ) {
165 document.getElementById('region_label').style.color = '#000000';
167 document.getElementById('phonenum_phonenum_label').style.color = '#000000';
169 var value = what.form.phonenum_state.options[ what.form.phonenum_state.selectedIndex].value;
173 if ( what.form.areacode ) {
174 what.form.areacode.disabled = false;
176 var areacode_value = what.form.areacode.options[ what.form.areacode.selectedIndex].value;
178 if ( areacode_value != '' ) {
179 what.form.exchange.disabled = false;
181 var exchange_value = what.form.exchange.options[ what.form.exchange.selectedIndex].value;
183 if ( exchange_value != '' ) {
184 what.form.phonenum.disabled = false;
190 if ( what.form.region ) {
191 what.form.region.disabled = false;
193 var region_value = what.form.region.options[ what.form.region.selectedIndex].value;
195 if ( region_value != '' ) {
196 what.form.phonenum.disabled = false;
205 if ( what.value == 'phonenum_manual' && what.checked ) {
207 what.form.phonenum_manual.disabled = false;
208 what.form.phonenum_manual.style.backgroundColor = '#ffffff';
210 what.form.phonenum_state.disabled = true;
212 document.getElementById('phonenum_state_label').style.color = '#999999';
213 if ( document.getElementById('areacode_label') ) {
214 document.getElementById('areacode_label').style.color = '#999999';
216 if ( document.getElementById('exchange_label') ) {
217 document.getElementById('exchange_label').style.color = '#999999';
219 if ( document.getElementById('region_label') ) {
220 document.getElementById('region_label').style.color = '#999999';
222 document.getElementById('phonenum_phonenum_label').style.color = '#999999';
224 if ( what.form.areacode ) {
225 what.form.areacode.disabled = true;
228 if ( what.form.exchange ) {
229 what.form.exchange.disabled = true;
232 if ( what.form.region ) {
233 what.form.region.disabled = true;
236 what.form.phonenum.disabled = true;
247 % if ( ( $export->option('restrict_selection') eq 'tollfree'
248 % || !$export->option('restrict_selection')
250 % and $export->get_dids_can_tollfree
252 <font size="-1">Toll-free</font>
253 <% include('/elements/select-phonenum.html',
254 'svcpart' => $svcpart,
255 'empty' => 'Select phone number',
257 'prefix' => 'tollfree',
264 <div id="bulkdid" style="padding-top: 11px">
266 % for($i=0; $i < $bulknum; $i++) {
267 <div id="bulkdid_<%$i%>" style="display: none">
268 <input type="checkbox" id="checkbox_bulkdid_<%$i%>"
269 name="bulkdid" value="">
270 <label for="checkbox_bulkdid_<%$i%>"
271 id="label_bulkdid_<%$i%>"></label>
279 <% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %>
286 my $conf = new FS::Conf;
288 #false laziness w/tr-select-did.html
289 #XXX make sure this comes through on errors too
290 my $svcpart = $opt{'svcpart'}
291 || $opt{'object'}->svcpart
292 || $opt{'object'}->cust_svc->svcpart;
294 my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
295 die "unknown svcpart $svcpart" unless $part_svc;
297 my @exports = $part_svc->part_export_did;
298 if ( scalar(@exports) > 1 ) {
299 die "more than one DID-providing export attached to svcpart $svcpart";
302 $export = $exports[0] if scalar(@exports);
304 my $use_selector = scalar(@exports) ? 1 : 0;
306 my $bulknum = $opt{'bulknum'} || 0; #Bulk DID orders via ordering system, vs.
307 my $multiple = $opt{'multiple'} || 0; #just selecting a bunch at a time
309 my $country = ( $export && $export->option('country') )
310 || $conf->config('countrydefault')
313 #my $field = $opt{'field'} || 'phonenum';