beginnings of one-screen new customer entry and some other miscellania
authorivan <ivan>
Tue, 23 Feb 1999 08:09:27 +0000 (08:09 +0000)
committerivan <ivan>
Tue, 23 Feb 1999 08:09:27 +0000 (08:09 +0000)
TODO
htdocs/docs/config.html
htdocs/edit/cust_main.cgi
htdocs/edit/part_svc.cgi
htdocs/edit/svc_acct.cgi
htdocs/edit/svc_acct_pop.cgi
htdocs/search/svc_domain.cgi
htdocs/view/svc_domain.cgi
site_perl/cust_main.pm

diff --git a/TODO b/TODO
index 93f9ed8..611f83e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.24 1999-02-10 08:27:55 ivan Exp $
+$Id: TODO,v 1.25 1999-02-23 08:09:18 ivan Exp $
 
 If you are interested in helping with any of these, please join the mailing
 list (send a blank message to ivan-freeside-subscribe@sisd.com) to avoid 
@@ -6,6 +6,8 @@ duplication of effort.
 
 -- before 1.2b1 --
 
+TEST email invoices
+
 one-screen new customer entry
 
 clean up view/cust_pkg and view/svc_* yuck (popurl and visual)!
@@ -15,6 +17,8 @@ Lay out the forms a bit better.
 libwww regression test - since it will create sample data, can also use this
 for the web demo
 make fs-setup option to add sample data so you can click on "New Customer" right away?  so people understand what this stuff is?
+(in sample data [ AND DOCUMENT! ] all svc_acct services should have a default
+ or fixed shell )
 
 (Test this)
 one-time/per-customer/? changes in rates and descriptions ('remembered
@@ -27,10 +31,24 @@ associated with any agent types so it won't show up for other customers to buy.
 
 update site_perl/table_template* (pry out of date)
 
+remove "records identical" warning?  gets in the way of more important stuff.
+
 update web demo
 
 -- release 1.2b1 ---
 
+password and slipip stuff in svc_acct.pm store need to be split into two fields or something, so the silliness in svc_acct.pm and svc_acct.export with looking at the data to decide what to do with it can be fixed
+
+i10n: Apache::Language
+
+Apache::Session?  Other useful Apache::* ?
+
+email invoices are only sent for the BILL payby.  If setup, should statements
+(since they're not invoices) be sent for COMP and CARD as well?
+
+$cgi->keywords is causing the (hard to trace) error:
+       Use of uninitialized value at (eval 5) line 5
+
 edit/cust_main.cgi gives an uninformative error message:
 > Can't call method "agentnum" without a package or object reference at   
 > /usr/local/apache-ssl/htdocs/freeside/edit/cust_main.cgi line 116.
@@ -45,13 +63,16 @@ Allow a cancelled/suspended/active status from packages to bubble up to
 the customer lists.  Put active, then suspended, then cancelled accounts.
 Similar ordering on the package listing inside a single customer.
 
+false laziness: edit/cust_main.cgi got some parts copied from edit/svc_acct.cgi
+the web interface in general needs to be redone in a more abstract way.
+
 false laziness: some of search/svc_acct_sm.cgi was copied to search/svc_domain.cgi.  but web interface in general needs to be rewritten in a mucho cleaner way.
 
 Portability: in FS::Record, $sth->execute does not return a number of rows for all DBD's.  see man DBI
 
 subroutine the where clause (eventually all SQL) as OO perhaps (has anyone done this?)
 
-add a select method to 
+add a select method to ?
 
 You can't delete the stuff under administration yet.  Add this,
 _including_ making sure the thing you are deleting is not in use!
@@ -386,8 +407,6 @@ configuration/setup should get web interface
 ...
 (probably as part of some automated installation process?)
 
-password and slipip stuff in svc_acct.pm store need to be split into two fields or something, so the silliness in svc_acct.pm and svc_acct.export with looking at the data to decide what to do with it can be fixed (1.2)
-
 This requires some serious magic in FS::Record:
 ok, if date_type in fs-setup is to be something besides int,
 now we need to create wrappers
index 848456c..1a30b52 100644 (file)
@@ -28,6 +28,7 @@ All further configuration files and directories are located in
   <li>domain - Your domain name.
   <li>erpcdmachines - Your ERPCD authenticaion machines, one per line.  This enables export of `/usr/annex/acp_passwd' and `/usr/annex/acp_dialup'.
   <li>home - For new users, prefixed to usrename to create a directory name.  Should have a leading but not a trailing slash.
+  <li>invoice_from - Return address on email invoices.
   <li>lpr - Print command for paper invoices, for example `lpr -h'.
   <li>nismachines - Your NIS master (not slave master) machines, one per line.  This enables export of `/etc/global/passwd' and `/etc/global/shadow'.
   <li>qmailmachines - Your qmail machines, one per line.  This enables export of `/var/qmail/control/virtualdomains', `/var/qmail/control/recipientmap', and `/var/qmail/control/rcpthosts'.  The existance of this file (even if empty) also turns on user `.qmail-extension' file maintenance in conjunction with `shellmachine'.
index 03252b0..ba86428 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: cust_main.cgi,v 1.8 1999-01-25 12:09:53 ivan Exp $
+# $Id: cust_main.cgi,v 1.9 1999-02-23 08:09:20 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.8  1999-01-25 12:09:53  ivan
+# Revision 1.9  1999-02-23 08:09:20  ivan
+# beginnings of one-screen new customer entry and some other miscellania
+#
+# Revision 1.8  1999/01/25 12:09:53  ivan
 # yet more mod_perl stuff
 #
 # Revision 1.7  1999/01/19 05:13:34  ivan
@@ -66,12 +69,25 @@ use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum
              $last $first $ss $company $address1 $address2 $city $zip 
              $daytime $night $fax @invoicing_list $invoicing_list $payinfo
              $payname %payby %paybychecked $refnum $otaker $r );
+use vars qw ( $conf $pkgpart $username $password $popnum $ulen $ulen2 );
 use CGI::Switch;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup getotaker);
