RT# 83450 - fixed rateplan export
[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 installdate - Installation date (as Unix timestamp)
40
41 =item note - Installation notes: location on property, physical access, etc.
42
43 =back
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new HASHREF
50
51 Creates a new svc_dish object.
52
53 =cut
54
55 sub table { 'svc_dish'; }
56
57 sub table_info {
58   my %opts = ( 'type' => 'text', 
59                'disable_select' => 1,
60                'disable_inventory' => 1,
61              );
62   {
63     'name'           => 'Dish service',
64     'display_weight' => 58,
65     'cancel_weight'  => 85,
66     'manual_require' => 1,
67     'fields' => {
68       'svcnum'    =>  { label => 'Service' },
69       'acctnum'   =>  { label => 'DISH account#', required => 1, %opts },
70       'installdate' => { label => 'Install date', %opts },
71       'note'      => { label => 'Installation notes', %opts },
72     }
73   }
74 }
75
76 sub label {
77   my $self = shift;
78   $self->acctnum;
79 }
80
81 sub search_sql {
82   my($class, $string) = @_;
83   $class->search_sql_field('acctnum', $string);
84 }
85
86 =item insert
87
88 Adds this record to the database.  If there is an error, returns the error,
89 otherwise returns false.
90
91 =item delete
92
93 Delete this record from the database.
94
95 =item replace OLD_RECORD
96
97 Replaces the OLD_RECORD with this one in the database.  If there is an error,
98 returns the error, otherwise returns false.
99
100 # the replace method can be inherited from FS::Record
101
102 =item check
103
104 Checks all fields to make sure this is a valid service.  If there is
105 an error, returns the error, otherwise returns false.  Called by the insert
106 and replace methods.
107
108 =cut
109
110 sub check {
111   my $self = shift;
112
113   my $x = $self->setfixed;
114   return $x unless ref $x;
115
116   my $error = 
117     $self->ut_numbern('svcnum')
118     || $self->ut_text('acctnum')
119     || $self->ut_numbern('installdate')
120     || $self->ut_anything('note')
121   ;
122   return $error if $error;
123
124   $self->SUPER::check;
125 }
126
127 =back
128
129 =head1 SEE ALSO
130
131 L<FS::Record>, L<FS::svc_Common>, schema.html from the base documentation.
132
133 =cut
134
135 1;
136