enable CardFortress in test database, #71513
[freeside.git] / FS / FS / deploy_zone_block.pm
1 package FS::deploy_zone_block;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::deploy_zone_block - Object methods for deploy_zone_block records
10
11 =head1 SYNOPSIS
12
13   use FS::deploy_zone_block;
14
15   $record = new FS::deploy_zone_block \%hash;
16   $record = new FS::deploy_zone_block { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::deploy_zone_block object represents a census block that's part of
29 a deployment zone.  FS::deploy_zone_block inherits from FS::Record.  The 
30 following fields are currently supported:
31
32 =over 4
33
34 =item blocknum
35
36 primary key
37
38 =item zonenum
39
40 L<FS::deploy_zone> foreign key for the zone.
41
42 =item censusblock
43
44 U.S. census block number (15 digits).
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new block entry.  To add the recordto the database, see L<"insert">.
55
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to.  You can ask the object for a copy with the I<hash> method.
58
59 =cut
60
61 # the new method can be inherited from FS::Record, if a table method is defined
62
63 sub table { 'deploy_zone_block'; }
64
65 =item insert
66
67 Adds this record to the database.  If there is an error, returns the error,
68 otherwise returns false.
69
70 =cut
71
72 # the insert method can be inherited from FS::Record
73
74 =item delete
75
76 Delete this record from the database.
77
78 =cut
79
80 # the delete method can be inherited from FS::Record
81
82 =item replace OLD_RECORD
83
84 Replaces the OLD_RECORD with this one in the database.  If there is an error,
85 returns the error, otherwise returns false.
86
87 =cut
88
89 # the replace method can be inherited from FS::Record
90
91 =item check
92
93 Checks all fields to make sure this is a valid record.  If there is
94 an error, returns the error, otherwise returns false.  Called by the insert
95 and replace methods.
96
97 =cut
98
99 sub check {
100   my $self = shift;
101
102   my $error = 
103     $self->ut_numbern('blocknum')
104     || $self->ut_number('zonenum')
105     || $self->ut_number('censusblock')
106   ;
107   return $error if $error;
108
109   if ($self->get('censusblock') !~ /^(\d{15})$/) {
110     return "Illegal census block number (must be 15 digits)";
111   }
112
113   $self->SUPER::check;
114 }
115
116 =back
117
118 =head1 SEE ALSO
119
120 L<FS::Record>
121
122 =cut
123
124 1;
125