bulk DID order/inventory improvements, RT11291
[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', 'confirmed', 'vendor_order_id' ],
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     <TR>
29         <TD ALIGN="RIGHT">Vendor Order #</TD>
30         <TD>
31             <INPUT TYPE="text" NAME="vendor_order_id" VALUE="<% $vendor_order_id %>">
32         </TD>
33     </TR>
34     
35     <% include( '/elements/tr-input-date-field.html', {
36                     'name' => 'confirmed',
37                     'label' => 'Order Confirmed',
38                     'value' => $confirmed,
39            })
40     %>
41
42 % } 
43   <TR>
44     <TD ALIGN="RIGHT">Import Format</TD>
45     <TD><% $format %><INPUT TYPE="hidden" NAME="format" VALUE="<% $format %>"></TD>
46   </TR>
47
48   <% include( '/elements/tr-select-table.html',
49                 'table'       => 'part_export',
50                 'name_col'    => 'label',
51                 'order_by'    => 'ORDER BY exportname, machine',
52                 'label'       => 'Export',
53                 'empty_label' => 'Select export',
54                 'hashref'     => { 'exporttype' => 'internal_diddb', },
55                 #'label_callback' => 
56             )
57   %>
58
59   <TR>
60     <TH ALIGN="right">Country code</TH>
61     <TD>
62       <INPUT TYPE  = "text"
63              NAME  = "countrycode"
64              VALUE = "<% $conf->config('default_phone_countrycode') || 1 %>"
65       >
66     </TD>
67   </TR>
68
69   <% include( '/elements/file-upload.html',
70                 'field' => 'file',
71                 'label' => 'Filename',
72             )
73   %>
74
75   <TR>
76     <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
77       <INPUT TYPE    = "submit"
78              ID      = "submit"
79              VALUE   = "Import file"
80              onClick = "document.PhonenumImportForm.submit.disabled=true;"
81       >
82     </TD>
83   </TR>
84
85 </TABLE>
86
87 </FORM>
88
89 <BR>
90
91 Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.  The file should have a .CSV or .XLS extension.
92 <BR><BR>
93
94 <b>Default</b> format has the following field order: <i>state, number, name</i><br>
95 <b>Bulk</b> format has the following field order: <i>state, number, rate center, rate_center_abbrev, msa, latanum</i>
96 <BR><BR>
97 Field information:
98 <ul>
99   <li><i>state</i>: Two-letter state code, i.e. "CA"
100   <li><i>number</i>: Phone number
101   <li><i>name</i>: optional, rate center
102   <li><i>rate center</i>: rate center (required)
103   <li><i>rate_center_abbrev</i>: rate center abbreviation
104   <li><i>msa</i>: MSA
105   <li><i>latanum</i>: LATA #
106 </ul>
107 <BR><BR>
108
109 <% include('/elements/footer.html') %>
110
111 <%init>
112
113 die "access denied"
114   unless $FS::CurrentUser::CurrentUser->access_right('Import');
115
116 my $conf = new FS::Conf;
117
118 my $ordernum = $cgi->param('ordernum');
119 $ordernum = '' unless $ordernum =~ /^\d+$/;
120
121 my $vendor_order_id = '';
122 my $confirmed = '';
123
124 my $order = '';
125 $order = qsearchs('did_order', { 'ordernum' => $ordernum } ) 
126     if $ordernum;
127
128 die 'invalid ordernum' unless (!$ordernum || $order);
129
130 my $format = 'default';
131
132 if ( $order ) {
133     $format = 'bulk';
134     $confirmed = $order->confirmed;
135     $vendor_order_id = $order->vendor_order_id;
136 }
137
138
139 my $availbatch =
140   time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
141
142 </%init>