diff options
author | ivan <ivan> | 1998-11-15 13:16:15 +0000 |
---|---|---|
committer | ivan <ivan> | 1998-11-15 13:16:15 +0000 |
commit | 61f2610ee6b8660a206a05675899ed72a5e59296 (patch) | |
tree | 9b3f7235c3fb25d8ecde0fc23b1583734f2ecb6e | |
parent | 2a7d9b79f305a57d84c49ee556242777bd739f74 (diff) |
first pass as per-user custom pricing
-rwxr-xr-x | htdocs/edit/part_pkg.cgi | 84 | ||||
-rwxr-xr-x | htdocs/edit/process/part_pkg.cgi | 50 |
2 files changed, 99 insertions, 35 deletions
diff --git a/htdocs/edit/part_pkg.cgi b/htdocs/edit/part_pkg.cgi index 9fe739bb7..ed309128d 100755 --- a/htdocs/edit/part_pkg.cgi +++ b/htdocs/edit/part_pkg.cgi @@ -1,5 +1,7 @@ #!/usr/bin/perl -Tw # +# $Id: part_pkg.cgi,v 1.2 1998-11-15 13:14:55 ivan Exp $ +# # part_pkg.cgi: Add/Edit package (output form) # # ivan@sisd.com 97-dec-10 @@ -9,38 +11,64 @@ # 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.2 1998-11-15 13:14:55 ivan +# first pass as per-user custom pricing +# use strict; -use CGI::Base; +use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); use FS::Record qw(qsearch qsearchs); use FS::part_pkg; +use FS::part_svc; use FS::pkg_svc; use FS::CGI qw(header menubar); -my($cgi) = new CGI::Base; -$cgi->get; +my($cgi) = new CGI; &cgisuidsetup($cgi); -SendHeaders(); # one guess. +if ( $cgi->param('clone') =~ /^(\d+)$/ ) { + $cgi->param('clone', $1); +} else { + $cgi->param('clone', ''); +} +if ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) { + $cgi->param('pkgnum', $1); +} else { + $cgi->param('pkgnum', ''); +} my($part_pkg,$action); -if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing - $part_pkg=qsearchs('part_pkg',{'pkgpart'=>$1}); +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 ( $cgi->keywords =~ /^(\d+)$/ ) { $action='Edit'; -} else { #adding - $part_pkg=create FS::part_pkg {}; + $part_pkg=qsearchs('part_pkg',{'pkgpart'=>$1}); +} else { $action='Add'; + $part_pkg=create FS::part_pkg {}; } my($hashref)=$part_pkg->hashref; -print header("$action Package Definition", menubar( +print $cgi->header, header("$action Package Definition", menubar( 'Main Menu' => '../', 'View all packages' => '../browse/part_pkg.cgi', )), '<FORM ACTION="process/part_pkg.cgi" METHOD=POST>'; +if ( $cgi->param('clone') ) { + print qq!<INPUT TYPE="hidden" NAME="clone" VALUE="!, $cgi->param('clone'), qq!">!; +} +if ( $cgi->param('pkgnum') ) { + print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="!, $cgi->param('pkgnum'), qq!">!; +} + print qq!<INPUT TYPE="hidden" NAME="pkgpart" VALUE="$hashref->{pkgpart}">!, "Package Part #", $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)"; @@ -54,10 +82,15 @@ Frequency (months) of recurring fee <INPUT TYPE="text" NAME="freq" VALUE="$hashr </PRE> +END + +unless ( $cgi->param('clone') ) { + print <<END; Enter the quantity of each service this package includes.<BR><BR> <TABLE BORDER><TR><TH><FONT SIZE=-1>Quan.</FONT></TH><TH>Service</TH> <TH><FONT SIZE=-1>Quan.</FONT></TH><TH>Service</TH></TR> END +} my($part_svc); my($count) = 0 ; @@ -65,7 +98,7 @@ foreach $part_svc ( qsearch('part_svc',{}) ) { my($svcpart)=$part_svc->getfield('svcpart'); my($pkg_svc)=qsearchs('pkg_svc',{ - 'pkgpart' => $part_pkg->getfield('pkgpart'), + 'pkgpart' => $cgi->param('clone') || $part_pkg->getfield('pkgpart'), 'svcpart' => $svcpart, }) || create FS::pkg_svc({ 'pkgpart' => $part_pkg->getfield('pkgpart'), @@ -74,21 +107,28 @@ foreach $part_svc ( qsearch('part_svc',{}) ) { }); next unless $pkg_svc; - print qq!<TR>! if $count == 0 ; - print qq!<TD><INPUT TYPE="text" NAME="pkg_svc$svcpart" SIZE=3 VALUE="!, - $pkg_svc->getfield('quantity') || 0,qq!"></TD>!, - qq!<TD><A HREF="part_svc.cgi?!,$part_svc->getfield('svcpart'), - qq!">!, $part_svc->getfield('svc'), "</A></TD>"; - $count ++ ; - if ($count == 2) - { - print qq!</TR>! ; - $count = 0 ; + unless ( $cgi->param('clone') ) { + print qq!<TR>! if $count == 0 ; + print qq!<TD><INPUT TYPE="text" NAME="pkg_svc$svcpart" SIZE=3 VALUE="!, + $pkg_svc->getfield('quantity') || 0,qq!"></TD>!, + qq!<TD><A HREF="part_svc.cgi?!,$part_svc->getfield('svcpart'), + qq!">!, $part_svc->getfield('svc'), "</A></TD>"; + $count ++ ; + if ($count == 2) + { + print qq!</TR>! ; + $count = 0 ; + } + } else { + print qq!<INPUT TYPE="hidden" NAME="pkg_svc$svcpart" VALUE="!, + $pkg_svc->getfield('quantity') || 0, qq!">\n!; } } -print qq!</TR>! if ($count != 0) ; -print "</TABLE>"; +unless ( $cgi->param('clone') ) { + print qq!</TR>! if ($count != 0) ; + print "</TABLE>"; +} print qq!<BR><INPUT TYPE="submit" VALUE="!, $hashref->{pkgpart} ? "Apply changes" : "Add package", diff --git a/htdocs/edit/process/part_pkg.cgi b/htdocs/edit/process/part_pkg.cgi index 7d787819a..78ed69613 100755 --- a/htdocs/edit/process/part_pkg.cgi +++ b/htdocs/edit/process/part_pkg.cgi @@ -1,5 +1,7 @@ #!/usr/bin/perl -Tw # +# $Id: part_pkg.cgi,v 1.2 1998-11-15 13:16:15 ivan Exp $ +# # process/part_pkg.cgi: Edit package definitions (process form) # # ivan@sisd.com 97-dec-10 @@ -13,30 +15,41 @@ # Added `|| 0 ' when getting quantity off web page ivan@sisd.com 98-jun-4 # # lose background, FS::CGI ivan@sisd.com 98-sep-2 +# +# $Log: part_pkg.cgi,v $ +# Revision 1.2 1998-11-15 13:16:15 ivan +# first pass as per-user custom pricing +# use strict; -use CGI::Request; +use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); +use FS::CGI qw(eidiot popurl); use FS::Record qw(qsearch qsearchs); use FS::part_pkg qw(fields); use FS::pkg_svc; -use FS::CGI qw(eidiot); - -my($req)=new CGI::Request; # create form object +use FS::cust_pkg; -&cgisuidsetup($req->cgi); +my($cgi)=new CGI; +&cgisuidsetup($cgi); -my($pkgpart)=$req->param('pkgpart'); +my($pkgpart)=$cgi->param('pkgpart'); my($old)=qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart; my($new)=create FS::part_pkg ( { map { - $_, $req->param($_); + $_, $cgi->param($_); } fields('part_pkg') } ); +local $SIG{HUP} = 'IGNORE'; +local $SIG{INT} = 'IGNORE'; +local $SIG{QUIT} = 'IGNORE'; +local $SIG{TERM} = 'IGNORE'; +local $SIG{TSTP} = 'IGNORE'; + if ( $pkgpart ) { my($error)=$new->replace($old); eidiot($error) if $error; @@ -50,8 +63,8 @@ my($part_svc); foreach $part_svc (qsearch('part_svc',{})) { # don't update non-changing records in part_svc (causing harmless but annoying # "Records identical" errors). ivan@sisd.com 98-jan-19 - #my($quantity)=$req->param('pkg_svc'. $part_svc->getfield('svcpart')), - my($quantity)=$req->param('pkg_svc'. $part_svc->svcpart) || 0, + #my($quantity)=$cgi->param('pkg_svc'. $part_svc->getfield('svcpart')), + my($quantity)=$cgi->param('pkg_svc'. $part_svc->svcpart) || 0, my($old_pkg_svc)=qsearchs('pkg_svc',{ 'pkgpart' => $pkgpart, 'svcpart' => $part_svc->getfield('svcpart'), @@ -61,7 +74,7 @@ foreach $part_svc (qsearch('part_svc',{})) { my($new_pkg_svc)=create FS::pkg_svc({ 'pkgpart' => $pkgpart, 'svcpart' => $part_svc->getfield('svcpart'), - #'quantity' => $req->param('pkg_svc'. $part_svc->getfield('svcpart')), + #'quantity' => $cgi->param('pkg_svc'. $part_svc->getfield('svcpart')), 'quantity' => $quantity, }); if ($old_pkg_svc) { @@ -73,7 +86,18 @@ foreach $part_svc (qsearch('part_svc',{})) { } } -#$req->cgi->redirect("../../view/part_pkg.cgi?$pkgpart"); -#$req->cgi->redirect("../../edit/part_pkg.cgi?$pkgpart"); -$req->cgi->redirect("../../browse/part_pkg.cgi"); +unless ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) { + #$req->cgi->redirect("../../view/part_pkg.cgi?$pkgpart"); + #$req->cgi->redirect("../../edit/part_pkg.cgi?$pkgpart"); + $cgi->redirect("../../browse/part_pkg.cgi"); +} else { + my($old_cust_pkg) = qsearchs( 'cust_pkg', { 'pkgnum' => $1 } ); + my %hash = $old_cust_pkg->hash; + $hash{'pkgpart'} = $pkgpart; + my($new_cust_pkg) = create FS::cust_pkg \%hash; + my $error = $new_cust_pkg->replace($old_cust_pkg); + eidiot "Error modifying cust_pkg record: $error\n" if $error; + print $cgi->redirect(popurl(3). "/view/cust_main.cgi?". $new_cust_pkg->custnum); +} + |