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 <% $phonenum_checked %>
42 % if ( $export->get_dids_npa_select ) {
45 <% include('/elements/select-state.html',
46 'prefix' => 'phonenum_', #$field.'_',
47 'country' => $country,
48 'svcpart' => $svcpart,
50 'empty_label' => 'Select state',
51 'disabled' => ( $manual_checked ? 1 : 0 ),
54 <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>State</FONT>
58 <% include('/elements/select-areacode.html',
59 'state_prefix' => 'phonenum_', #$field.'_',
60 'svcpart' => $svcpart,
61 'empty' => 'Select area code',
64 <BR><FONT SIZE="-1" ID="areacode_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Area code</FONT>
68 <% include('/elements/select-exchange.html',
69 'svcpart' => $svcpart,
70 'empty' => 'Select exchange',
73 <BR><FONT SIZE="-1" ID="exchange_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>City / Exchange</FONT>
78 % #this code path currently only being used by fibernetics
79 % # should change "Province" label to "State" or make it configurable
80 % # if/when other folks need an areacode-less DID selector that goes
81 % # directly from state to region
84 <% include('/elements/select.html',
85 'field' => 'phonenum_state',
86 'id' => 'phonenum_state',
87 'options' => [ '', @{ $export->get_dids } ],
88 'labels' => { '' => 'Select province' },
89 'onchange' => 'phonenum_state_changed(this);',
90 'disabled' => ( $manual_checked ? 1 : 0 ),
93 <BR><FONT SIZE="-1" ID="phonenum_state_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Province</FONT>
97 <% include('/elements/select-region.html',
98 'state_prefix' => 'phonenum_', #$field.'_',
99 'svcpart' => $svcpart,
100 'empty' => 'Select region',
103 <BR><FONT SIZE="-1" ID="region_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Region</FONT>
109 <% include('/elements/select-phonenum.html',
110 'svcpart' => $svcpart,
111 'empty' => 'Select phone number',
112 'bulknum' => $bulknum,
113 'multiple' => $multiple,
114 'region' => ! $export->get_dids_npa_select,
117 <BR><FONT SIZE="-1" ID="phonenum_phonenum_label" <% $manual_checked ? 'STYLE="color:#999999"' : '' %>>Phone number</FONT>
122 % if ( $export->get_dids_can_manual ) {
126 <INPUT TYPE = "radio"
127 NAME = "phonenum_which"
128 VALUE = "phonenum_manual"
129 onChange = "phonenum_which_changed(this)"
130 <% $manual_checked %>
135 <& /elements/input-text.html,
137 field => 'phonenum_manual',
138 id => 'phonenum_manual',
140 disabled => ( $phonenum_checked ? 1 : 0 ),
145 <SCRIPT TYPE="text/javascript">
146 function phonenum_which_changed(what) {
148 if ( what.value == 'phonenum' && what.checked ) {
150 what.form.phonenum_manual.disabled = true;
151 what.form.phonenum_manual.style.backgroundColor = '#dddddd';
153 what.form.phonenum_state.disabled = false;
155 document.getElementById('phonenum_state_label').style.color = '#000000';
156 if ( document.getElementById('areacode_label') ) {
157 document.getElementById('areacode_label').style.color = '#000000';
159 if ( document.getElementById('exchange_label') ) {
160 document.getElementById('exchange_label').style.color = '#000000';
162 if ( document.getElementById('region_label') ) {
163 document.getElementById('region_label').style.color = '#000000';
165 document.getElementById('phonenum_phonenum_label').style.color = '#000000';
167 var value = what.form.phonenum_state.options[ what.form.phonenum_state.selectedIndex].value;
171 if ( what.form.areacode ) {
172 what.form.areacode.disabled = false;
174 var areacode_value = what.form.areacode.options[ what.form.areacode.selectedIndex].value;
176 if ( areacode_value != '' ) {
177 what.form.exchange.disabled = false;
179 var exchange_value = what.form.exchange.options[ what.form.exchange.selectedIndex].value;
181 if ( exchange_value != '' ) {
182 what.form.phonenum.disabled = false;
188 if ( what.form.region ) {
189 what.form.region.disabled = false;
191 var region_value = what.form.region.options[ what.form.region.selectedIndex].value;
193 if ( region_value != '' ) {
194 what.form.phonenum.disabled = false;
203 if ( what.value == 'phonenum_manual' && what.checked ) {
205 what.form.phonenum_manual.disabled = false;
206 what.form.phonenum_manual.style.backgroundColor = '#ffffff';
208 what.form.phonenum_state.disabled = true;
210 document.getElementById('phonenum_state_label').style.color = '#999999';
211 if ( document.getElementById('areacode_label') ) {
212 document.getElementById('areacode_label').style.color = '#999999';
214 if ( document.getElementById('exchange_label') ) {
215 document.getElementById('exchange_label').style.color = '#999999';
217 if ( document.getElementById('region_label') ) {
218 document.getElementById('region_label').style.color = '#999999';
220 document.getElementById('phonenum_phonenum_label').style.color = '#999999';
222 if ( what.form.areacode ) {
223 what.form.areacode.disabled = true;
226 if ( what.form.exchange ) {
227 what.form.exchange.disabled = true;
230 if ( what.form.region ) {
231 what.form.region.disabled = true;
234 what.form.phonenum.disabled = true;
245 % if ( ( $export->option('restrict_selection') eq 'tollfree'
246 % || !$export->option('restrict_selection')
248 % and $export->get_dids_can_tollfree
250 <font size="-1">Toll-free</font>
251 <% include('/elements/select-phonenum.html',
252 'svcpart' => $svcpart,
253 'empty' => 'Select phone number',
255 'prefix' => 'tollfree',
262 <div id="bulkdid" style="padding-top: 11px">
264 % for($i=0; $i < $bulknum; $i++) {
265 <div id="bulkdid_<%$i%>" style="display: none">
266 <input type="checkbox" id="checkbox_bulkdid_<%$i%>"
267 name="bulkdid" value="">
268 <label for="checkbox_bulkdid_<%$i%>"
269 id="label_bulkdid_<%$i%>"></label>
277 <% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %>
284 my $conf = new FS::Conf;
286 #false laziness w/tr-select-did.html
287 #XXX make sure this comes through on errors too
288 my $svcpart = $opt{'svcpart'}
289 || $opt{'object'}->svcpart
290 || $opt{'object'}->cust_svc->svcpart;
292 my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
293 die "unknown svcpart $svcpart" unless $part_svc;
295 my @exports = $part_svc->part_export_did;
296 if ( scalar(@exports) > 1 ) {
297 die "more than one DID-providing export attached to svcpart $svcpart";
300 $export = $exports[0] if scalar(@exports);
302 my $use_selector = scalar(@exports) ? 1 : 0;
304 my $bulknum = $opt{'bulknum'} || 0; #Bulk DID orders via ordering system, vs.
305 my $multiple = $opt{'multiple'} || 0; #just selecting a bunch at a time
307 my $country = ( $export && $export->option('country') )
308 || $conf->config('countrydefault')
311 #my $field = $opt{'field'} || 'phonenum';