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
|
<% include('/elements/header.html', 'Phone number (DID) import') %>
Import a file containing phone numbers (DIDs).
<BR><BR>
<% include( '/elements/form-file_upload.html',
'name' => 'PhonenumImportForm',
'action' => 'process/phone_avail-import.html',
'num_files' => 1,
'fields' => [ 'format', 'availbatch', 'exportnum', 'countrycode', 'ordernum' ],
'message' => 'DID import successful',
'url' => $p."search/phone_avail.html?availbatch=$availbatch",
)
%>
<% &ntable("#cccccc", 2) %>
<INPUT TYPE="hidden" NAME="availbatch" VALUE="<% $availbatch %>">
% if ( $ordernum ) {
<TR>
<TD ALIGN="RIGHT">Bulk DID Order #</TD>
<TD><% $ordernum %>
<INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
</TD>
</TR>
% }
<TR>
<TD ALIGN="RIGHT">Import Format</TD>
<TD><% $format %><INPUT TYPE="hidden" NAME="format" VALUE="<% $format %>"></TD>
</TR>
<% include( '/elements/tr-select-table.html',
'table' => 'part_export',
'name_col' => 'label',
'order_by' => 'ORDER BY exportname, machine',
'label' => 'Export',
'empty_label' => 'Select export',
'hashref' => { 'exporttype' => 'internal_diddb', },
#'label_callback' =>
)
%>
<TR>
<TH ALIGN="right">Country code</TH>
<TD>
<INPUT TYPE = "text"
NAME = "countrycode"
VALUE = "<% $conf->config('default_phone_countrycode') || 1 %>"
>
</TD>
</TR>
<% include( '/elements/file-upload.html',
'field' => 'file',
'label' => 'Filename',
)
%>
<TR>
<TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
<INPUT TYPE = "submit"
ID = "submit"
VALUE = "Import file"
onClick = "document.PhonenumImportForm.submit.disabled=true;"
>
</TD>
</TR>
</TABLE>
</FORM>
<BR>
Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. The file should have a .CSV or .XLS extension.
<BR><BR>
<b>Default</b> format has the following field order: <i>state, number, name</i><br>
<b>Bulk</b> format has the following field order: <i>state, number, rate center, rate_center_abbrev</i>
<BR><BR>
Field information:
<ul>
<li><i>state</i>: Two-letter state code, i.e. "CA"
<li><i>number</i>: Phone number
<li><i>name</i>: optional, rate center
<li><i>rate center</i>: rate center (required)
<li><i>rate_center_abbrev</i>: rate center abbreviation
</ul>
<BR><BR>
<% include('/elements/footer.html') %>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
my $conf = new FS::Conf;
my $ordernum = $cgi->param('ordernum');
$ordernum = '' unless $ordernum =~ /^\d+$/;
die 'invalid ordernum'
unless (!$ordernum || qsearchs('did_order', { 'ordernum' => $ordernum }));
my $format = 'default';
$format = 'bulk' if $ordernum;
my $availbatch =
time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
</%init>
|