RT# 79284 Updated discounts UI for Change Package screen
[freeside.git] / httemplate / misc / cust_attachment.cgi
1 <% '',$cgi->redirect(popurl(2). "browse/cust_attachment.html?$browse_opts") %>
2 <%init>
3
4 $cgi->param('action') =~ /^(Delete|Undelete|Purge) selected$/
5   or die "Illegal action";
6 my $action = $1;
7
8 my $browse_opts = join(';', map { $_.'='.$cgi->param($_) } 
9     qw( orderby show_deleted )
10     );
11
12 die "access denied"
13   unless $FS::CurrentUser::CurrentUser->access_right("$action attachment");
14
15 foreach my $attachnum (
16     map { /^attachnum(\d+)$/; $1; } grep /^attachnum\d+$/, $cgi->param
17   ) {
18   my $attach = qsearchs('cust_attachment', { 'attachnum' => $attachnum });
19   my $error;
20   if ( $action eq 'Delete' and !$attach->disabled ) {
21     $attach->disabled(time);
22     $error = $attach->replace;
23   }
24   elsif ( $action eq 'Undelete' and $attach->disabled ) {
25     $attach->disabled('');
26     $error = $attach->replace;
27   }
28   elsif ( $action eq 'Purge' and $attach->disabled ) {
29     $error = $attach->delete;
30   }
31   die $error if $error;
32 }
33
34 </%init>