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

(-)a/C4/Items.pm (+27 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 540-545 sub ModItem { Link Here
540
542
541
    $item->{onloan} = undef if $item->{itemlost};
543
    $item->{onloan} = undef if $item->{itemlost};
542
544
545
    my @fields = qw( itemlost withdrawn );
546
547
    # Only call GetItem if we need to set an "on" date field
548
    if ( $item->{itemlost} || $item->{withdrawn} ) {
549
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
550
        for my $field (@fields) {
551
            if (    defined( $item->{$field} )
552
                and not $pre_mod_item->{$field}
553
                and $item->{$field} )
554
            {
555
                $item->{ $field . '_on' } =
556
                  DateTime::Format::MySQL->format_datetime( dt_from_string() );
557
            }
558
        }
559
    }
560
561
    # If the field is defined but empty, we are removing and,
562
    # and thus need to clear out the 'on' field as well
563
    for my $field (@fields) {
564
        if ( defined( $item->{$field} ) && !$item->{$field} ) {
565
            $item->{ $field . '_on' } = undef;
566
        }
567
    }
568
569
543
    _set_derived_columns_for_mod($item);
570
    _set_derived_columns_for_mod($item);
544
    _do_column_fixes_for_mod($item);
571
    _do_column_fixes_for_mod($item);
545
    # FIXME add checks
572
    # FIXME add checks
(-)a/installer/data/mysql/kohastructure.sql (+4 lines)
Lines 888-894 CREATE TABLE `deleteditems` ( Link Here
888
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
888
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
889
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
889
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
890
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
890
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
891
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
891
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
892
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
893
  `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
892
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
894
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
893
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
895
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
894
  `issues` smallint(6) default NULL, -- number of times this item has been checked out
896
  `issues` smallint(6) default NULL, -- number of times this item has been checked out
Lines 1181-1187 CREATE TABLE `items` ( -- holdings/item information Link Here
1181
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1183
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1182
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1184
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1183
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
1185
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
1186
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
1184
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
1187
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
1188
  `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
1185
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
1189
  `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
1186
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
1190
  `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
1187
  `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
1191
  `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 7743-7748 if(CheckVersion($DBversion)) { Link Here
7743
    SetVersion($DBversion);
7743
    SetVersion($DBversion);
7744
}
7744
}
7745
7745
7746
$DBversion = "3.13.00.XXX";
7747
if ( CheckVersion($DBversion) ) {
7748
   $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7749
   $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER wthdrawn");
7750
   $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7751
   $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER wthdrawn");
7752
   print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7753
   SetVersion ($DBversion);
7754
}
7755
7746
=head1 FUNCTIONS
7756
=head1 FUNCTIONS
7747
7757
7748
=head2 TableExists($table)
7758
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-1 / +2 lines)
Lines 127-132 Link Here
127
                         
127
                         
128
                    [% END %]
128
                    [% END %]
129
                </li>
129
                </li>
130
                [% IF ITEM_DAT.itemlost_on %]<li><span class="label">Lost on:</span>[% ITEM_DAT.itemlost_on | $KohaDates %] &nbsp;</li>[% END %]
130
            [% END %]
131
            [% END %]
131
            [% IF ( ITEM_DAT.itemdamagedloop ) %]
132
            [% IF ( ITEM_DAT.itemdamagedloop ) %]
132
            <li><span class="label">Damaged status:</span>
133
            <li><span class="label">Damaged status:</span>
Lines 176-181 Link Here
176
                    </form>
177
                    </form>
177
                [% END %]
178
                [% END %]
178
            </li>
179
            </li>
180
            [% IF ITEM_DAT.withdrawn_on %]<li><span class="label">Withdrawn on:</span>[% ITEM_DAT.withdrawn_on | $KohaDates %] &nbsp;</li>[% END %]
179
            </ol></div>
181
            </ol></div>
180
            <div class="listgroup"><h4>History</h4>
182
            <div class="listgroup"><h4>History</h4>
181
            <ol class="bibliodetails">
183
            <ol class="bibliodetails">
182
- 

Return to bug 9673