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

(-)a/C4/Items.pm (-6 / +23 lines)
Lines 30-37 use MARC::Record; Link Here
30
use C4::ClassSource;
30
use C4::ClassSource;
31
use C4::Log;
31
use C4::Log;
32
use List::MoreUtils qw/any/;
32
use List::MoreUtils qw/any/;
33
use DateTime::Format::MySQL;
33
use Data::Dumper; # used as part of logging item record changes, not just for
34
use Data::Dumper; # used as part of logging item record changes, not just for
34
                  # debugging; so please don't remove this
35
                  # debugging; so please don't remove this
36
use Koha::DateUtils qw/dt_from_string/;
35
37
36
use vars qw($VERSION @ISA @EXPORT);
38
use vars qw($VERSION @ISA @EXPORT);
37
39
Lines 535-550 sub ModItem { Link Here
535
537
536
    $item->{onloan} = undef if $item->{itemlost};
538
    $item->{onloan} = undef if $item->{itemlost};
537
539
538
    for my $field ( qw( itemlost withdrawn ) ) {
540
    my @fields = qw( itemlost withdrawn );
539
        if ( defined( $item->{$field} ) ) {
541
540
            if ( $item->{$field} ) {
542
    # Only call GetItem if we need to set an "on" date field
541
                $item->{$field . '_on'} = DateTime::Format::MySQL->format_datetime( DateTime->now() );
543
    if ( $item->{itemlost} || $item->{withdrawn} ) {
542
            } else {
544
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
543
                $item->{$field . '_on'} = undef;
545
        for my $field (@fields) {
546
            if (    defined( $item->{$field} )
547
                and not $pre_mod_item->{$field}
548
                and $item->{$field} )
549
            {
550
                $item->{ $field . '_on' } =
551
                  DateTime::Format::MySQL->format_datetime( dt_from_string() );
544
            }
552
            }
545
        }
553
        }
546
    }
554
    }
547
555
556
    # If the field is defined but empty, we are removing and,
557
    # and thus need to clear out the 'on' field as well
558
    for my $field (@fields) {
559
        if ( defined( $item->{$field} ) && !$item->{$field} ) {
560
            $item->{ $field . '_on' } = undef;
561
        }
562
    }
563
564
548
    _set_derived_columns_for_mod($item);
565
    _set_derived_columns_for_mod($item);
549
    _do_column_fixes_for_mod($item);
566
    _do_column_fixes_for_mod($item);
550
    # FIXME add checks
567
    # 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 7045-7053 if ( CheckVersion($DBversion) ) { Link Here
7045
$DBversion = "3.13.00.XXX";
7045
$DBversion = "3.13.00.XXX";
7046
if ( CheckVersion($DBversion) ) {
7046
if ( CheckVersion($DBversion) ) {
7047
   $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7047
   $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7048
   $dbh->do("ALTER TABLE items ADD wthdrawn_on DATETIME NULL AFTER wthdrawn");
7048
   $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER wthdrawn");
7049
   $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7049
   $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7050
   $dbh->do("ALTER TABLE deleteditems ADD wthdrawn_on DATETIME NULL AFTER wthdrawn");
7050
   $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER wthdrawn");
7051
   print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7051
   print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7052
   SetVersion ($DBversion);
7052
   SetVersion ($DBversion);
7053
}
7053
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-2 / +1 lines)
Lines 166-172 Link Here
166
                    </form>
166
                    </form>
167
                [% END %]
167
                [% END %]
168
            </li>
168
            </li>
169
            [% IF ITEM_DAT.wthdrawn_on %]<li><span class="label">Withdrawn on:</span>[% ITEM_DAT.wthdrawn_on | $KohaDates %] &nbsp;</li>[% END %]
169
            [% IF ITEM_DAT.withdrawn_on %]<li><span class="label">Withdrawn on:</span>[% ITEM_DAT.withdrawn_on | $KohaDates %] &nbsp;</li>[% END %]
170
            </ol></div>
170
            </ol></div>
171
            <div class="listgroup"><h4>History</h4>
171
            <div class="listgroup"><h4>History</h4>
172
            <ol class="bibliodetails">
172
            <ol class="bibliodetails">
173
- 

Return to bug 9673