Revision e5097146
Von Bernd Bleßmann vor mehr als 4 Jahren hinzugefügt
SL/DB/Shipto.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use Carp; |
6 |
use List::MoreUtils qw(all); |
|
7 |
|
|
8 |
use SL::Util qw(trim); |
|
6 | 9 |
|
7 | 10 |
use SL::DB::MetaSetup::Shipto; |
8 | 11 |
use SL::DB::Manager::Shipto; |
... | ... | |
16 | 19 |
|
17 | 20 |
__PACKAGE__->meta->initialize; |
18 | 21 |
|
22 |
|
|
19 | 23 |
sub displayable_id { |
20 | 24 |
my $self = shift; |
21 | 25 |
my $text = join('; ', grep { $_ } (map({ $self->$_ } qw(shiptoname shiptostreet)), |
... | ... | |
40 | 44 |
|| SL::DB::Manager::DeliveryOrder->get_all_count(query => [ shipto_id => $self->shipto_id ]); |
41 | 45 |
} |
42 | 46 |
|
47 |
sub is_empty { |
|
48 |
my ($self) = @_; |
|
49 |
|
|
50 |
# todo: consider cvars |
|
51 |
my @fields_to_consider = grep { !m{^ (?: itime | mtime | shipto_id | trans_id | shiptocp_gender | module ) $}x } map {$_->name} $self->meta->columns; |
|
52 |
|
|
53 |
return all { trim($self->$_) eq '' } @fields_to_consider; |
|
54 |
} |
|
55 |
|
|
43 | 56 |
sub detach { |
44 | 57 |
$_[0]->trans_id(undef); |
45 | 58 |
$_[0]; |
... | ... | |
90 | 103 |
|
91 | 104 |
=over 4 |
92 | 105 |
|
106 |
=item C<is_empty> |
|
107 |
|
|
108 |
Returns truish if all fields to consider are empty, falsish if not. |
|
109 |
Fields are trimmed before the test is performed. |
|
110 |
C<shiptocp_gender> is not considered because in forms this is usually |
|
111 |
a selection with 'm' as default value. |
|
112 |
CVar fields are not considered by now. |
|
113 |
|
|
114 |
=back |
|
115 |
|
|
116 |
=over 4 |
|
117 |
|
|
93 | 118 |
=item C<clone $target> |
94 | 119 |
|
95 | 120 |
Creates and returns a clone of the current object. The mandatory |
Auch abrufbar als: Unified diff
S/D/Shipto: Methode is_empty, um auf leere Lieferadresse zu prüfen