<% include("/elements/header.html",'Call Detail Record Import') %>
-<FORM ACTION="process/cdr-import.html" METHOD="POST" ENCTYPE="multipart/form-data">
-Import a CSV file containing Call Detail Records (CDRs).<BR><BR>
-CDR Format: <SELECT NAME="format">
-<OPTION VALUE="asterisk">Asterisk (untested)</OPTION>
-<OPTION VALUE="unitel">Unitel/RSLCOM</OPTION>
-<OPTION VALUE="ams">AMS</OPTION>
-</SELECT><BR><BR>
+
+<& /elements/form-file_upload.html,
+ 'name' => 'CDRImportForm',
+ 'action' => 'process/cdr-import.html',
+ 'num_files' => 1,
+ 'fields' => [ 'format', 'cdrbatch', ],
+ 'message' => 'CDR import successful',
+ 'url' => $p."search/cdr.html?cdrbatch=$cdrbatch",
+ 'onsubmit' => "document.CDRImportForm.submitButton.disabled=true;",
+&>
-Filename: <INPUT TYPE="file" NAME="csvfile"><BR><BR>
+Import a file containing Call Detail Records (CDRs).<BR><BR>
+
+<INPUT TYPE="hidden" NAME="cdrbatch" VALUE="<% $cdrbatch %>"%>
+
+<% ntable('#cccccc', 2) %>
+
+ <TR>
+ <TD>CDR Format</TD>
+ <TD>
+ <SELECT NAME="format">
+% foreach my $format ( keys %formats ) {
+ <OPTION VALUE="<% $format %>"><% $formats{$format} %></OPTION>
+% }
+ </SELECT>
+ </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>
-<INPUT TYPE="submit" VALUE="Upload">
</FORM>
<% include('/elements/footer.html') %>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
+tie my %formats, 'Tie::IxHash', FS::cdr->import_formats;
+
+my $cdrbatch = time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
+
</%init>