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