summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-02-10 10:35:13 +0000
committerivan <ivan>2009-02-10 10:35:13 +0000
commitab85518b116ffe93751adbd05ae1412b8a8b2a2e (patch)
tree9c09a9399206d41225a6b76f32a3779544af9f1e
parent380a9fc2da2a9b2bad99485a5d7048dc1ac64ca8 (diff)
quick n' dirty CDR deletion from web interface, RT#4766 / RT#4731
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--httemplate/misc/cdr.cgi48
-rw-r--r--httemplate/search/cdr.html45
3 files changed, 91 insertions, 3 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index bf076f649..fe10572ca 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -221,6 +221,7 @@ tie my %rights, 'Tie::IxHash',
{ rightname=>'Reprocess batches', global=>1 },
{ rightname=>'Import', global=>1 }, #some of these are ag-virt'ed now? give em their own ACLs
{ rightname=>'Export', global=>1 },
+ { rightname=> 'Edit rating data', desc=>'Delete CDRs', global=>1 },
#],
#
###
diff --git a/httemplate/misc/cdr.cgi b/httemplate/misc/cdr.cgi
new file mode 100644
index 000000000..d2ee77364
--- /dev/null
+++ b/httemplate/misc/cdr.cgi
@@ -0,0 +1,48 @@
+%# <% $cgi->redirect(popurl(2). "search/cdr.html") %>
+%# i should be a popup and reload my parent... until then, this will do
+<% include('/elements/header.html','CDR update successful') %>
+<% include('/elements/footer.html') %>
+<%init>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit rating data');
+
+$cgi->param('action') =~ /^(new|del|(reprocess|delete) selected)$/
+ or die "Illegal action";
+my $action = $1;
+
+my $cdr;
+if ( $action eq 'new' || $action eq 'del' ) {
+ $cgi->param('acctid') =~ /^(\d+)$/ or die "Illegal acctid";
+ my $acctid = $1;
+ $cdr = qsearchs('cdr', { 'acctid' => $1 })
+ or die "unknown acctid $acctid";
+}
+
+if ( $action eq 'new' ) {
+ my %hash = $cdr->hash;
+ $hash{'freesidestatus'} = '';
+ my $new = new FS::cdr \%hash;
+ my $error = $new->replace($cdr);
+ die $error if $error;
+} elsif ( $action eq 'del' ) {
+ my $error = $cdr->delete;
+ die $error if $error;
+} elsif ( $action =~ /^(reprocess|delete) selected$/ ) {
+ foreach my $acctid (
+ map { /^acctid(\d+)$/; $1; } grep /^acctid\d+$/, $cgi->param
+ ) {
+ my $cdr = qsearchs('cdr', { 'acctid' => $acctid });
+ if ( $action eq 'reprocess selected' && $cdr ) { #new
+ my %hash = $cdr->hash;
+ $hash{'freesidestatus'} = '';
+ my $new = new FS::cdr \%hash;
+ my $error = $new->replace($cdr);
+ die $error if $error;
+ } elsif ( $action eq 'delete selected' && $cdr ) { #del
+ my $error = $cdr->delete;
+ die $error if $error;
+ }
+ }
+}
+
+</%init>
diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html
index 0fa64c00c..bef49219f 100644
--- a/httemplate/search/cdr.html
+++ b/httemplate/search/cdr.html
@@ -1,15 +1,50 @@
<% include( 'elements/search.html',
'title' => $title,
'name' => 'call detail records',
+
'query' => { 'table' => 'cdr',
'hashref' => $hashref,
'extra_sql' => $qsearch,
'order_by' => 'ORDER BY calldate',
},
'count_query' => $count_query,
- 'header' => [ fields('cdr') ], #XXX fill in some nice names
- 'fields' => [ fields('cdr') ], #XXX fill in some pretty-print
- # processing, etc.
+ 'header' => [
+ '', # checkbox column
+ fields('cdr'), #XXX fill in some nice names
+ ],
+ 'fields' => [
+ sub {
+ return '' unless $edit_data;
+ $areboxes = 1;
+ my $cdr = shift;
+ my $acctid = $cdr->acctid;
+ qq!<INPUT NAME="acctid$acctid" TYPE="checkbox" VALUE="1">!;
+ },
+ fields('cdr'), #XXX fill in some pretty-print
+ #processing, etc.
+ ],
+
+ 'html_form' => qq!<FORM NAME="cdrForm" ACTION="$p/misc/cdr.cgi" METHOD="POST">!,
+ #false laziness w/queue.html
+ 'html_foot' => sub {
+ if ( $areboxes ) {
+ '<BR><INPUT TYPE="button" VALUE="select all" onClick="setAll(true)">'.
+ '<INPUT TYPE="button" VALUE="unselect all" onClick="setAll(false)">'.
+ qq!<BR><INPUT TYPE="submit" NAME="action" VALUE="reprocess selected" onClick="return confirm('Are you sure you want to reprocess the selected CDRs?')">!.
+ qq!<INPUT TYPE="submit" NAME="action" VALUE="delete selected" onClick="return confirm('Are you sure you want to delete the selected CDRs?')"><BR>!.
+ '<SCRIPT TYPE="text/javascript">'.
+ ' function setAll(setTo) { '.
+ ' theForm = document.cdrForm;'.
+ ' for (i=0,n=theForm.elements.length;i<n;i++)'.
+ ' if (theForm.elements[i].name.indexOf("jobnum") != -1)'.
+ ' theForm.elements[i].checked = setTo;'.
+ ' }'.
+ '</SCRIPT>';
+ } else {
+ '';
+ }
+ },
+
)
%>
<%init>
@@ -17,6 +52,10 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
+my $edit_data = $FS::CurrentUser::CurrentUser->access_right('Edit rating data');
+
+my $areboxes = 0;
+
my $title = 'Call Detail Records';
my $hashref = {};