[freeside-commits] freeside/httemplate/misc cdr-post.cgi, NONE, 1.1 cdr-post.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Tue Jun 8 01:24:48 PDT 2010
- Previous message: [freeside-commits] freeside/FS/FS cdr.pm,1.57,1.58
- Next message: [freeside-commits] freeside/FS/FS Conf.pm, 1.365, 1.366 Mason.pm, 1.39, 1.40 Schema.pm, 1.219, 1.220 cust_bill.pm, 1.283, 1.284 bill_batch.pm, NONE, 1.1 cust_bill_batch.pm, NONE, 1.1 cust_bill_batch_option.pm, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail.420.am:/tmp/cvs-serv22452
Added Files:
cdr-post.cgi cdr-post.html
Log Message:
add programmatic CDR posting, RT#8201
--- NEW FILE: cdr-post.html ---
<% include("/elements/header.html",'Call Detail Record - POST Import') %>
<FORM METHOD="POST" ACTION="cdr-post.cgi" enctype="multipart/form-data">
cdr_file: <INPUT TYPE="file" NAME="cdr_file"><BR><BR>
<INPUT TYPE="submit" VALUE="upload">
</FORM>
<% include("/elements/footer.html") %>
--- NEW FILE: cdr-post.cgi ---
% if ( $error ) {
0,"<% $error %>",,
% } else {
1,"CDR import successful',<% $cdr_batch->cdrbatchnum %>,"<% $cdrbatch %>"
% }
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
my $error = '';
my $cdr_batch;
{
my $filename = $cgi->param('cdr_file');
unless ( $filename ) {
$error = "No cdr_file filename";
last;
}
my $fh = $cgi->upload('cdr_file');
unless ( defined($fh) ) {
$error = 'No cdr_file file';
last;
}
#i should probably be transactionalized.
my $csv = new Text::CSV_XS or die Text::CSV->error_diag;
my $cdrbatch = time2str('post-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
$cdr_batch = new FS::cdr_batch { 'cdrbatch' => $cdrbatch };
$error = $cdr_batch->insert and last;
chomp(my $hline = scalar(<$fh>));
$csv->parse($hline);
my @header = $csv->fields;
#while ( my $row = $csv->getline($fh) ) {
while (<$fh>) {
$csv->parse($_);
my @row = $csv->fields;
my $cdr = new FS::cdr { 'cdrbatchnum' => $cdr_batch->cdrbatchnum };
$cdr->set( lc($_) => shift(@row) ) foreach @header;
$error = $cdr->insert and last;
}
}
</%init>
- Previous message: [freeside-commits] freeside/FS/FS cdr.pm,1.57,1.58
- Next message: [freeside-commits] freeside/FS/FS Conf.pm, 1.365, 1.366 Mason.pm, 1.39, 1.40 Schema.pm, 1.219, 1.220 cust_bill.pm, 1.283, 1.284 bill_batch.pm, NONE, 1.1 cust_bill_batch.pm, NONE, 1.1 cust_bill_batch_option.pm, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list