-use FS::Record qw(qsearch qsearchs fields);
+#use FS::Record qw(qsearch qsearchs fields);
+use FS::Record qw(qsearch qsearchs fields dbdef);
 use FS::CGI qw(header popurl itable table);
 use FS::cust_main;
+use FS::agent;
+use FS::part_referral;
+use FS::cust_main_county;
+
+  #for misplaced logic below
+  use FS::pkg_svc;
+  use FS::part_svc;
+  use FS::part_pkg;
+
+  #for false laziness below
+  use FS::svc_acct_pop;
 
 $cgi = new CGI;
 cgisuidsetup($cgi);
@@ -83,15 +99,27 @@ if ( $cgi->param('error') ) {
     map { $_, scalar($cgi->param($_)) } fields('cust_main')
   } );
   $custnum = $cust_main->custnum;
+  $pkgpart = $cgi->param('pkgpart');
+  $username = $cgi->param('username');
+  $password = $cgi->param('_password');
+  $popnum = $cgi->param('popnum');
 } elsif ( $cgi->keywords ) { #editing
   my( $query ) = $cgi->keywords;
   $query =~ /^(\d+)$/;
   $custnum=$1;
   $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+  $pkgpart = 0;
+  $username = '';
+  $password = '';
+  $popnum = 0;
 } else {
   $custnum='';
   $cust_main = new FS::cust_main ( {} );
   $cust_main->setfield('otaker',&getotaker);
+  $pkgpart = 0;
+  $username = '';
+  $password = '';
+  $popnum = 0;
 }
 $action = $custnum ? 'Edit' : 'Add';
 
