This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / svc_dish.pm
1 package FS::svc_dish;
2
3 use strict;
4 use base qw( FS::svc_Common );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::svc_dish - Object methods for svc_dish records
10
11 =head1 SYNOPSIS
12
13   use FS::svc_dish;
14
15   $record = new FS::svc_dish \%hash;
16   $record = new FS::svc_dish { '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::svc_dish object represents a Dish Network service.  FS::svc_dish 
29 inherits from FS::svc_Common.
30
31 The following fields are currently supported:
32
33 =over 4
34
35 =item svcnum - Primary key
36
37 =item acctnum - DISH account number
38
39 =item note - Installation notes: location on property, physical access, etc.
40
41 =back
42
43 =head1 METHODS
44
45 =over 4
46
47 =item new HASHREF
48
49 Creates a new svc_dish object.
50
51 =cut
52
53 sub table { 'svc_dish'; }
54
55 sub table_info {
56   my %opts = ( 'type' => 'text', 
57                'disable_select' => 1,
58                'disable_inventory' => 1,
59              );
60   {
61     'name'           => 'Dish service',
62     'display_weight' => 58,
63     'cancel_weight'  => 85,
64     'fields' => {
65       'svcnum'    => { label => 'Service' },
66       'acctnum'   => { label => 'DISH account#', %opts },
67       'note'      => { label => 'Installation notes', %opts },
68     }
69   }
70 }
71
72 sub label {
73   my $self = shift;
74   $self->acctnum;
75 }
76
77 sub search_sql {
78   my($class, $string) = @_;
79   $class->search_sql_field('acctnum', $string);
80 }
81
82 =item insert
83
84 Adds this record to the database.  If there is an error, returns the error,
85 otherwise returns false.
86
87 =item delete
88
89 Delete this record from the database.
90
91 =item replace OLD_RECORD
92
93 Replaces the OLD_RECORD with this one in the database.  If there is an error,
94 returns the error, otherwise returns false.
95
96 # the replace method can be inherited from FS::Record
97
98 =item check
99
100 Checks all fields to make sure this is a valid service.  If there is
101 an error, returns the error, otherwise returns false.  Called by the insert
102 and replace methods.
103
104 =cut
105
106 sub check {
107   my $self = shift;
108
109   my $x = $self->setfixed;
110   return $x unless ref $x;
111
112   my $error = 
113     $self->ut_numbern('svcnum')
114     || $self->ut_text('acctnum')
115     || $self->ut_textn('note')
116   ;
117   return $error if $error;
118
119   $self->SUPER::check;
120 }
121
122 =back
123
124 =head1 SEE ALSO
125
126 L<FS::Record>, L<FS::svc_Common>, schema.html from the base documentation.
127
128 =cut
129
130 1;
131