6 use FS::Record qw( qsearchs );
14 @ISA = qw( FS::Record );
18 FS::cust_svc - Object method for cust_svc objects
24 $record = new FS::cust_svc \%hash
25 $record = new FS::cust_svc { 'column' => 'value' };
27 $error = $record->insert;
29 $error = $new_record->replace($old_record);
31 $error = $record->delete;
33 $error = $record->check;
35 ($label, $value) = $record->label;
39 An FS::cust_svc represents a service. FS::cust_svc inherits from FS::Record.
40 The following fields are currently supported:
44 =item svcnum - primary key (assigned automatically for new services)
46 =item pkgnum - Package (see L<FS::cust_pkg>)
48 =item svcpart - Service definition (see L<FS::part_svc>)
58 Creates a new service. To add the refund to the database, see L<"insert">.
59 Services are normally created by creating FS::svc_ objects (see
60 L<FS::svc_acct>, L<FS::svc_domain>, and L<FS::svc_acct_sm>, among others).
64 sub table { 'cust_svc'; }
68 Adds this service to the database. If there is an error, returns the error,
69 otherwise returns false.
73 Deletes this service from the database. If there is an error, returns the
74 error, otherwise returns false.
76 Called by the cancel method of the package (see L<FS::cust_pkg>).
78 =item replace OLD_RECORD
80 Replaces the OLD_RECORD with this one in the database. If there is an error,
81 returns the error, otherwise returns false.
85 Checks all fields to make sure this is a valid service. If there is an error,
86 returns the error, otehrwise returns false. Called by the insert and
95 $self->ut_numbern('svcnum')
96 || $self->ut_numbern('pkgnum')
97 || $self->ut_number('svcpart')
99 return $error if $error;
101 return "Unknown pkgnum"
102 unless ! $self->pkgnum
103 || qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
105 return "Unknown svcpart" unless
106 qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
113 Returns a list consisting of:
114 - The name of this service (from part_svc)
115 - A meaningful identifier (username, domain, or mail alias)
116 - The table name (i.e. svc_domain) for this service
122 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
123 my $svcdb = $part_svc->svcdb;
124 my $svc_x = qsearchs( $svcdb, { 'svcnum' => $self->svcnum } );
125 my $svc = $part_svc->svc;
127 if ( $svcdb eq 'svc_acct' ) {
128 $tag = $svc_x->getfield('username');
129 } elsif ( $svcdb eq 'svc_acct_sm' ) {
130 my $domuser = $svc_x->domuser eq '*' ? '(anything)' : $svc_x->domuser;
131 my $svc_domain = qsearchs ( 'svc_domain', { 'svcnum' => $svc_x->domsvc } );
132 my $domain = $svc_domain->domain;
133 $tag = "$domuser\@$domain";
134 } elsif ( $svcdb eq 'svc_domain' ) {
135 $tag = $svc_x->getfield('domain');
137 cluck "warning: asked for label of unsupported svcdb; using svcnum";
138 $tag = $svc_x->getfield('svcnum');
147 $Id: cust_svc.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
151 Behaviour of changing the svcpart of cust_svc records is undefined and should
152 possibly be prohibited, and pkg_svc records are not checked.
154 pkg_svc records are not checked in general (here).
156 Deleting this record doesn't check or delete the svc_* record associated
161 L<FS::Record>, L<FS::cust_pkg>, L<FS::part_svc>, L<FS::pkg_svc>,
162 schema.html from the base documentation