summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authormark <mark>2009-11-24 01:11:22 +0000
committermark <mark>2009-11-24 01:11:22 +0000
commit0d68f85684a28f28dd895bd37c6a59d0bd91c496 (patch)
tree49b06c99f4c62c8b0a5ef7a939186ac6a33942e5 /httemplate/misc
parentc1d9ee594c7a950e44c0bc6d7e4e25b3d62b9f7b (diff)
cust_attachment improvement, RT#4964 and #6225
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/cust_attachment.cgi34
1 files changed, 34 insertions, 0 deletions
diff --git a/httemplate/misc/cust_attachment.cgi b/httemplate/misc/cust_attachment.cgi
new file mode 100644
index 000000000..d1ec777d8
--- /dev/null
+++ b/httemplate/misc/cust_attachment.cgi
@@ -0,0 +1,34 @@
+<% '',$cgi->redirect(popurl(2). "browse/cust_attachment.html?$browse_opts") %>
+<%init>
+
+$cgi->param('action') =~ /^(Delete|Undelete|Purge) selected$/
+ or die "Illegal action";
+my $action = $1;
+
+my $browse_opts = join(';', map { $_.'='.$cgi->param($_) }
+ qw( orderby show_deleted )
+ );
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right("$action attachment");
+
+foreach my $attachnum (
+ map { /^attachnum(\d+)$/; $1; } grep /^attachnum\d+$/, $cgi->param
+ ) {
+ my $attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
+ my $error;
+ if ( $action eq 'Delete' and !$attach->disabled ) {
+ $attach->disabled(time);
+ $error = $attach->replace;
+ }
+ elsif ( $action eq 'Undelete' and $attach->disabled ) {
+ $attach->disabled('');
+ $error = $attach->replace;
+ }
+ elsif ( $action eq 'Purge' and $attach->disabled ) {
+ $error = $attach->delete;
+ }
+ die $error if $error;
+}
+
+</%init>