diff options
author | ivan <ivan> | 1998-09-03 02:00:49 +0000 |
---|---|---|
committer | ivan <ivan> | 1998-09-03 02:00:49 +0000 |
commit | 3c86cf59beb26bd3f8269a93ae1f641d88be53d1 (patch) | |
tree | 59a42cad3d5821d2bc9d9aa65569003478457f08 /htdocs | |
parent | c2f38666a7aa746c560efcf64f72261ff8a1d2f2 (diff) |
Initial revision
Diffstat (limited to 'htdocs')
-rwxr-xr-x | htdocs/browse/agent.cgi | 72 | ||||
-rwxr-xr-x | htdocs/browse/agent_type.cgi | 81 | ||||
-rwxr-xr-x | htdocs/browse/cust_main_county.cgi | 65 | ||||
-rwxr-xr-x | htdocs/browse/part_pkg.cgi | 81 | ||||
-rwxr-xr-x | htdocs/browse/part_referral.cgi | 57 | ||||
-rwxr-xr-x | htdocs/browse/part_svc.cgi | 81 | ||||
-rwxr-xr-x | htdocs/browse/svc_acct_pop.cgi | 63 | ||||
-rwxr-xr-x | htdocs/edit/cust_main_county-expand.cgi | 49 | ||||
-rwxr-xr-x | htdocs/edit/cust_main_county.cgi | 66 | ||||
-rwxr-xr-x | htdocs/edit/part_referral.cgi | 66 | ||||
-rwxr-xr-x | htdocs/edit/process/agent.cgi | 53 | ||||
-rwxr-xr-x | htdocs/edit/process/agent_type.cgi | 83 | ||||
-rwxr-xr-x | htdocs/edit/process/cust_main_county-expand.cgi | 71 | ||||
-rwxr-xr-x | htdocs/edit/process/cust_main_county.cgi | 38 | ||||
-rwxr-xr-x | htdocs/edit/process/part_pkg.cgi | 79 | ||||
-rwxr-xr-x | htdocs/edit/process/part_referral.cgi | 45 | ||||
-rwxr-xr-x | htdocs/edit/process/part_svc.cgi | 47 | ||||
-rwxr-xr-x | htdocs/edit/process/svc_acct_pop.cgi | 43 | ||||
-rwxr-xr-x | htdocs/edit/svc_acct_pop.cgi | 67 | ||||
-rwxr-xr-x | htdocs/view/cust_main.cgi | 336 |
20 files changed, 1543 insertions, 0 deletions
diff --git a/htdocs/browse/agent.cgi b/htdocs/browse/agent.cgi new file mode 100755 index 000000000..cf5f2281f --- /dev/null +++ b/htdocs/browse/agent.cgi @@ -0,0 +1,72 @@ +#!/usr/bin/perl -Tw +# +# agent.cgi: browse agent +# +# ivan@sisd.com 97-dec-12 +# +# changes to allow pages to load from a relative location in the web tree. +# bmccane@maxbaud.net 98-mar-25 +# +# changed 'type' to 'atype' because type is reserved word in Pg6.3 +# bmccane@maxbaud.net 98-apr-3 +# +# agent type was linking to wrong cgi ivan@sisd.com 98-jul-18 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. +print header('Agent Listing', menubar( + 'Main Menu' => '../', + 'Add new agent' => '../edit/agent.cgi' +)), <<END; + <BR> + Click on agent number to edit. + <TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>Agent #</FONT></TH> + <TH>Agent</TH> + <TH>Type</TH> + <TH><FONT SIZE=-1>Freq. (unimp.)</FONT></TH> + <TH><FONT SIZE=-1>Prog. (unimp.)</FONT></TH> + </TR> +END + +my($agent); +foreach $agent ( sort { + $a->getfield('agentnum') <=> $b->getfield('agentnum') +} qsearch('agent',{}) ) { + my($hashref)=$agent->hashref; + my($typenum)=$hashref->{typenum}; + my($agent_type)=qsearchs('agent_type',{'typenum'=>$typenum}); + my($atype)=$agent_type->getfield('atype'); + print <<END; + <TR> + <TD><A HREF="../edit/agent.cgi?$hashref->{agentnum}"> + $hashref->{agentnum}</A></TD> + <TD>$hashref->{agent}</TD> + <TD><A HREF="../edit/agent_type.cgi?$typenum">$atype</A></TD> + <TD>$hashref->{freq}</TD> + <TD>$hashref->{prog}</TD> + </TR> +END + +} + +print <<END; + </TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/browse/agent_type.cgi b/htdocs/browse/agent_type.cgi new file mode 100755 index 000000000..5f05bd514 --- /dev/null +++ b/htdocs/browse/agent_type.cgi @@ -0,0 +1,81 @@ +#!/usr/bin/perl -Tw +# +# agent_type.cgi: browse agent_type +# +# ivan@sisd.com 97-dec-10 +# +# Changes to allow page to work at a relative position in server +# Changes to make "Packages" display 2-wide in table (old way was too vertical) +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +print header("Agent Type Listing", menubar( + 'Main Menu' => '../', + 'Add new agent type' => "../edit/agent_type.cgi", +)), <<END; + <BR>Click on agent type number to edit. + <TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>Type #</FONT></TH> + <TH>Type</TH> + <TH colspan="2">Packages</TH> + </TR> +END + +my($agent_type); +foreach $agent_type ( sort { + $a->getfield('typenum') <=> $b->getfield('typenum') +} qsearch('agent_type',{}) ) { + my($hashref)=$agent_type->hashref; + my(@type_pkgs)=qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} }); + my($rowspan)=scalar(@type_pkgs); + $rowspan = int($rowspan/2+0.5) ; + print <<END; + <TR> + <TD ROWSPAN=$rowspan><A HREF="../edit/agent_type.cgi?$hashref->{typenum}"> + $hashref->{typenum} + </A></TD> + <TD ROWSPAN=$rowspan>$hashref->{atype}</TD> +END + + my($type_pkgs); + my($tdcount) = -1 ; + foreach $type_pkgs ( @type_pkgs ) { + my($pkgpart)=$type_pkgs->getfield('pkgpart'); + my($part_pkg) = qsearchs('part_pkg',{'pkgpart'=> $pkgpart }); + print qq!<TR>! if ($tdcount == 0) ; + $tdcount = 0 if ($tdcount == -1) ; + print qq!<TD><A HREF="../edit/part_pkg.cgi?$pkgpart">!, + $part_pkg->getfield('pkg'),"</A></TD>"; + $tdcount ++ ; + if ($tdcount == 2) + { + print qq!</TR>\n! ; + $tdcount = 0 ; + } + } + + print "</TR>"; +} + +print <<END; + </TR></TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/browse/cust_main_county.cgi b/htdocs/browse/cust_main_county.cgi new file mode 100755 index 000000000..d615198c9 --- /dev/null +++ b/htdocs/browse/cust_main_county.cgi @@ -0,0 +1,65 @@ +#!/usr/bin/perl -Tw +# +# cust_main_county.cgi: browse cust_main_county +# +# ivan@sisd.com 97-dec-13 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. +print header("Tax Rate Listing", menubar( + 'Main Menu' => '../', + 'Edit tax rates' => "../edit/cust_main_county.cgi", +)),<<END; + <BR>Click on <u>expand</u> to specify tax rates by county. + <P><TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>State</FONT></TH> + <TH>County</TH> + <TH><FONT SIZE=-1>Tax</FONT></TH> + </TR> +END + +my($cust_main_county); +foreach $cust_main_county ( qsearch('cust_main_county',{}) ) { + my($hashref)=$cust_main_county->hashref; + print <<END; + <TR> + <TD>$hashref->{state}</TD> +END + + print "<TD>", $hashref->{county} + ? $hashref->{county} + : qq!(ALL) <FONT SIZE=-1>!. + qq!<A HREF="../edit/cust_main_county-expand.cgi?!. $hashref->{taxnum}. + qq!">expand</A></FONT>! + , "</TD>"; + + print <<END; + <TD>$hashref->{tax}%</TD> + </TR> +END + +} + +print <<END; + </TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/browse/part_pkg.cgi b/htdocs/browse/part_pkg.cgi new file mode 100755 index 000000000..e5ff31e9e --- /dev/null +++ b/htdocs/browse/part_pkg.cgi @@ -0,0 +1,81 @@ +#!/usr/bin/perl -Tw +# +# part_svc.cgi: browse part_pkg +# +# ivan@sisd.com 97-dec-5,9 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +print header("Package Part Listing",menubar( + 'Main Menu' => '../', + 'Add new package' => "../edit/part_pkg.cgi", +)), <<END; + <BR>Click on package part number to edit. + <TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>Part #</FONT></TH> + <TH>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>Service</TH> + <TH><FONT SIZE=-1>Quan.</FONT></TH> + </TR> +END + +my($part_pkg); +foreach $part_pkg ( sort { + $a->getfield('pkgpart') <=> $b->getfield('pkgpart') +} qsearch('part_pkg',{}) ) { + my($hashref)=$part_pkg->hashref; + my(@pkg_svc)=grep $_->getfield('quantity'), + qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} }); + my($rowspan)=scalar(@pkg_svc); + print <<END; + <TR> + <TD ROWSPAN=$rowspan><A HREF="../edit/part_pkg.cgi?$hashref->{pkgpart}"> + $hashref->{pkgpart} + </A></TD> + <TD ROWSPAN=$rowspan>$hashref->{pkg}</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> +END + + my($pkg_svc); + foreach $pkg_svc ( @pkg_svc ) { + my($svcpart)=$pkg_svc->getfield('svcpart'); + my($part_svc) = qsearchs('part_svc',{'svcpart'=> $svcpart }); + print qq!<TD><A HREF="../edit/part_svc.cgi?$svcpart">!, + $part_svc->getfield('svc'),"</A></TD><TD>", + $pkg_svc->getfield('quantity'),"</TD></TR><TR>\n"; + } + + print "</TR>"; +} + +print <<END; + </TR></TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/browse/part_referral.cgi b/htdocs/browse/part_referral.cgi new file mode 100755 index 000000000..b16fa896d --- /dev/null +++ b/htdocs/browse/part_referral.cgi @@ -0,0 +1,57 @@ +#!/usr/bin/perl -Tw +# +# part_referral.cgi: Browse part_referral +# +# ivan@sisd.com 98-feb-23 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. +print header("Referral Listing", menubar( + 'Main Menu' => '../', + 'Add new referral' => "../edit/part_referral.cgi", +)), <<END; + <BR>Click on referral number to edit. + <TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>Referral #</FONT></TH> + <TH>Referral</TH> + </TR> +END + +my($part_referral); +foreach $part_referral ( sort { + $a->getfield('refnum') <=> $b->getfield('refnum') +} qsearch('part_referral',{}) ) { + my($hashref)=$part_referral->hashref; + print <<END; + <TR> + <TD><A HREF="../edit/part_referral.cgi?$hashref->{refnum}"> + $hashref->{refnum}</A></TD> + <TD>$hashref->{referral}</TD> + </TR> +END + +} + +print <<END; + </TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/browse/part_svc.cgi b/htdocs/browse/part_svc.cgi new file mode 100755 index 000000000..71a556421 --- /dev/null +++ b/htdocs/browse/part_svc.cgi @@ -0,0 +1,81 @@ +#!/usr/bin/perl -Tw +# +# part_svc.cgi: browse part_svc +# +# ivan@sisd.com 97-nov-14, 97-dec-9 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch); +use FS::part_svc qw(fields); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. +print header('Service Part Listing', menubar( + 'Main Menu' => '../', + 'Add new service' => "../edit/part_svc.cgi", +)),<<END; + <BR>Click on service part number to edit. + <TABLE BORDER> + <TR> + <TH>Part #</TH> + <TH>Service</TH> + <TH>Table</TH> + <TH>Field</TH> + <TH>Action</TH> + <TH>Value</TH> + </TR> +END + +my($part_svc); +foreach $part_svc ( sort { + $a->getfield('svcpart') <=> $b->getfield('svcpart') +} qsearch('part_svc',{}) ) { + my($hashref)=$part_svc->hashref; + my($svcdb)=$hashref->{svcdb}; + my(@rows)= + grep $hashref->{${svcdb}.'__'.$_.'_flag'}, + map { /^${svcdb}__(.*)$/; $1 } + grep ! /_flag$/, + grep /^${svcdb}__/, + fields('part_svc') + ; + my($rowspan)=scalar(@rows); + print <<END; + <TR> + <TD ROWSPAN=$rowspan><A HREF="../edit/part_svc.cgi?$hashref->{svcpart}"> + $hashref->{svcpart} + </A></TD> + <TD ROWSPAN=$rowspan>$hashref->{svc}</TD> + <TD ROWSPAN=$rowspan>$hashref->{svcdb}</TD> +END + my($row); + foreach $row ( @rows ) { + my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag'); + print "<TD>$row</TD><TD>"; + if ( $flag eq "D" ) { print "Default"; } + elsif ( $flag eq "F" ) { print "Fixed"; } + else { print "(Unknown!)"; } + print "</TD><TD>",$part_svc->getfield($svcdb."__".$row),"</TD></TR><TR>"; + } +print "</TR>"; +} + +print <<END; + </TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/browse/svc_acct_pop.cgi b/htdocs/browse/svc_acct_pop.cgi new file mode 100755 index 000000000..a8a3a9224 --- /dev/null +++ b/htdocs/browse/svc_acct_pop.cgi @@ -0,0 +1,63 @@ +#!/usr/bin/perl -Tw +# +# svc_acct_pop.cgi: browse pops +# +# ivan@sisd.com 98-mar-8 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use FS::UID qw(cgisuidsetup swapuid); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. +print header('POP Listing', menubar( + 'Main Menu' => '../', + 'Add new POP' => "../edit/svc_acct_pop.cgi", +)), <<END; + <BR>Click on pop number to edit. + <TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>POP #</FONT></TH> + <TH>City</TH> + <TH>State</TH> + <TH>Area code</TH> + <TH>Exchange</TH> + </TR> +END + +my($svc_acct_pop); +foreach $svc_acct_pop ( sort { + $a->getfield('popnum') <=> $b->getfield('popnum') +} qsearch('svc_acct_pop',{}) ) { + my($hashref)=$svc_acct_pop->hashref; + print <<END; + <TR> + <TD><A HREF="../edit/svc_acct_pop.cgi?$hashref->{popnum}"> + $hashref->{popnum}</A></TD> + <TD>$hashref->{city}</TD> + <TD>$hashref->{state}</TD> + <TD>$hashref->{ac}</TD> + <TD>$hashref->{exch}</TD> + </TR> +END + +} + +print <<END; + </TABLE> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/edit/cust_main_county-expand.cgi b/htdocs/edit/cust_main_county-expand.cgi new file mode 100755 index 000000000..59ff7043a --- /dev/null +++ b/htdocs/edit/cust_main_county-expand.cgi @@ -0,0 +1,49 @@ +#!/usr/bin/perl -Tw +# +# cust_main_county-expand.cgi: Expand a state into counties (output form) +# +# ivan@sisd.com 97-dec-16 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +$cgi->var('QUERY_STRING') =~ /^(\d+)$/ + or die "Illegal taxnum!"; +my($taxnum)=$1; + +my($cust_main_county)=qsearchs('cust_main_county',{'taxnum'=>$taxnum}); +die "Can't expand entry!" if $cust_main_county->getfield('county'); + +print header("Tax Rate (expand state)", menubar( + 'Main Menu' => '../', +)), <<END; + <FORM ACTION="process/cust_main_county-expand.cgi" METHOD=POST> + <INPUT TYPE="hidden" NAME="taxnum" VALUE="$taxnum"> + Separate counties by + <INPUT TYPE="radio" NAME="delim" VALUE="n" CHECKED>line + (rumor has it broken on some browsers) or + <INPUT TYPE="radio" NAME="delim" VALUE="s">whitespace. + <BR><INPUT TYPE="submit" VALUE="Submit"> + <BR><TEXTAREA NAME="counties" ROWS=100></TEXTAREA> + </FORM> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/edit/cust_main_county.cgi b/htdocs/edit/cust_main_county.cgi new file mode 100755 index 000000000..904d58346 --- /dev/null +++ b/htdocs/edit/cust_main_county.cgi @@ -0,0 +1,66 @@ +#!/usr/bin/perl -Tw +# +# cust_main_county.cgi: Edit tax rates (output form) +# +# ivan@sisd.com 97-dec-13-16 +# +# Changes to allow page to work at a relative position in server +# Changed tax field to accept 6 chars (MO uses 6.1%) +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +print header("Edit tax rates", menubar( + 'Main Menu' => '../', +)),<<END; + <FORM ACTION="process/cust_main_county.cgi" METHOD=POST> + <TABLE BORDER> + <TR> + <TH><FONT SIZE=-1>State</FONT></TH> + <TH>County</TH> + <TH><FONT SIZE=-1>Tax</FONT></TH> + </TR> +END + +my($cust_main_county); +foreach $cust_main_county ( qsearch('cust_main_county',{}) ) { + my($hashref)=$cust_main_county->hashref; + print <<END; + <TR> + <TD>$hashref->{state}</TD> +END + + print "<TD>", $hashref->{county} + ? $hashref->{county} + : '(ALL)' + , "</TD>"; + + print qq!<TD><INPUT TYPE="text" NAME="tax!, $hashref->{taxnum}, + qq!" VALUE="!, $hashref->{tax}, qq!" SIZE=6 MAXLENGTH=6>%</TD></TR>!; +END + +} + +print <<END; + </TABLE> + <INPUT TYPE="submit" VALUE="Apply changes"> + </FORM> + </CENTER> + </BODY> +</HTML> +END + diff --git a/htdocs/edit/part_referral.cgi b/htdocs/edit/part_referral.cgi new file mode 100755 index 000000000..f29802239 --- /dev/null +++ b/htdocs/edit/part_referral.cgi @@ -0,0 +1,66 @@ +#!/usr/bin/perl -Tw +# +# agent.cgi: Add/Edit referral (output form) +# +# ivan@sisd.com 98-feb-23 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# confisuing typo on submit button ivan@sisd.com 98-jun-14 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::part_referral; +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +my($part_referral,$action); +if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing + $part_referral=qsearchs('part_referral',{'refnum'=>$1}); + $action='Edit'; +} else { #adding + $part_referral=create FS::part_referral {}; + $action='Add'; +} +my($hashref)=$part_referral->hashref; + +print header("$action Referral", menubar( + 'Main Menu' => '../', + 'View all referrals' => "../browse/part_referral.cgi", +)), <<END; + <FORM ACTION="process/part_referral.cgi" METHOD=POST> +END + +#display + +print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$hashref->{refnum}">!, + "Referral #", $hashref->{refnum} ? $hashref->{refnum} : "(NEW)"; + +print <<END; +<PRE> +Referral <INPUT TYPE="text" NAME="referral" SIZE=32 VALUE="$hashref->{referral}"> +</PRE> +END + +print qq!<BR><INPUT TYPE="submit" VALUE="!, + $hashref->{refnum} ? "Apply changes" : "Add referral", + qq!">!; + +print <<END; + </FORM> + </BODY> +</HTML> +END + diff --git a/htdocs/edit/process/agent.cgi b/htdocs/edit/process/agent.cgi new file mode 100755 index 000000000..5d1ce3232 --- /dev/null +++ b/htdocs/edit/process/agent.cgi @@ -0,0 +1,53 @@ +#!/usr/bin/perl -Tw +# +# process/agent.cgi: Edit agent (process form) +# +# ivan@sisd.com 97-dec-12 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::agent qw(fields); +use FS::CGI qw(idiot); + +my($req)=new CGI::Request; # create form object + +&cgisuidsetup($req->cgi); + +my($agentnum)=$req->param('agentnum'); + +my($old)=qsearchs('agent',{'agentnum'=>$agentnum}) if $agentnum; + +#unmunge typenum +$req->param('typenum') =~ /^(\d+)(:.*)?$/; +$req->param('typenum',$1); + +my($new)=create FS::agent ( { + map { + $_, $req->param($_); + } fields('agent') +} ); + +my($error); +if ( $agentnum ) { + $error=$new->replace($old); +} else { + $error=$new->insert; + $agentnum=$new->getfield('agentnum'); +} + +if ( $error ) { + &idiot($error); +} else { + #$req->cgi->redirect("../../view/agent.cgi?$agentnum"); + #$req->cgi->redirect("../../edit/agent.cgi?$agentnum"); + $req->cgi->redirect("../../browse/agent.cgi"); +} + diff --git a/htdocs/edit/process/agent_type.cgi b/htdocs/edit/process/agent_type.cgi new file mode 100755 index 000000000..43f129fd5 --- /dev/null +++ b/htdocs/edit/process/agent_type.cgi @@ -0,0 +1,83 @@ +#!/usr/bin/perl -Tw +# +# process/agent_type.cgi: Edit agent type (process form) +# +# ivan@sisd.com 97-dec-11 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::agent_type qw(fields); +use FS::type_pkgs; +use FS::CGI qw(idiot); + +my($req)=new CGI::Request; +&cgisuidsetup($req->cgi); + +my($typenum)=$req->param('typenum'); +my($old)=qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum; + +my($new)=create FS::agent_type ( { + map { + $_, $req->param($_); + } fields('agent_type') +} ); + +my($error); +if ( $typenum ) { + $error=$new->replace($old); +} else { + $error=$new->insert; + $typenum=$new->getfield('typenum'); +} + +if ( $error ) { + idiot($error); + exit; +} + +my($part_pkg); +foreach $part_pkg (qsearch('part_pkg',{})) { + my($pkgpart)=$part_pkg->getfield('pkgpart'); + + my($type_pkgs)=qsearchs('type_pkgs',{ + 'typenum' => $typenum, + 'pkgpart' => $pkgpart, + }); + if ( $type_pkgs && ! $req->param("pkgpart$pkgpart") ) { + my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below. + $error=$d_type_pkgs->del; #FS::Record not FS::type_pkgs, + #so ->del not ->delete. hmm. hmm. + if ( $error ) { + idiot($error); + exit; + } + + } elsif ( $req->param("pkgpart$pkgpart") + && ! $type_pkgs + ) { + #ok to clobber it now (but bad form nonetheless?) + $type_pkgs=create FS::type_pkgs ({ + 'typenum' => $typenum, + 'pkgpart' => $pkgpart, + }); + $error= $type_pkgs->insert; + if ( $error ) { + idiot($error); + exit; + } + } + +} + +#$req->cgi->redirect("../../view/agent_type.cgi?$typenum"); +#$req->cgi->redirect("../../edit/agent_type.cgi?$typenum"); +$req->cgi->redirect("../../browse/agent_type.cgi"); + diff --git a/htdocs/edit/process/cust_main_county-expand.cgi b/htdocs/edit/process/cust_main_county-expand.cgi new file mode 100755 index 000000000..a821560c6 --- /dev/null +++ b/htdocs/edit/process/cust_main_county-expand.cgi @@ -0,0 +1,71 @@ +#!/usr/bin/perl -Tw +# +# process/cust_main_county-expand.cgi: Expand counties (process form) +# +# ivan@sisd.com 97-dec-16 +# +# Changes to allow page to work at a relative position in server +# Added import of datasrc from UID.pm for Pg6.3 +# Default tax to 0.0 if using Pg6.3 +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI +# undo default tax to 0.0 if using Pg6.3: comes from pre-expanded record +# for that state +#ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup datasrc); +use FS::Record qw(qsearch qsearchs); +use FS::cust_main_county; +use FS::CGI qw(eidiot); + +my($req)=new CGI::Request; # create form object + +&cgisuidsetup($req->cgi); + +$req->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!"; +my($taxnum)=$1; +my($cust_main_county)=qsearchs('cust_main_county',{'taxnum'=>$taxnum}) + or die ("Unknown taxnum!"); + +my(@counties); +if ( $req->param('delim') eq 'n' ) { + @counties=split(/\n/,$req->param('counties')); +} elsif ( $req->param('delim') eq 's' ) { + @counties=split(/\s+/,$req->param('counties')); +} else { + die "Illegal delim!"; +} + +@counties=map { + /^\s*([\w\- ]+)\s*$/ or eidiot("Illegal county"); + $1; +} @counties; + +my($county); +foreach ( @counties) { + my(%hash)=$cust_main_county->hash; + my($new)=create FS::cust_main_county \%hash; + $new->setfield('taxnum',''); + $new->setfield('county',$_); + #if (datasrc =~ m/Pg/) + #{ + # $new->setfield('tax',0.0); + #} + my($error)=$new->insert; + die $error if $error; +} + +unless ( qsearch('cust_main',{ + 'state' => $cust_main_county->getfield('state'), + 'county' => $cust_main_county->getfield('county'), +} ) ) { + my($error)=($cust_main_county->delete); + die $error if $error; +} + +$req->cgi->redirect("../../edit/cust_main_county.cgi"); + diff --git a/htdocs/edit/process/cust_main_county.cgi b/htdocs/edit/process/cust_main_county.cgi new file mode 100755 index 000000000..58eaa63ce --- /dev/null +++ b/htdocs/edit/process/cust_main_county.cgi @@ -0,0 +1,38 @@ +#!/usr/bin/perl -Tw +# +# process/agent.cgi: Edit cust_main_county (process form) +# +# ivan@sisd.com 97-dec-16 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::cust_main_county; +use FS::CGI qw(eidiot); + +my($req)=new CGI::Request; # create form object + +&cgisuidsetup($req->cgi); + +foreach ( $req->params ) { + /^tax(\d+)$/ or die "Illegal form $_!"; + my($taxnum)=$1; + my($old)=qsearchs('cust_main_county',{'taxnum'=>$taxnum}) + or die "Couldn't find taxnum $taxnum!"; + next unless $old->getfield('tax') ne $req->param("tax$taxnum"); + my(%hash)=$old->hash; + $hash{tax}=$req->param("tax$taxnum"); + my($new)=create FS::cust_main_county \%hash; + my($error)=$new->replace($old); + eidiot($error) if $error; +} + +$req->cgi->redirect("../../browse/cust_main_county.cgi"); + diff --git a/htdocs/edit/process/part_pkg.cgi b/htdocs/edit/process/part_pkg.cgi new file mode 100755 index 000000000..7d787819a --- /dev/null +++ b/htdocs/edit/process/part_pkg.cgi @@ -0,0 +1,79 @@ +#!/usr/bin/perl -Tw +# +# process/part_pkg.cgi: Edit package definitions (process form) +# +# ivan@sisd.com 97-dec-10 +# +# don't update non-changing records in part_svc (causing harmless but annoying +# "Records identical" errors). ivan@sisd.com 98-feb-19 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# Added `|| 0 ' when getting quantity off web page ivan@sisd.com 98-jun-4 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +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 + +&cgisuidsetup($req->cgi); + +my($pkgpart)=$req->param('pkgpart'); + +my($old)=qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart; + +my($new)=create FS::part_pkg ( { + map { + $_, $req->param($_); + } fields('part_pkg') +} ); + +if ( $pkgpart ) { + my($error)=$new->replace($old); + eidiot($error) if $error; +} else { + my($error)=$new->insert; + eidiot($error) if $error; + $pkgpart=$new->getfield('pkgpart'); +} + +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($old_pkg_svc)=qsearchs('pkg_svc',{ + 'pkgpart' => $pkgpart, + 'svcpart' => $part_svc->getfield('svcpart'), + }); + my($old_quantity)=$old_pkg_svc ? $old_pkg_svc->quantity : 0; + next unless $old_quantity != $quantity; #!here + 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' => $quantity, + }); + if ($old_pkg_svc) { + my($error)=$new_pkg_svc->replace($old_pkg_svc); + eidiot($error) if $error; + } else { + my($error)=$new_pkg_svc->insert; + eidiot($error) if $error; + } +} + +#$req->cgi->redirect("../../view/part_pkg.cgi?$pkgpart"); +#$req->cgi->redirect("../../edit/part_pkg.cgi?$pkgpart"); +$req->cgi->redirect("../../browse/part_pkg.cgi"); + diff --git a/htdocs/edit/process/part_referral.cgi b/htdocs/edit/process/part_referral.cgi new file mode 100755 index 000000000..08a4c01d0 --- /dev/null +++ b/htdocs/edit/process/part_referral.cgi @@ -0,0 +1,45 @@ +#!/usr/bin/perl -Tw +# +# process/part_referral.cgi: Edit referrals (process form) +# +# ivan@sisd.com 98-feb-23 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearchs); +use FS::part_referral qw(fields); +use FS::CGI qw(eidiot); +use FS::CGI qw(eidiot); + +my($req)=new CGI::Request; # create form object + +&cgisuidsetup($req->cgi); + +my($refnum)=$req->param('refnum'); + +my($new)=create FS::part_referral ( { + map { + $_, $req->param($_); + } fields('part_referral') +} ); + +if ( $refnum ) { + my($old)=qsearchs('part_referral',{'refnum'=>$refnum}); + eidiot("(Old) Record not found!") unless $old; + my($error)=$new->replace($old); + eidiot($error) if $error; +} else { + my($error)=$new->insert; + eidiot($error) if $error; +} + +$refnum=$new->getfield('refnum'); +$req->cgi->redirect("../../browse/part_referral.cgi"); + diff --git a/htdocs/edit/process/part_svc.cgi b/htdocs/edit/process/part_svc.cgi new file mode 100755 index 000000000..0f0fbc6e8 --- /dev/null +++ b/htdocs/edit/process/part_svc.cgi @@ -0,0 +1,47 @@ +#!/usr/bin/perl -Tw +# +# process/part_svc.cgi: Edit service definitions (process form) +# +# ivan@sisd.com 97-nov-14 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearchs); +use FS::part_svc qw(fields); +use FS::CGI qw(eidiot); + +my($req)=new CGI::Request; # create form object + +&cgisuidsetup($req->cgi); + +my($svcpart)=$req->param('svcpart'); + +my($old)=qsearchs('part_svc',{'svcpart'=>$svcpart}) if $svcpart; + +my($new)=create FS::part_svc ( { + map { + $_, $req->param($_); +# } qw(svcpart svc svcdb) + } fields('part_svc') +} ); + +if ( $svcpart ) { + my($error)=$new->replace($old); + eidiot($error) if $error; +} else { + my($error)=$new->insert; + eidiot($error) if $error; + $svcpart=$new->getfield('svcpart'); +} + +#$req->cgi->redirect("../../view/part_svc.cgi?$svcpart"); +#$req->cgi->redirect("../../edit/part_svc.cgi?$svcpart"); +$req->cgi->redirect("../../browse/part_svc.cgi"); + diff --git a/htdocs/edit/process/svc_acct_pop.cgi b/htdocs/edit/process/svc_acct_pop.cgi new file mode 100755 index 000000000..18d7940b4 --- /dev/null +++ b/htdocs/edit/process/svc_acct_pop.cgi @@ -0,0 +1,43 @@ +#!/usr/bin/perl -Tw +# +# process/svc_acct_pop.cgi: Edit POP (process form) +# +# ivan@sisd.com 98-mar-8 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Request; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::svc_acct_pop qw(fields); +use FS::CGI qw(eidiot); + +my($req)=new CGI::Request; # create form object + +&cgisuidsetup($req->cgi); + +my($popnum)=$req->param('popnum'); + +my($old)=qsearchs('svc_acct_pop',{'popnum'=>$popnum}) if $popnum; + +my($new)=create FS::svc_acct_pop ( { + map { + $_, $req->param($_); + } fields('svc_acct_pop') +} ); + +if ( $popnum ) { + my($error)=$new->replace($old); + eidiot($error) if $error; +} else { + my($error)=$new->insert; + eidiot($error) if $error; + $popnum=$new->getfield('popnum'); +} +$req->cgi->redirect("../../browse/svc_acct_pop.cgi"); + diff --git a/htdocs/edit/svc_acct_pop.cgi b/htdocs/edit/svc_acct_pop.cgi new file mode 100755 index 000000000..46d803f07 --- /dev/null +++ b/htdocs/edit/svc_acct_pop.cgi @@ -0,0 +1,67 @@ +#!/usr/bin/perl -Tw +# +# svc_acct_pop.cgi: Add/Edit pop (output form) +# +# ivan@sisd.com 98-mar-8 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::svc_acct_pop; +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; + +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. + +my($svc_acct_pop,$action); +if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing + $svc_acct_pop=qsearchs('svc_acct_pop',{'popnum'=>$1}); + $action='Edit'; +} else { #adding + $svc_acct_pop=create FS::svc_acct_pop {}; + $action='Add'; +} +my($hashref)=$svc_acct_pop->hashref; + +print header("$action POP", menubar( + 'Main Menu' => '../', + 'View all POPs' => "../browse/svc_acct_pop.cgi", +)), <<END; + <FORM ACTION="process/svc_acct_pop.cgi" METHOD=POST> +END + +#display + +print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$hashref->{popnum}">!, + "POP #", $hashref->{popnum} ? $hashref->{popnum} : "(NEW)"; + +print <<END; +<PRE> +City <INPUT TYPE="text" NAME="city" SIZE=32 VALUE="$hashref->{city}"> +State <INPUT TYPE="text" NAME="state" SIZE=3 MAXLENGTH=2 VALUE="$hashref->{state}"> +Area Code <INPUT TYPE="text" NAME="ac" SIZE=4 MAXLENGTH=3 VALUE="$hashref->{ac}"> +Exchange <INPUT TYPE="text" NAME="exch" SIZE=4 MAXLENGTH=3 VALUE="$hashref->{exch}"> +</PRE> +END + +print qq!<BR><INPUT TYPE="submit" VALUE="!, + $hashref->{popnum} ? "Apply changes" : "Add POP", + qq!">!; + +print <<END; + </FORM> + </BODY> +</HTML> +END + diff --git a/htdocs/view/cust_main.cgi b/htdocs/view/cust_main.cgi new file mode 100755 index 000000000..ca5fcd94f --- /dev/null +++ b/htdocs/view/cust_main.cgi @@ -0,0 +1,336 @@ +#!/usr/bin/perl -Tw +# +# cust_main.cgi: View a customer +# +# Usage: cust_main.cgi custnum +# http://server.name/path/cust_main.cgi?custnum +# +# Note: Should be run setuid freeside as user nobody. +# +# the payment history section could use some work, see below +# +# ivan@voicenet.com 96-nov-29 -> 96-dec-11 +# +# added navigation bar (go to main menu ;) +# ivan@voicenet.com 97-jan-30 +# +# changes to the way credits/payments are applied (the links are here). +# ivan@voicenet.com 97-apr-21 +# +# added debugging code to diagnose CPU sucking problem. +# ivan@voicenet.com 97-may-19 +# +# CPU sucking problem was in comment code? fixed? +# ivan@voicenet.com 97-may-22 +# +# rewrote for new API +# ivan@voicenet.com 97-jul-22 +# +# Changes to allow page to work at a relative position in server +# Changed 'day' to 'daytime' because Pg6.3 reserves the day word +# bmccane@maxbaud.net 98-apr-3 +# +# lose background, FS::CGI ivan@sisd.com 98-sep-2 + +use strict; +use CGI::Base qw(:DEFAULT :CGI); # CGI module +use CGI::Carp qw(fatalsToBrowser); +use Date::Format; +use FS::UID qw(cgisuidsetup); +use FS::Record qw(qsearchs qsearch); +use FS::CGI qw(header menubar); + +my($cgi) = new CGI::Base; +$cgi->get; +&cgisuidsetup($cgi); + +SendHeaders(); # one guess. +print header("Customer View", menubar( + 'Main Menu' => '../', +)),<<END; + <BASEFONT SIZE=3> +END + +#untaint custnum & get customer record +$QUERY_STRING =~ /^(\d+)$/; +my($custnum)=$1; +my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum}); +die "Customer not found!" unless $cust_main; +my($hashref)=$cust_main->hashref; + +#custnum +print "<FONT SIZE=+1><CENTER>Customer #<B>$custnum</B></CENTER></FONT>", + qq!<CENTER><A HREF="#cust_main">Customer Information</A> | !, + qq!<A HREF="#cust_comments">Comments</A> | !, + qq!<A HREF="#cust_pkg">Packages</A> | !, + qq!<A HREF="#history">Payment History</A> </CENTER>!; + +#bill now linke +print qq!<HR><CENTER><A HREF="../misc/bill.cgi?$custnum">!, + qq!Bill this customer now</A></CENTER>!; + +#formatting +print qq!<HR><A NAME="cust_main"><CENTER><FONT SIZE=+1>Customer Information!, + qq!</FONT>!, + qq!<BR><A HREF="../edit/cust_main.cgi?$custnum!, + qq!">Edit this information</A></CENTER><FONT SIZE=-1>!; + +#agentnum +my($agent)=qsearchs('agent',{ + 'agentnum' => $cust_main->getfield('agentnum') +} ); +die "Agent not found!" unless $agent; +print "<BR>Agent #<B>" , $agent->getfield('agentnum') , ": " , + $agent->getfield('agent') , "</B>"; + +#refnum +my($referral)=qsearchs('part_referral',{'refnum' => $cust_main->refnum}); +die "Referral not found!" unless $referral; +print "<BR>Referral #<B>", $referral->refnum, ": ", + $referral->referral, "<\B>"; + +#last, first +print "<P><B>", $hashref->{'last'}, ", ", $hashref->{first}, "</B>"; + +#ss +print " (SS# <B>", $hashref->{ss}, "</B>)" if $hashref->{ss}; + +#company +print "<BR><B>", $hashref->{company}, "</B>" if $hashref->{company}; + +#address1 +print "<BR><B>", $hashref->{address1}, "</B>"; + +#address2 +print "<BR><B>", $hashref->{address2}, "</B>" if $hashref->{address2}; + +#city +print "<BR><B>", $hashref->{city}, "</B>"; + +#county +print " (<B>", $hashref->{county}, "</B> county)" if $hashref->{county}; + +#state +print ",<B>", $hashref->{state}, "</B>"; + +#zip +print " <B>", $hashref->{zip}, "</B>"; + +#country +print "<BR><B>", $hashref->{country}, "</B>" + unless $hashref->{country} eq "US"; + +#daytime +print "<P><B>", $hashref->{daytime}, "</B>" if $hashref->{daytime}; +print " (Day)" if $hashref->{daytime} && $hashref->{night}; + +#night +print "<BR><B>", $hashref->{night}, "</B>" if $hashref->{night}; +print " (Night)" if $hashref->{daytime} && $hashref->{night}; + +#fax +print "<BR><B>", $hashref->{fax}, "</B> (Fax)" if $hashref->{fax}; + +#payby/payinfo/paydate/payname +if ($hashref->{payby} eq "CARD") { + print "<P>Card #<B>", $hashref->{payinfo}, "</B> Exp. <B>", + $hashref->{paydate}, "</B>"; + print " (<B>", $hashref->{payname}, "</B>)" if $hashref->{payname}; +} elsif ($hashref->{payby} eq "BILL") { + print "<P>Bill"; + print " on P.O. #<B>", $hashref->{payinfo}, "</B>" + if $hashref->{payinfo}; + print " until <B>", $hashref->{paydate}, "</B>" + if $hashref->{paydate}; + print " to <B>", $hashref->{payname}, "</B> at above address" + if $hashref->{payname}; +} elsif ($hashref->{payby} eq "COMP") { + print "<P>Access complimentary"; + print " courtesy of <B>", $hashref->{payinfo}, "</B>" + if $hashref->{payinfo}; + print " until <B>", $hashref->{paydate}, "</B>" + if $hashref->{paydate}; +} else { + print "Unknown payment type ", $hashref->{payby}, "!"; +} + +#tax +print "<BR>(Tax exempt)" if $hashref->{tax}; + +#otaker +print "<P>Order taken by <B>", $hashref->{otaker}, "</B>"; + +#formatting +print qq!<HR><FONT SIZE=+1><A NAME="cust_pkg"><CENTER>Packages</A></FONT>!, + qq!<BR>Click on package number to view/edit package.!, + qq!<BR><A HREF="../edit/cust_pkg.cgi?$custnum">Add/Edit packages</A>!, + qq!</CENTER><BR>!; + +#display packages + +#formatting +print qq!<CENTER><TABLE BORDER=4>\n!, + qq!<TR><TH ROWSPAN=2>#</TH><TH ROWSPAN=2>Package</TH><TH COLSPAN=5>!, + qq!Dates</TH></TR>\n!, + qq!<TR><TH><FONT SIZE=-1>Setup</FONT></TH><TH>!, + qq!<FONT SIZE=-1>Next bill</FONT>!, + qq!</TH><TH><FONT SIZE=-1>Susp.</FONT></TH><TH><FONT SIZE=-1>Expire!, + qq!</FONT></TH>!, + qq!<TH><FONT SIZE=-1>Cancel</FONT></TH>!, + qq!</TR>\n!; + +#get package info +my(@packages)=qsearch('cust_pkg',{'custnum'=>$custnum}); +my($package); +foreach $package (@packages) { + my($pref)=$package->hashref; + my($part_pkg)=qsearchs('part_pkg',{ + 'pkgpart' => $pref->{pkgpart} + } ); + print qq!<TR><TD><FONT SIZE=-1><A HREF="../view/cust_pkg.cgi?!, + $pref->{pkgnum}, qq!">!, + $pref->{pkgnum}, qq!</A></FONT></TD>!, + "<TD><FONT SIZE=-1>", $part_pkg->getfield('pkg'), " - ", + $part_pkg->getfield('comment'), "</FONT></TD>", + "<TD><FONT SIZE=-1>", + $pref->{setup} ? time2str("%D",$pref->{setup} ) : "" , + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + $pref->{bill} ? time2str("%D",$pref->{bill} ) : "" , + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + $pref->{susp} ? time2str("%D",$pref->{susp} ) : "" , + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + $pref->{expire} ? time2str("%D",$pref->{expire} ) : "" , + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + $pref->{cancel} ? time2str("%D",$pref->{cancel} ) : "" , + "</FONT></TD>", + "</TR>"; +} + +#formatting +print "</TABLE></CENTER>"; + +#formatting +print qq!<CENTER><HR><A NAME="history"><FONT SIZE=+1>Payment History!, + qq!</FONT></A><BR>!, + qq!Click on invoice to view invoice/enter payment.<BR>!, + qq!<A HREF="../edit/cust_credit.cgi?$custnum">!, + qq!Post Credit / Refund</A></CENTER><BR>!; + +#get payment history +# +# major problem: this whole thing is way too sloppy. +# minor problem: the description lines need better formatting. + +my(@history); + +my(@bills)=qsearch('cust_bill',{'custnum'=>$custnum}); +my($bill); +foreach $bill (@bills) { + my($bref)=$bill->hashref; + push @history, + $bref->{_date} . qq!\t<A HREF="../view/cust_bill.cgi?! . + $bref->{invnum} . qq!">Invoice #! . $bref->{invnum} . + qq! (Balance \$! . $bref->{owed} . qq!)</A>\t! . + $bref->{charged} . qq!\t\t\t!; + + my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } ); + my($payment); + foreach $payment (@payments) { +# my($pref)=$payment->hashref; + my($date,$invnum,$payby,$payinfo,$paid)=($payment->getfield('_date'), + $payment->getfield('invnum'), + $payment->getfield('payby'), + $payment->getfield('payinfo'), + $payment->getfield('paid'), + ); + push @history, + "$date\tPayment, Invoice #$invnum ($payby $payinfo)\t\t$paid\t\t"; + } +} + +my(@credits)=qsearch('cust_credit',{'custnum'=>$custnum}); +my($credit); +foreach $credit (@credits) { + my($cref)=$credit->hashref; + push @history, + $cref->{_date} . "\tCredit #" . $cref->{crednum} . ", (Balance \$" . + $cref->{credited} . ") by " . $cref->{otaker} . " - " . + $cref->{reason} . "\t\t\t" . $cref->{amount} . "\t"; + + my(@refunds)=qsearch('cust_refund',{'crednum'=> $cref->{crednum} } ); + my($refund); + foreach $refund (@refunds) { + my($rref)=$refund->hashref; + push @history, + $rref->{_date} . "\tRefund, Credit #" . $rref->{crednum} . " (" . + $rref->{payby} . " " . $rref->{payinfo} . ") by " . + $rref->{otaker} . " - ". $rref->{reason} . "\t\t\t\t" . + $rref->{refund}; + } +} + + #formatting + print <<END; +<CENTER><TABLE BORDER=4> +<TR> + <TH>Date</TH> + <TH>Description</TH> + <TH><FONT SIZE=-1>Charge</FONT></TH> + <TH><FONT SIZE=-1>Payment</FONT></TH> + <TH><FONT SIZE=-1>In-house<BR>Credit</FONT></TH> + <TH><FONT SIZE=-1>Refund</FONT></TH> + <TH><FONT SIZE=-1>Balance</FONT></TH> +</TR> +END + +#display payment history + +my($balance)=0; +my($item); +foreach $item (sort keyfield_numerically @history) { + my($date,$desc,$charge,$payment,$credit,$refund)=split(/\t/,$item); + $charge ||= 0; + $payment ||= 0; + $credit ||= 0; + $refund ||= 0; + $balance += $charge - $payment; + $balance -= $credit - $refund; + + print "<TR><TD><FONT SIZE=-1>",time2str("%D",$date),"</FONT></TD>", + "<TD><FONT SIZE=-1>$desc</FONT></TD>", + "<TD><FONT SIZE=-1>", + ( $charge ? "\$".sprintf("%.2f",$charge) : '' ), + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + ( $payment ? "- \$".sprintf("%.2f",$payment) : '' ), + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + ( $credit ? "- \$".sprintf("%.2f",$credit) : '' ), + "</FONT></TD>", + "<TD><FONT SIZE=-1>", + ( $refund ? "\$".sprintf("%.2f",$refund) : '' ), + "</FONT></TD>", + "<TD><FONT SIZE=-1>\$" . sprintf("%.2f",$balance), + "</FONT></TD>", + "\n"; +} + +#formatting +print "</TABLE></CENTER>"; + +#end + +#formatting +print <<END; + + </BODY> +</HTML> +END + +#subroutiens +sub keyfield_numerically { (split(/\t/,$a))[0] <=> (split(/\t/,$b))[0] ; } + |