63f988f03a608763ba9415911a40c57555cfba86
[kivitendo-erp.git] / SL / DB / Shop.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::Shop;
5
6 use strict;
7
8 use SL::DB::MetaSetup::Shop;
9 use SL::DB::Manager::Shop;
10 use SL::DB::Helper::ActsAsList;
11 use SL::Locale::String qw(t8);
12
13 __PACKAGE__->meta->initialize;
14
15 sub validate {
16   my ($self) = @_;
17
18   my @errors;
19
20   push @errors, $::locale->text('The description is missing.') unless $self->{description};
21   push @errors, $::locale->text('The path is missing.') unless $self->{path};
22
23   return @errors;
24 }
25
26 sub shops_dd {
27   my ( $self ) = @_;
28
29   my @shops_dd = ( { title => t8("all") ,   value =>'' } );
30   my $shops = SL::DB::Manager::Shop->get_all( where => [ obsolete => 0 ] );
31   my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
32   push @shops_dd, @tmp;
33   return \@shops_dd;
34 }
35
36 1;
37
38 __END__
39
40 =pod
41
42 =encoding utf-8
43
44 =head1 NAME
45
46 SL::DB::Shop - Model for the 'shops' table
47
48 =head1 SYNOPSIS
49
50 This is a standard Rose::DB::Object based model and can be used as one.
51
52 =head1 METHODS
53
54 =over 4
55
56 =item C<validate>
57
58 Returns an error if the shop description is missing
59
60 =item C<shops_dd>
61
62 Returns an array of hashes for dropdowns in filters
63
64 =back
65
66 =head1 AUTHORS
67
68 Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
69
70 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
71
72 =cut