fcbfcc3987201d7da526063183c601ba216420e7
[freeside.git] / httemplate / misc / phone_avail-import.html
1 <% include('/elements/header.html', 'Phone number (DID) import') %>
2
3 Import a file containing phone numbers (DIDs).
4 <BR><BR>
5
6 <% include( '/elements/form-file_upload.html',
7               'name'      => 'PhonenumImportForm',
8               'action'    => 'process/phone_avail-import.html',
9               'num_files' => 1,
10               'fields'    => [ 'format', 'availbatch', 'exportnum', 'countrycode', 'ordernum' ],
11               'message'   => 'DID import successful',
12               'url'       => $p."search/phone_avail.html?availbatch=$availbatch",
13           )
14 %>
15
16 <% &ntable("#cccccc", 2) %>
17
18
19   <INPUT TYPE="hidden" NAME="availbatch" VALUE="<% $availbatch %>">
20
21 % if ( $ordernum ) {
22     <TR>
23         <TD ALIGN="RIGHT">Bulk DID Order #</TD>
24         <TD><% $ordernum %>
25             <INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
26         </TD>
27     </TR>
28 % } 
29   <TR>
30     <TD ALIGN="RIGHT">Import Format</TD>
31     <TD><% $format %><INPUT TYPE="hidden" NAME="format" VALUE="<% $format %>"></TD>
32   </TR>
33
34   <% include( '/elements/tr-select-table.html',
35                 'table'       => 'part_export',
36                 'name_col'    => 'label',
37                 'order_by'    => 'ORDER BY exportname, machine',
38                 'label'       => 'Export',
39                 'empty_label' => 'Select export',
40                 'hashref'     => { 'exporttype' => 'internal_diddb', },
41                 #'label_callback' => 
42             )
43   %>
44
45   <TR>
46     <TH ALIGN="right">Country code</TH>
47     <TD>
48       <INPUT TYPE  = "text"
49              NAME  = "countrycode"
50              VALUE = "<% $conf->config('default_phone_countrycode') || 1 %>"
51       >
52     </TD>
53   </TR>
54
55   <% include( '/elements/file-upload.html',
56                 'field' => 'file',
57                 'label' => 'Filename',
58             )
59   %>
60
61   <TR>
62     <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
63       <INPUT TYPE    = "submit"
64              ID      = "submit"
65              VALUE   = "Import file"
66              onClick = "document.PhonenumImportForm.submit.disabled=true;"
67       >
68     </TD>
69   </TR>
70
71 </TABLE>
72
73 </FORM>
74
75 <BR>
76
77 Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.  The file should have a .CSV or .XLS extension.
78 <BR><BR>
79
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>
82 <BR><BR>
83 Field information:
84 <ul>
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
90 </ul>
91 <BR><BR>
92
93 <% include('/elements/footer.html') %>
94
95 <%init>
96
97 die "access denied"
98   unless $FS::CurrentUser::CurrentUser->access_right('Import');
99
100 my $conf = new FS::Conf;
101
102 my $ordernum = $cgi->param('ordernum');
103 $ordernum = '' unless $ordernum =~ /^\d+$/;
104
105 die 'invalid ordernum' 
106     unless (!$ordernum || qsearchs('did_order', { 'ordernum' => $ordernum }));
107
108 my $format = 'default';
109 $format = 'bulk' if $ordernum;
110
111 my $availbatch =
112   time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
113
114 </%init>