Bulk DID order 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 % if ( $ordernum ) {
95     <b>Bulk</b> format has the following field order: <i>state, number, rate center, rate_center_abbrev, msa, latanum</i>
96 % } else {
97     <b>Default</b> format has the following field order: <i>state, number, name</i><br>
98 % }
99 <BR><BR>
100 Field information:
101 <ul>
102   <li><i>state</i>: Two-letter state code, i.e. "CA"
103   <li><i>number</i>: Phone number
104
105 % if ( $ordernum ) { 
106   <li><i>rate center</i>: rate center (required)
107   <li><i>rate_center_abbrev</i>: rate center abbreviation
108   <li><i>msa</i>: MSA
109   <li><i>latanum</i>: LATA #
110 % } else {
111   <li><i>name</i>: optional, rate center
112 % }
113 </ul>
114 <BR><BR>
115
116 <% include('/elements/footer.html') %>
117
118 <%init>
119
120 die "access denied"
121   unless $FS::CurrentUser::CurrentUser->access_right('Import');
122
123 my $conf = new FS::Conf;
124
125 my $ordernum = $cgi->param('ordernum');
126 $ordernum = '' unless $ordernum =~ /^\d+$/;
127
128 my $vendor_order_id = '';
129 my $confirmed = '';
130
131 my $order = '';
132 $order = qsearchs('did_order', { 'ordernum' => $ordernum } ) 
133     if $ordernum;
134
135 die 'invalid ordernum' unless (!$ordernum || $order);
136
137 my $format = 'default';
138
139 if ( $order ) {
140     $format = 'bulk';
141     $confirmed = $order->confirmed;
142     $vendor_order_id = $order->vendor_order_id;
143 }
144
145
146 my $availbatch =
147   time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
148
149 </%init>