#!/usr/bin/perl -Tw
#
-# $Id: agent.cgi,v 1.7 1998-12-17 05:25:16 ivan Exp $
+# $Id: agent.cgi,v 1.8 1999-01-18 09:22:26 ivan Exp $
#
# ivan@sisd.com 97-dec-12
#
# lose background, FS::CGI ivan@sisd.com 98-sep-2
#
# $Log: agent.cgi,v $
-# Revision 1.7 1998-12-17 05:25:16 ivan
+# Revision 1.8 1999-01-18 09:22:26 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.7 1998/12/17 05:25:16 ivan
# fix visual and other bugs
#
# Revision 1.6 1998/11/23 05:29:46 ivan
use FS::agent;
use FS::agent_type;
+#Begin silliness
+
+use FS::UI::CGI;
+use FS::UI::agent;
+
+my $ui = new FS::UI::agent;
+$ui->browse;
+exit;
+
+#End silliness
+
+__END__
+
my($cgi) = new CGI;
&cgisuidsetup($cgi);
<h1>Troubleshooting</h1>
<ul>
<li>When troubleshooting the web interface, helpful information is often in your web server's error log.
- <li>Internet Explorer will not work with Freeside's HTML interface.
+ <li>Internet Explorer will not work with Freeside's HTML interface. <b>This may be fixed in >1.2, please report your experiences!</b>
<a HREF="http://www.netscape.com">Netscape</a>,
<a HREF="http://lynx.browser.org">Lynx</a>, and
<a HREF="http://www.cs.indiana.edu/elisp/w3/docs.html">Emacs/W3</a>,
at /usr/lib/perl5/site_perl/File/CounterFile.pm line 132.
</pre>
This clutters up your log files but is otherwise harmless. Upgrade to the latest File::CounterFile.
- <li>If you get an Internal Server Error when adding or editing, but find that the update has occured, and you get something like the following in your web server's error log:
+ <li><b>(No longer applicable in >1.2!)</b> If you get an Internal Server Error when adding or editing, but find that the update has occured, and you get something like the following in your web server's error log:
<pre>
access to <i>/your/path</i>/edit/process/<i>some_table</i>.cgi failed for
<i>machine.domain.tld</i>, reason: malformed header from script.
<li>Move /var/spool/freeside/export to /usr/local/etc/freeside/export.<i>datasrc</i>.
<li>Apply the following changes to your database:
<pre>
-ALTER TABLE cust_main ADD middle varchar(80) NULL;
+<!-- ALTER TABLE cust_main ADD middle varchar(80) NULL;
ALTER TABLE cust_main ADD titlenum int NULL;
-ALTER TABLE cust_main CHANGE state state varchar(80) NULL;
+-->ALTER TABLE cust_main CHANGE state state varchar(80) NULL;
ALTER TABLE cust_main_county CHANGE state state varchar(80) NULL;
ALTER TABLE cust_main_county ADD country char(2);
-UPDATE cust_main_county SET country = "US" where country IS NULL;
-CREATE TABLE part_title (
+UPDATE cust_main SET country = "US" where country IS NULL OR country = '';
+UPDATE cust_main_county SET country = "US" where country IS NULL OR country = "";
+<!--CREATE TABLE part_title (
titlenum int NOT NULL,
title varchar(80) NOT NULL,
PRIMARY KEY (titlenum)
);
-CREATE TABLE cust_main_invoice (
+-->CREATE TABLE cust_main_invoice (
destnum int NOT NULL,
custnum int NOT NULL,
dest varchar(80) NOT NULL,
#!/usr/bin/perl -Tw
#
-# $Id: agent_type.cgi,v 1.6 1998-12-17 06:16:58 ivan Exp $
+# $Id: agent_type.cgi,v 1.7 1999-01-18 09:22:29 ivan Exp $
#
# agent_type.cgi: Add/Edit agent type (output form)
#
# use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
#
# $Log: agent_type.cgi,v $
-# Revision 1.6 1998-12-17 06:16:58 ivan
+# Revision 1.7 1999-01-18 09:22:29 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.6 1998/12/17 06:16:58 ivan
# fix double // in relative URLs, s/CGI::Base/CGI/;
#
# Revision 1.5 1998/11/21 07:58:27 ivan
&cgisuidsetup($cgi);
my($agent_type,$action);
-if ( $cgi->keywords =~ /^(\d+)$/ ) { #editing
+if ( $cgi->keywords ) { #editing
+ my( $query ) = $cgi->keywords;
+ $query =~ /^(\d+)$/;
$agent_type=qsearchs('agent_type',{'typenum'=>$1});
$action='Edit';
} else { #adding
#!/usr/bin/perl -Tw
#
-# $Id: cust_main.cgi,v 1.4 1998-12-23 08:08:15 ivan Exp $
+# $Id: cust_main.cgi,v 1.5 1999-01-18 09:22:30 ivan Exp $
#
# Usage: cust_main.cgi custnum
# http://server.name/path/cust_main.cgi?custnum
# fixed one missed day->daytime ivan@sisd.com 98-jul-13
#
# $Log: cust_main.cgi,v $
-# Revision 1.4 1998-12-23 08:08:15 ivan
+# Revision 1.5 1999-01-18 09:22:30 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.4 1998/12/23 08:08:15 ivan
# fix typo
#
# Revision 1.3 1998/12/17 06:17:00 ivan
#
use strict;
-use CGI;
+use CGI::Switch;
use CGI::Carp qw(fatalsToBrowser);
use FS::UID qw(cgisuidsetup getotaker);
use FS::Record qw(qsearch qsearchs);
-use FS::CGI qw(header popurl);
+use FS::CGI qw(header popurl itable table);
use FS::cust_main;
-my($cgi) = new CGI;
-
+my $cgi = new CGI;
cgisuidsetup($cgi);
#get record
-my($custnum,$action,$cust_main);
-my($query) = $cgi->keywords;
-if ( $query =~ /^(\d+)$/ ) { #editing
+
+my ( $custnum, $action, $cust_main );
+if ( $cgi->keywords ) { #editing
+ my( $query ) = $cgi->keywords;
+ $query =~ /^(\d+)$/;
$custnum=$1;
- $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
+ $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
$action='Edit';
} else {
$custnum='';
- $cust_main = create FS::cust_main ( {} );
+ $cust_main = new FS::cust_main ( {} );
$cust_main->setfield('otaker',&getotaker);
$action='Add';
}
+# top
+
my $p1 = popurl(1);
-print $cgi->header, header("Customer $action", ''), <<END;
- <FORM ACTION="${p1}process/cust_main.cgi" METHOD=POST>
- <PRE>
-END
+print $cgi->header, header("Customer $action", ''),
+ qq!<FORM ACTION="${p1}process/cust_main.cgi" METHOD=POST>!,
+ qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!,
+ qq!Customer # !, ( $custnum ? $custnum : " (NEW)" ),
+
+;
-print qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!,
- qq!Customer #<FONT SIZE="+1"><B>!;
-print $custnum ? $custnum : " (NEW)" , "</B></FONT>";
+# agent
-#agentnum
-my($agentnum)=$cust_main->agentnum || 1; #set to first agent by default
my @agents = qsearch( 'agent', {} );
-print qq!\n\nAgent # <SELECT NAME="agentnum" SIZE="1">!;
-my($agent);
-foreach $agent (sort {
- $a->agent cmp $b->agent;
-} @agents) {
- print "<OPTION" . " SELECTED"x($agent->agentnum==$agentnum),
- ">", $agent->agentnum,": ", $agent->agent, "\n";
-}
-print "</SELECT>";
-
-#referral
-#unless ($custnum) {
- my($refnum)=$cust_main->refnum || 0; #to avoid "arguement not numeric" error
- my(@referrals) = qsearch('part_referral',{});
- print qq!\nReferral <SELECT NAME="refnum" SIZE="1">!;
- print "<OPTION> \n";
- my($referral);
- foreach $referral (sort {
- $a->refnum <=> $b->refnum;
- } @referrals) {
- print "<OPTION" . " SELECTED"x($referral->refnum==$refnum),
- ">", $referral->refnum, ": ", $referral->referral,"\n";
+my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first
+if ( scalar(@agents) == 1 ) {
+ print qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$agentnum">!;
+} else {
+ print qq!<BR><BR>Agent <SELECT NAME="agentnum" SIZE="1">!;
+ my $agent;
+ foreach $agent (sort {
+ $a->agent cmp $b->agent;
+ } @agents) {
+ print "<OPTION" . " SELECTED"x($agent->agentnum==$agentnum),
+ ">", $agent->agentnum,": ", $agent->agent;
}
print "</SELECT>";
-#}
+}
-my($last,$first,$ss,$company,$address1,$address2,$city)=(
+# contact info
+
+my($last,$first,$ss,$company,$address1,$address2,$city,$zip)=(
$cust_main->last,
$cust_main->first,
$cust_main->ss,
$cust_main->address1,
$cust_main->address2,
$cust_main->city,
+ $cust_main->zip,
);
-print <<END;
-
-
-Name (last)<INPUT TYPE="text" NAME="last" VALUE="$last"> (first)<INPUT TYPE="text" NAME="first" VALUE="$first"> SS# <INPUT TYPE="text" NAME="ss" VALUE="$ss" SIZE=11 MAXLENGTH=11>
-Company <INPUT TYPE="text" NAME="company" VALUE="$company">
-Address <INPUT TYPE="text" NAME="address1" VALUE="$address1" SIZE=40 MAXLENGTH=40>
- <INPUT TYPE="text" NAME="address2" VALUE="$address2" SIZE=40 MAXLENGTH=40>
-City <INPUT TYPE="text" NAME="city" VALUE="$city"> State (county) / Country<SELECT NAME="state" SIZE="1">
+print "<BR><BR>Contact information", itable("#c0c0c0"), <<END;
+<TR><TH ALIGN="right">Contact name<BR>(last, first)</TH><TD COLSPAN=3><INPUT TYPE="text" NAME="last" VALUE="$last">, <INPUT TYPE="text" NAME="first" VALUE="$first"></TD><TD ALIGN="right">SS#</TD><TD><INPUT TYPE="text" NAME="ss" VALUE="$ss" SIZE=11></TD></TR>
+<TR><TD ALIGN="right">Company</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="company" VALUE="$company" SIZE=70></TD></TR>
+<TR><TH ALIGN="right">Address</TH><TD COLSPAN=5><INPUT TYPE="text" NAME="address1" VALUE="$address1" SIZE=70></TH></TR>
+<TR><TD ALIGN="right"> </TD><TD COLSPAN=5><INPUT TYPE="text" NAME="address2" VALUE="$address2" SIZE=70></TD></TR>
+<TR><TH ALIGN="right">City</TH><TD><INPUT TYPE="text" NAME="city" VALUE="$city"><TH ALIGN="right">State/Country</TH><TD><SELECT NAME="state" SIZE="1">
END
+$cust_main->country('US') unless $cust_main->country; #eww
foreach ( qsearch('cust_main_county',{}) ) {
print "<OPTION";
print " SELECTED" if ( $cust_main->state eq $_->state
print " (",$_->county,")" if $_->county;
print " / ", $_->country;
}
-print "</SELECT>";
+print qq!</SELECT></TD><TH>Zip</TH><TD><INPUT TYPE="text" NAME="zip" VALUE="$zip" SIZE=10></TD></TR>!;
-my($zip,$daytime,$night,$fax)=(
- $cust_main->zip,
+my($daytime,$night,$fax)=(
$cust_main->daytime,
$cust_main->night,
$cust_main->fax,
);
print <<END;
- Zip <INPUT TYPE="text" NAME="zip" VALUE="$zip" SIZE=10 MAXLENGTH=10>
-
-Phone (daytime)<INPUT TYPE="text" NAME="daytime" VALUE="$daytime" SIZE=18 MAXLENGTH=20> (night)<INPUT TYPE="text" NAME="night" VALUE="$night" SIZE=18 MAXLENGTH=20> (fax)<INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12 MAXLENGTH=12>
-
+<TR><TD ALIGN="right">Day Phone</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="$daytime" SIZE=18></TD></TR>
+<TR><TD ALIGN="right">Night Phone</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="$night" SIZE=18></TD></TR>
+<TR><TD ALIGN="right">Fax</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12></TD></TR>
END
-my(%payby)=(
- 'CARD' => "Credit card ",
- 'BILL' => "Billing ",
- 'COMP' => "Complimentary",
-);
-for (qw(CARD BILL COMP)) {
- print qq!<INPUT TYPE="radio" NAME="payby" VALUE="$_"!;
- print qq! CHECKED! if ($cust_main->payby eq "$_");
- print qq!>$payby{$_}!;
-}
+print "</TABLE>";
+# billing info
-my($payinfo,$payname,$otaker)=(
- $cust_main->payinfo,
- $cust_main->payname,
- $cust_main->otaker,
-);
+sub expselect {
+ my $prefix = shift;
+ my $date = shift || '';
+ my( $m, $y ) = ( 0, 0 );
+ if ( $date =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #PostgreSQL date format
+ ( $m, $y ) = ( $2, $1 );
+ } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
+ ( $m, $y ) = ( $1, $3 );
+ }
+ my $return = qq!<SELECT NAME="$prefix!. qq!_month" SIZE="1">!;
+ for ( 1 .. 12 ) {
+ $return .= "<OPTION";
+ $return .= " SELECTED" if $_ == $m;
+ $return .= ">$_";
+ }
+ $return .= qq!</SELECT>/<SELECT NAME="$prefix!. qq!_year" SIZE="1">!;
+ for ( 1999 .. 2037 ) {
+ $return .= "<OPTION";
+ $return .= " SELECTED" if $_ == $y;
+ $return .= ">$_";
+ }
+ $return .= "</SELECT>";
-my($paydate);
-if ( $cust_main->paydate =~ /^(\d{4})-(\d{2})-\d{2}$/ ) {
- $paydate="$2/$1"
-} elsif ( $cust_main->paydate =~ /^(\d{2})-\d{2}-(\d{4}$)/ ) {
- $paydate="$1/$2"
-}
-else {
- $paydate='';
+ $return;
}
-print <<END;
+print "<BR>Billing information", itable("#c0c0c0"),
+ qq!<TR><TD><INPUT TYPE="checkbox" NAME="tax" VALUE="Y"!;
+print qq! CHECKED! if $cust_main->tax eq "Y";
+print qq!>Tax Exempt!;
+print qq!</TD></TR><TR><TD><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"!;
+my @invoicing_list = $cust_main->invoicing_list;
+print qq! CHECKED!
+ if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
+print qq!> Postal mail invoice!;
+my $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list );
+print qq!</TD></TR><TR><TD>Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="$invoicing_list"></TD>!;
- Card number , P.O. # or Authorization <INPUT TYPE="text" NAME="payinfo" VALUE="$payinfo" SIZE=19 MAXLENGTH=19>
-END
+print "</TD></TR></TABLE>";
-print qq!Exp. date (MM/YY or MM/YYYY)<INPUT TYPE="text" NAME="paydate" VALUE="$paydate" SIZE=8 MAXLENGTH=7> Billing name <INPUT TYPE="text" NAME="payname" VALUE="$payname">\n<INPUT TYPE="checkbox" NAME="tax" VALUE="Y"!;
-print qq! CHECKED! if $cust_main->tax eq "Y";
-print qq!> Tax Exempt!;
+print table("#c0c0c0"), "<TR>";
-print <<END;
+my($payinfo, $payname)=(
+ $cust_main->payinfo,
+ $cust_main->payname,
+);
+my %payby = (
+ 'CARD' => qq!Credit card<BR><INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR>Exp !. expselect("CARD"). qq!<BR>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
+ 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR>Exp !. expselect("BILL", "12-2037"). qq!<BR>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
+ 'COMP' => qq!Complimentary<BR>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR>Exp !. expselect("COMP"),
+);
+my %paybychecked = (
+ 'CARD' => qq!Credit card<BR><INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>Exp !. expselect("CARD", $cust_main->paydate). qq!<BR>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
+ 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR>Exp !. expselect("BILL", $cust_main->paydate). qq!<BR>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
+ 'COMP' => qq!Complimentary<BR>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR>Exp !. expselect("COMP", $cust_main->paydate),
+);
+for (qw(CARD BILL COMP)) {
+ print qq!<TD VALIGN=TOP><INPUT TYPE="radio" NAME="payby" VALUE="$_"!;
+ if ($cust_main->payby eq "$_") {
+ print qq! CHECKED> $paybychecked{$_}</TD>!;
+ } else {
+ print qq!> $payby{$_}</TD>!;
+ }
+}
-Order taken by: <FONT SIZE="+1"><B>$otaker</B></FONT><INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">
-</PRE>
-END
+print "</TR></TABLE>";
-print qq!<CENTER><INPUT TYPE="submit" VALUE="!,
- $custnum ? "Apply Changes" : "Add Customer", qq!"></CENTER>!;
+#referral
-print <<END;
+my $refnum = $cust_main->refnum || 0;
+if ( $custnum ) {
+ print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$refnum">!;
+} else {
+ my(@referrals) = qsearch('part_referral',{});
+ print qq!<BR>Referral <SELECT NAME="refnum" SIZE="1">!;
+ print "<OPTION> ";
+ my($referral);
+ foreach $referral (sort {
+ $a->refnum <=> $b->refnum;
+ } @referrals) {
+ print "<OPTION" . " SELECTED"x($referral->refnum==$refnum),
+ ">", $referral->refnum, ": ", $referral->referral;
+ }
+ print "</SELECT>";
+}
- </FORM>
- </BODY>
-</HTML>
-END
+my $otaker = $cust_main->otaker;
+print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!,
+ qq!<BR><BR><INPUT TYPE="submit" VALUE="!,
+ $custnum ? "Apply Changes" : "Add Customer", qq!">!,
+ "</FORM></BODY></HTML>",
+;
#!/usr/bin/perl -Tw
#
-# $Id: cust_main.cgi,v 1.3 1998-12-17 08:40:19 ivan Exp $
+# $Id: cust_main.cgi,v 1.4 1999-01-18 09:22:32 ivan Exp $
#
# Usage: post form to:
# http://server.name/path/cust_main.cgi
# bmccane@maxbaud.net 98-apr-3
#
# $Log: cust_main.cgi,v $
-# Revision 1.3 1998-12-17 08:40:19 ivan
+# Revision 1.4 1999-01-18 09:22:32 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.3 1998/12/17 08:40:19 ivan
# s/CGI::Request/CGI.pm/; etc
#
# Revision 1.2 1998/11/18 08:57:36 ivan
#
use strict;
+#use CGI;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup);
+use FS::UID qw(cgisuidsetup getotaker);
use FS::CGI qw(eidiot popurl);
-use FS::Record qw(qsearchs);
+use FS::Record qw(qsearchs fields);
use FS::cust_main;
my($cgi)=new CGI;
-
&cgisuidsetup($cgi);
-#create new record object
+#unmunge stuff
-#unmunge agentnum
-$cgi->param('agentnum',
- (split(/:/, ($cgi->param('agentnum'))[0] ))[0]
-);
+$cgi->param('agentnum', (split(/:/, ($cgi->param('agentnum'))[0] ))[0] );
-#unmunge tax
$cgi->param('tax','') unless defined($cgi->param('tax'));
-#unmunge refnum
-$cgi->param('refnum',
- (split(/:/, ($cgi->param('refnum'))[0] ))[0]
-);
+$cgi->param('refnum', (split(/:/, ($cgi->param('refnum'))[0] ))[0] );
-#unmunge state/county/country
$cgi->param('state') =~ /^(\w+)( \((\w+)\))? \/ (\w+)$/;
$cgi->param('state', $1);
$cgi->param('county', $3 || '');
$cgi->param('country', $4);
-my($new) = create FS::cust_main ( {
+my $payby = $cgi->param('payby');
+$cgi->param('payinfo', $cgi->param( $payby. '_payinfo' ) );
+$cgi->param('paydate',
+ $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' ) );
+$cgi->param('payname', $cgi->param( $payby. '_payname' ) );
+
+$cgi->param('otaker', &getotaker );
+
+my @invoicing_list = split( /\s*\,\s*/, $cgi->param('invoicing_list') );
+push @invoicing_list, 'POST' if $cgi->param('invoicing_list_POST');
+
+#create new record object
+
+my($new) = new FS::cust_main ( {
map {
$_, scalar($cgi->param($_))
- } qw(custnum agentnum last first ss company address1 address2 city county
- state zip daytime night fax payby payinfo paydate payname tax
- otaker refnum)
+# } qw(custnum agentnum last first ss company address1 address2 city county
+# state zip daytime night fax payby payinfo paydate payname tax
+# otaker refnum)
+ } fields('cust_main')
} );
+#perhaps the invocing_list magic should move to cust_main.pm?
if ( $new->custnum eq '' ) {
-
- my($error)=$new->insert;
+ my $error;
+ $error = $new->check_invoicing_list( \@invoicing_list );
+ &ediot($error) if $error;
+ $error = $new->insert;
&eidiot($error) if $error;
-
+ $new->invoicing_list( \@invoicing_list );
} else { #create old record object
-
- my($old) = qsearchs( 'cust_main', { 'custnum', $new->custnum } );
+ my $error;
+ my $old = qsearchs( 'cust_main', { 'custnum' => $new->custnum } );
&eidiot("Old record not found!") unless $old;
- my($error)=$new->replace($old);
+ $error = $new->check_invoicing_list( \@invoicing_list );
&eidiot($error) if $error;
-
+ $error = $new->replace($old);
+ &eidiot($error) if $error;
+ $new->invoicing_list( \@invoicing_list );
}
-my($custnum)=$new->custnum;
+my $custnum = $new->custnum;
print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum#cust_main");
#!/usr/bin/perl -Tw
#
-# $Id: cust_pkg.cgi,v 1.3 1998-12-23 03:05:59 ivan Exp $
+# $Id: cust_pkg.cgi,v 1.4 1999-01-18 09:22:33 ivan Exp $
#
# based on search/svc_acct.cgi ivan@sisd.com 98-jul-17
#
# $Log: cust_pkg.cgi,v $
-# Revision 1.3 1998-12-23 03:05:59 ivan
+# Revision 1.4 1999-01-18 09:22:33 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.3 1998/12/23 03:05:59 ivan
# $cgi->keywords instead of $cgi->query_string
#
# Revision 1.2 1998/12/17 09:41:09 ivan
exit;
} else {
my($total)=scalar(@cust_pkg);
- CGI::Base::SendHeaders(); # one guess
- print header('Package Search Results',''), <<END;
+ print $cgi->header, header('Package Search Results',''), <<END;
$total matching packages found
<TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
<TR>
</TR>
END
- my($lines)=16;
- my($lcount)=$lines;
my(%saw,$cust_pkg);
foreach $cust_pkg (
sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg)
<TD><FONT SIZE=-1>$company</FONT></TD>
</TR>
END
- if ($lcount-- == 0) { # lots of little tables instead of one big one
- $lcount=$lines;
- print <<END;
- </TABLE>
- <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
- <TR>
- <TH>Package #</TH>
- <TH>Customer #</TH>
- <TH>Name</TH>
- <TH>Company</TH>
- <TH>
- </TR>
-END
- }
+
}
print <<END;
#!/usr/bin/perl -Tw
#
-# $Id: svc_acct.cgi,v 1.3 1998-12-23 03:06:28 ivan Exp $
+# $Id: svc_acct.cgi,v 1.4 1999-01-18 09:22:34 ivan Exp $
#
# Usage: post form to:
# http://server.name/path/svc_acct.cgi
# give service and customer info too ivan@sisd.com 98-aug-16
#
# $Log: svc_acct.cgi,v $
-# Revision 1.3 1998-12-23 03:06:28 ivan
+# Revision 1.4 1999-01-18 09:22:34 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.3 1998/12/23 03:06:28 ivan
# $cgi->keywords instead of $cgi->query_string
#
# Revision 1.2 1998/12/17 09:41:10 ivan
use FS::UID qw(cgisuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::CGI qw(header idiot popurl);
+use FS::svc_acct;
+use FS::cust_main;
my($cgi)=new CGI;
&cgisuidsetup($cgi);
my(@svc_acct,$sortby);
my($query)=$cgi->keywords;
+$query ||= ''; #to avoid use of unitialized value errors
#this tree is a little bit redundant
if ( $query eq 'svcnum' ) {
$sortby=\*svcnum_sort;
exit;
} else {
my($total)=scalar(@svc_acct);
- print $cgi->header("Account Search Results",''), <<END;
+ print $cgi->header, header("Account Search Results",''), <<END;
$total matching accounts found
<TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
<TR>
? "<A HREF=\"${p}view/cust_main.cgi?$custnum\"><FONT SIZE=-1>$custnum</FONT></A>"
: "<I>(unlinked)</I>"
;
- my($pname) = $custnum ? "$last, $first" : '';
+ my($pname) = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$last, $first</A>" : '';
+ my $pcompany = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$company</A>" : '';
print <<END;
<TR>
<TD><A HREF="${p}view/svc_acct.cgi?$svcnum"><FONT SIZE=-1>$svcnum</FONT></A></TD>
<TD><FONT SIZE=-1>$svc</FONT></TH>
<TD><FONT SIZE=-1>$pcustnum</FONT></TH>
<TD><FONT SIZE=-1>$pname<FONT></TH>
- <TD><FONT SIZE=-1>$company</FONT></TH>
+ <TD><FONT SIZE=-1>$pcompany</FONT></TH>
</TR>
END
#!/usr/bin/perl -Tw
#
-# $Id: cust_main.cgi,v 1.7 1998-12-30 23:03:34 ivan Exp $
+# $Id: cust_main.cgi,v 1.8 1999-01-18 09:22:35 ivan Exp $
#
# Usage: cust_main.cgi custnum
# http://server.name/path/cust_main.cgi?custnum
# lose background, FS::CGI ivan@sisd.com 98-sep-2
#
# $Log: cust_main.cgi,v $
-# Revision 1.7 1998-12-30 23:03:34 ivan
+# Revision 1.8 1999-01-18 09:22:35 ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.7 1998/12/30 23:03:34 ivan
# bugfixes; fields isn't exported by derived classes
#
# Revision 1.6 1998/12/23 02:42:33 ivan
#formatting
print qq!<HR><A NAME="cust_main"><CENTER><FONT SIZE=+1>Customer Information!,
qq!</FONT>!,
- qq!<BR><A HREF="!, popurl(2), qq!/edit/cust_main.cgi?$custnum!,
+ qq!<BR><A HREF="!, popurl(2), qq!edit/cust_main.cgi?$custnum!,
qq!">Edit this information</A></CENTER><FONT SIZE=-1>!;
#agentnum
#!/usr/bin/perl -Tw
#
-# $Id: svc_acct.cgi,v 1.4 1998-12-23 03:09:19 ivan Exp $
+# $Id: svc_acct.cgi,v 1.5 1999-01-18 09:22:36 ivan Exp $
#
# Usage: svc_acct.cgi svcnum
# http://server.name/path/svc_acct.cgi?svcnum
# displays arbitrary radius attributes ivan@sisd.com 98-aug-16
#
# $Log: svc_acct.cgi,v $
-# Revision 1.4 1998-12-23 03:09:19 ivan
+# 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
#
use strict;
-use vars qw($conf);
+use vars qw( $conf );
use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup);
-use FS::Record qw(qsearchs fields);
+use CGI::Carp qw( fatalsToBrowser );
+use FS::UID qw( cgisuidsetup );
+use FS::CGI qw( header popurl );
+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;
my($cgi) = new CGI;
&cgisuidsetup($cgi);
use FS::UID;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(header menubar idiot eidiot popurl table);
+@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable);
=head1 NAME
sub header {
my($title,$menubar)=@_;
- <<END;
+ my $x = <<END;
<HTML>
<HEAD>
<TITLE>
$title
</TITLE>
</HEAD>
- <BODY BGCOLOR="#ffffff">
+ <BODY BGCOLOR="#e8e8e8">
<FONT COLOR="#FF0000" SIZE=7>
$title
</FONT>
<BR><BR>
- $menubar
- <BR><BR>
END
+ $x .= $menubar. "<BR><BR>" if $menubar;
+ $x;
}
=item menubar ITEM, URL, ...
=cut
sub table {
- "<TABLE BORDER=1>";
+ my $col = shift;
+ if ( $col ) {
+ "<TABLE BGCOLOR=$col BORDER=1 WIDTH=\"100%\">";
+ } else {
+ "<TABLE BORDER=1>";
+ }
}
=item itable
=cut
sub itable {
- "<TABLE>";
+ my $col = shift;
+ if ( $col ) {
+ qq!<TABLE BGCOLOR=$col BORDER=0 CELLSPACING=0 WIDTH=\"100%\">!;
+ } else {
+ "<TABLE>";
+ }
}
=back
pod ivan@sisd.com 98-sep-12
$Log: CGI.pm,v $
-Revision 1.13 1999-01-17 04:04:13 ivan
-itable
+Revision 1.14 1999-01-18 09:22:37 ivan
+changes to track email addresses for email invoicing
Revision 1.12 1998/12/23 02:23:16 ivan
popurl always has trailing slash
? " WHERE ". join(' AND ',
map {
$record->{$_} eq ''
- ? "$_ IS NULL"
+ ? "( $_ IS NULL OR $_ = \"\" )"
: "$_ = ". _quote($record->{$_},$table,$_)
} @fields
) : ''
my($statement)="DELETE FROM ". $self->table. " WHERE ". join(' AND ',
map {
$self->getfield($_) eq ''
- ? "$_ IS NULL"
+ ? "( $_ IS NULL OR $_ = \"\" )"
: "$_ = ". _quote($self->getfield($_),$self->table,$_)
} ( $self->dbdef_table->primary_key )
? ( $self->dbdef_table->primary_key)
join(' AND ',
map {
$old->getfield($_) eq ''
- ? "$_ IS NULL"
+ ? "( $_ IS NULL OR $_ = \"\" )"
: "$_ = ". _quote($old->getfield($_),$old->table,$_)
} ( $primary_key ? ( $primary_key ) : $old->fields )
)
=head1 VERSION
-$Id: Record.pm,v 1.10 1998-12-29 11:59:33 ivan Exp $
+$Id: Record.pm,v 1.11 1999-01-18 09:22:38 ivan Exp $
=head1 BUGS
ut_phonen got ''; at the end ivan@sisd.com 98-sep-27
$Log: Record.pm,v $
-Revision 1.10 1998-12-29 11:59:33 ivan
+Revision 1.11 1999-01-18 09:22:38 ivan
+changes to track email addresses for email invoicing
+
+Revision 1.10 1998/12/29 11:59:33 ivan
mostly properly OO, some work still to be done with svc_ stuff
Revision 1.9 1998/11/21 07:26:45 ivan
'ChopBlanks' => 'true',
} ) or die "DBI->connect error: $DBI::errstr\n";
- swapuid(); #go to non-privledged user if running setuid freeside
+ #swapuid(); #go to non-privledged user if running setuid freeside
foreach ( keys %callback ) {
&{$callback{$_}};
=cut
sub swapuid {
- ($<,$>) = ($>,$<);
+ ($<,$>) = ($>,$<) if $< != $>;
}
=item getsecrets [ USER ]
=head1 VERSION
-$Id: UID.pm,v 1.6 1998-11-15 05:27:48 ivan Exp $
+$Id: UID.pm,v 1.7 1999-01-18 09:22:40 ivan Exp $
=head1 BUGS
ivan@sisd.com 98-sep-12
$Log: UID.pm,v $
-Revision 1.6 1998-11-15 05:27:48 ivan
+Revision 1.7 1999-01-18 09:22:40 ivan
+changes to track email addresses for email invoicing
+
+Revision 1.6 1998/11/15 05:27:48 ivan
bugfix for new configuration layout
Revision 1.5 1998/11/15 00:51:51 ivan
my $self = shift;
my $error =
- $self->ut_number('agentnum')
+ $self->ut_numbern('custnum')
+ || $self->ut_number('agentnum')
|| $self->ut_number('refnum')
|| $self->ut_textn('company')
|| $self->ut_text('address1')
} );
}
- $self->zip =~ /^([\w\-]{10})$/ or return "Illegal zip";
+ $self->zip =~ /^([\w\-]{5,10})$/ or return "Illegal zip";
$self->zip($1);
$self->payby =~ /^(CARD|BILL|COMP)$/ or return "Illegal payby";
sprintf( "%.2f", $self->total_owed - $self->total_credited );
}
-=item invoicing_list [ ITEM, ITEM, ... ]
+=item invoicing_list [ ARRAYREF ]
-If arguements are given, sets these email addresses as invoice recipients
+If an arguement is given, sets these email addresses as invoice recipients
(see L<FS::cust_main_invoice>). Errors are not fatal and are not reported
(except as warnings), so use check_invoicing_list first.
Returns a list of email addresses (with svcnum entries expanded).
+Note: You can clear the invoicing list by passing an empty ARRAYREF. You can
+check it without disturbing anything by passing nothing.
+
+This interface may change in the future.
+
=cut
sub invoicing_list {
- my( $self, @addresses ) = @_;
- if ( @addresses ) {
+ my( $self, $arrayref ) = @_;
+ if ( $arrayref ) {
my @cust_main_invoice =
qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } );
foreach my $cust_main_invoice ( @cust_main_invoice ) {
- unless ( grep { $cust_main_invoice->address eq $_ } @addresses ) {
- $cust_main_invoice->delete;
+ #warn $cust_main_invoice->destnum;
+ unless ( grep { $cust_main_invoice->address eq $_ } @{$arrayref} ) {
+ #warn $cust_main_invoice->destnum;
+ my $error = $cust_main_invoice->delete;
+ warn $error if $error;
}
}
@cust_main_invoice =
qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } );
- foreach my $address ( @addresses ) {
+ foreach my $address ( @{$arrayref} ) {
unless ( grep { $address eq $_->address } @cust_main_invoice ) {
- my $cust_main_invoice = new FS::cust_main_invoice (
+ my $cust_main_invoice = new FS::cust_main_invoice ( {
'custnum' => $self->custnum,
'dest' => $address,
- );
+ } );
my $error = $cust_main_invoice->insert;
warn $error if $error;
}
qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } );
}
-=item check_invoicing_list ITEM, ITEM
+=item check_invoicing_list ARRAYREF
Checks these arguements as valid input for the invoicing_list method. If there
is an error, returns the error, otherwise returns false.
=cut
sub check_invoicing_list {
- my( $self, @addresses ) = @_;
- foreach my $address ( @addresses ) {
- my $cust_main_invoice = new FS::cust_main_invoice (
+ my( $self, $arrayref ) = @_;
+ foreach my $address ( @{$arrayref} ) {
+ my $cust_main_invoice = new FS::cust_main_invoice ( {
'custnum' => $self->custnum,
'dest' => $address,
- );
+ } );
my $error = $cust_main_invoice->check;
return $error if $error;
}
=head1 VERSION
-$Id: cust_main.pm,v 1.8 1998-12-29 11:59:39 ivan Exp $
+$Id: cust_main.pm,v 1.9 1999-01-18 09:22:41 ivan Exp $
=head1 BUGS
FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21
$Log: cust_main.pm,v $
-Revision 1.8 1998-12-29 11:59:39 ivan
+Revision 1.9 1999-01-18 09:22:41 ivan
+changes to track email addresses for email invoicing
+
+Revision 1.8 1998/12/29 11:59:39 ivan
mostly properly OO, some work still to be done with svc_ stuff
Revision 1.7 1998/12/16 09:58:52 ivan
sub check {
my $self = shift;
- my $error = $self->ut_number('destnum')
- or $self->ut_number('custnum')
- or $self->ut_text('dest')
+ my $error = $self->ut_numbern('destnum')
+ || $self->ut_number('custnum')
+ || $self->ut_text('dest')
;
return $error if $error;
} elsif ( $self->dest =~ /^(\d+)$/ ) {
return "Unknown local account (specified by svcnum)"
unless qsearchs( 'svc_acct', { 'svcnum' => $self->dest } );
- } elsif ( $self->dest =~ /^([\w\.\-]+)\@(([\w\.\-]\.)+\w+)$/ ) {
+ } elsif ( $self->dest =~ /^([\w\.\-]+)\@(([\w\.\-]+\.)+\w+)$/ ) {
my($user, $domain) = ($1, $2);
if ( $domain eq $mydomain ) {
my $svc_acct = qsearchs( 'svc_acct', { 'username' => $user } );
=head1 VERSION
-$Id: cust_main_invoice.pm,v 1.3 1998-12-29 11:59:42 ivan Exp $
+$Id: cust_main_invoice.pm,v 1.4 1999-01-18 09:22:42 ivan Exp $
=head1 BUGS
ivan@sisd.com 97-nov-13
$Log: cust_main_invoice.pm,v $
-Revision 1.3 1998-12-29 11:59:42 ivan
+Revision 1.4 1999-01-18 09:22:42 ivan
+changes to track email addresses for email invoicing
+
+Revision 1.3 1998/12/29 11:59:42 ivan
mostly properly OO, some work still to be done with svc_ stuff
Revision 1.2 1998/12/16 09:58:53 ivan