discounts, RT#6679
[freeside.git] / httemplate / edit / process / discount.html
1 <% include( 'elements/process.html',
2                'table'       => 'discount',
3                'viewall_dir' => 'browse',
4                'precheck_callback' => $precheck_callback,
5            )
6 %>
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
11
12 my $precheck_callback = sub {
13   my( $cgi ) = @_;
14
15   if ( $cgi->param('_type') eq 'Select discount type' ) {
16     return 'Please select a discount type';
17   } elsif ( $cgi->param('_type') eq 'Amount' ) {
18     $cgi->param('percent', '0');
19     return 'Amount must be greater than 0' unless $cgi->param('amount') > 0;
20   } elsif ( $cgi->param('_type') eq 'Percentage' ) {
21     $cgi->param('amount', '0.00');
22     return 'Percentage must be greater than 0' unless $cgi->param('percent') > 0;
23   }
24
25   '';
26 };
27
28 </%init>