From: Marc Chantreux Date: Fri, 16 Jan 2009 09:23:27 +0000 (+0000) Subject: _set_defaults_for_add easier to read X-Git-Tag: ontop~123 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=6be431d79edf810a40d4d6853ab85450ebcabfa7;p=koha.git _set_defaults_for_add easier to read Signed-off-by: Galen Charlton --- diff --git a/C4/Items.pm b/C4/Items.pm index 0f7d6a30f3..b637e82998 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1811,20 +1811,8 @@ C sub _set_defaults_for_add { my $item = shift; - - # if dateaccessioned is provided, use it. Otherwise, set to NOW() - if (!(exists $item->{'dateaccessioned'}) || - ($item->{'dateaccessioned'} eq '')) { - # FIXME add check for invalid date - my $today = C4::Dates->new(); - $item->{'dateaccessioned'} = $today->output("iso"); #TODO: check time issues - } - - # various item status fields cannot be null - $item->{'notforloan'} = 0 unless exists $item->{'notforloan'} and defined $item->{'notforloan'} and $item->{'notforloan'} ne ''; - $item->{'damaged'} = 0 unless exists $item->{'damaged'} and defined $item->{'damaged'} and $item->{'damaged'} ne ''; - $item->{'itemlost'} = 0 unless exists $item->{'itemlost'} and defined $item->{'itemlost'} and $item->{'itemlost'} ne ''; - $item->{'wthdrawn'} = 0 unless exists $item->{'wthdrawn'} and defined $item->{'wthdrawn'} and $item->{'wthdrawn'} ne ''; + $item->{dateaccessioned} ||= C4::Dates->new->output('iso'); + $item->{$_} ||= 0 for (qw( notforloan damaged itemlost wthdrawn)); } =head2 _koha_new_item