Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / misc / delete-invoice_conf.html
1 <%init>
2 my $curuser = $FS::CurrentUser::CurrentUser;
3 die "access denied"
4   unless $curuser->access_right(['Edit templates', 'Edit global templates']);
5
6 my ($query) = $cgi->keywords;
7 $query =~ /^(\d+)$/ or die "bad confnum";
8 my $invoice_conf = FS::invoice_conf->by_key($1)
9   or die "couldn't find invoice_conf #$1";
10 if ( !$curuser->access_right('Edit global templates') ) {
11   my $agentnum = FS::invoice_mode->by_key($invoice_conf->modenum)->agentnum;
12   die "access denied"
13     unless $curuser->agentnums_href->{$agentnum};
14 }
15
16 my $error = $invoice_conf->delete; # may also delete the invoice_mode
17 my $url = $p.'browse/invoice_conf.html';
18 </%init>
19 <% $cgi->redirect($url) %>