projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[freeside.git]
/
site_perl
/
agent.pm
diff --git
a/site_perl/agent.pm
b/site_perl/agent.pm
index
7fc370e
..
cc4fb10
100644
(file)
--- a/
site_perl/agent.pm
+++ b/
site_perl/agent.pm
@@
-1,12
+1,12
@@
package FS::agent;
use strict;
package FS::agent;
use strict;
-use vars qw(@ISA @EXPORT_OK);
-use Exporter;
-use FS::Record qw(fields qsearch qsearchs);
+use vars qw( @ISA );
+use FS::Record qw( qsearch qsearchs );
+use FS::cust_main;
+use FS::agent_type;
-@ISA = qw(FS::Record Exporter);
-@EXPORT_OK = qw(fields);
+@ISA = qw( FS::Record );
=head1 NAME
=head1 NAME
@@
-16,8
+16,8
@@
FS::agent - Object methods for agent records
use FS::agent;
use FS::agent;
- $record =
create
FS::agent \%hash;
- $record =
create
FS::agent { 'column' => 'value' };
+ $record =
new
FS::agent \%hash;
+ $record =
new
FS::agent { 'column' => 'value' };
$error = $record->insert;
$error = $record->insert;
@@
-51,38
+51,19
@@
from FS::Record. The following fields are currently supported:
=over 4
=over 4
-=item
create
HASHREF
+=item
new
HASHREF
Creates a new agent. To add the agent to the database, see L<"insert">.
=cut
Creates a new agent. To add the agent to the database, see L<"insert">.
=cut
-sub create {
- my($proto,$hashref)=@_;
-
- #now in FS::Record::new
- #my($field);
- #foreach $field (fields('agent')) {
- # $hashref->{$field}='' unless defined $hashref->{$field};
- #}
-
- $proto->new('agent',$hashref);
-}
+sub table { 'agent'; }
=item insert
Adds this agent to the database. If there is an error, returns the error,
otherwise returns false.
=item insert
Adds this agent 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 agent from the database. Only agents with no customers can be
=item delete
Deletes this agent from the database. Only agents with no customers can be
@@
-91,10
+72,12
@@
deleted. If there is an error, returns the error, otherwise returns false.
=cut
sub delete {
=cut
sub delete {
- my($self)=@_;
+ my $self = shift;
+
return "Can't delete an agent with customers!"
return "Can't delete an agent with customers!"
- if qsearch('cust_main',{'agentnum' => $self->agentnum});
- $self->del;
+ if qsearch( 'cust_main', { 'agentnum' => $self->agentnum } );
+
+ $self->SUPER::delete;
}
=item replace OLD_RECORD
}
=item replace OLD_RECORD
@@
-102,17
+85,6
@@
sub delete {
Replaces OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
Replaces OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
-=cut
-
-sub replace {
- my($new,$old)=@_;
- return "(Old) Not an agent record!" unless $old->table eq "agent";
- return "Can't change agentnum!"
- unless $old->getfield('agentnum') eq $new->getfield('agentnum');
- $new->check or
- $new->rep($old);
-}
-
=item check
Checks all fields to make sure this is a valid agent. If there is an error,
=item check
Checks all fields to make sure this is a valid agent. If there is an error,
@@
-122,20
+94,19
@@
methods.
=cut
sub check {
=cut
sub check {
- my($self)=@_;
- return "Not a agent record!" unless $self->table eq "agent";
+ my $self = shift;
- my
($error)
=
+ my
$error
=
$self->ut_numbern('agentnum')
$self->ut_numbern('agentnum')
-
or
$self->ut_text('agent')
-
or
$self->ut_number('typenum')
-
or
$self->ut_numbern('freq')
-
or
$self->ut_textn('prog')
+
||
$self->ut_text('agent')
+
||
$self->ut_number('typenum')
+
||
$self->ut_numbern('freq')
+
||
$self->ut_textn('prog')
;
return $error if $error;
return "Unknown typenum!"
;
return $error if $error;
return "Unknown typenum!"
- unless qsearchs(
'agent_type',{'typenum'=> $self->getfield('typenum') }
);
+ unless qsearchs(
'agent_type', { 'typenum' => $self->typenum }
);
'';
'';
@@
-143,9
+114,11
@@
sub check {
=back
=back
-=head1
BUGS
+=head1
VERSION
-It doesn't properly override FS::Record yet.
+$Id: agent.pm,v 1.4 1998-12-30 00:30:44 ivan Exp $
+
+=head1 BUGS
=head1 SEE ALSO
=head1 SEE ALSO