From 05a2de23366aba7011e42eb3678e8e875bd8174e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 20 Feb 2013 09:34:38 -0500 Subject: [PATCH] Bug 9673 - Track when items are marked as lost or withdrawn Add date fields to track when an item was marked as lost or withdrawn. Display those fields on catalogue/moredetail.pl Test Plan: 1) Apply patch 2) Run updatedatabase.pl 3) Pick a record with items, browse to the 'items' tab ( moredetail.pl ) 4) Mark an item as lost, verify the field "Lost on:" displays below the "Lost status" field with todays date. 5) Mark the item as not lost, verify the field no longer displays 6) Repeat steps 4 and 5 with the Withdrawn field. Signed-off-by: Mathieu Saby Signed-off-by: Kyle M Hall --- C4/Items.pm | 10 ++++++++++ installer/data/mysql/kohastructure.sql | 4 ++++ installer/data/mysql/updatedatabase.pl | 10 ++++++++++ .../prog/en/modules/catalogue/moredetail.tt | 2 ++ 4 files changed, 26 insertions(+), 0 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 8116c22..050f1c4 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -536,6 +536,16 @@ sub ModItem { $item->{onloan} = undef if $item->{itemlost}; + for my $field ( qw( itemlost withdrawn ) ) { + if ( defined( $item->{$field} ) ) { + if ( $item->{$field} ) { + $item->{$field . '_on'} = DateTime::Format::MySQL->format_datetime( DateTime->now() ); + } else { + $item->{$field . '_on'} = undef; + } + } + } + _set_derived_columns_for_mod($item); _do_column_fixes_for_mod($item); # FIXME add checks diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index fdab879..23f851e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -866,7 +866,9 @@ CREATE TABLE `deleteditems` ( `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) `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) + `wthdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o) `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f) `issues` smallint(6) default NULL, -- number of times this item has been checked out @@ -1158,7 +1160,9 @@ CREATE TABLE `items` ( -- holdings/item information `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) `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) + `wthdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o) `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f) `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a37ea02..bdc684c 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7155,6 +7155,16 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost"); + $dbh->do("ALTER TABLE items ADD wthdrawn_on DATETIME NULL AFTER wthdrawn"); + $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost"); + $dbh->do("ALTER TABLE deleteditems ADD wthdrawn_on DATETIME NULL AFTER wthdrawn"); + print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt index 40798eb..5008bdb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -127,6 +127,7 @@   [% END %] + [% IF ITEM_DAT.itemlost_on %]
  • Lost on:[% ITEM_DAT.itemlost_on | $KohaDates %]  
  • [% END %] [% END %] [% IF ( ITEM_DAT.itemdamagedloop ) %]
  • Damaged status: @@ -176,6 +177,7 @@ [% END %]
  • + [% IF ITEM_DAT.wthdrawn_on %]
  • Withdrawn on:[% ITEM_DAT.wthdrawn_on | $KohaDates %]  
  • [% END %]

    History

      -- 1.7.2.5