1 <% include('/elements/header.html', 'Phone number (DID) import') %>
3 Import a file containing phone numbers (DIDs).
6 <% include( '/elements/form-file_upload.html',
7 'name' => 'PhonenumImportForm',
8 'action' => 'process/phone_avail-import.html',
10 'fields' => [ 'format', 'availbatch', 'exportnum', 'countrycode', 'ordernum' ],
11 'message' => 'DID import successful',
12 'url' => $p."search/phone_avail.html?availbatch=$availbatch",
16 <% &ntable("#cccccc", 2) %>
19 <INPUT TYPE="hidden" NAME="availbatch" VALUE="<% $availbatch %>">
23 <TD ALIGN="RIGHT">Bulk DID Order #</TD>
25 <INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
30 <TD ALIGN="RIGHT">Import Format</TD>
31 <TD><% $format %><INPUT TYPE="hidden" NAME="format" VALUE="<% $format %>"></TD>
34 <% include( '/elements/tr-select-table.html',
35 'table' => 'part_export',
36 'name_col' => 'label',
37 'order_by' => 'ORDER BY exportname, machine',
39 'empty_label' => 'Select export',
40 'hashref' => { 'exporttype' => 'internal_diddb', },
46 <TH ALIGN="right">Country code</TH>
50 VALUE = "<% $conf->config('default_phone_countrycode') || 1 %>"
55 <% include( '/elements/file-upload.html',
57 'label' => 'Filename',
62 <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
63 <INPUT TYPE = "submit"
66 onClick = "document.PhonenumImportForm.submit.disabled=true;"
77 Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. The file should have a .CSV or .XLS extension.
80 <b>Default</b> format has the following field order: <i>state, number, name</i><br>
81 <b>Bulk</b> format has the following field order: <i>state, number, rate center, rate_center_abbrev</i>
85 <li><i>state</i>: Two-letter state code, i.e. "CA"
86 <li><i>number</i>: Phone number
87 <li><i>name</i>: optional, rate center
88 <li><i>rate center</i>: rate center (required)
89 <li><i>rate_center_abbrev</i>: rate center abbreviation
93 <% include('/elements/footer.html') %>
98 unless $FS::CurrentUser::CurrentUser->access_right('Import');
100 my $conf = new FS::Conf;
102 my $ordernum = $cgi->param('ordernum');
103 $ordernum = '' unless $ordernum =~ /^\d+$/;
105 die 'invalid ordernum'
106 unless (!$ordernum || qsearchs('did_order', { 'ordernum' => $ordernum }));
108 my $format = 'default';
109 $format = 'bulk' if $ordernum;
112 time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);