From 5f3bd890eaf5d09ec87ab9627fde0b6510d88121 Mon Sep 17 00:00:00 2001 From: Michal Urban Date: Sat, 16 Jul 2022 10:55:42 -0400 Subject: [PATCH] Bug 31212: Change datelastseen from date to datetime field This patch changes the datelastseen field to a datetime field for better time accuracy. It also fixes the interface in order to display datelastseen as a datetime field. To test: 1. Apply patch 2. Search the catalogue and select a biblio with at least one item. Confirm in the holdings table that every entry in the "Last Seen" column is in date-time format. 3. Navigate to "Items" in for that same biblio and check the item "History" section to have "Last Seen" in the correct format 4. Click "Edit" then "Edit Items" and confirm that the table has date-time format for the "Date Last Seen" Column entries 5. Edit one of the items to have lost status, then navigate to the Reports section, find "Items Lost", and search for the item with the barcode. Confirm the proper date-time format in the result. 6. Navigate to Tools, then Inventory, run inventory and confirm that the "Date Last Seen" column entries are in proper format Signed-off-by: Ann Flournoy Signed-off-by: David Nind --- C4/Items.pm | 3 +++ Koha/Schema/Result/Deleteditem.pm | 4 ++-- Koha/Schema/Result/Item.pm | 4 ++-- installer/data/mysql/kohastructure.sql | 4 ++-- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 2 +- .../intranet-tmpl/prog/en/modules/catalogue/moredetail.tt | 2 +- .../intranet-tmpl/prog/en/modules/cataloguing/additem.tt | 8 ++++---- .../intranet-tmpl/prog/en/modules/reports/itemslost.tt | 2 +- .../intranet-tmpl/prog/en/modules/tools/inventory.tt | 6 +++--- 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 9d443bb6ec..53b9742c24 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -399,6 +399,8 @@ The last optional parameter allows for passing skip_record_index through to the sub ModDateLastSeen { my ( $itemnumber, $leave_item_lost, $params ) = @_; + my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 0 }); + my $item = Koha::Items->find($itemnumber); $item->datelastseen(dt_from_string->ymd); my $log = $item->itemlost && !$leave_item_lost ? 1 : 0; # If item was lost, record the change to the item @@ -582,6 +584,7 @@ sub GetItemsForInventory { } if ($datelastseen) { + $datelastseen = output_pref({ str => $datelastseen, dateformat => 'iso', dateonly => 0 }); push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)'; push @bind_params, $datelastseen; } diff --git a/Koha/Schema/Result/Deleteditem.pm b/Koha/Schema/Result/Deleteditem.pm index 8ccb4d4499..436629af5c 100644 --- a/Koha/Schema/Result/Deleteditem.pm +++ b/Koha/Schema/Result/Deleteditem.pm @@ -112,7 +112,7 @@ the date the item was last checked out =head2 datelastseen - data_type: 'date' + data_type: 'datetime' datetime_undef_if_invalid: 1 is_nullable: 1 @@ -404,7 +404,7 @@ __PACKAGE__->add_columns( "datelastborrowed", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "datelastseen", - { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, + { data_type => "datetime", datetime_undef_if_invalid => 1, is_nullable => 1 }, "stack", { data_type => "tinyint", is_nullable => 1 }, "notforloan", diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 55d33e4a19..6da9361ecd 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -115,7 +115,7 @@ the date the item was last checked out/issued =head2 datelastseen - data_type: 'date' + data_type: 'datetime' datetime_undef_if_invalid: 1 is_nullable: 1 @@ -418,7 +418,7 @@ __PACKAGE__->add_columns( "datelastborrowed", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "datelastseen", - { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, + { data_type => "datetime", datetime_undef_if_invalid => 1, is_nullable => 1 }, "stack", { data_type => "tinyint", is_nullable => 1 }, "notforloan", diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b0dea05b7b..8a0ef9da1f 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2645,7 +2645,7 @@ CREATE TABLE `deleteditems` ( `replacementprice` decimal(8,2) DEFAULT NULL COMMENT 'cost the library charges to replace the item if it has been marked lost (MARC21 952$v)', `replacementpricedate` date DEFAULT NULL COMMENT 'the date the price is effective from (MARC21 952$w)', `datelastborrowed` date DEFAULT NULL COMMENT 'the date the item was last checked out', - `datelastseen` date DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)', + `datelastseen` datetime DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)', `stack` tinyint(1) DEFAULT NULL, `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining why this item is not for loan (MARC21 952$7)', `damaged` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as damaged (MARC21 952$4)', @@ -3208,7 +3208,7 @@ CREATE TABLE `items` ( `replacementprice` decimal(8,2) DEFAULT NULL COMMENT 'cost the library charges to replace the item if it has been marked lost (MARC21 952$v)', `replacementpricedate` date DEFAULT NULL COMMENT 'the date the price is effective from (MARC21 952$w)', `datelastborrowed` date DEFAULT NULL COMMENT 'the date the item was last checked out/issued', - `datelastseen` date DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)', + `datelastseen` datetime DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)', `stack` tinyint(1) DEFAULT NULL, `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining why this item is not for loan (MARC21 952$7)', `damaged` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as damaged (MARC21 952$4)', diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 0077bf5add..8baf60f1bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -560,7 +560,7 @@ Note that permanent location is a code, and location may be an authval. [% END %] - [% item.datelastseen | $KohaDates %] + [% item.datelastseen | $KohaDates with_hours => 1 %] [% item.issues || 0 | html %] [% item.renewals || 0 | html %] [% item.dateaccessioned | $KohaDates %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt index e337dc1b28..7d83ffa9ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -333,7 +333,7 @@ 0 [% END %] (View item's checkout history) -
  • Last seen:[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %] 
  • +
  • Last seen:[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates with_hours => 1 %] [%END %] 
  • Last borrowed:[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %] 
  • [% IF Koha.Preference('StoreLastBorrower') && ITEM_DAT.object.last_returned_by %]
  • Last returned by: [% ITEM_DAT.object.last_returned_by.cardnumber | html %] 
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index b80404a420..688fcfed66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -128,10 +128,10 @@ [% END %] [% FOREACH header IN item_header_loop %] [% SET attribute = header.attribute %] - [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %] - [% item.$attribute | $KohaDates %] - [% ELSIF ( item.$attribute && ( attribute == 'price' || attribute == 'replacementprice' ) ) %] - [% item.$attribute | $Price %] + [% IF header.attribute == 'datelastseen' %] + [% item.$attribute | $KohaDates with_hours => 1%] + [% ELSIF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %] + [% item.$attribute | $KohaDates with_hours %] [% ELSE %] [% item.$attribute | html %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt index abb076b248..d0cc1e43c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt @@ -129,7 +129,7 @@ [% item.barcode | html %] [% item.itemcallnumber | html %] - [% item.datelastseen | $KohaDates %] + [% item.datelastseen | $KohaDates with_hours => 1 %] [% item.price | $Price %] [% item.replacementprice | $Price %] [% Branches.GetName(item.homebranch) | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 98e0d85589..085919d859 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -50,7 +50,7 @@

    Inventory

    - [% IF (moddatecount) %]
    [% moddatecount | html %] items modified : datelastseen set to [% date | $KohaDates %]
    + [% IF (moddatecount) %]
    [% moddatecount | html %] items modified : datelastseen set to [% date | $KohaDates with_hours => 1 %]
    Number of potential barcodes read: [% LinesRead | html %]
    [% END %] [% IF (errorfile) %]
    [% errorfile | html %] can't be opened
    [% END %] [% IF (err_length && err_length==1) %]
    There was 1 barcode that was too long.
    [% END %] @@ -188,7 +188,7 @@

  • - + (Skip records marked as seen on or after this date.)
  • @@ -312,7 +312,7 @@ [% result.withdrawn | html %] - [% result.datelastseen | $KohaDates%] + [% result.datelastseen | $KohaDates with_hours => 1 %] [% FOREACH problem IN result.problems %] -- 2.30.2