5 include('/elements/select-did.html',
6 #can't actuall change from phonenum yet# 'field' => 'phonenum',
10 'object' => $svc_phone,
14 % if ( $conf->exists('svc_phone-lnp') ) { #ask exports if they can_lnp instead?
15 <& /elements/selectlayers.html,
16 'field' => 'lnp_status',
17 'curr_value' => $opt{'lnp_status'},
18 'options' => [ '', 'portingin', 'native', 'portedin', 'portingout',
19 'portin-reject', 'portout-reject',
21 'labels' => { '' => 'Select new number',
22 'portingin' => 'Port an existing number',
24 'portedin' => 'Ported In',
25 'portingout' => 'Porting Out',
26 'portin-reject' => 'Port-In Reject',
27 'portout-reject' => 'Port-Out Reject',
29 'layer_callback' => sub {
30 my( $layer, $layer_fields, $layer_values, $layer_prefix ) = @_;
31 if ( $layer eq 'portingin' ) {
32 $m->scomp('/elements/input-text.html', %opt, 'type'=>'text' );
33 } elsif ( $layer ne '' ) {
34 $m->scomp('/elements/hidden.html', %opt).
35 $m->scomp('/elements/phonenumber.html', $opt{'curr_value'}, 'callable' => 1);
37 $m->scomp('/elements/select-did.html:not_porting', %opt);
44 <& /elements/select-did.html:not_porting, %opt &>
50 my $conf = new FS::Conf;
54 % if ( $use_selector ) {
56 % if ( $export->option('restrict_selection') eq 'non-tollfree'
57 % || !$export->option('restrict_selection') ) {
61 % my( $phonenum_checked, $manual_checked ) = ( '', '' );
62 % if ( $export->get_dids_can_manual ) {
63 % #not 100% perfect UI on error handling, but it'll do
64 % if ( $opt{'curr_value'} ) {
65 % $phonenum_checked = '';
66 % $manual_checked = 'CHECKED';
68 % $phonenum_checked = 'CHECKED';
69 % $manual_checked = '';
74 NAME = "phonenum_which"
76 onChange = "phonenum_which_changed(this)"
77 onClick = "phonenum_which_changed(this)"
78 <% $phonenum_checked %>
83 % if ( $export->get_dids_npa_select ) {
86 <% include('/elements/select-state.html',
87 'prefix' => 'phonenum_', #$field.'_',
88 'country' => $country,
89 'svcpart' => $svcpart,
91 'empty_label' => 'Select state',
92 'disabled' => ( $manual_checked ? 1 : 0 ),
95 <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>State</FONT>
99 <% include('/elements/select-areacode.html',
100 'state_prefix' => 'phonenum_', #$field.'_',
101 'svcpart' => $svcpart,
102 'empty' => 'Select area code',
105 <BR><FONT SIZE="-1" ID="areacode_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Area code</FONT>
109 <% include('/elements/select-exchange.html',
110 'svcpart' => $svcpart,
111 'empty' => 'Select exchange',
114 <BR><FONT SIZE="-1" ID="exchange_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>City / Exchange</FONT>
119 % #this code path currently only being used by fibernetics
120 % # should change "Province" label to "State" or make it configurable
121 % # if/when other folks need an areacode-less DID selector that goes
122 % # directly from state to region
125 <% include('/elements/select.html',
126 'field' => 'phonenum_state',
127 'id' => 'phonenum_state',
128 'options' => [ '', @{ $export->get_dids } ],
129 'labels' => { '' => 'Select province' },
130 'onchange' => 'phonenum_state_changed(this);',
131 'disabled' => ( $manual_checked ? 1 : 0 ),
134 <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Province</FONT>
138 <% include('/elements/select-region.html',
139 'state_prefix' => 'phonenum_', #$field.'_',
140 'svcpart' => $svcpart,
141 'empty' => 'Select region',
144 <BR><FONT SIZE="-1" ID="region_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Region</FONT>
150 <% include('/elements/select-phonenum.html',
151 'svcpart' => $svcpart,
152 'empty' => 'Select phone number',
153 'bulknum' => $bulknum,
154 'multiple' => $multiple,
155 'region' => ! $export->get_dids_npa_select,
158 <BR><FONT SIZE="-1" ID="phonenum_phonenum_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Phone number</FONT>
163 % if ( $export->get_dids_can_manual ) {
167 <INPUT TYPE = "radio"
168 NAME = "phonenum_which"
169 VALUE = "phonenum_manual"
170 onChange = "phonenum_which_changed(this)"
171 onClick = "phonenum_which_changed(this)"
172 <% $manual_checked %>
176 <TD VALIGN="top" COLSPAN=4>
177 <& /elements/input-text.html,
179 field => 'phonenum_manual',
180 id => 'phonenum_manual',
182 disabled => ( $phonenum_checked ? 1 : 0 ),
187 <SCRIPT TYPE="text/javascript">
188 function phonenum_which_changed(what) {
190 if ( what.value == 'phonenum' && what.checked ) {
192 what.form.phonenum_manual.disabled = true;
193 what.form.phonenum_manual.style.backgroundColor = '#dddddd';
195 what.form.phonenum_state.disabled = false;
197 document.getElementById('phonenum_state_label').style.color = '#000000';
198 if ( document.getElementById('areacode_label') ) {
199 document.getElementById('areacode_label').style.color = '#000000';
201 if ( document.getElementById('exchange_label') ) {
202 document.getElementById('exchange_label').style.color = '#000000';
204 if ( document.getElementById('region_label') ) {
205 document.getElementById('region_label').style.color = '#000000';
207 document.getElementById('phonenum_phonenum_label').style.color = '#000000';
209 var value = what.form.phonenum_state.options[ what.form.phonenum_state.selectedIndex].value;
213 if ( what.form.areacode ) {
214 what.form.areacode.disabled = false;
216 var areacode_value = what.form.areacode.options[ what.form.areacode.selectedIndex].value;
218 if ( areacode_value != '' ) {
219 what.form.exchange.disabled = false;
221 var exchange_value = what.form.exchange.options[ what.form.exchange.selectedIndex].value;
223 if ( exchange_value != '' ) {
224 what.form.phonenum.disabled = false;
230 if ( what.form.region ) {
231 what.form.region.disabled = false;
233 var region_value = what.form.region.options[ what.form.region.selectedIndex].value;
235 if ( region_value != '' ) {
236 what.form.phonenum.disabled = false;
245 if ( what.value == 'phonenum_manual' && what.checked ) {
247 what.form.phonenum_manual.disabled = false;
248 what.form.phonenum_manual.style.backgroundColor = '#ffffff';
250 what.form.phonenum_state.disabled = true;
252 document.getElementById('phonenum_state_label').style.color = '#999999';
253 if ( document.getElementById('areacode_label') ) {
254 document.getElementById('areacode_label').style.color = '#999999';
256 if ( document.getElementById('exchange_label') ) {
257 document.getElementById('exchange_label').style.color = '#999999';
259 if ( document.getElementById('region_label') ) {
260 document.getElementById('region_label').style.color = '#999999';
262 document.getElementById('phonenum_phonenum_label').style.color = '#999999';
264 if ( what.form.areacode ) {
265 what.form.areacode.disabled = true;
268 if ( what.form.exchange ) {
269 what.form.exchange.disabled = true;
272 if ( what.form.region ) {
273 what.form.region.disabled = true;
276 what.form.phonenum.disabled = true;
287 % if ( ( $export->option('restrict_selection') eq 'tollfree'
288 % || !$export->option('restrict_selection')
290 % and $export->get_dids_can_tollfree
292 <font size="-1">Toll-free</font>
293 <% include('/elements/select-phonenum.html',
294 'svcpart' => $svcpart,
295 'empty' => 'Select phone number',
297 'prefix' => 'tollfree',
304 <div id="bulkdid" style="padding-top: 11px">
306 % for($i=0; $i < $bulknum; $i++) {
307 <div id="bulkdid_<%$i%>" style="display: none">
308 <input type="checkbox" id="checkbox_bulkdid_<%$i%>"
309 name="bulkdid" value="">
310 <label for="checkbox_bulkdid_<%$i%>"
311 id="label_bulkdid_<%$i%>"></label>
319 <% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %>
326 my $conf = new FS::Conf;
328 #false laziness w/tr-select-did.html
329 #XXX make sure this comes through on errors too
330 my $svcpart = $opt{'svcpart'}
331 || $opt{'object'}->svcpart
332 || $opt{'object'}->cust_svc->svcpart;
334 my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
335 die "unknown svcpart $svcpart" unless $part_svc;
337 my @exports = $part_svc->part_export_did;
338 if ( scalar(@exports) > 1 ) {
339 die "more than one DID-providing export attached to svcpart $svcpart";
341 my $export = scalar(@exports) ? $exports[0] : '';
343 my $use_selector = scalar(@exports) ? 1 : 0;
345 my $bulknum = $opt{'bulknum'} || 0; #Bulk DID orders via ordering system, vs.
346 my $multiple = $opt{'multiple'} || 0; #just selecting a bunch at a time
348 my $country = ( $export && $export->option('country') )
349 || $conf->config('countrydefault')