summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorivan <ivan>2005-01-29 12:34:12 +0000
committerivan <ivan>2005-01-29 12:34:12 +0000
commit55a68e4aabe10db4d9c3ab1bb8befd2f9f4b9008 (patch)
tree44ed1c89bce3e5e204e45347b0c97ccc55ae7972 /httemplate/edit
parentd35298e7ac78dff1fde4bf8e6d8f0104260a527e (diff)
registration codes
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/process/reg_code.cgi41
-rw-r--r--httemplate/edit/reg_code.cgi36
2 files changed, 77 insertions, 0 deletions
diff --git a/httemplate/edit/process/reg_code.cgi b/httemplate/edit/process/reg_code.cgi
new file mode 100644
index 000000000..581ede893
--- /dev/null
+++ b/httemplate/edit/process/reg_code.cgi
@@ -0,0 +1,41 @@
+<%
+
+$cgi->param('agentnum') =~ /^(\d+)$/
+ or eidiot '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);
+
+unless ( ref($error) ) { %><%=
+ $cgi->redirect(popurl(3). "edit/reg_code.cgi?". $cgi->query_string )
+%><% } else { %>
+
+<%= header("$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>
+
+</BODY></HTML>
+<% } %>
diff --git a/httemplate/edit/reg_code.cgi b/httemplate/edit/reg_code.cgi
new file mode 100644
index 000000000..899d1ec45
--- /dev/null
+++ b/httemplate/edit/reg_code.cgi
@@ -0,0 +1,36 @@
+<%
+my $agentnum = $cgi->param('agentnum');
+$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum";
+$agentnum = $1;
+my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
+
+%>
+
+<%= header('Generate registration codes for '. $agent->agent, menubar(
+ 'Main Menu' => $p,
+ ))
+%>
+
+<% if ( $cgi->param('error') ) { %>
+ <FONT SIZE="+1" COLOR="#FF0000">Error: <%= $cgi->param('error') %></FONT>
+<% } %>
+
+<FORM ACTION="<%=popurl(1)%>process/reg_code.cgi" METHOD="POST" NAME="OneTrueForm" onSubmit="document.OneTrueForm.submit.disabled=true">
+<INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agent->agentnum %>">
+
+Generate
+<INPUT TYPE="text" NAME="num" VALUE="<%= $cgi->param('num') %>" SIZE=5 MAXLENGTH=4>
+registration codes for <B><%= $agent->agent %></B> allowing the following packages:
+<BR><BR>
+
+<% foreach my $part_pkg ( qsearch('part_pkg', { 'disabled' => '' } ) ) { %>
+ <INPUT TYPE="checkbox" NAME="pkgpart<%= $part_pkg->pkgpart %>">
+ <%= $part_pkg->pkg %> - <%= $part_pkg->comment %>
+ <BR>
+<% } %>
+
+<BR>
+<INPUT TYPE="submit" NAME="submit" VALUE="Generate">
+
+</FORM></BODY></HTML>
+