$item->{'itemnumber'} = $itemnumber or return;
- my @fields = qw( itemlost withdrawn );
+ my @fields = qw( itemlost withdrawn damaged );
# Only call GetItem if we need to set an "on" date field
- if ( $item->{itemlost} || $item->{withdrawn} ) {
+ if ( $item->{itemlost} || $item->{withdrawn} || $item->{damaged} ) {
my $pre_mod_item = GetItem( $item->{'itemnumber'} );
for my $field (@fields) {
if ( defined( $item->{$field} )
itemst:
# NOTE: These columns are in the same order as kohastructure.sql, and contain all items
# columns except for the following internal/obsolete fields: stack, more_subfields_xml,
- # cn_sort, permanent_location, itemlost_on, withdrawn_on, issues, renewals and reserves.
+ # cn_sort, permanent_location, damaged_on itemlost_on, withdrawn_on, issues, renewals and
+ # reserves.
-
columnname: barcode
-
--- /dev/null
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "ALTER TABLE items ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
+ $dbh->do( "ALTER TABLE deleteditems ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
+
+ # Always end with this (adjust the bug info)
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17672: Add damaged_on to items and deleteditems tables)\n";
+}
`stack` tinyint(1) default NULL,
`notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
`damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
+ `damaged_on` datetime DEFAULT NULL, -- the date and time an item was last marked as damaged, NULL if not damaged
`itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
`itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
`withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
`stack` tinyint(1) default NULL,
`notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
`damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
+ `damaged_on` datetime DEFAULT NULL, -- the date and time an item was last marked as damaged, NULL if not damaged
`itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
`itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
`withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
<field name="items.itype">Koha itemtype</field>
<field name="items.stocknumber">Inventory number</field>
<field name="items.damaged">Damaged status</field>
+<field name="items.damaged_on">Damaged on</field>
<field name="items.materials">Materials specified</field>
<field name="items.uri">Uniform Resource Identifier</field>
<field name="items.more_subfields_xml">Additional subfields (XML)</field>
[% END %]
</li>
+ [% IF ITEM_DAT.damaged != "" && ITEM_DAT.damaged_on %]
+ <li><span class="label">Damaged on:</span>[% ITEM_DAT.damaged_on | $KohaDates %] </li>
+ [% END %]
[% END %]
[% IF itemwithdrawnloop %]
use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Library;
+use Koha::DateUtils;
use t::lib::Mocks;
use t::lib::TestBuilder;
$schema->storage->txn_rollback;
};
+subtest 'ModItem tests' => sub {
+ plan tests => 6;
+
+ $schema->storage->txn_begin;
+
+ my $builder = t::lib::TestBuilder->new;
+ my $item = $builder->build({
+ source => 'Item',
+ value => {
+ itemlost => 0,
+ damaged => 0,
+ withdrawn => 0,
+ itemlost_on => undef,
+ damaged_on => undef,
+ withdrawn_on => undef,
+ }
+ });
+
+ my @fields = qw( itemlost withdrawn damaged );
+ for my $field (@fields) {
+ $item->{$field} = 1;
+ ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
+ my $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
+ is( output_pref({ str => $post_mod_item->{$field."_on"}, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field"."_on is updated" );
+
+ $item->{$field} = 0;
+ ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
+ $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
+ is( $post_mod_item->{$field."_on"}, undef, "When clearing $field, $field"."_on is cleared" );
+ }
+
+ $schema->storage->txn_rollback;
+
+};
+
subtest 'GetHiddenItemnumbers tests' => sub {
plan tests => 9;
# check if itemlost_on was not touched
$item->{itemlost_on} = '12345678';
$item->{withdrawn_on} = '12/31/2015 23:59:00';
+ $item->{damaged_on} = '01/20/2017 09:00:00';
$orgitem = { %$item };
C4::Items::_mod_item_dates($item);
is_deeply( $item, $orgitem, 'Colums with _on are not touched' );