1 package FS::deploy_zone;
4 use base qw( FS::o2m_Common FS::Record );
5 use FS::Record qw( qsearch qsearchs dbh );
9 FS::deploy_zone - Object methods for deploy_zone records
15 $record = new FS::deploy_zone \%hash;
16 $record = new FS::deploy_zone { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::deploy_zone object represents a geographic zone where a certain kind
29 of service is available. Currently we store this information to generate
30 the FCC Form 477 deployment reports, but it may find other uses later.
32 FS::deploy_zone inherits from FS::Record. The following fields are currently
43 Optional text describing the zone.
47 The agent that serves this zone.
51 The name under which service is marketed in this zone. If null, will
52 default to the agent name.
56 The way the zone geography is defined: "B" for a list of census blocks
57 (used by the FCC for fixed broadband service), "P" for a polygon (for
58 mobile services). See L<FS::deploy_zone_block> and L<FS::deploy_zone_vertex>.
62 The FCC technology code for the type of service available.
66 For mobile service zones, the FCC code for the RF band.
70 "broadband" or "voice"
74 For broadband, the advertised upstream bandwidth in the zone. If multiple
75 speed tiers are advertised, use the highest.
79 For broadband, the advertised downstream bandwidth in the zone.
83 For broadband, the contractually guaranteed upstream bandwidth, if that type
88 For broadband, the contractually guaranteed downstream bandwidth, if that
89 type of service is sold.
93 'Y' if this service is sold for consumer/household use.
97 'Y' if this service is sold to business or institutional use. Not mutually
98 exclusive with is_consumer.
108 Creates a new zone. To add the zone to the database, see L<"insert">.
112 # the new method can be inherited from FS::Record, if a table method is defined
114 sub table { 'deploy_zone'; }
116 =item insert ELEMENTS
118 Adds this record to the database. If there is an error, returns the error,
119 otherwise returns false.
123 # the insert method can be inherited from FS::Record
127 Delete this record from the database.
132 my $oldAutoCommit = $FS::UID::AutoCommit;
133 local $FS::UID::AutoCommit = 0;
134 # clean up linked records
136 my $error = $self->process_o2m(
137 'table' => $self->element_table,
138 'num_col' => 'zonenum',
139 'fields' => 'zonenum',
141 ) || $self->SUPER::delete(@_);
144 dbh->rollback if $oldAutoCommit;
150 =item replace OLD_RECORD
152 Replaces the OLD_RECORD with this one in the database. If there is an error,
153 returns the error, otherwise returns false.
157 # the replace method can be inherited from FS::Record
161 Checks all fields to make sure this is a valid zone record. If there is
162 an error, returns the error, otherwise returns false. Called by the insert
171 $self->ut_numbern('zonenum')
172 || $self->ut_textn('description')
173 || $self->ut_number('agentnum')
174 || $self->ut_foreign_key('agentnum', 'agent', 'agentnum')
175 || $self->ut_alphan('dbaname')
176 || $self->ut_enum('zonetype', [ 'B', 'P' ])
177 || $self->ut_number('technology')
178 || $self->ut_numbern('spectrum')
179 || $self->ut_enum('servicetype', [ 'broadband', 'voice' ])
180 || $self->ut_decimaln('adv_speed_up', 3)
181 || $self->ut_decimaln('adv_speed_down', 3)
182 || $self->ut_decimaln('cir_speed_up', 3)
183 || $self->ut_decimaln('cir_speed_down', 3)
184 || $self->ut_flag('is_consumer')
185 || $self->ut_flag('is_business')
187 return $error if $error;
194 Returns the name of the table that contains the zone's elements (blocks or
201 if ($self->zonetype eq 'B') {
202 return 'deploy_zone_block';
203 } elsif ( $self->zonetype eq 'P') {
204 return 'deploy_zone_vertex';
206 die 'unknown zonetype';