From 51984ac3d3da3006809c6866fdecd4ad83610731 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 07:36:04 +0000 Subject: templates!!! --- httemplate/edit/part_pkg.cgi | 180 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 httemplate/edit/part_pkg.cgi (limited to 'httemplate/edit/part_pkg.cgi') diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi new file mode 100755 index 000000000..002d54139 --- /dev/null +++ b/httemplate/edit/part_pkg.cgi @@ -0,0 +1,180 @@ +<% +# +# $Id: part_pkg.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# part_pkg.cgi: Add/Edit package (output form) +# +# ivan@sisd.com 97-dec-10 +# +# Changes to allow page to work at a relative position in server +# Changed to display services 2-wide in table +# bmccane@maxbaud.net 98-apr-3 +# +# use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12 +# +# $Log: part_pkg.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.9 1999/02/07 09:59:19 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.8 1999/01/19 05:13:39 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.7 1999/01/18 09:41:29 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.6 1998/12/17 06:17:05 ivan +# fix double // in relative URLs, s/CGI::Base/CGI/; +# +# Revision 1.5 1998/11/21 07:12:26 ivan +# *** empty log message *** +# +# Revision 1.4 1998/11/21 07:11:08 ivan +# *** empty log message *** +# +# Revision 1.3 1998/11/21 07:07:40 ivan +# popurl, bugfix +# +# Revision 1.2 1998/11/15 13:14:55 ivan +# first pass as per-user custom pricing +# + +use strict; +use vars qw( $cgi $part_pkg $action $query $hashref $part_svc $count ); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs fields); +use FS::part_pkg; +use FS::part_svc; +use FS::pkg_svc; +use FS::CGI qw(header menubar popurl); + +$cgi = new CGI; + +&cgisuidsetup($cgi); + +if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { + $cgi->param('clone', $1); +} else { + $cgi->param('clone', ''); +} +if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { + $cgi->param('pkgnum', $1); +} else { + $cgi->param('pkgnum', ''); +} + +($query) = $cgi->keywords; +$action = ''; +$part_pkg = ''; +if ( $cgi->param('error') ) { + $part_pkg = new FS::part_pkg ( { + map { $_, scalar($cgi->param($_)) } fields('part_pkg') + } ); +} +if ( $cgi->param('clone') ) { + $action='Custom Pricing'; + my $old_part_pkg = + qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); + $part_pkg ||= $old_part_pkg->clone; +} elsif ( $query && $query =~ /^(\d+)$/ ) { + $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); +} else { + $part_pkg ||= new FS::part_pkg {}; +} +$action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; +$hashref = $part_pkg->hashref; + +print $cgi->header( '-expires' => 'now' ), header("$action Package Definition", menubar( + 'Main Menu' => popurl(2), + 'View all packages' => popurl(2). 'browse/part_pkg.cgi', +)); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print '
'; + +if ( $cgi->param('clone') ) { + print qq!!; +} +if ( $cgi->param('pkgnum') ) { + print qq!!; +} + +print qq!!, + "Package Part #", $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)"; + +print < +Package (customer-visable) +Comment (customer-hidden) +Setup fee for this package +Recurring fee for this package +Frequency (months) of recurring fee + + + +END + +unless ( $cgi->param('clone') ) { + print <
+ + +END +} + +$count = 0; +foreach $part_svc ( ( qsearch( 'part_svc', {} ) ) ) { + my $svcpart = $part_svc->svcpart; + my $pkg_svc = qsearchs( 'pkg_svc', { + 'pkgpart' => $cgi->param('clone') || $part_pkg->pkgpart, + 'svcpart' => $svcpart, + } ) || new FS::pkg_svc ( { + 'pkgpart' => $cgi->param('clone') || $part_pkg->pkgpart, + 'svcpart' => $svcpart, + 'quantity' => 0, + }); + #? #next unless $pkg_svc; + + unless ( defined ($cgi->param('clone')) && $cgi->param('clone') ) { + print '' if $count == 0 ; + print qq!"; + $count++; + if ($count == 2) + { + print ''; + $count = 0; + } + } else { + print qq!quantity || 0, qq!">\n!; + } +} + +unless ( $cgi->param('clone') ) { + print qq!! if ($count != 0) ; + print "
Quan.ServiceQuan.Service
quantity || 0, + qq!">!, $part_svc->getfield('svc'), "
"; +} + +print qq!
!; + +print < + + +END + +%> -- cgit v1.2.1 From 3d671921441ba8422650b54435a1959ad1d4c71d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 21 Aug 2001 02:31:57 +0000 Subject: remove $Log$ messages. whew. --- httemplate/edit/part_pkg.cgi | 44 +------------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'httemplate/edit/part_pkg.cgi') diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 002d54139..4813fdf8b 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,47 +1,5 @@ <% -# -# $Id: part_pkg.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# part_pkg.cgi: Add/Edit package (output form) -# -# ivan@sisd.com 97-dec-10 -# -# Changes to allow page to work at a relative position in server -# Changed to display services 2-wide in table -# bmccane@maxbaud.net 98-apr-3 -# -# use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12 -# -# $Log: part_pkg.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.9 1999/02/07 09:59:19 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.8 1999/01/19 05:13:39 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.7 1999/01/18 09:41:29 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.6 1998/12/17 06:17:05 ivan -# fix double // in relative URLs, s/CGI::Base/CGI/; -# -# Revision 1.5 1998/11/21 07:12:26 ivan -# *** empty log message *** -# -# Revision 1.4 1998/11/21 07:11:08 ivan -# *** empty log message *** -# -# Revision 1.3 1998/11/21 07:07:40 ivan -# popurl, bugfix -# -# Revision 1.2 1998/11/15 13:14:55 ivan -# first pass as per-user custom pricing -# +# use strict; use vars qw( $cgi $part_pkg $action $query $hashref $part_svc $count ); -- cgit v1.2.1 From 5820f3d7ca493e3e6318efe6e8e677b71b01c1ad Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 11 Oct 2001 17:44:33 +0000 Subject: "price plans" UP support.CVS: ---------------------------------------------------------------------- --- httemplate/edit/part_pkg.cgi | 218 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 181 insertions(+), 37 deletions(-) (limited to 'httemplate/edit/part_pkg.cgi') diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 4813fdf8b..b7707f3e8 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,16 +1,18 @@ + + +<% my $plan = 'flat'; %> + + + <% -# - -use strict; -use vars qw( $cgi $part_pkg $action $query $hashref $part_svc $count ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs fields); -use FS::part_pkg; -use FS::part_svc; -use FS::pkg_svc; -use FS::CGI qw(header menubar popurl); $cgi = new CGI; @@ -27,9 +29,9 @@ if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { $cgi->param('pkgnum', ''); } -($query) = $cgi->keywords; -$action = ''; -$part_pkg = ''; +my ($query) = $cgi->keywords; +my $action = ''; +my $part_pkg = ''; if ( $cgi->param('error') ) { $part_pkg = new FS::part_pkg ( { map { $_, scalar($cgi->param($_)) } fields('part_pkg') @@ -46,9 +48,9 @@ if ( $cgi->param('clone') ) { $part_pkg ||= new FS::part_pkg {}; } $action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; -$hashref = $part_pkg->hashref; +my $hashref = $part_pkg->hashref; -print $cgi->header( '-expires' => 'now' ), header("$action Package Definition", menubar( +print header("$action Package Definition", menubar( 'Main Menu' => popurl(2), 'View all packages' => popurl(2). 'browse/part_pkg.cgi', )); @@ -57,24 +59,24 @@ print qq!Error: !, $cgi->param('error'), "" if $cgi->param('error'); -print ''; - -if ( $cgi->param('clone') ) { - print qq!!; -} -if ( $cgi->param('pkgnum') ) { - print qq!!; -} +#print ''; +print ''; -print qq!!, - "Package Part #", $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)"; +#if ( $cgi->param('clone') ) { +# print qq!!; +#} +#if ( $cgi->param('pkgnum') ) { +# print qq!!; +#} +# +#print qq!!, +print "Package Part #", $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)"; print < Package (customer-visable) Comment (customer-hidden) -Setup fee for this package -Recurring fee for this package + Frequency (months) of recurring fee @@ -89,8 +91,9 @@ Enter the quantity of each service this package includes.

