summaryrefslogtreecommitdiff
path: root/httemplate/misc/phone_avail-import.html
blob: 0febfbcf5db25de8bf885ba3adab4effb3457087 (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<% include('/elements/header.html', 'Phone number (DID) import') %>

Import a file containing phone numbers (DIDs).
<BR><BR>

<& /elements/form-file_upload.html,
     'name'      => 'PhonenumImportForm',
     'action'    => 'process/phone_avail-import.html',
     'num_files' => 1,
     'fields'    => [ 'format', 'availbatch', 'exportnum', 'countrycode',
                      'ordernum', 'confirmed', 'vendor_order_id' ],
     'message'   => 'DID import successful',
     'url'       => $p."search/phone_avail.html?availbatch=$availbatch",
     'onsubmit'  => "document.PhonenumImportForm.submitButton.disabled=true;",
&>

<% &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">Vendor Order #</TD>
	<TD>
	    <INPUT TYPE="text" NAME="vendor_order_id" VALUE="<% $vendor_order_id %>">
	</TD>
    </TR>
    
    <% include( '/elements/tr-input-date-field.html', {
		    'name' => 'confirmed',
		    'label' => 'Order Confirmed',
		    'value' => $confirmed,
           })
    %>

% } 
  <TR>
    <TD ALIGN="RIGHT">Import Format</TD>
    <TD><% $format %><INPUT TYPE="hidden" NAME="format" VALUE="<% $format %>"></TD>
  </TR>

% if ( scalar(@exports) == 1 ) { 
%   my $export = $exports[0];
    <TR>
        <TD>Export</TD>
        <TD>
            <INPUT TYPE="hidden" name="exportnum" value="<%$export->exportnum%>">
            <% $export->exportname %>
        </TD>
    </TR>
% } else {
  <% 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      = "submitButton"
             NAME    = "submitButton"
             VALUE   = "Import file"
      >
    </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>

% if ( $ordernum ) {
    <b>Bulk</b> format has the following field order: <i>state, number, rate center, rate_center_abbrev, msa, latanum</i>
% } else {
    <b>Default</b> format has the following field order: <i>state, number, name</i><br>
% }
<BR><BR>
Field information:
<ul>
  <li><i>state</i>: Two-letter state code, i.e. "CA"
  <li><i>number</i>: Phone number

% if ( $ordernum ) { 
  <li><i>rate center</i>: rate center (required)
  <li><i>rate_center_abbrev</i>: rate center abbreviation
  <li><i>msa</i>: MSA
  <li><i>latanum</i>: LATA #
% } else {
  <li><i>name</i>: optional, rate center
% }
</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+$/;

my $vendor_order_id = '';
my $confirmed = '';

my $order = '';
$order = qsearchs('did_order', { 'ordernum' => $ordernum } ) 
    if $ordernum;

die 'invalid ordernum' unless (!$ordernum || $order);

my $format = 'default';

if ( $order ) {
    $format = 'bulk';
    $confirmed = $order->confirmed;
    $vendor_order_id = $order->vendor_order_id;
}


my $availbatch =
  time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
                
my @exports = qsearch('part_export', { 'exporttype' => 'internal_diddb', });

</%init>