diff options
author | ivan <ivan> | 2005-01-29 12:34:12 +0000 |
---|---|---|
committer | ivan <ivan> | 2005-01-29 12:34:12 +0000 |
commit | 55a68e4aabe10db4d9c3ab1bb8befd2f9f4b9008 (patch) | |
tree | 44ed1c89bce3e5e204e45347b0c97ccc55ae7972 /httemplate | |
parent | d35298e7ac78dff1fde4bf8e6d8f0104260a527e (diff) |
registration codes
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/docs/install.html | 1 | ||||
-rw-r--r-- | httemplate/docs/schema.html | 11 | ||||
-rw-r--r-- | httemplate/docs/upgrade10.html | 21 | ||||
-rw-r--r-- | httemplate/edit/process/reg_code.cgi | 41 | ||||
-rw-r--r-- | httemplate/edit/reg_code.cgi | 36 | ||||
-rw-r--r-- | httemplate/search/reg_code.html | 35 |
6 files changed, 143 insertions, 2 deletions
diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 898eb9e..a880d91 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -59,6 +59,7 @@ Before installing, you need: <li><a href="http://search.cpan.org/search?dist=Chart">Chart</a> <li><a href="http://search.cpan.org/search?dist=Crypt-PasswdMD5">Crypt::PasswdMD5</a> <li><a href="http://search.cpan.org/search?dist=JavaScript-RPC">JavaScript::RPC (JavaScript::RPC::Server::CGI)</a> +<!-- <li><a href="http://search.cpan.org/search?dist=Crypt-YAPassGen">Crypt::YAPassGen</a> --> <li><a href="http://search.cpan.org/search?dist=ApacheDBI">Apache::DBI</a> <i>(optional but recommended for better webinterface performance)</i> </ul> </ul> diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index c5cfd51..8af8aa9 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -285,6 +285,17 @@ <li>optionname - option name <li>optionvalue - option value </ul> + <li><a name="reg_code" href="man/FS/reg_code.html">reg_code</A> - One-time registration codes + <ul> + <li>codenum - primary key + <li>code + <li>agentnum - <a href="#agent">Agent</a> + </ul> + <li><a name="reg_code_pkg" href="man/FS/reg_code_pkg.html">reg_code_pkg</A> - Registration code link to package definitions + <ul> + <li>codenum - <a href="#reg_code">Registration code</a> + <li>pkgpart - <a href="#part_pkg">Package definition</a> + </ul> <li><a name="part_referral" href="man/FS/part_referral.html">part_referral</a> - Referral listing <ul> <li>refnum - primary key diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index d818685..7441cf1 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -8,7 +8,8 @@ install Net::SSH 0.08 - In httpd.conf, change <Files ~ \.cgi> to <Files ~ (\.cgi|\.html)> - In httpd.conf, change <b>AddHandler perl-script .cgi</b> or <b>SetHandler perl-script</b> to <b>AddHandler perl-script .cgi .html</b> -install NetAddr::IP, Chart::Base, IPC::ShareLite and Locale::SubCountry +install NetAddr::IP, Chart::Base, IPC::ShareLite, Locale::SubCountry, +JavaScript::RPC (JavaScript::RPC::Server::CGI) <!-- and Crypt::YAPassGen--> INSERT INTO msgcat ( msgnum, msgcode, locale, msg ) VALUES ( 20, 'svc_external-id', 'en_US', 'External ID' ); INSERT INTO msgcat ( msgnum, msgcode, locale, msg ) VALUES ( 21, 'svc_external-title', 'en_US', 'Title' ); @@ -223,6 +224,22 @@ CREATE TABLE rate_prefix ( CREATE INDEX rate_prefix1 ON rate_prefix ( countrycode ); CREATE INDEX rate_prefix2 ON rate_prefix ( regionnum ); +CREATE TABLE reg_code ( + codenum serial NOT NULL, + code varchar(80) NOT NULL, + agentnum int NOT NULL, + PRIMARY KEY (codenum) +); +CREATE UNIQUE INDEX reg_code1 ON reg_code ( agentnum, code ); +CREATE INDEX reg_code2 ON reg_code ( agentnum ); + +CREATE TABLE reg_code_pkg ( + codenum int NOT NULL, + pkgpart int NOT NULL +); +CREATE UNIQUE INDEX reg_code_pkg1 ON reg_code_pkg ( codenum, pkgpart ); +CREATE INDEX reg_code_pkg2 ON reg_code_pkg ( codenum ); + DROP INDEX cust_bill_pkg1; ALTER TABLE cust_bill_pkg ADD itemdesc varchar(80) NULL; @@ -296,7 +313,7 @@ optionally: mandatory again: dbdef-create username -create-history-tables username cust_bill_pkg_detail router part_svc_router addr_block svc_broadband acct_snarf svc_external cust_pay_refund cust_pay_void part_pkg_option rate rate_detail rate_region rate_prefix +create-history-tables username cust_bill_pkg_detail router part_svc_router addr_block svc_broadband acct_snarf svc_external cust_pay_refund cust_pay_void part_pkg_option rate rate_detail rate_region rate_prefix reg_code reg_code_pkg dbdef-create username apache - fix <Files> sections to include .html also diff --git a/httemplate/edit/process/reg_code.cgi b/httemplate/edit/process/reg_code.cgi new file mode 100644 index 0000000..581ede8 --- /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 0000000..899d1ec --- /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> + diff --git a/httemplate/search/reg_code.html b/httemplate/search/reg_code.html new file mode 100644 index 0000000..ba1eee0 --- /dev/null +++ b/httemplate/search/reg_code.html @@ -0,0 +1,35 @@ +<% + +my $agentnum = $cgi->param('agentnum'); +$agentnum =~ /^(\d+)$/ or eidiot "illegal agentnum $agentnum"; +$agentnum = $1; +my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); + +my $count_query = "SELECT COUNT(*) FROM reg_code WHERE agentnum = $agentnum"; + +%> +<%= include( 'elements/search.html', + 'title' => 'Unused Registration Codes for '. $agent->agent, + 'name' => 'registration codes', + 'query' => { 'table' => 'reg_code', + 'hashref' => { 'agentnum' => $agentnum, }, + }, + 'count_query' => $count_query, + #'redirect' => $link, + 'header' => [ qw(Code Packages) ], + 'fields' => [ + 'code', + sub { map { + qq!<A HREF="${p}edit/part_pkg.cgi?!. $_->pkgpart. '">'. + $_->pkg. ' - '. $_->comment. + '</A><BR>' + } $_[0]->part_pkg + }, + ], + 'links' => [ + '', + #$plink, + '', + ], + ) +%> |