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

(-)a/C4/Items.pm (-2 / +2 lines)
Lines 561-570 sub ModItem { Link Here
561
561
562
    $item->{'itemnumber'} = $itemnumber or return;
562
    $item->{'itemnumber'} = $itemnumber or return;
563
563
564
    my @fields = qw( itemlost withdrawn );
564
    my @fields = qw( itemlost withdrawn damaged );
565
565
566
    # Only call GetItem if we need to set an "on" date field
566
    # Only call GetItem if we need to set an "on" date field
567
    if ( $item->{itemlost} || $item->{withdrawn} ) {
567
    if ( $item->{itemlost} || $item->{withdrawn} || $item->{damaged} ) {
568
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
568
        my $pre_mod_item = GetItem( $item->{'itemnumber'} );
569
        for my $field (@fields) {
569
        for my $field (@fields) {
570
            if (    defined( $item->{$field} )
570
            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: Add damaged_on to items and deleteditems tables)\n";
9
}
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 637-642 CREATE TABLE `deleteditems` ( Link Here
637
  `stack` tinyint(1) default NULL,
637
  `stack` tinyint(1) default NULL,
638
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
638
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
639
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
639
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
640
  `damaged_on` datetime DEFAULT NULL, -- the date and time an item was last marked as damaged, NULL if not damaged
640
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
641
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
641
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
642
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
642
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
643
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
Lines 897-902 CREATE TABLE `items` ( -- holdings/item information Link Here
897
  `stack` tinyint(1) default NULL,
898
  `stack` tinyint(1) default NULL,
898
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
899
  `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
899
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
900
  `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
901
  `damaged_on` datetime DEFAULT NULL, -- the date and time an item was last marked as damaged, NULL if not damaged
900
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
902
  `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
901
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
903
  `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
902
  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
904
  `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 24-29 use C4::Biblio; Link Here
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::DateUtils qw( dt_from_string );
25
use Koha::DateUtils qw( dt_from_string );
26
use Koha::Library;
26
use Koha::Library;
27
use Koha::DateUtils;
27
28
28
use t::lib::Mocks;
29
use t::lib::Mocks;
29
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
Lines 108-113 subtest 'General Add, Get and Del tests' => sub { Link Here
108
    $schema->storage->txn_rollback;
109
    $schema->storage->txn_rollback;
109
};
110
};
110
111
112
subtest 'ModItem tests' => sub {
113
    plan tests => 6;
114
115
    $schema->storage->txn_begin;
116
117
    my $builder = t::lib::TestBuilder->new;
118
    my $item = $builder->build({
119
        source => 'Item',
120
        value  => {
121
            itemlost     => 0,
122
            damaged      => 0,
123
            withdrawn    => 0,
124
            itemlost_on  => undef,
125
            damaged_on   => undef,
126
            withdrawn_on => undef,
127
        }
128
    });
129
130
    my @fields = qw( itemlost withdrawn damaged );
131
    for my $field (@fields) {
132
        $item->{$field} = 1;
133
        ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
134
        my $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
135
        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" );
136
137
        $item->{$field} = 0;
138
        ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
139
        $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
140
        is( $post_mod_item->{$field."_on"}, undef, "When clearing $field, $field"."_on is cleared" );
141
    }
142
143
    $schema->storage->txn_rollback;
144
145
};
146
111
subtest 'GetHiddenItemnumbers tests' => sub {
147
subtest 'GetHiddenItemnumbers tests' => sub {
112
148
113
    plan tests => 9;
149
    plan tests => 9;
Lines 732-737 subtest '_mod_item_dates' => sub { Link Here
732
    # check if itemlost_on was not touched
768
    # check if itemlost_on was not touched
733
    $item->{itemlost_on} = '12345678';
769
    $item->{itemlost_on} = '12345678';
734
    $item->{withdrawn_on} = '12/31/2015 23:59:00';
770
    $item->{withdrawn_on} = '12/31/2015 23:59:00';
771
    $item->{damaged_on} = '01/20/2017 09:00:00';
735
    $orgitem = { %$item };
772
    $orgitem = { %$item };
736
    C4::Items::_mod_item_dates($item);
773
    C4::Items::_mod_item_dates($item);
737
    is_deeply( $item, $orgitem, 'Colums with _on are not touched' );
774
    is_deeply( $item, $orgitem, 'Colums with _on are not touched' );
738
- 

Return to bug 17672