diff options
author | ivan <ivan> | 2001-07-30 07:36:04 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-07-30 07:36:04 +0000 |
commit | 51984ac3d3da3006809c6866fdecd4ad83610731 (patch) | |
tree | ac16f533c25a1947eee7bee226fed5638c42bd94 /httemplate/view | |
parent | 9c2016b3a564d439960420114ce6f4cab3bf723b (diff) |
templates!!!
Diffstat (limited to 'httemplate/view')
-rwxr-xr-x | httemplate/view/cust_bill.cgi | 97 | ||||
-rwxr-xr-x | httemplate/view/cust_main.cgi | 398 | ||||
-rwxr-xr-x | httemplate/view/cust_pkg.cgi | 210 | ||||
-rwxr-xr-x | httemplate/view/svc_acct.cgi | 181 | ||||
-rwxr-xr-x | httemplate/view/svc_acct_sm.cgi | 132 | ||||
-rwxr-xr-x | httemplate/view/svc_domain.cgi | 106 |
6 files changed, 1124 insertions, 0 deletions
diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi new file mode 100755 index 000000000..24d67ddc6 --- /dev/null +++ b/httemplate/view/cust_bill.cgi @@ -0,0 +1,97 @@ +<% +# +# $Id: cust_bill.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# this is a quick & ugly hack which does little more than add some formatting to the ascii output from /dbin/print-invoice +# +# ivan@voicenet.com 96-dec-05 +# +# added navigation bar +# ivan@voicenet.com 97-jan-30 +# +# now uses Invoice.pm +# ivan@voicenet.com 97-jun-30 +# +# what to do if cust_bill search errors? +# ivan@voicenet.com 97-jul-7 +# +# s/FS::Search/FS::Record/; $cgisuidsetup($cgi); ivan@sisd.com 98-mar-14 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# also print 'printed' field ivan@sisd.com 98-jul-10 +# +# $Log: cust_bill.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.8 1999/02/28 00:03:58 ivan +# removed misleading comments +# +# Revision 1.7 1999/01/25 12:26:03 ivan +# yet more mod_perl stuff +# +# Revision 1.6 1999/01/19 05:14:18 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.5 1999/01/18 09:41:42 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.4 1998/12/30 23:03:33 ivan +# bugfixes; fields isn't exported by derived classes +# +# Revision 1.3 1998/12/23 03:07:49 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.2 1998/12/17 09:57:20 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# + +use strict; +use vars qw ( $cgi $query $invnum $cust_bill $custnum $printed $p ); +use IO::File; +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(header popurl menubar); +use FS::Record qw(qsearchs); +use FS::cust_bill; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +#untaint invnum +($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +$invnum = $1; + +$cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +die "Invoice #$invnum not found!" unless $cust_bill; +$custnum = $cust_bill->getfield('custnum'); + +$printed = $cust_bill->printed; + +$p = popurl(2); +print $cgi->header( '-expires' => 'now' ), header('Invoice View', menubar( + "Main Menu" => $p, + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", +)), <<END; + <A HREF="${p}edit/cust_pay.cgi?$invnum">Enter payments (check/cash) against this invoice</A> + <BR><A HREF="${p}misc/print-invoice.cgi?$invnum">Reprint this invoice</A> + <BR><BR>(Printed $printed times) + <PRE> +END + +print $cust_bill->print_text; + + #formatting + print <<END; + </PRE></FONT> + </BODY> +</HTML> +END + +%> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi new file mode 100755 index 000000000..6c260bb7d --- /dev/null +++ b/httemplate/view/cust_main.cgi @@ -0,0 +1,398 @@ +<!-- $Id: cust_main.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ --> +<% + +use vars qw ( $cgi $query $custnum $cust_main $hashref $agent $referral + @packages $package @history @bills $bill @credits $credit + $balance $item @agents @referrals @invoicing_list $n1 $conf ); +use CGI; +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 popurl table itable ntable); +use FS::cust_credit; +use FS::cust_pay; +use FS::cust_bill; +use FS::part_pkg; +use FS::cust_pkg; +use FS::part_referral; +use FS::agent; +use FS::cust_main; +use FS::cust_refund; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; + +print $cgi->header( '-expires' => 'now' ), header("Customer View", menubar( + 'Main Menu' => popurl(2) +)); + +die "No customer specified (bad URL)!" unless $cgi->keywords; +($query) = $cgi->keywords; # needs parens with my, ->keywords returns array +$query =~ /^(\d+)$/; +$custnum = $1; +$cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); +die "Customer not found!" unless $cust_main; +$hashref = $cust_main->hashref; + +print qq!<A HREF="!, popurl(2), + qq!edit/cust_main.cgi?$custnum">Edit this customer</A>!; +print qq! | <A HREF="!, popurl(2), + qq!misc/delete-customer.cgi?$custnum"> Delete this customer</A>! + if $conf->exists('deletecustomers'); +print '<BR><BR>'; + +print '<A NAME="cust_main"></A>'; + +print &itable(), '<TR>'; + +print '<TD VALIGN="top">'; + + print "Billing address", &ntable("#cccccc"), "<TR><TD>", + &ntable("#cccccc",2), + '<TR><TD ALIGN="right">Contact name</TD>', + '<TD COLSPAN=3 BGCOLOR="#ffffff">', + $cust_main->last, ', ', $cust_main->first, + '</TD><TD ALIGN="right">SS#</TD><TD BGCOLOR="#ffffff">', + $cust_main->ss || ' ', '</TD></TR>', + '<TR><TD ALIGN="right">Company</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->company, + '</TD></TR>', + '<TR><TD ALIGN="right">Address</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->address1, + '</TD></TR>', + ; + print '<TR><TD ALIGN="right"> </TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->address2, '</TD></TR>' + if $cust_main->address2; + print '<TR><TD ALIGN="right">City</TD><TD BGCOLOR="#ffffff">', + $cust_main->city, + '</TD><TD ALIGN="right">State</TD><TD BGCOLOR="#ffffff">', + $cust_main->state, + '</TD><TD ALIGN="right">Zip</TD><TD BGCOLOR="#ffffff">', + $cust_main->zip, '</TD></TR>', + '<TR><TD ALIGN="right">Country</TD><TD BGCOLOR="#ffffff">', + $cust_main->country, + '</TD></TR>', + ; + print '<TR><TD ALIGN="right">Day Phone</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->daytime || ' ', '</TD></TR>', + '<TR><TD ALIGN="right">Night Phone</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->night || ' ', '</TD></TR>', + '<TR><TD ALIGN="right">Fax</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->fax || ' ', '</TD></TR>', + '</TABLE>', "</TD></TR></TABLE>" + ; + + if ( defined $cust_main->dbdef_table->column('ship_last') ) { + + my $pre = $cust_main->ship_last ? 'ship_' : ''; + + print "<BR>Service address", &ntable("#cccccc"), "<TR><TD>", + &ntable("#cccccc",2), + '<TR><TD ALIGN="right">Contact name</TD>', + '<TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}last"), ', ', $cust_main->get("${$pre}first"), + '</TD></TR>', + '<TR><TD ALIGN="right">Company</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}company"), + '</TD></TR>', + '<TR><TD ALIGN="right">Address</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}address1"), + '</TD></TR>', + ; + print '<TR><TD ALIGN="right"> </TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}address2"), '</TD></TR>' + if $cust_main->get("${$pre}address2"); + print '<TR><TD ALIGN="right">City</TD><TD BGCOLOR="#ffffff">', + $cust_main->get("${$pre}city"), + '</TD><TD ALIGN="right">State</TD><TD BGCOLOR="#ffffff">', + $cust_main->get("${$pre}state"), + '</TD><TD ALIGN="right">Zip</TD><TD BGCOLOR="#ffffff">', + $cust_main->get("${$pre}zip"), '</TD></TR>', + '<TR><TD ALIGN="right">Country</TD><TD BGCOLOR="#ffffff">', + $cust_main->get("${$pre}country"), + '</TD></TR>', + ; + print '<TR><TD ALIGN="right">Day Phone</TD>', + '<TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}daytime") || ' ', '</TD></TR>', + '<TR><TD ALIGN="right">Night Phone</TD>'. + '<TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}night") || ' ', '</TD></TR>', + '<TR><TD ALIGN="right">Fax</TD><TD COLSPAN=5 BGCOLOR="#ffffff">', + $cust_main->get("${$pre}fax") || ' ', '</TD></TR>', + '</TABLE>', "</TD></TR></TABLE>" + ; + + } + +print '</TD>'; + +print '<TD VALIGN="top">'; + + print &ntable("#cccccc"), "<TR><TD>", &ntable("#cccccc",2), + '<TR><TD ALIGN="right">Customer number</TD><TD BGCOLOR="#ffffff">', + $custnum, '</TD></TR>', + ; + + @agents = qsearch( 'agent', {} ); + unless ( scalar(@agents) == 1 ) { + $agent = qsearchs('agent',{ + 'agentnum' => $cust_main->agentnum + } ); + print '<TR><TD ALIGN="right">Agent</TD><TD BGCOLOR="#ffffff">', + $agent->agentnum, ": ", $agent->agent, '</TD></TR>'; + } + @referrals = qsearch( 'part_referral', {} ); + unless ( scalar(@referrals) == 1 ) { + my $referral = qsearchs('part_referral', { + 'refnum' => $cust_main->refnum + } ); + print '<TR><TD ALIGN="right">Referral</TD><TD BGCOLOR="#ffffff">', + $referral->refnum, ": ", $referral->referral, '</TD></TR>'; + } + print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">', + $cust_main->otaker, '</TD></TR>'; + + print '</TABLE></TD></TR></TABLE>'; + +print '<BR>'; + + @invoicing_list = $cust_main->invoicing_list; + print "Billing information (", + qq!<A HREF="!, popurl(2), qq!/misc/bill.cgi?$custnum">!, "Bill now</A>)", + &ntable("#cccccc"), "<TR><TD>", &ntable("#cccccc",2), + '<TR><TD ALIGN="right">Tax exempt</TD><TD BGCOLOR="#ffffff">', + $cust_main->tax ? 'yes' : 'no', + '</TD></TR>', + '<TR><TD ALIGN="right">Postal invoices</TD><TD BGCOLOR="#ffffff">', + ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no', + '</TD></TR>', + '<TR><TD ALIGN="right">Email invoices</TD><TD BGCOLOR="#ffffff">', + join(', ', grep { $_ ne 'POST' } @invoicing_list ) || 'no', + '</TD></TR>', + '<TR><TD ALIGN="right">Billing type</TD><TD BGCOLOR="#ffffff">', + ; + + if ( $cust_main->payby eq 'CARD' ) { + print 'Credit card</TD></TR>', + '<TR><TD ALIGN="right">Card number</TD><TD BGCOLOR="#ffffff">', + $cust_main->payinfo, '</TD></TR>', + '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">', + $cust_main->paydate, '</TD></TR>', + '<TR><TD ALIGN="right">Name on card</TD><TD BGCOLOR="#ffffff">', + $cust_main->payname, '</TD></TR>' + ; + } elsif ( $cust_main->payby eq 'BILL' ) { + print 'Billing</TD></TR>'; + print '<TR><TD ALIGN="right">P.O. </TD><TD BGCOLOR="#ffffff">', + $cust_main->payinfo, '</TD></TR>', + if $cust_main->payinfo; + print '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">', + $cust_main->paydate, '</TD></TR>', + '<TR><TD ALIGN="right">Attention</TD><TD BGCOLOR="#ffffff">', + $cust_main->payname, '</TD></TR>', + ; + } elsif ( $cust_main->payby eq 'COMP' ) { + print 'Complimentary</TD></TR>', + '<TR><TD ALIGN="right">Authorized by</TD><TD BGCOLOR="#ffffff">', + $cust_main->payinfo, '</TD></TR>', + '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">', + $cust_main->paydate, '</TD></TR>', + ; + } + + print "</TABLE></TD></TR></TABLE>"; + +print '</TD></TR></TABLE>'; + +print qq!<BR><BR><A NAME="cust_pkg">Packages</A> !, +# qq!<BR>Click on package number to view/edit package.!, + qq!( <A HREF="!, popurl(2), qq!edit/cust_pkg.cgi?$custnum">Order and cancel packages</A> (preserves services) )!, +; + +#display packages + +#formatting +print qq!!, &table(), "\n", + qq!<TR><TH COLSPAN=2 ROWSPAN=2>Package</TH><TH COLSPAN=5>!, + qq!Dates</TH><TH COLSPAN=2 ROWSPAN=2>Services</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 +if ( $conf->exists('hidecancelledpackages') ) { + @packages = $cust_main->ncancelled_pkgs; +} else { + @packages = $cust_main->all_pkgs; +} + +$n1 = '<TR>'; +foreach $package (@packages) { + my $pkgnum = $package->pkgnum; + my $pkg = $package->part_pkg->pkg; + my $comment = $package->part_pkg->comment; + my $pkgview = popurl(2). "view/cust_pkg.cgi?$pkgnum"; + my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ); + my $rowspan = scalar(@cust_svc) || 1; + + my $button_cgi = new CGI; + $button_cgi->param('clone', $package->part_pkg->pkgpart); + $button_cgi->param('pkgnum', $package->pkgnum); + my $button_url = popurl(2). "edit/part_pkg.cgi?". $button_cgi->query_string; + + #print $n1, qq!<TD ROWSPAN=$rowspan><A HREF="$pkgview">$pkgnum</A></TD>!, + print $n1, qq!<TD ROWSPAN=$rowspan>$pkgnum</TD>!, + qq!<TD ROWSPAN=$rowspan><FONT SIZE=-1>!, + #qq!<A HREF="$pkgview">$pkg - $comment</A>!, + qq!$pkg - $comment!, + qq! ( <A HREF="$pkgview">Edit</A> | <A HREF="$button_url">Customize pricing</A> )</FONT></TD>!, + ; + for ( qw( setup bill susp expire cancel ) ) { + print "<TD ROWSPAN=$rowspan><FONT SIZE=-1>", ( $package->getfield($_) + ? time2str("%D", $package->getfield($_) ) + : ' ' + ), '</FONT></TD>', + ; + } + + my $n2 = ''; + foreach my $cust_svc ( @cust_svc ) { + my($label, $value, $svcdb) = $cust_svc->label; + my($svcnum) = $cust_svc->svcnum; + my($sview) = popurl(2). "view"; + print $n2,qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!, + qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!; + $n2="</TR><TR>"; + } + $n1="</TR><TR>"; +} +print "</TR>"; + +#formatting +print "</TABLE>"; + +#formatting +print qq!<BR><BR><A NAME="history">Payment History!, + qq!</A>!, + qq! ( Click on invoice to view invoice/enter payment. | !, + qq!<A HREF="!, popurl(2), qq!edit/cust_credit.cgi?$custnum">!, + qq!Post credit / refund</A> )!; + +#get payment history +# +# major problem: this whole thing is way too sloppy. +# minor problem: the description lines need better formatting. + +@history = (); #needed for mod_perl :) + +@bills = qsearch('cust_bill',{'custnum'=>$custnum}); +foreach $bill (@bills) { + my($bref)=$bill->hashref; + push @history, + $bref->{_date} . qq!\t<A HREF="!. popurl(2). qq!view/cust_bill.cgi?! . + $bref->{invnum} . qq!">Invoice #! . $bref->{invnum} . + qq! (Balance \$! . $bill->owed . qq!)</A>\t! . + $bref->{charged} . qq!\t\t\t!; + + my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } ); + my($payment); + foreach $payment (@payments) { + 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"; + } +} + +@credits = qsearch('cust_credit',{'custnum'=>$custnum}); +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 &table(), <<END; +<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 + +$balance = 0; +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>"; + +#end + +#formatting +print <<END; + + </BODY> +</HTML> +END + +#subroutiens +sub keyfield_numerically { (split(/\t/,$a))[0] <=> (split(/\t/,$b))[0] ; } + +%> diff --git a/httemplate/view/cust_pkg.cgi b/httemplate/view/cust_pkg.cgi new file mode 100755 index 000000000..5e733225b --- /dev/null +++ b/httemplate/view/cust_pkg.cgi @@ -0,0 +1,210 @@ +<% +# +# $Id: cust_pkg.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: cust_pkg.cgi pkgnum +# http://server.name/path/cust_pkg.cgi?pkgnum +# +# ivan@voicenet.com 96-dec-15 +# +# services section needs to be cleaned up, needs to display extraneous +# entries in cust_pkg! +# ivan@voicenet.com 96-dec-31 +# +# added navigation bar +# ivan@voicenet.com 97-jan-30 +# +# changed and fixed up suspension and cancel stuff, now you can't add +# services to a cancelled package +# ivan@voicenet.com 97-feb-27 +# +# rewrote for new API, still needs to be cleaned up! +# ivan@voicenet.com 97-jul-29 +# +# no FS::Search ivan@sisd.com 98-mar-7 +# +# $Log: cust_pkg.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.11 1999/04/09 04:22:34 ivan +# also table() +# +# Revision 1.10 1999/04/09 03:52:55 ivan +# explicit & for table/itable/ntable +# +# Revision 1.9 1999/04/08 12:00:19 ivan +# aesthetic update +# +# Revision 1.8 1999/02/28 00:04:01 ivan +# removed misleading comments +# +# Revision 1.7 1999/01/19 05:14:20 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.6 1999/01/18 09:41:44 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.5 1998/12/23 03:11:40 ivan +# *** empty log message *** +# +# Revision 1.3 1998/12/17 09:57:22 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# +# Revision 1.2 1998/11/13 09:56:49 ivan +# change configuration file layout to support multiple distinct databases (with +# own set of config files, export, etc.) +# + +use strict; +use vars qw ( $cgi %uiview %uiadd $part_svc $query $pkgnum $cust_pkg $part_pkg + $custnum $susp $cancel $expire $pkg $comment $setup $bill + $otaker ); +use Date::Format; +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(popurl header menubar ntable table); +use FS::Record qw(qsearch qsearchs); +use FS::part_svc; +use FS::cust_pkg; +use FS::part_pkg; +use FS::pkg_svc; +use FS::cust_svc; + +$cgi = new CGI; +cgisuidsetup($cgi); + +foreach $part_svc ( qsearch('part_svc',{}) ) { + $uiview{$part_svc->svcpart} = popurl(2). "view/". $part_svc->svcdb . ".cgi"; + $uiadd{$part_svc->svcpart}= popurl(2). "edit/". $part_svc->svcdb . ".cgi"; +} + +($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +$pkgnum = $1; + +#get package record +$cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +die "No package!" unless $cust_pkg; +$part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')}); + +$custnum = $cust_pkg->getfield('custnum'); +print $cgi->header( '-expires' => 'now' ), header('Package View', menubar( + "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum", + 'Main Menu' => popurl(2) +)); + +#print info +($susp,$cancel,$expire)=( + $cust_pkg->getfield('susp'), + $cust_pkg->getfield('cancel'), + $cust_pkg->getfield('expire'), +); +($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment')); +($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill')); +$otaker = $cust_pkg->getfield('otaker'); + +print "Package information"; +print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum. + '">unsuspend</A>)' if ( $susp && ! $cancel ); +print ' (<A HREF="'. popurl(2). 'misc/susp_pkg.cgi?'. $pkgnum. + '">suspend</A>)' unless ( $susp || $cancel ); +print ' (<A HREF="'. popurl(2). 'misc/cancel_pkg.cgi?'. $pkgnum. + '">cancel</A>)' unless $cancel; + +print &ntable("#cccccc"), '<TR><TD>', &ntable("#cccccc",2), + '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">', + $pkgnum, '</TD></TR>', + '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">', + $pkg, '</TD></TR>', + '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">', + $comment, '</TD></TR>', + '<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">', + ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>', + '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">', + ( $bill ? time2str("%D",$bill) : " " ), '</TD></TR>', +; +print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">', + time2str("%D",$susp), '</TD></TR>' if $susp; +print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">', + time2str("%D",$expire), '</TD></TR>' if $expire; +print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">', + time2str("%D",$cancel), '</TD></TR>' if $cancel; +print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">', + $otaker, '</TD></TR>', + '</TABLE></TD></TR></TABLE>' +; + +# print <<END; +#<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post"> +#<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum"> +#Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" > +#<INPUT TYPE="submit" VALUE="Cancel later"> +#END + +unless ($cancel) { + + #services + print '<BR>Service Information', &table(); + + #list of services this pkgpart includes + my $pkg_svc; + my %pkg_svc = (); + foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) { + $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity; + } + + #list of records from cust_svc + my $svcpart; + foreach $svcpart (sort {$a <=> $b} keys %pkg_svc) { + + my($svc)=qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc'); + + my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum, + 'svcpart'=>$svcpart, + }); + + my($enum); + for $enum ( 1 .. $pkg_svc{$svcpart} ) { + + my($cust_svc); + if ( $cust_svc=shift @cust_svc ) { + my($svcnum)=$cust_svc->svcnum; + my($label, $value, $svcdb) = $cust_svc->label; + print <<END; +<TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View) $svc: $value<A></TD></TR> +END + } else { + print <<END; +<TR> + <TD><A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart"> + (Add) $svc</A> + or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart"> + (Link to existing) $svc</A> + </TD> +</TR> +END + } + + } + warn "WARNING: Leftover services pkgnum $pkgnum!" if @cust_svc;; + } + + print "</TABLE><FONT SIZE=-1>", + "Choose (View) to view or edit an existing service<BR>", + "Choose (Add) to setup a new service<BR>", + "Choose (Link to existing) to link to a legacy (pre-Freeside) service", + "</FONT>" + ; +} + +#formatting +print <<END; + </BODY> +</HTML> +END + +%> diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi new file mode 100755 index 000000000..f28bd9497 --- /dev/null +++ b/httemplate/view/svc_acct.cgi @@ -0,0 +1,181 @@ +<% +# +# $Id: svc_acct.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: svc_acct.cgi svcnum +# http://server.name/path/svc_acct.cgi?svcnum +# +# ivan@voicenet.com 96-dec-17 +# +# added link to send info +# ivan@voicenet.com 97-jan-4 +# +# added navigation bar and ability to change username, etc. +# ivan@voicenet.com 97-jan-30 +# +# activate 800 service +# ivan@voicenet.com 97-feb-10 +# +# modified navbar code (should be a subroutine?), added link to cancel account (only if not audited) +# ivan@voicenet.com 97-apr-16 +# +# INCOMPLETELY rewrote some things for new API +# ivan@voicenet.com 97-jul-29 +# +# FS::Search became FS::Record, use strict, etc. ivan@sisd.com 98-mar-9 +# +# Changes to allow page to work at a relative position in server +# Changed 'password' to '_password' because Pg6.3 reserves the password word +# bmccane@maxbaud.net 98-apr-3 +# +# /var/spool/freeside/conf/domain ivan@sisd.com 98-jul-17 +# +# displays arbitrary radius attributes ivan@sisd.com 98-aug-16 +# +# $Log: svc_acct.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.12 2001/01/31 07:21:00 ivan +# fix tyops +# +# Revision 1.11 2000/12/03 20:25:20 ivan +# session monitor updates +# +# Revision 1.10 1999/04/14 11:27:06 ivan +# showpasswords config option to show passwords +# +# Revision 1.9 1999/04/08 12:00:19 ivan +# aesthetic update +# +# Revision 1.8 1999/02/28 00:04:02 ivan +# removed misleading comments +# +# Revision 1.7 1999/01/19 05:14:21 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.6 1999/01/18 09:41:45 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.5 1999/01/18 09:22:36 ivan +# changes to track email addresses for email invoicing +# +# Revision 1.4 1998/12/23 03:09:19 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.3 1998/12/17 09:57:23 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# +# Revision 1.2 1998/12/16 05:24:29 ivan +# use FS::Conf; +# + +use strict; +use vars qw( $conf $cgi $mydomain $query $svcnum $svc_acct $cust_svc $pkgnum + $cust_pkg $custnum $part_svc $p $svc_acct_pop $password ); +use CGI; +use CGI::Carp qw( fatalsToBrowser ); +use FS::UID qw( cgisuidsetup ); +use FS::CGI qw( header popurl menubar); +use FS::Record qw( qsearchs fields ); +use FS::Conf; +use FS::svc_acct; +use FS::cust_svc; +use FS::cust_pkg; +use FS::part_svc; +use FS::svc_acct_pop; + +$cgi = new CGI; +&cgisuidsetup($cgi); + +$conf = new FS::Conf; +$mydomain = $conf->config('domain'); + +($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +$svcnum = $1; +$svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum}); +die "Unknown svcnum" unless $svc_acct; + +$cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +$pkgnum = $cust_svc->getfield('pkgnum'); +if ($pkgnum) { + $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + $custnum=$cust_pkg->getfield('custnum'); +} else { + $cust_pkg = ''; + $custnum = ''; +} + +$part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); +die "Unknown svcpart" unless $part_svc; + +$p = popurl(2); +print $cgi->header( '-expires' => 'now' ), header('Account View', menubar( + ( ( $pkgnum || $custnum ) + ? ( "View this package (#$pkgnum)" => "${p}view/cust_pkg.cgi?$pkgnum", + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + ) + : ( "Cancel this (unaudited) account" => + "${p}misc/cancel-unaudited.cgi?$svcnum" ) + ), + "Main menu" => $p, +)); + +#print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!; + +print qq!<A HREF="${p}edit/svc_acct.cgi?$svcnum">Edit this information</A>!, + "<BR>Service #$svcnum", + "<BR>Service: <B>", $part_svc->svc, "</B>", + "<BR><BR>Username: <B>", $svc_acct->username, "</B>" +; + +print "<BR>Password: "; +$password = $svc_acct->_password; +if ( $password =~ /^\*\w+\* (.*)$/ ) { + $password = $1; + print "<I>(login disabled)</I> "; +} +if ( $conf->exists('showpasswords') ) { + print "<B>$password</B>"; +} else { + print "<I>(hidden)</I>"; +} +$password = ''; + +$svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum}); +print "<BR>POP: <B>", $svc_acct_pop->city, ", ", $svc_acct_pop->state, + " (", $svc_acct_pop->ac, ")/", $svc_acct_pop->exch, "</B>" + if $svc_acct_pop; + +if ($svc_acct->uid ne '') { + print "<BR><BR>Uid: <B>", $svc_acct->uid, "</B>", + "<BR>Gid: <B>", $svc_acct->gid, "</B>", + "<BR>Finger name: <B>", $svc_acct->finger, "</B>", + "<BR>Home directory: <B>", $svc_acct->dir, "</B>", + "<BR>Shell: <B>", $svc_acct->shell, "</B>", + "<BR>Quota: <B>", $svc_acct->quota, "</B> <I>(unimplemented)</I>" + ; +} else { + print "<BR><BR>(No shell account)"; +} + +if ($svc_acct->slipip) { + print "<BR><BR>IP address: <B>", ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) ? "<I>(Dynamic)</I>" : $svc_acct->slipip ,"</B>"; + my($attribute); + foreach $attribute ( grep /^radius_/, fields('svc_acct') ) { + #warn $attribute; + $attribute =~ /^radius_(.*)$/; + my($pattribute) = ($1); + $pattribute =~ s/_/-/g; + print "<BR>Radius $pattribute: <B>". $svc_acct->getfield($attribute), "</B>"; + } +} else { + print "<BR><BR>(No SLIP/PPP account)"; +} + +print "</BODY></HTML>"; + +%> diff --git a/httemplate/view/svc_acct_sm.cgi b/httemplate/view/svc_acct_sm.cgi new file mode 100755 index 000000000..9c6ca6e5c --- /dev/null +++ b/httemplate/view/svc_acct_sm.cgi @@ -0,0 +1,132 @@ +<% +# +# $Id: svc_acct_sm.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: svc_acct_sm.cgi svcnum +# http://server.name/path/svc_acct_sm.cgi?svcnum +# +# based on view/svc_acct.cgi +# +# ivan@voicenet.com 97-jan-5 +# +# added navigation bar +# ivan@voicenet.com 97-jan-30 +# +# rewrite ivan@sisd.com 98-mar-15 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# /var/spool/freeside/conf/domain ivan@sisd.com 98-jul-17 +# +# $Log: svc_acct_sm.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.11 2000/07/17 10:58:42 ivan +# better error messages if svc_acct or svc_domain records are missing +# +# Revision 1.10 1999/04/08 12:00:19 ivan +# aesthetic update +# +# Revision 1.9 1999/02/28 00:04:03 ivan +# removed misleading comments +# +# Revision 1.8 1999/02/09 09:23:00 ivan +# visual and bugfixes +# +# Revision 1.7 1999/02/07 09:59:42 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.6 1999/01/19 05:14:22 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.5 1999/01/18 09:41:46 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.4 1998/12/23 03:09:52 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.3 1998/12/17 09:57:24 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# +# Revision 1.2 1998/12/16 05:24:30 ivan +# use FS::Conf; +# + +use strict; +use vars qw($conf $cgi $mydomain $query $svcnum $svc_acct_sm $cust_svc + $pkgnum $cust_pkg $custnum $part_svc $p $domsvc $domuid $domuser + $svc $svc_domain $domain $svc_acct $username ); +use CGI; +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(header popurl menubar ); +use FS::Record qw(qsearchs); +use FS::Conf; +use FS::svc_acct_sm; +use FS::cust_svc; +use FS::cust_pkg; +use FS::part_svc; +use FS::svc_domain; +use FS::svc_acct; + +$cgi = new CGI; +cgisuidsetup($cgi); + +$conf = new FS::Conf; +$mydomain = $conf->config('domain'); + +($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +$svcnum = $1; +$svc_acct_sm = qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}); +die "Unknown svcnum" unless $svc_acct_sm; + +$cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +$pkgnum = $cust_svc->getfield('pkgnum'); +if ($pkgnum) { + $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + $custnum=$cust_pkg->getfield('custnum'); +} else { + $cust_pkg = ''; + $custnum = ''; +} + +$part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ) + or die "Unkonwn svcpart"; + +$p = popurl(2); +print $cgi->header( '-expires' => 'now' ), header('Mail Alias View', menubar( + ( ( $pkgnum || $custnum ) + ? ( "View this package (#$pkgnum)" => "${p}view/cust_pkg.cgi?$pkgnum", + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + ) + : ( "Cancel this (unaudited) account" => + "${p}misc/cancel-unaudited.cgi?$svcnum" ) + ), + "Main menu" => $p, +)); + +($domsvc,$domuid,$domuser) = ( + $svc_acct_sm->domsvc, + $svc_acct_sm->domuid, + $svc_acct_sm->domuser, +); +$svc = $part_svc->svc; +$svc_domain = qsearchs('svc_domain',{'svcnum'=>$domsvc}) + or die "Corrupted database: no svc_domain.svcnum matching domsvc $domsvc"; +$domain = $svc_domain->domain; +$svc_acct = qsearchs('svc_acct',{'uid'=>$domuid}) + or die "Corrupted database: no svc_acct.uid matching domuid $domuid"; +$username = $svc_acct->username; + +print qq!<A HREF="${p}edit/svc_acct_sm.cgi?$svcnum">Edit this information</A>!, + "<BR>Service #$svcnum", + "<BR>Service: <B>$svc</B>", + qq!<BR>Mail to <B>!, ( ($domuser eq '*') ? "<I>(anything)</I>" : $domuser ) , qq!</B>\@<B>$domain</B> forwards to <B>$username</B>\@$mydomain mailbox.!, + '</BODY></HTML>' +; + +%> diff --git a/httemplate/view/svc_domain.cgi b/httemplate/view/svc_domain.cgi new file mode 100755 index 000000000..f852400da --- /dev/null +++ b/httemplate/view/svc_domain.cgi @@ -0,0 +1,106 @@ +<% +# +# $Id: svc_domain.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ +# +# Usage: svc_domain svcnum +# http://server.name/path/svc_domain.cgi?svcnum +# +# ivan@voicenet.com 97-jan-6 +# +# rewrite ivan@sisd.com 98-mar-14 +# +# Changes to allow page to work at a relative position in server +# bmccane@maxbaud.net 98-apr-3 +# +# $Log: svc_domain.cgi,v $ +# Revision 1.1 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.11 2000/12/03 15:14:00 ivan +# bugfixes from Jeff Finucane <jeff@cmh.net>, thanks! +# +# Revision 1.10 1999/08/27 22:18:44 ivan +# point to patrick instead of internic! +# +# Revision 1.9 1999/04/08 12:00:19 ivan +# aesthetic update +# +# Revision 1.8 1999/02/28 00:04:04 ivan +# removed misleading comments +# +# Revision 1.7 1999/02/23 08:09:25 ivan +# beginnings of one-screen new customer entry and some other miscellania +# +# Revision 1.6 1999/01/19 05:14:23 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.5 1999/01/18 09:41:47 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.4 1998/12/23 03:10:19 ivan +# $cgi->keywords instead of $cgi->query_string +# +# Revision 1.3 1998/12/17 09:57:25 ivan +# s/CGI::(Base|Request)/CGI.pm/; +# +# Revision 1.2 1998/11/13 09:56:50 ivan +# change configuration file layout to support multiple distinct databases (with +# own set of config files, export, etc.) +# + +use strict; +use vars qw( $cgi $query $svcnum $svc_domain $domain $cust_svc $pkgnum + $cust_pkg $custnum $part_svc $p ); +use CGI; +use FS::UID qw(cgisuidsetup); +use FS::CGI qw(header menubar popurl menubar); +use FS::Record qw(qsearchs); +use FS::svc_domain; +use FS::cust_svc; +use FS::cust_pkg; +use FS::part_svc; + +$cgi = new CGI; +cgisuidsetup($cgi); + +($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +$svcnum = $1; +$svc_domain = qsearchs('svc_domain',{'svcnum'=>$svcnum}); +die "Unknown svcnum" unless $svc_domain; + +$cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +$pkgnum = $cust_svc->getfield('pkgnum'); +if ($pkgnum) { + $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); + $custnum=$cust_pkg->getfield('custnum'); +} else { + $cust_pkg = ''; + $custnum = ''; +} + +$part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); +die "Unkonwn svcpart" unless $part_svc; + +$domain = $svc_domain->domain; + +$p = popurl(2); +print $cgi->header( '-expires' => 'now' ), header('Domain View', menubar( + ( ( $pkgnum || $custnum ) + ? ( "View this package (#$pkgnum)" => "${p}view/cust_pkg.cgi?$pkgnum", + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + ) + : ( "Cancel this (unaudited) account" => + "${p}misc/cancel-unaudited.cgi?$svcnum" ) + ), + "Main menu" => $p, +)), + "Service #$svcnum", + "<BR>Service: <B>", $part_svc->svc, "</B>", + "<BR>Domain name: <B>$domain</B>.", + qq!<BR><BR><A HREF="http://www.geektools.com/cgi-bin/proxy.cgi?query=$domain;targetnic=auto">View whois information.</A>!, + '</BODY></HTML>', +; +%> |