diff options
author | ivan <ivan> | 2001-10-15 10:42:29 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-10-15 10:42:29 +0000 |
commit | a6d3e4dc73803cffad96fd4b6270b2fb5f4b0568 (patch) | |
tree | ade2d125ae65a21bf314d6cad84ee2cd4d767218 /httemplate | |
parent | 87b5424ee8f16f824865cd7dbf1efde8da3bd429 (diff) |
price plans web gui 1st pass, oh my
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 20 | ||||
-rw-r--r-- | httemplate/docs/config.html | 3 | ||||
-rw-r--r-- | httemplate/docs/schema.html | 6 | ||||
-rw-r--r-- | httemplate/docs/upgrade8.html | 6 | ||||
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 96 | ||||
-rwxr-xr-x | httemplate/edit/part_svc.cgi | 3 | ||||
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 9 |
7 files changed, 92 insertions, 51 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 1538a7127..e20ba2404 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -1,5 +1,5 @@ <% -#<!-- $Id: part_pkg.cgi,v 1.4 2001-09-04 14:44:06 ivan Exp $ --> +#<!-- $Id: part_pkg.cgi,v 1.5 2001-10-15 10:42:28 ivan Exp $ --> use strict; use vars qw( $cgi $p $part_pkg ); @@ -27,9 +27,9 @@ print $cgi->header( '-expires' => 'now' ), header("Package Definition Listing",m <TR> <TH COLSPAN=2>Package</TH> <TH>Comment</TH> - <TH><FONT SIZE=-1>Setup Fee</FONT></TH> <TH><FONT SIZE=-1>Freq.</FONT></TH> - <TH><FONT SIZE=-1>Recur. Fee</FONT></TH> + <TH><FONT SIZE=-1>Plan</FONT></TH> + <TH><FONT SIZE=-1>Data</FONT></TH> <TH>Service</TH> <TH><FONT SIZE=-1>Quan.</FONT></TH> </TR> @@ -42,6 +42,16 @@ foreach $part_pkg ( sort { my(@pkg_svc)=grep $_->getfield('quantity'), qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} }); my($rowspan)=scalar(@pkg_svc); + my $plandata; + if ( $hashref->{plan} ) { + $plandata = $hashref->{plandata}; + $plandata =~ s/^(\w+)=/$1 /mg; + $plandata =~ s/\n/<BR>/g; + } else { + $hashref->{plan} = "(legacy)"; + $plandata = "Setup ". $hashref->{setup}. + "<BR>Recur ". $hashref->{recur}; + } print <<END; <TR> <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}"> @@ -49,9 +59,9 @@ foreach $part_pkg ( sort { </A></TD> <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}">$hashref->{pkg}</A></TD> <TD ROWSPAN=$rowspan>$hashref->{comment}</TD> - <TD ROWSPAN=$rowspan>$hashref->{setup}</TD> <TD ROWSPAN=$rowspan>$hashref->{freq}</TD> - <TD ROWSPAN=$rowspan>$hashref->{recur}</TD> + <TD ROWSPAN=$rowspan>$hashref->{plan}</TD> + <TD ROWSPAN=$rowspan>$plandata</TD> END my($pkg_svc); diff --git a/httemplate/docs/config.html b/httemplate/docs/config.html index 63f6baba9..3c6fe0252 100644 --- a/httemplate/docs/config.html +++ b/httemplate/docs/config.html @@ -53,7 +53,8 @@ All further configuration files and directories are located in <li><a name="disable_customer_referrals">disable_customer_referrals</a> - The existance of this file will disable new customer-to-customer referrals in the web interface. <li><a name="domain"><font color="#ff0000">domain</font></a> - Your domain name. <li><a name="editreferrals">editreferrals</a> - The existance of this file will allow you to change the referral of existing customers. - <li><a name="emailinvoiceonly">emailinvoiceonly</a> + <li><a name="emailinvoiceonly">emailinvoiceonly</a> - Disables postal mail invoices. + <li><a name="emailinvoiceauto">emailinvoiceauto</a> - Automatically adds new accounts to the email invoice list upon customer creation. <li><a name="erpcdmachines">erpcdmachines</a> - Your ERPCD authenticaion machines, one per line. This enables export of `/usr/annex/acp_passwd' and `/usr/annex/acp_dialup'. <li><a name="hidecancelledpackages">hidecancelledpackages</a> - The existance of this file will prevent cancelled packages from showing up in listings (though they will still be in the database) <li><a name="hidecancelledcustomers">hidecancelledcustomers</a> - The existance of this file will prevent customers with only cancelled packages from showing up in listings (though they will still be in the database) diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index d831c59f4..88b4cb2b1 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -193,9 +193,11 @@ <li>pkgpart - primary key <li>pkg - package name <li>comment - non-customer visable package comment - <li>setup - setup fee + <li>setup - setup fee expression <li>freq - recurring frequency (months) - <li>recur - recurring fee + <li>recur - recurring fee expression + <li>plan - price plan + <li>plandata - additional price plan data </ul> <li><a name="part_referral" href="man/FS/part_referral.html">part_referral</a> - Referral listing <ul> diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html index 79eb6da3f..c317e88c8 100644 --- a/httemplate/docs/upgrade8.html +++ b/httemplate/docs/upgrade8.html @@ -135,6 +135,8 @@ ALTER TABLE cust_pay ADD custnum integer; ALTER TABLE cust_pay_batch ADD paybatchnum integer; ALTER TABLE cust_refund ADD custnum integer; ALTER TABLE cust_pkg ADD manual_flag char(1) NULL; +ALTER TABLE part_pkg ADD plan varchar NULL; +ALTER TABLE part_pkg ADD plandata varchar NULL; CREATE INDEX cust_main3 ON cust_main ( referral_custnum ); CREATE INDEX cust_credit_bill1 ON cust_credit_bill ( crednum ); CREATE INDEX cust_credit_bill2 ON cust_credit_bill ( invnum ); @@ -223,7 +225,7 @@ CREATE TABLE cust_pay_temp ( INSERT INTO cust_pay_temp SELECT * from cust_pay; DROP TABLE cust_pay; ALTER TABLE cust_pay_temp RENAME TO cust_pay; -CREATE UNIQUE INDEX cust_pay1 ON cust_pay paynum; +CREATE UNIQUE INDEX cust_pay1 ON cust_pay (paynum); CREATE TABLE cust_refund_temp ( refundnum int primary key, custnum int not null, @@ -238,7 +240,7 @@ CREATE TABLE cust_refund_temp ( INSERT INTO cust_refund_temp SELECT * from cust_refund; DROP TABLE cust_refund; ALTER TABLE cust_refund_temp RENAME TO cust_refund; -CREATE UNIQUE INDEX cust_refund1 ON cust_refund refundnum; +CREATE UNIQUE INDEX cust_refund1 ON cust_refund (refundnum); </pre></font> </td><td> <font size=-1><pre> diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index b7707f3e8..a4123e137 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,23 +1,7 @@ -<!-- $Id: part_pkg.cgi,v 1.3 2001-10-11 17:44:33 ivan Exp $ --> - -<% my $plan = 'flat'; %> - -<SCRIPT> -function visualize(what) { - if (document.getElementById) { - document.getElementById('d<%= $plan %>').style.visibility = "visible"; - } else { - document.l<%= $plan %>.visibility = "visible"; - } -} -</SCRIPT> +<!-- $Id: part_pkg.cgi,v 1.4 2001-10-15 10:42:29 ivan Exp $ --> <% -$cgi = new CGI; - -&cgisuidsetup($cgi); - if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { $cgi->param('clone', $1); } else { @@ -44,16 +28,36 @@ if ( $cgi->param('clone') ) { $part_pkg ||= $old_part_pkg->clone; } elsif ( $query && $query =~ /^(\d+)$/ ) { $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); + unless ( $part_pkg->plan ) { + $part_pkg->plan('flat'); + $part_pkg->plandata("setup=". $part_pkg->setup. "\n". + "recur=". $part_pkg->recur. "\n"); + } } else { $part_pkg ||= new FS::part_pkg {}; + $part_pkg->plan('flat'); } $action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; my $hashref = $part_pkg->hashref; +%> + +<SCRIPT> +function visualize(what) { + if (document.getElementById) { + document.getElementById('d<%= $part_pkg->plan %>').style.visibility = "visible"; + } else { + document.l<%= $part_pkg->plan %>.visibility = "visible"; + } +} +</SCRIPT> + +<% + print header("$action Package Definition", menubar( 'Main Menu' => popurl(2), 'View all packages' => popurl(2). 'browse/part_pkg.cgi', -)); +), ' onLoad="visualize()"'); print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), "</FONT>" @@ -136,8 +140,12 @@ my %plans = ( 'flat' => { 'name' => 'Flat rate', 'fields' => { - 'setup_fee' => { 'name' => 'Setup fee for this package' }, - 'recur_fee' => { 'name' => 'Recurring fee for this package' }, + 'setup_fee' => { 'name' => 'Setup fee for this package', + 'default' => 0, + }, + 'recur_fee' => { 'name' => 'Recurring fee for this package', + 'default' => 0, + }, }, 'setup' => 'what.setup_fee.value', 'recur' => 'what.recur_fee.value', @@ -146,13 +154,21 @@ my %plans = ( 'flat_comission' => { 'name' => 'Flat rate with recurring referral comission as credit', 'fields' => { - 'setup_fee' => { 'name' => 'Setup fee for this package' }, - 'recur_fee' => { 'name' => 'Recurring fee for this package' }, - 'comission_amount' => { 'name' => 'Comission amount' }, - 'comission_depth' => { 'name' => 'Number of layers' }, + 'setup_fee' => { 'name' => 'Setup fee for this package', + 'default' => 0, + }, + 'recur_fee' => { 'name' => 'Recurring fee for this package', + 'default' => 0, + }, + 'comission_amount' => { 'name' => 'Comission amount', + 'default' => 0, + }, + 'comission_depth' => { 'name' => 'Number of layers', + 'default' => 1, + }, }, 'setup' => 'what.setup_fee.value', - 'recur' => '\'$cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ) ; \' + what.recur_fee.value + \';\'', + 'recur' => '\'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'', }, ); @@ -160,8 +176,7 @@ my %plans = ( %> <SCRIPT> -var svcdb = null; -var something = null; +var layer = null; function changed(what) { layer = what.options[what.selectedIndex].value; @@ -185,9 +200,10 @@ function changed(what) { </SCRIPT> <BR> -Price plan <SELECT NAME="plan" SIZE=1 onChange="changed(this)"> +Price plan <SELECT NAME="plan" SIZE=1 onChange="changed(this);"> +<OPTION> <% foreach my $layer (keys %plans ) { %> -<OPTION VALUE="<%= $layer %>"<%= ' SELECTED'x($layer eq $plan) %>><%= $plans{$layer}->{'name'} %> +<OPTION VALUE="<%= $layer %>"<%= ' SELECTED'x($layer eq $part_pkg->plan) %>><%= $plans{$layer}->{'name'} %> <% } %> </SELECT></FORM> @@ -197,6 +213,7 @@ function fchanged(what) { } function fixup(what) { +alert(what); <% foreach my $f ( qw( pkg comment freq ), @fixups ) { %> what.<%= $f %>.value = document.dummy.<%= $f %>.value; <% } %> @@ -210,7 +227,9 @@ function fixup(what) { } </SCRIPT> -<% #foreach my $layer ( 'konq_kludge', keys %plans ) { +<% my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } + split("\n", $part_pkg->plandata ); + #foreach my $layer ( 'konq_kludge', keys %plans ) { foreach my $layer ( 'konq_kludge', keys %plans ) { my $visibility = "hidden"; %> @@ -224,9 +243,9 @@ if (document.getElementById) { </SCRIPT> <FORM NAME="<%= $layer %>" ACTION="process/part_pkg.cgi" METHOD=POST onSubmit="fixup(this)"> -<INPUT TYPE="hidden" NAME="plan" VALUE="<%= $plan %>"> +<INPUT TYPE="hidden" NAME="plan" VALUE="<%= $part_pkg->plan %>"> <INPUT TYPE="hidden" NAME="pkg" VALUE="<%= $hashref->{pkg} %>"> -<INPUT TYPE="hidden" NAME="comment" VALUE="$<%= hashref->{comment} %>"> +<INPUT TYPE="hidden" NAME="comment" VALUE="$<%= $hashref->{comment} %>"> <INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>"> <% foreach my $f ( @fixups ) { %> <INPUT TYPE="hidden" NAME="<%= $f %>" VALUE=""> @@ -245,12 +264,13 @@ print qq!<INPUT TYPE="hidden" NAME="pkgpart" VALUE="$hashref->{pkgpart}">!, <% my $href = $plans{$layer}->{'fields'}; foreach my $field ( keys %{ $href } ) { %> <%= $href->{$field}{'name'} %>: -<INPUT TYPE="text" NAME="<%= $field %>" VALUE="<%= $ref->{$field}{'default'} %>" onChange="fchanged(this)"><BR> +<INPUT TYPE="text" NAME="<%= $field %>" VALUE="<%= exists($plandata{$field}) ? $plandata{$field} : $href->{$field}{'default'} %>" onChange="fchanged(this)"><BR> <% } %> +<INPUT TYPE="hidden" NAME="plandata" VALUE="<%= join(',', keys %{ $href } ) %>"> -<FONT SIZE="-2"> -Setup expression <INPUT TYPE="text" NAME="setup" SIZE="100%" VALUE="<%= $hashref->{setup} %>"><BR> -Recurring espression <INPUT TYPE="text" NAME="recur" SIZE="100%" VALUE="<%= $hashref->{recur} %>"><BR> +<FONT SIZE="1"> +Setup expression<BR><INPUT TYPE="text" NAME="setup" SIZE="160" VALUE="<%= $hashref->{setup} %>" onLoad="fchanged(this)"><BR> +Recurring espression<BR><INPUT TYPE="text" NAME="recur" SIZE="160" VALUE="<%= $hashref->{recur} %>" onLoad="fchanged(this)"><BR> </FONT> <% @@ -273,9 +293,9 @@ if (document.getElementById) { <TAG onLoad=" if (document.getElementById) { - document.getElementById('d<%= $plan %>').style.visibility = 'visible'; + document.getElementById('d<%= $part_pkg->plan %>').style.visibility = 'visible'; } else { - document.l<%= $plan %>.visibility = 'visible'; + document.l<%= $part_pkg->plan %>.visibility = 'visible'; } "> </BODY> diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 7797230e8..29778567e 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -1,4 +1,4 @@ -<!-- $Id: part_svc.cgi,v 1.11 2001-09-11 19:16:41 ivan Exp $ --> +<!-- $Id: part_svc.cgi,v 1.12 2001-10-15 10:42:29 ivan Exp $ --> <% my $part_svc; if ( $cgi->param('error') ) { #error @@ -65,7 +65,6 @@ blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or <BR><BR> <SCRIPT> var svcdb = null; -var something = null; function changed(what) { svcdb = what.options[what.selectedIndex].value; <% foreach my $svcdb ( qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ) ) { %> diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 5850599c8..6cfaa122e 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,5 +1,5 @@ <% -#<!-- $Id: part_pkg.cgi,v 1.2 2001-08-21 02:31:56 ivan Exp $ --> +#<!-- $Id: part_pkg.cgi,v 1.3 2001-10-15 10:42:29 ivan Exp $ --> use strict; use vars qw( $cgi $pkgpart $old $new $part_svc $error $dbh ); @@ -19,6 +19,13 @@ $pkgpart = $cgi->param('pkgpart'); $old = qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart; +#fixup plandata +my $plandata = $cgi->param('plandata'); +my @plandata = split(',', $plandata); +$cgi->param('plandata', + join('', map { "$_=". $cgi->param($_). "\n" } @plandata ) +); + $new = new FS::part_pkg ( { map { $_, scalar($cgi->param($_)); |