X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=site_perl%2Fpkg_svc.pm;h=f28745d2818d5cbe45c80f3aee5f813d14e5578b;hb=19c3d2717fb417187fb0f020a7ba2b065f3f8e30;hp=517125c01946fbb6d7711400bf3a91a55674b96d;hpb=889bf4b600c134f91174caf0919a86dbdc4dcf03;p=freeside.git diff --git a/site_perl/pkg_svc.pm b/site_perl/pkg_svc.pm index 517125c01..f28745d28 100644 --- a/site_perl/pkg_svc.pm +++ b/site_perl/pkg_svc.pm @@ -1,12 +1,12 @@ package FS::pkg_svc; use strict; -use vars qw(@ISA @EXPORT_OK); -use Exporter; -use FS::Record qw(fields hfields qsearchs); +use vars qw( @ISA ); +use FS::Record qw( qsearchs ); +use FS::part_pkg; +use FS::part_svc; -@ISA = qw(FS::Record Exporter); -@EXPORT_OK = qw(hfields); +@ISA = qw( FS::Record ); =head1 NAME @@ -16,8 +16,8 @@ FS::pkg_svc - Object methods for pkg_svc records use FS::pkg_svc; - $record = create FS::pkg_svc \%hash; - $record = create FS::pkg_svc { 'column' => 'value' }; + $record = new FS::pkg_svc \%hash; + $record = new FS::pkg_svc { 'column' => 'value' }; $error = $record->insert; @@ -27,6 +27,10 @@ FS::pkg_svc - Object methods for pkg_svc records $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) to @@ -48,52 +52,24 @@ definition includes =over 4 -=item create HASHREF +=item new HASHREF Create a new record. To add the record to the database, see L<"insert">. =cut -sub create { - my($proto,$hashref)=@_; - - #now in FS::Record::new - #my($field); - #foreach $field (fields('pkg_svc')) { - # $hashref->{$field}='' unless defined $hashref->{$field}; - #} - - $proto->new('pkg_svc',$hashref); - -} +sub table { 'pkg_svc'; } =item insert Adds this record to the database. If there is an error, returns the error, otherwise returns false. -=cut - -sub insert { - my($self)=@_; - - $self->check or - $self->add; -} - =item delete Deletes this record from the database. If there is an error, returns the error, otherwise returns false. -=cut - -sub delete { - my($self)=@_; - - $self->del; -} - =item replace OLD_RECORD Replaces OLD_RECORD with this one in the database. If there is an error, @@ -102,15 +78,12 @@ returns the error, otherwise returns false. =cut sub replace { - my($new,$old)=@_; - return "(Old) Not a pkg_svc record!" unless $old->table eq "pkg_svc"; - return "Can't change pkgpart!" - if $old->getfield('pkgpart') ne $new->getfield('pkgpart'); - return "Can't change svcpart!" - if $old->getfield('svcpart') ne $new->getfield('svcpart'); - - $new->check or - $new->rep($old); + my ( $new, $old ) = ( shift, shift ); + + return "Can't change pkgpart!" if $old->pkgpart != $new->pkgpart; + return "Can't change svcpart!" if $old->svcpart != $new->svcpart; + + $new->SUPER::replace($old); } =item check @@ -122,31 +95,51 @@ methods. =cut sub check { - my($self)=@_; - return "Not a pkg_svc record!" unless $self->table eq "pkg_svc"; - my($recref) = $self->hashref; + my $self = shift; - my($error); - return $error if $error = + my $error; + $error = $self->ut_number('pkgpart') || $self->ut_number('svcpart') || $self->ut_number('quantity') ; + return $error if $error; - return "Unknown pkgpart!" - unless qsearchs('part_pkg',{'pkgpart'=> $self->getfield('pkgpart')}); - - return "Unknown svcpart!" - unless qsearchs('part_svc',{'svcpart'=> $self->getfield('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). + +=cut + +sub part_pkg { + my $self = shift; + qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } ); +} + +=item part_svc + +Returns the FS::part_svc object (see L). + +=cut + +sub part_svc { + my $self = shift; + qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } ); +} + =back -=head1 BUGS +=head1 VERSION -It doesn't properly override FS::Record yet. +$Id: pkg_svc.pm,v 1.4 1999-07-20 10:37:05 ivan Exp $ + +=head1 BUGS =head1 SEE ALSO @@ -162,6 +155,18 @@ ivan@sisd.com 97-nov-13 pod ivan@sisd.com 98-sep-22 +$Log: pkg_svc.pm,v $ +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 +mostly properly OO, some work still to be done with svc_ stuff + + =cut 1;