Shopware-Proxy: Leeren Wert '' erlauben und danach regex prüfen
[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('The Proxy Name seems invalid') unless $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
25   push @errors, $::locale->text('The Proxy Name seems invalid') . $self->{proxy} . ':' unless !$self->{proxy} ||  $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
26   push @errors, $::locale->text('Orders to fetch neeeds a positive Integer')
27                                                                unless $self->{orders_to_fetch} > 0;
28
29   # not yet implemented checks
30   push @errors, $::locale->text('Transaction Description is not yet implemented')    if $self->{transaction_description};
31   if ($self->{connector} eq 'shopware6') {
32     push @errors, $::locale->text('Shipping cost article is not implemented')        if $self->{shipping_costs_parts_id};
33     push @errors, $::locale->text('Fetch from last order number is not implemented') if $self->{last_order_number};
34   } else {
35     push @errors, $::locale->text('Use Long Description from Parts is only for Shopware6 implemented')
36       if $self->{use_part_longdescription};
37   }
38   return @errors;
39 }
40
41 sub shops_dd {
42   my ( $self ) = @_;
43
44   my @shops_dd = ( { title => t8("all") ,   value =>'' } );
45   my $shops = SL::DB::Manager::Shop->get_all( where => [ obsolete => 0 ] );
46   my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
47   push @shops_dd, @tmp;
48   return \@shops_dd;
49 }
50
51 1;
52
53 __END__
54
55 =pod
56
57 =encoding utf-8
58
59 =head1 NAME
60
61 SL::DB::Shop - Model for the 'shops' table
62
63 =head1 SYNOPSIS
64
65 This is a standard Rose::DB::Object based model and can be used as one.
66
67 =head1 METHODS
68
69 =over 4
70
71 =item C<validate>
72
73 Returns an error if the shop description is missing
74
75 =item C<shops_dd>
76
77 Returns an array of hashes for dropdowns in filters
78
79 =back
80
81 =head1 AUTHORS
82
83 Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
84
85 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
86
87 =cut