e75f17c6e77aaf73135d541e61eb87792adb6e60
[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   # critical checks
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   push @errors, $::locale->text('The Host Name is missing')    unless $self->{server};
23   push @errors, $::locale->text('The Host Name seems invalid') unless $self->{server} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
24   push @errors, $::locale->text('Orders to fetch neeeds a positive Integer')
25                                                                unless $self->{orders_to_fetch} > 0;
26   return @errors;
27 }
28
29 sub shops_dd {
30   my ( $self ) = @_;
31
32   my @shops_dd = ( { title => t8("all") ,   value =>'' } );
33   my $shops = SL::DB::Manager::Shop->get_all( where => [ obsolete => 0 ] );
34   my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
35   push @shops_dd, @tmp;
36   return \@shops_dd;
37 }
38
39 1;
40
41 __END__
42
43 =pod
44
45 =encoding utf-8
46
47 =head1 NAME
48
49 SL::DB::Shop - Model for the 'shops' table
50
51 =head1 SYNOPSIS
52
53 This is a standard Rose::DB::Object based model and can be used as one.
54
55 =head1 METHODS
56
57 =over 4
58
59 =item C<validate>
60
61 Returns an error if the shop description is missing
62
63 =item C<shops_dd>
64
65 Returns an array of hashes for dropdowns in filters
66
67 =back
68
69 =head1 AUTHORS
70
71 Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
72
73 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
74
75 =cut