6 use FS::Record qw( qsearchs );
15 @ISA = qw( FS::Record );
19 FS::cust_svc - Object method for cust_svc objects
25 $record = new FS::cust_svc \%hash
26 $record = new FS::cust_svc { 'column' => 'value' };
28 $error = $record->insert;
30 $error = $new_record->replace($old_record);
32 $error = $record->delete;
34 $error = $record->check;
36 ($label, $value) = $record->label;
40 An FS::cust_svc represents a service. FS::cust_svc inherits from FS::Record.
41 The following fields are currently supported:
45 =item svcnum - primary key (assigned automatically for new services)
47 =item pkgnum - Package (see L<FS::cust_pkg>)
49 =item svcpart - Service definition (see L<FS::part_svc>)
59 Creates a new service. To add the refund to the database, see L<"insert">.
60 Services are normally created by creating FS::svc_ objects (see
61 L<FS::svc_acct>, L<FS::svc_domain>, and L<FS::svc_acct_sm>, among others).
65 sub table { 'cust_svc'; }
69 Adds this service to the database. If there is an error, returns the error,
70 otherwise returns false.
74 Deletes this service from the database. If there is an error, returns the
75 error, otherwise returns false.
77 Called by the cancel method of the package (see L<FS::cust_pkg>).
79 =item replace OLD_RECORD
81 Replaces the OLD_RECORD with this one in the database. If there is an error,
82 returns the error, otherwise returns false.
86 Checks all fields to make sure this is a valid service. If there is an error,
87 returns the error, otehrwise returns false. Called by the insert and
96 $self->ut_numbern('svcnum')
97 || $self->ut_numbern('pkgnum')
98 || $self->ut_number('svcpart')
100 return $error if $error;
102 return "Unknown pkgnum"
103 unless ! $self->pkgnum
104 || qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
106 return "Unknown svcpart" unless
107 qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
114 Returns a list consisting of:
115 - The name of this service (from part_svc)
116 - A meaningful identifier (username, domain, or mail alias)
117 - The table name (i.e. svc_domain) for this service
123 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
124 my $svcdb = $part_svc->svcdb;
125 my $svc_x = qsearchs( $svcdb, { 'svcnum' => $self->svcnum } )
126 or die "can't find $svcdb.svcnum ". $self->svcnum;
127 my $svc = $part_svc->svc;
129 if ( $svcdb eq 'svc_acct' ) {
130 $tag = $svc_x->email;
131 } elsif ( $svcdb eq 'svc_acct_sm' ) {
132 my $domuser = $svc_x->domuser eq '*' ? '(anything)' : $svc_x->domuser;
133 my $svc_domain = qsearchs ( 'svc_domain', { 'svcnum' => $svc_x->domsvc } );
134 my $domain = $svc_domain->domain;
135 $tag = "$domuser\@$domain";
136 } elsif ( $svcdb eq 'svc_forward' ) {
137 my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_x->srcsvc } );
138 $tag = $svc_acct->email. '->';
139 if ( $svc_x->dstsvc ) {
140 $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_x->dstsvc } );
141 $tag .= $svc_acct->email;
145 } elsif ( $svcdb eq 'svc_domain' ) {
146 $tag = $svc_x->getfield('domain');
148 cluck "warning: asked for label of unsupported svcdb; using svcnum";
149 $tag = $svc_x->getfield('svcnum');
158 $Id: cust_svc.pm,v 1.4 2001-09-02 04:51:11 ivan Exp $
162 Behaviour of changing the svcpart of cust_svc records is undefined and should
163 possibly be prohibited, and pkg_svc records are not checked.
165 pkg_svc records are not checked in general (here).
167 Deleting this record doesn't check or delete the svc_* record associated
172 L<FS::Record>, L<FS::cust_pkg>, L<FS::part_svc>, L<FS::pkg_svc>,
173 schema.html from the base documentation