#!/usr/bin/perl -Tw
#
-# $Id: cust_main.cgi,v 1.15 1999-04-14 13:14:54 ivan Exp $
+# $Id: cust_main.cgi,v 1.16 1999-07-20 10:37:05 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.15 1999-04-14 13:14:54 ivan
+# Revision 1.16 1999-07-20 10:37:05 ivan
+# cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+# prepare for a signup server
+#
+# Revision 1.15 1999/04/14 13:14:54 ivan
# configuration option to edit referrals of existing customers
#
# Revision 1.14 1999/04/14 07:47:53 ivan
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
unless ( $custnum ) {
# pry the wrong place for this logic. also pretty expensive
- #use FS::pkg_svc;
- #use FS::part_svc;
#use FS::part_pkg;
#false laziness, copied from FS::cust_pkg::order
- my %part_pkg;
+ my $pkgpart;
if ( scalar(@agents) == 1 ) {
- # generate %part_pkg
- # $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart
- #my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
- #my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
+ # $pkgpart->{$pkgpart} is true iff $custnum may purchase $pkgpart
my($agent)=qsearchs('agent',{'agentnum'=> $agentnum });
-
- my($type_pkgs);
- foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
- my($pkgpart)=$type_pkgs->pkgpart;
- $part_pkg{$pkgpart}++;
- }
+ $pkgpart = $agent->pkgpart_hashref;
} else {
#can't know (agent not chosen), so, allow all
my %typenum;
foreach my $agent ( @agents ) {
next if $typenum{$agent->typenum}++;
- foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
- my($pkgpart)=$type_pkgs->pkgpart;
- $part_pkg{$pkgpart}++;
- }
+ $pkgpart->{$_}++ foreach keys %{ $agent->pkgpart_hashref }
}
-
}
#eslaf
- my %pkgpart;
- #foreach ( @pkg_svc ) {
- foreach ( qsearch( 'pkg_svc', {} ) ) {
- my $part_svc = qsearchs ( 'part_svc', { 'svcpart' => $_->svcpart } );
- $pkgpart{ $_->pkgpart } = -1 # never will == 1 below
- if ( $part_svc->svcdb ne 'svc_acct' );
- if ( $pkgpart{ $_->pkgpart } ) {
- $pkgpart{ $_->pkgpart } = '-1';
- } else {
- $pkgpart{ $_->pkgpart } = $_->svcpart;
- }
- }
-
- my @part_pkg =
- #grep { $pkgpart{ $_->pkgpart } == 1 } qsearch( 'part_pkg', {} );
- grep {
- #( $pkgpart{ $_->pkgpart } || 0 ) == 1
- $pkgpart{ $_->pkgpart }
- && $pkgpart{ $_->pkgpart } != -1
- && $part_pkg{ $_->pkgpart }
- ;
- } qsearch( 'part_pkg', {} );
+ my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
+ qsearch( 'part_pkg', {} );
if ( @part_pkg ) {
foreach my $part_pkg ( @part_pkg ) {
print qq!<OPTION VALUE="!,
- $part_pkg->pkgpart. "_". $pkgpart{ $part_pkg->pkgpart }, '"';
+# $part_pkg->pkgpart. "_". $pkgpart{ $part_pkg->pkgpart }, '"';
+ $part_pkg->pkgpart. "_". $part_pkg->svcpart, '"';
print " SELECTED" if $pkgpart && ( $part_pkg->pkgpart == $pkgpart );
print ">", $part_pkg->pkg, " - ", $part_pkg->comment;
}
$error = $record->check;
+ $agent_type = $record->agent_type;
+
+ $hashref = $record->pkgpart_hashref;
+ #may purchase $pkgpart if $hashref->{$pkgpart};
+
=head1 DESCRIPTION
An FS::agent object represents an agent. Every customer has an agent. Agents
return $error if $error;
return "Unknown typenum!"
- unless qsearchs( 'agent_type', { 'typenum' => $self->typenum } );
+ unless $self->agent_type;
'';
}
+=item agent_type
+
+Returns the FS::agent_type object (see L<FS::agent_type>) for this agent.
+
+=cut
+
+sub agent_type {
+ my $self = shift;
+ qsearchs( 'agent_type', { 'typenum' => $self->typenum } );
+}
+
+=item pkgpart_hashref
+
+Returns a hash reference. The keys of the hash are pkgparts. The value is
+true iff this agent may purchase the specified package definition. See
+L<FS::part_pkg>.
+
+=cut
+
+sub pkgpart_hashref {
+ my $self = shift;
+ $self->agent_type->pkgpart_hashref;
+}
+
=back
=head1 VERSION
-$Id: agent.pm,v 1.4 1998-12-30 00:30:44 ivan Exp $
+$Id: agent.pm,v 1.5 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
=head1 SEE ALSO
-L<FS::Record>, L<FS::agent_type>, L<FS::cust_main>, schema.html from the base
-documentation.
+L<FS::Record>, L<FS::agent_type>, L<FS::cust_main>, L<FS::part_pkg>,
+schema.html from the base documentation.
=head1 HISTORY
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearch );
+use FS::agent;
+use FS::type_pkgs;
@ISA = qw( FS::Record );
$error = $record->check;
+ $hashref = $record->pkgpart_hashref;
+ #may purchase $pkgpart if $hashref->{$pkgpart};
+
+ @type_pkgs = $record->type_pkgs;
+
+ @pkgparts = $record->pkgpart;
+
=head1 DESCRIPTION
An FS::agent_type object represents an agent type. Every agent (see
}
+=item pkgpart_hashref
+
+Returns a hash reference. The keys of the hash are pkgparts. The value is
+true iff this agent may purchase the specified package definition. See
+L<FS::part_pkg>.
+
+=cut
+
+sub pkgpart_hashref {
+ my $self = shift;
+ my %pkgpart;
+ $pkgpart{$_}++ foreach $self->pkgpart;
+ \%pkgpart;
+}
+
+=item type_pkgs
+
+Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this agent type.
+
+=cut
+
+sub type_pkgs {
+ my $self = shift;
+ qsearch('type_pkgs', { 'typenum' => $self->typenum } );
+}
+
+=item pkgpart
+
+Returns the pkgpart of all package definitions (see L<FS::part_pkg>) for this
+agent type.
+
+=cut
+
+sub pkgpart {
+ my $self = shift;
+ map $_->pkgpart, $self->type_pkgs;
+}
+
=back
=head1 VERSION
-$Id: agent_type.pm,v 1.2 1998-12-29 11:59:35 ivan Exp $
+$Id: agent_type.pm,v 1.3 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
pod, added check in delete ivan@sisd.com 98-sep-21
$Log: agent_type.pm,v $
-Revision 1.2 1998-12-29 11:59:35 ivan
+Revision 1.3 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.2 1998/12/29 11:59:35 ivan
mostly properly OO, some work still to be done with svc_ stuff
=item night - phone (optional)
+=item fax - phone (optional)
+
=item payby - `CARD' (credit cards), `BILL' (billing), or `COMP' (free)
=item payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username)
=head1 VERSION
-$Id: cust_main.pm,v 1.23 1999-07-17 02:24:14 ivan Exp $
+$Id: cust_main.pm,v 1.24 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21
$Log: cust_main.pm,v $
-Revision 1.23 1999-07-17 02:24:14 ivan
+Revision 1.24 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.23 1999/07/17 02:24:14 ivan
bug noticed by Steve Gertz <sglist@hollywood.mwis.net>
Revision 1.22 1999/04/15 16:44:36 ivan
$self->ut_numbern('taxnum')
|| $self->ut_textn('state')
|| $self->ut_textn('county')
+ || $self->ut_text('country')
|| $self->ut_float('tax')
;
=head1 VERSION
-$Id: cust_main_county.pm,v 1.3 1998-12-29 11:59:41 ivan Exp $
+$Id: cust_main_county.pm,v 1.4 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
pod ivan@sisd.com 98-sep-21
$Log: cust_main_county.pm,v $
-Revision 1.3 1998-12-29 11:59:41 ivan
+Revision 1.4 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.3 1998/12/29 11:59:41 ivan
mostly properly OO, some work still to be done with svc_ stuff
Revision 1.2 1998/11/18 09:01:43 ivan
sub order {
my($custnum,$pkgparts,$remove_pkgnums)=@_;
- my(%part_pkg);
# generate %part_pkg
# $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart
- my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
- my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
-
- my($type_pkgs);
- foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
- my($pkgpart)=$type_pkgs->pkgpart;
- $part_pkg{$pkgpart}++;
- }
#
+ my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
+ my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
+ my %part_pkg = %{ $agent->pkgpart_hashref };
my(%svcnum);
# generate %svcnum
=head1 VERSION
-$Id: cust_pkg.pm,v 1.9 1999-03-29 01:11:51 ivan Exp $
+$Id: cust_pkg.pm,v 1.10 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
pod ivan@sisd.com 98-sep-21
$Log: cust_pkg.pm,v $
-Revision 1.9 1999-03-29 01:11:51 ivan
+Revision 1.10 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.9 1999/03/29 01:11:51 ivan
use FS::type_pkgs
Revision 1.8 1999/03/25 13:48:14 ivan
use strict;
use vars qw( @ISA );
-use FS::Record;
+use FS::Record qw( qsearch );
+use FS::pkg_svc;
@ISA = qw( FS::Record );
$error = $record->check;
+ @pkg_svc = $record->pkg_svc;
+
+ $svcnum = $record->svcpart;
+ $svcnum = $record->svcpart( 'svc_acct' );
+
=head1 DESCRIPTION
An FS::part_pkg object represents a billing item definition. FS::part_pkg
;
}
+=item pkg_svc
+
+Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package
+definition.
+
+=cut
+
+sub pkg_svc {
+ my $self = shift;
+ qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
+}
+
+=item svcpart [ SVCDB ]
+
+Returns the svcpart of a single service definition (see L<FS::part_svc>)
+associated with this billing item definition (see L<FS::pkg_svc>). Returns
+false if there not exactly one service definition with quantity 1, or if
+SVCDB is specified and does not match the svcdb of the service definition,
+
+=cut
+
+sub svcpart {
+ my $self = shift;
+ my $svcdb = shift;
+ my @pkg_svc = $self->pkg_svc;
+ return '' if scalar(@pkg_svc) != 1
+ || $pkg_svc[0]->quantity != 1
+ || ( $svcdb && $pkg_svc[0]->part_svc->svcdb ne $svcdb );
+ $pkg_svc[0]->svcpart;
+}
+
=back
=head1 VERSION
-$Id: part_pkg.pm,v 1.5 1998-12-31 01:04:16 ivan Exp $
+$Id: part_pkg.pm,v 1.6 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
-It doesn't properly override FS::Record yet.
-
The delete method is unimplemented.
setup and recur semantics are not yet defined (and are implemented in
pod ivan@sisd.com 98-sep-21
$Log: part_pkg.pm,v $
-Revision 1.5 1998-12-31 01:04:16 ivan
+Revision 1.6 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.5 1998/12/31 01:04:16 ivan
doc
Revision 1.3 1998/11/15 13:00:15 ivan
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearchs );
+use FS::part_pkg;
+use FS::part_svc;
@ISA = qw( FS::Record );
$error = $record->check;
+ $part_pkg = $record->part_pkg;
+
+ $part_svc = $record->part_svc;
+
=head1 DESCRIPTION
An FS::pkg_svc record links a billing item definition (see L<FS::part_pkg>) to
;
return $error if $error;
- return "Unknown pkgpart!"
- unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
-
- return "Unknown svcpart!"
- unless qsearchs('part_svc', { 'svcpart' => $self->svcpart } );
+ return "Unknown pkgpart!" unless $self->part_pkg;
+ return "Unknown svcpart!" unless $self->part_svc;
''; #no error
}
+=item part_pkg
+
+Returns the FS::part_pkg object (see L<FS::part_pkg>).
+
+=cut
+
+sub part_pkg {
+ my $self = shift;
+ qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
+}
+
+=item part_svc
+
+Returns the FS::part_svc object (see L<FS::part_svc>).
+
+=cut
+
+sub part_svc {
+ my $self = shift;
+ qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
+}
+
=back
=head1 VERSION
-$Id: pkg_svc.pm,v 1.3 1999-01-18 21:58:08 ivan Exp $
+$Id: pkg_svc.pm,v 1.4 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
pod ivan@sisd.com 98-sep-22
$Log: pkg_svc.pm,v $
-Revision 1.3 1999-01-18 21:58:08 ivan
+Revision 1.4 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.3 1999/01/18 21:58:08 ivan
esthetic: eq and ne were used in a few places instead of == and !=
Revision 1.2 1998/12/29 11:59:51 ivan