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

(-)a/C4/Items.pm (-2 / +2 lines)
Lines 562-571 sub ModItem { Link Here
562
562
563
    $item->{'itemnumber'} = $itemnumber or return;
563
    $item->{'itemnumber'} = $itemnumber or return;
564
564
565
    my @fields = qw( itemlost withdrawn );
565
    my @fields = qw( itemlost withdrawn damaged );
566
566
567
    # Only call GetItem if we need to set an "on" date field
567
    # Only call GetItem if we need to set an "on" date field
568
    if ( $item->{itemlost} || $item->{withdrawn} ) {
568
    if ( $item->{itemlost} || $item->{withdrawn} || $item->{damaged} ) {
569
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
569
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
570
        for my $field (@fields) {
570
        for my $field (@fields) {
571
            if (    defined( $item->{$field} )
571
            if (    defined( $item->{$field} )
(-)a/admin/columns_settings.yml (-1 / +2 lines)
Lines 88-94 modules: Link Here
88
      itemst:
88
      itemst:
89
        # NOTE: These columns are in the same order as kohastructure.sql, and contain all items
89
        # NOTE: These columns are in the same order as kohastructure.sql, and contain all items
90
        # columns except for the following internal/obsolete fields: stack, more_subfields_xml,
90
        # columns except for the following internal/obsolete fields: stack, more_subfields_xml,
91
        # cn_sort, permanent_location, itemlost_on, withdrawn_on, issues, renewals and reserves.
91
        # cn_sort, permanent_location, damaged_on itemlost_on, withdrawn_on, issues, renewals and
92
        # reserves.
92
        -
93
        -
93
          columnname: barcode
94
          columnname: barcode
94
        -
95
        -
(-)a/installer/data/mysql/atomicupdate/bug17672_add_damaged_on_column_to_items.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( "ALTER TABLE items ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
4
    $dbh->do( "ALTER TABLE deleteditems ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
5
6
    # Always end with this (adjust the bug info)
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug 17672 - Items table should have a damaged_on column)\n";
9
}
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 667-672 CREATE TABLE `deleteditems` ( Link Here
667
  `stack` tinyint(1) default NULL,
667
  `stack` tinyint(1) default NULL,
668
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
668
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
669
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
669
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
670
  `damaged_on` datetime DEFAULT NULL, -- the date and time an item was last marked as damaged, NULL if not damaged
670
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
671
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
671
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
672
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
672
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
673
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
Lines 927-932 CREATE TABLE `items` ( -- holdings/item information Link Here
927
  `stack` tinyint(1) default NULL,
928
  `stack` tinyint(1) default NULL,
928
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
929
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
929
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
930
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
931
  `damaged_on` datetime DEFAULT NULL, -- the date and time an item was last marked as damaged, NULL if not damaged
930
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
932
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
931
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
933
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
932
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
934
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
(-)a/koha-tmpl/intranet-tmpl/prog/en/columns.def (+1 lines)
Lines 100-105 Link Here
100
<field name="items.itype">Koha itemtype</field>
100
<field name="items.itype">Koha itemtype</field>
101
<field name="items.stocknumber">Inventory number</field>
101
<field name="items.stocknumber">Inventory number</field>
102
<field name="items.damaged">Damaged status</field>
102
<field name="items.damaged">Damaged status</field>
103
<field name="items.damaged_on">Damaged on</field>
103
<field name="items.materials">Materials specified</field>
104
<field name="items.materials">Materials specified</field>
104
<field name="items.uri">Uniform Resource Identifier</field>
105
<field name="items.uri">Uniform Resource Identifier</field>
105
<field name="items.more_subfields_xml">Additional subfields (XML)</field>
106
<field name="items.more_subfields_xml">Additional subfields (XML)</field>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (+3 lines)
Lines 152-157 Link Here
152
                    &nbsp;
152
                    &nbsp;
153
                [% END %]
153
                [% END %]
154
            </li>
154
            </li>
155
            [% IF ITEM_DAT.damaged != "" && ITEM_DAT.damaged_on %]
156
                <li><span class="label">Damaged on:</span>[% ITEM_DAT.damaged_on | $KohaDates %] &nbsp;</li>
157
            [% END %]
155
            [% END %]
158
            [% END %]
156
159
157
            [% IF itemwithdrawnloop %]
160
            [% IF itemwithdrawnloop %]
(-)a/t/db_dependent/Items.t (-1 / +37 lines)
Lines 22-27 use MARC::Record; Link Here
22
use C4::Biblio;
22
use C4::Biblio;
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::Library;
24
use Koha::Library;
25
use Koha::DateUtils;
25
26
26
use t::lib::Mocks;
27
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
use t::lib::TestBuilder;
Lines 103-108 subtest 'General Add, Get and Del tests' => sub { Link Here
103
    $schema->storage->txn_rollback;
104
    $schema->storage->txn_rollback;
104
};
105
};
105
106
107
subtest 'ModItem tests' => sub {
108
    plan tests => 6;
109
110
    $schema->storage->txn_begin;
111
112
    my $builder = t::lib::TestBuilder->new;
113
    my $item = $builder->build({
114
        source => 'Item',
115
        value  => {
116
            itemlost     => 0,
117
            damaged      => 0,
118
            withdrawn    => 0,
119
            itemlost_on  => undef,
120
            damaged_on   => undef,
121
            withdrawn_on => undef,
122
        }
123
    });
124
125
    my @fields = qw( itemlost withdrawn damaged );
126
    for my $field (@fields) {
127
        $item->{$field} = 1;
128
        ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
129
        my $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
130
        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" );
131
132
        $item->{$field} = 0;
133
        ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
134
        $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
135
        is( $post_mod_item->{$field."_on"}, undef, "When clearing $field, $field"."_on is cleared" );
136
    }
137
138
    $schema->storage->txn_rollback;
139
140
};
141
106
subtest 'GetHiddenItemnumbers tests' => sub {
142
subtest 'GetHiddenItemnumbers tests' => sub {
107
143
108
    plan tests => 9;
144
    plan tests => 9;
Lines 769-774 subtest '_mod_item_dates' => sub { Link Here
769
    # check if itemlost_on was not touched
805
    # check if itemlost_on was not touched
770
    $item->{itemlost_on} = '12345678';
806
    $item->{itemlost_on} = '12345678';
771
    $item->{withdrawn_on} = '12/31/2015 23:59:00';
807
    $item->{withdrawn_on} = '12/31/2015 23:59:00';
808
    $item->{damaged_on} = '01/20/2017 09:00:00';
772
    $orgitem = { %$item };
809
    $orgitem = { %$item };
773
    C4::Items::_mod_item_dates($item);
810
    C4::Items::_mod_item_dates($item);
774
    is_deeply( $item, $orgitem, 'Colums with _on are not touched' );
811
    is_deeply( $item, $orgitem, 'Colums with _on are not touched' );
775
- 

Return to bug 17672