@@ -140,7 +168,7 @@ if ( $custnum ) {
     $refnum ||= $referrals[0]->refnum;
     print qq!<INPUT TYPE="hidden" NAME="refnum" VALUE="$refnum">!;
   } else {
-    print qq!<BR>${r}Referral <SELECT NAME="refnum" SIZE="1">!;
+    print qq!<BR><BR>${r}Referral <SELECT NAME="refnum" SIZE="1">!;
     print "<OPTION> ";
     my($referral);
     foreach $referral (sort {
@@ -200,7 +228,7 @@ print <<END;
 <TR><TD ALIGN="right">Fax</TD><TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12></TD></TR>
 END
 
-print "</TABLE>$r designates required fields<BR>";
+print "</TABLE>$r required fields<BR>";
 
 # billing info
 
@@ -270,8 +298,66 @@ for (qw(CARD BILL COMP)) {
   }
 }
 
-print "</TR></TABLE>$r designates required fields for each billing type";
+print "</TR></TABLE>$r required fields for each billing type";
+
+unless ( $custnum ) {
+  # pry the wrong place for this logic.  also pretty expensive
+  #use FS::pkg_svc;
+  #use FS::part_svc;
+  #use FS::part_pkg;
+
+  my %pkgpart;
+  #foreach ( @pkg_svc ) {
+  foreach ( qsearch( 'pkg_svc', {} ) ) {
+    my $part_svc = qsearchs ( 'part_svc', { 'svcpart' => $_->svcpart } );
+    $pkgpart{ $_->pkgpart } = 9999 # never will == 1 below
+      if ( $part_svc->svcdb ne 'svc_acct' );
+    $pkgpart{ $_->pkgpart }++;
+  }
+
+  my @part_pkg =
+    #grep { $pkgpart{ $_->pkgpart } == 1 } qsearch( 'part_pkg', {} );
+    grep { ( $pkgpart{ $_->pkgpart } || 0 ) == 1 } qsearch( 'part_pkg', {} );
+
+  if ( @part_pkg ) {
 
+    print "<BR><BR>First package", itable("#c0c0c0"),
+          qq!<TR><TD COLSPAN=2><SELECT NAME="pkgpart">!;
+
+    print qq!<OPTION VALUE="">(none)!;
+
+    foreach my $part_pkg ( @part_pkg ) {
+      print qq!<OPTION VALUE="!, $part_pkg->pkgpart, '"',
+            " SELECTED"x($part_pkg->pkgpart == $pkgpart),
+            ">", $part_pkg->pkg, " - ", $part_pkg->comment;
+    }
+    print "</SELECT></TD></TR>";
+
+    #false laziness: (mostly) copied from edit/svc_acct.cgi
+    #$ulen = $svc_acct->dbdef_table->column('username')->length;
+    $ulen = dbdef->table('svc_acct')->column('username')->length;
+    $ulen2 = $ulen+2;
+    print <<END;
+<TR><TD ALIGN="right">Username</TD>
+<TD><INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen></TD></TR>
+<TR><TD ALIGN="right">Password</TD>
+<TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
+(blank to generate)</TD></TR>
+END
+    print qq!<TR><TD ALIGN="right">POP</TD><TD><SELECT NAME="popnum" SIZE=1><OPTION> !;
+    my($svc_acct_pop);
+    foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
+    print "<OPTION", $svc_acct_pop->popnum == $popnum ? ' SELECTED' : '', ">", 
+          $svc_acct_pop->popnum, ": ", 
+          $svc_acct_pop->city, ", ",
+          $svc_acct_pop->state,
+          " (", $svc_acct_pop->ac, ")/",
+          $svc_acct_pop->exch, "\n"
+        ;
+    }
+    print "</SELECT></TD></TR></TABLE>";
+  }
+}
 
 $otaker = $cust_main->otaker;
 print qq!<INPUT TYPE="hidden" NAME="otaker" VALUE="$otaker">!,
index 8a39fc7..95e1c87 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: part_svc.cgi,v 1.8 1999-02-07 09:59:21 ivan Exp $
+# $Id: part_svc.cgi,v 1.9 1999-02-23 08:09:21 ivan Exp $
 #
 # ivan@sisd.com 97-nov-14
 #
 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
 #
 # $Log: part_svc.cgi,v $
-# Revision 1.8  1999-02-07 09:59:21  ivan
+# Revision 1.9  1999-02-23 08:09:21  ivan
+# beginnings of one-screen new customer entry and some other miscellania
+#
+# Revision 1.8  1999/02/07 09:59:21  ivan
 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
 #
 # Revision 1.7  1999/01/19 05:13:42  ivan
@@ -151,9 +154,12 @@ foreach $svcdb ( qw(
   my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
   my($row);
   foreach $row (@rows) {
-    my($value)=$part_svc->getfield($svcdb.'__'.$row);
-    my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag');
-    print "<TR>$ptmp<TD>$row - <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT></TD>";
+    my $value = $part_svc->getfield($svcdb. '__'. $row);
+    my $flag = $part_svc->getfield($svcdb. '__'. $row. '_flag');
+    print "<TR>$ptmp<TD>$row";
+    print "- <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT>"
+      if defined $defs{$svcdb}{$row};
+    print "</TD>";
     print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
       ' CHECKED'x($flag eq ''). ">Off</TD>";
     print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
index 876d7be..010cdca 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: svc_acct.cgi,v 1.7 1999-02-07 09:59:22 ivan Exp $
+# $Id: svc_acct.cgi,v 1.8 1999-02-23 08:09:22 ivan Exp $
 #
 # Usage: svc_acct.cgi {svcnum} | pkgnum{pkgnum}-svcpart{svcpart}
 #        http://server.name/path/svc_acct.cgi? {svcnum} | pkgnum{pkgnum}-svcpart{svcpart}
 # use conf/shells and dbdef username length ivan@sisd.com 98-jul-13
 #
 # $Log: svc_acct.cgi,v $
-# Revision 1.7  1999-02-07 09:59:22  ivan
+# Revision 1.8  1999-02-23 08:09:22  ivan
+# beginnings of one-screen new customer entry and some other miscellania
+#
+# Revision 1.7  1999/02/07 09:59:22  ivan
 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
 #
 # Revision 1.6  1999/01/19 05:13:43  ivan
@@ -156,7 +159,7 @@ if ( $part_svc->svc_acct__popnum_flag eq "F" ) {
         $svc_acct_pop->popnum, ": ", 
         $svc_acct_pop->city, ", ",
         $svc_acct_pop->state,
-        "(", $svc_acct_pop->ac, ")/",
+        " (", $svc_acct_pop->ac, ")/",
         $svc_acct_pop->exch, "\n"
       ;
   }
index 41a163e..d6e2e5d 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: svc_acct_pop.cgi,v 1.7 1999-02-07 09:59:23 ivan Exp $
+# $Id: svc_acct_pop.cgi,v 1.8 1999-02-23 08:09:23 ivan Exp $
 #
 # ivan@sisd.com 98-mar-8 
 #
 # lose background, FS::CGI ivan@sisd.com 98-sep-2
 #
 # $Log: svc_acct_pop.cgi,v $
-# Revision 1.7  1999-02-07 09:59:23  ivan
+# Revision 1.8  1999-02-23 08:09:23  ivan
+# beginnings of one-screen new customer entry and some other miscellania
+#
+# Revision 1.7  1999/02/07 09:59:23  ivan
 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
 #
 # Revision 1.6  1999/01/19 05:13:44  ivan
@@ -38,11 +41,9 @@ use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearch qsearchs fields);
-use FS::svc_acct_pop;
 use FS::CGI qw(header menubar popurl);
-
+use FS::svc_acct_pop;
 $cgi = new CGI;
-
 &cgisuidsetup($cgi);
 
 if ( $cgi->param('error') ) {
index 778584d..0058aca 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: svc_domain.cgi,v 1.6 1999-02-09 09:22:59 ivan Exp $
+# $Id: svc_domain.cgi,v 1.7 1999-02-23 08:09:24 ivan Exp $
 #
 # Usage: post form to:
 #        http://server.name/path/svc_domain.cgi
 # display total, use FS::CGI now does browsing too ivan@sisd.com 98-jul-17
 #
 # $Log: svc_domain.cgi,v $
-# Revision 1.6  1999-02-09 09:22:59  ivan
+# Revision 1.7  1999-02-23 08:09:24  ivan
+# beginnings of one-screen new customer entry and some other miscellania
+#
+# Revision 1.6  1999/02/09 09:22:59  ivan
 # visual and bugfixes
 #
 # Revision 1.5  1999/02/07 09:59:39  ivan
 #
 
 use strict;
-use vars qw ( $cgi @svc_domain $sortby $query $conf );
+use vars qw ( $cgi @svc_domain $sortby $query $conf $mydomain );
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearch qsearchs);
 use FS::CGI qw(header eidiot popurl);
+use FS::svc_domain;
+use FS::cust_svc;
+use FS::svc_acct_sm;
+use FS::svc_acct;
 
 $cgi = new CGI;
 &cgisuidsetup($cgi);
index a6de404..8941a3c 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: svc_domain.cgi,v 1.6 1999-01-19 05:14:23 ivan Exp $
+# $Id: svc_domain.cgi,v 1.7 1999-02-23 08:09:25 ivan Exp $
 #
 # Usage: svc_domain svcnum
 #        http://server.name/path/svc_domain.cgi?svcnum
 #       bmccane@maxbaud.net     98-apr-3
 #
 # $Log: svc_domain.cgi,v $
-# Revision 1.6  1999-01-19 05:14:23  ivan
+# 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/;
 #
@@ -41,6 +44,10 @@ use CGI;
 use FS::UID qw(cgisuidsetup);
 use FS::CGI qw(header menubar popurl);
 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);
index a89896d..5a83741 100644 (file)
@@ -5,12 +5,14 @@ use vars qw($paymentserversecret $paymentserverport $paymentserverhost);
 package FS::cust_main;
 
 use strict;
-use vars qw(@ISA $conf $lpr $processor $xaction $E_NoErr);
+use vars qw(@ISA $conf $lpr $processor $xaction $E_NoErr $invoice_from);
 use Safe;
 use Carp;
 use Time::Local;
 use Date::Format;
 use Date::Manip;
+use Mail::Internet;
+use Mail::Header;
 use Business::CreditCard;
 use FS::UID qw( getotaker );
 use FS::Record qw( qsearchs qsearch );
@@ -31,6 +33,7 @@ use FS::cust_main_invoice;
 $FS::UID::callback{'FS::cust_main'} = sub { 
   $conf = new FS::Conf;
   $lpr = $conf->config('lpr');
+  $invoice_from = $conf->config('invoice_from');
 
   if ( $conf->exists('cybercash3.2') ) {
     require CCMckLib3_2;
@@ -585,11 +588,30 @@ sub collect {
            && ( $cust_bill->printed * 2592000 ) <= $since
       ) {
 
-        open(LPR, "|$lpr") or die "Can't open pipe to $lpr: $!";
-        print LPR $cust_bill->print_text; #( date )
-        close LPR
-          or die $! ? "Error closing $lpr: $!"
-                       : "Exit status $? from $lpr";
+        #my @print_text = $cust_bill->print_text; #( date )
+        my @invoicing_list = $self->invoicing_list;
+        if ( grep { $_ ne 'POST' } @invoicing_list ) { #email invoice
+          my $header = new Mail::Header ( [
+            "From: $invoice_from",
+            "To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ),
+            "Sender: $invoice_from",
+            "Reply-To: $invoice_from",
+            "Date: ". time2str("%a, %d %b %Y %X %z", time),
+            "Subject: Invoice",
+          ] );
+          my $message = new Mail::Internet (
+            'Header' => $header,
+            'Body' => [ $cust_bill->print_text ], #( date)
+          );
+          $message->smtpsend or die "Can't send invoice email!"; #die?  warn?
+
+        } elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
+          open(LPR, "|$lpr") or die "Can't open pipe to $lpr: $!";
+          print LPR $cust_bill->print_text; #( date )
+          close LPR
+            or die $! ? "Error closing $lpr: $!"
+                         : "Exit status $? from $lpr";
+        }
 
         my %hash = $cust_bill->hash;
         $hash{'printed'}++;
@@ -611,6 +633,7 @@ sub collect {
       my $error = $cust_pay->insert;
       return 'Error COMPing invnum #' . $cust_bill->invnum .
              ':' . $error if $error;
+
     } elsif ( $self->payby eq 'CARD' ) {
 
       if ( $options{'batch_card'} ne 'yes' ) {
@@ -712,6 +735,10 @@ sub collect {
       return "Unknown payment type ". $self->payby;
     }
 
+
+
+
+
   }
   '';
 
@@ -835,7 +862,7 @@ sub check_invoicing_list {
 
 =head1 VERSION
 
-$Id: cust_main.pm,v 1.10 1999-01-25 12:26:09 ivan Exp $
+$Id: cust_main.pm,v 1.11 1999-02-23 08:09:27 ivan Exp $
 
 =head1 BUGS
 
@@ -891,7 +918,10 @@ enable cybercash, cybercash v3 support, don't need to import
 FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21
 
 $Log: cust_main.pm,v $
-Revision 1.10  1999-01-25 12:26:09  ivan
+Revision 1.11  1999-02-23 08:09:27  ivan
+beginnings of one-screen new customer entry and some other miscellania
+
+Revision 1.10  1999/01/25 12:26:09  ivan
 yet more mod_perl stuff
 
 Revision 1.9  1999/01/18 09:22:41  ivan