summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/reg_code.cgi
blob: 035e10b9019e14fbe75911d0b36b82315cfeff6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%unless ( ref($error) ) {
%  $cgi->param('error'. $error );
<% $cgi->redirect(popurl(3). "edit/reg_code.cgi?". $cgi->query_string ) %>
% } else { 

<% include("/elements/header.html","$num registration codes generated for ". $agent->agent, menubar(
  'View all agents' => popurl(3). 'browse/agent.cgi',
) ) %>

<PRE><FONT SIZE="+1">
% foreach my $code ( @$error ) { 
  <% $code %>
% } 
</FONT></PRE>

<% include('/elements/footer.html') %>
% } 
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

$cgi->param('agentnum') =~ /^(\d+)$/
  or errorpage('illegal agentnum '. $cgi->param('agentnum'));
my $agentnum = $1;
my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );

my $error = '';

my $num = 0;
if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) {
  $num = $1;
} else {
  $error = 'Illegal number of codes: '. $cgi->param('num');
}

my @pkgparts = 
  map  { /^pkgpart(.*)$/; $1 }
  grep { $cgi->param($_) }
  grep { /^pkgpart/ }
  $cgi->param;

$error ||= $agent->generate_reg_codes($num, \@pkgparts);

</%init>