END } -$count = 0; -foreach $part_svc ( ( qsearch( 'part_svc', {} ) ) ) { +my $count = 0; +my @fixups = (); +foreach my $part_svc ( ( qsearch( 'part_svc', {} ) ) ) { my $svcpart = $part_svc->svcpart; my $pkg_svc = qsearchs( 'pkg_svc', { 'pkgpart' => $cgi->param('clone') || $part_pkg->pkgpart, @@ -102,6 +105,8 @@ foreach $part_svc ( ( qsearch( 'part_svc', {} ) ) ) { }); #? #next unless $pkg_svc; + push @fixups, "pkg_svc$svcpart"; + unless ( defined ($cgi->param('clone')) && $cgi->param('clone') ) { print '' if $count == 0 ; print qq!"; } +# prolly should be in database +my %plans = ( + + 'flat' => { + 'name' => 'Flat rate', + 'fields' => { + 'setup_fee' => { 'name' => 'Setup fee for this package' }, + 'recur_fee' => { 'name' => 'Recurring fee for this package' }, + }, + 'setup' => 'what.setup_fee.value', + 'recur' => 'what.recur_fee.value', + }, + + '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' => '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 + \';\'', + }, + +); + +%> + + +
+Price plan + + + +<% #foreach my $layer ( 'konq_kludge', keys %plans ) { + foreach my $layer ( 'konq_kludge', keys %plans ) { + my $visibility = "hidden"; +%> + + +
+ + + + +<% foreach my $f ( @fixups ) { %> + +<% } %> + +<% +if ( $cgi->param('clone') ) { + print qq!!; +} +if ( $cgi->param('pkgnum') ) { + print qq!!; +} +print qq!!, +%> + +<% my $href = $plans{$layer}->{'fields'}; + foreach my $field ( keys %{ $href } ) { %> +<%= $href->{$field}{'name'} %>: +
+<% } %> + + +Setup expression
+Recurring espression
+
+ +<% print qq!
!; + qq!" onClick="fchanged(this)">!; +%> -print < + + + + +<% } %> + + -END - -%> -- cgit v1.2.1 From a6d3e4dc73803cffad96fd4b6270b2fb5f4b0568 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Oct 2001 10:42:29 +0000 Subject: price plans web gui 1st pass, oh my --- httemplate/edit/part_pkg.cgi | 96 ++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 38 deletions(-) (limited to 'httemplate/edit/part_pkg.cgi') 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 @@ - - -<% my $plan = 'flat'; %> - - + <% -$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; +%> + + + +<% + print header("$action Package Definition", menubar( 'Main Menu' => popurl(2), 'View all packages' => popurl(2). 'browse/part_pkg.cgi', -)); +), ' onLoad="visualize()"'); print qq!Error: !, $cgi->param('error'), "" @@ -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 = ( %>
-Price plan +