View | Details | Raw Unified | Return to bug 9673
Collapse All | Expand All

(-)a/C4/Items.pm (-6 / +23 lines)
Lines 31-38 use C4::ClassSource; Link Here
31
use C4::Log;
31
use C4::Log;
32
use List::MoreUtils qw/any/;
32
use List::MoreUtils qw/any/;
33
use YAML qw/Load/;
33
use YAML qw/Load/;
34
use DateTime::Format::MySQL;
34
use Data::Dumper; # used as part of logging item record changes, not just for
35
use Data::Dumper; # used as part of logging item record changes, not just for
35
                  # debugging; so please don't remove this
36
                  # debugging; so please don't remove this
37
use Koha::DateUtils qw/dt_from_string/;
36
38
37
use vars qw($VERSION @ISA @EXPORT);
39
use vars qw($VERSION @ISA @EXPORT);
38
40
Lines 536-551 sub ModItem { Link Here
536
538
537
    $item->{onloan} = undef if $item->{itemlost};
539
    $item->{onloan} = undef if $item->{itemlost};
538
540
539
    for my $field ( qw( itemlost withdrawn ) ) {
541
    my @fields = qw( itemlost withdrawn );
540
        if ( defined( $item->{$field} ) ) {
542
541
            if ( $item->{$field} ) {
543
    # Only call GetItem if we need to set an "on" date field
542
                $item->{$field . '_on'} = DateTime::Format::MySQL->format_datetime( DateTime->now() );
544
    if ( $item->{itemlost} || $item->{withdrawn} ) {
543
            } else {
545
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
544
                $item->{$field . '_on'} = undef;
546
        for my $field (@fields) {
547
            if (    defined( $item->{$field} )
548
                and not $pre_mod_item->{$field}
549
                and $item->{$field} )
550
            {
551
                $item->{ $field . '_on' } =
552
                  DateTime::Format::MySQL->format_datetime( dt_from_string() );
545
            }
553
            }
546
        }
554
        }
547
    }
555
    }
548
556
557
    # If the field is defined but empty, we are removing and,
558
    # and thus need to clear out the 'on' field as well
559
    for my $field (@fields) {
560
        if ( defined( $item->{$field} ) && !$item->{$field} ) {
561
            $item->{ $field . '_on' } = undef;
562
        }
563
    }
564
565
549
    _set_derived_columns_for_mod($item);
566
    _set_derived_columns_for_mod($item);
550
    _do_column_fixes_for_mod($item);
567
    _do_column_fixes_for_mod($item);
551
    # FIXME add checks
568
    # FIXME add checks
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 868-874 CREATE TABLE `deleteditems` ( Link Here
868
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
868
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
869
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
869
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
870
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
870
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
871
  `wthdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
871
  `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
872
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
872
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
873
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
873
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
874
  `issues` smallint(6) default NULL, -- number of times this item has been checked out
874
  `issues` smallint(6) default NULL, -- number of times this item has been checked out
Lines 1162-1168 CREATE TABLE `items` ( -- holdings/item information Link Here
1162
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
1162
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
1163
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
1163
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
1164
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
1164
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
1165
  `wthdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
1165
  `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
1166
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
1166
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
1167
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
1167
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
1168
  `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
1168
  `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +2 lines)
Lines 7158-7166 if ( CheckVersion($DBversion) ) { Link Here
7158
$DBversion = "3.13.00.XXX";
7158
$DBversion = "3.13.00.XXX";
7159
if ( CheckVersion($DBversion) ) {
7159
if ( CheckVersion($DBversion) ) {
7160
   $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7160
   $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7161
   $dbh->do("ALTER TABLE items ADD wthdrawn_on DATETIME NULL AFTER wthdrawn");
7161
   $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER wthdrawn");
7162
   $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7162
   $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7163
   $dbh->do("ALTER TABLE deleteditems ADD wthdrawn_on DATETIME NULL AFTER wthdrawn");
7163
   $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER wthdrawn");
7164
   print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7164
   print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7165
   SetVersion ($DBversion);
7165
   SetVersion ($DBversion);
7166
}
7166
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-2 / +1 lines)
Lines 177-183 Link Here
177
                    </form>
177
                    </form>
178
                [% END %]
178
                [% END %]
179
            </li>
179
            </li>
180
            [% IF ITEM_DAT.wthdrawn_on %]<li><span class="label">Withdrawn on:</span>[% ITEM_DAT.wthdrawn_on | $KohaDates %] &nbsp;</li>[% END %]
180
            [% IF ITEM_DAT.withdrawn_on %]<li><span class="label">Withdrawn on:</span>[% ITEM_DAT.withdrawn_on | $KohaDates %] &nbsp;</li>[% END %]
181
            </ol></div>
181
            </ol></div>
182
            <div class="listgroup"><h4>History</h4>
182
            <div class="listgroup"><h4>History</h4>
183
            <ol class="bibliodetails">
183
            <ol class="bibliodetails">
184
- 

Return to bug 9673