a6f801f22f91518501aca70292af282c346f27c7
[freeside.git] / site_perl / svc_acct_pop.pm
1 package FS::svc_acct_pop;
2
3 use strict;
4 use vars qw(@ISA @EXPORT_OK);
5 use Exporter;
6 use FS::Record qw(fields qsearchs);
7
8 @ISA = qw(FS::Record Exporter);
9 @EXPORT_OK = qw(fields);
10
11 =head1 NAME
12
13 FS::svc_acct_pop - Object methods for svc_acct_pop records
14
15 =head1 SYNOPSIS
16
17   use FS::svc_acct_pop;
18
19   $record = create FS::svc_acct_pop \%hash;
20   $record = create FS::svc_acct_pop { 'column' => 'value' };
21
22   $error = $record->insert;
23
24   $error = $new_record->replace($old_record);
25
26   $error = $record->delete;
27
28   $error = $record->check;
29
30 =head1 DESCRIPTION
31
32 An FS::svc_acct object represents an point of presence.  FS::svc_acct_pop
33 inherits from FS::Record.  The following fields are currently supported:
34
35 =over 4
36
37 =item popnum - primary key (assigned automatically for new accounts)
38
39 =item city
40
41 =item state
42
43 =item ac - area code
44
45 =item exch - exchange
46
47 =back
48
49 =head1 METHODS
50
51 =over 4
52
53 =item create HASHREF
54
55 Creates a new point of presence (if only it were that easy!).  To add the 
56 point of presence to the database, see L<"insert">.
57
58 =cut
59
60 sub create {
61   my($proto,$hashref)=@_;
62
63   #now in FS::Record::new
64   #my($field);
65   #foreach $field (fields('svc_acct_pop')) {
66   #  $hashref->{$field}='' unless defined $hashref->{$field};
67   #}
68
69   $proto->new('svc_acct_pop',$hashref);
70 }
71
72 =item insert
73
74 Adds this point of presence to the databaes.  If there is an error, returns the
75 error, otherwise returns false.
76
77 =cut
78
79 sub insert {
80   my($self)=@_;
81
82   $self->check or
83   $self->add;
84 }
85
86 =item delete
87
88 Currently unimplemented.
89
90 =cut
91
92 sub delete {
93   my($self)=@_;
94   return "Can't (yet) delete POPs!";
95   #$self->del;
96 }
97
98 =item replace OLD_RECORD
99
100 Replaces OLD_RECORD with this one in the database.  If there is an error,
101 returns the error, otherwise returns false.
102
103 =cut
104
105 sub replace {
106   my($new,$old)=@_;
107   return "(Old) Not an svc_acct_pop record!"
108     unless $old->table eq "svc_acct_pop";
109   return "Can't change popnum!"
110     unless $old->getfield('popnum') eq $new->getfield('popnum');
111   $new->check or
112   $new->rep($old);
113 }
114
115 =item check
116
117 Checks all fields to make sure this is a valid point of presence.  If there is
118 an error, returns the error, otherwise returns false.  Called by the insert
119 and replace methods.
120
121 =cut
122
123 sub check {
124   my($self)=@_;
125   return "Not a svc_acct_pop record!" unless $self->table eq "svc_acct_pop";
126
127   my($error)=
128     $self->ut_numbern('popnum')
129       or $self->ut_text('city')
130       or $self->ut_text('state')
131       or $self->ut_number('ac')
132       or $self->ut_number('exch')
133   ;
134   return $error if $error;
135
136   '';
137
138 }
139
140 =back
141
142 =head1 BUGS
143
144 It doesn't properly override FS::Record yet.
145
146 It should be renamed to part_pop.
147
148 =head1 SEE ALSO
149
150 L<FS::Record>, L<svc_acct>, schema.html from the base documentation.
151
152 =head1 HISTORY
153
154 Class dealing with pops 
155
156 ivan@sisd.com 98-mar-8 
157
158 pod ivan@sisd.com 98-sep-23
159
160 =cut
161
162 1;
163