RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / reg_code.cgi
index 899d1ec..76790ab 100644 (file)
@@ -1,36 +1,44 @@
-<%
-my $agentnum = $cgi->param('agentnum');
-$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum";
-$agentnum = $1;
-my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
-
-%>
+<% include('/elements/header.html', 'Generate registration codes for '. $agent->agent) %>
 
-<%= header('Generate registration codes for '. $agent->agent, menubar(
-      'Main Menu' => $p,
-    ))
-%>
+<% include('/elements/error.html') %>
 
-<% 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 %>">
+<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:
+% my $num = '';
+% if ( $cgi->param('num') =~ /^\s*(\d+)\s*$/ ) {
+%   $num = $1;
+% }
+<INPUT TYPE="text" NAME="num" VALUE="<% $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>
-<% } %>
+% foreach my $part_pkg ( qsearch('part_pkg', { 'disabled' => '' } ) ) { 
+%   my $pkgpart = $part_pkg->pkgpart;
+
+    <INPUT TYPE="checkbox" NAME="pkgpart<% $pkgpart %>" <% $cgi->param("pkgpart$pkgpart") ? 'CHECKED' : '' %>>
+    <% $part_pkg->pkg_comment %>
+    <BR>
+
+% } 
+
 
 <BR>
 <INPUT TYPE="submit" NAME="submit" VALUE="Generate">
 
-</FORM></BODY></HTML>
+</FORM>
+
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $agentnum = $cgi->param('agentnum');
+$agentnum =~ /^(\d+)$/ or errorpage("illegal agentnum $agentnum");
+$agentnum = $1;
+my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
 
+</%init>