From 45921f47f9b8d5f079e0f08d2be860ba9014f83e Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Tue, 31 Aug 2010 11:32:04 +1200 Subject: [PATCH] Bug 5185 - allow the last seen time to be updated by batch modification This adds a syspref "UpdateLastSeenBatch" that will make batch modifications update the last seen time of their item. --- C4/Items.pm | 8 +++++++- installer/data/mysql/en/mandatory/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../en/modules/admin/preferences/cataloguing.pref | 8 +++++++- kohaversion.pl | 2 +- tools/batchMod.pl | 3 ++- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 794bff7..1930a27 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -373,7 +373,8 @@ sub AddItemBatchFromMarc { =head2 ModItemFromMarc - ModItemFromMarc($item_marc, $biblionumber, $itemnumber); + ModItemFromMarc($item_marc, $biblionumber, $itemnumber, + $update_last_seen); This function updates an item record based on a supplied C object containing an embedded item field. @@ -428,6 +429,7 @@ sub ModItemFromMarc { my $item_marc = shift; my $biblionumber = shift; my $itemnumber = shift; + my $update_last_seen = shift; my $dbh = C4::Context->dbh; my $frameworkcode = GetFrameworkCode( $biblionumber ); @@ -439,6 +441,10 @@ sub ModItemFromMarc { foreach my $item_field (keys %default_values_for_mod_from_marc) { $item->{$item_field} = $default_values_for_mod_from_marc{$item_field} unless exists $item->{$item_field}; } + if ($update_last_seen) { + my $today = C4::Dates->new(); + $item->{'datelastseen'} = $today->output("iso"); + } my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode); return ModItem($item, $biblionumber, $itemnumber, $dbh, $frameworkcode, $unlinked_item_subfields); diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 8bfed37..19dcec6 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -286,3 +286,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ILS-DI:Authorized_IPs','','.','Restricts usage of ILS-DI to some IPs','Free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OverduesBlockCirc','noblock','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','noblock|confirmation|block','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UpdateLastSeenBatch','0','Whether to update datelastseen when doing batch modifications','','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a0b5c4a..309613b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3701,6 +3701,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.01.00.146"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UpdateLastSeenBatch','0','Whether to update datelastseen when doing batch modifications','','YesNo')"); + print "Upgrade to $DBversion done (Add UpdateLastSeenBatch system preference)\n"; + SetVersion($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 4e06abc..b8adaf4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -130,4 +130,10 @@ Cataloging: simplified: a summary full: a full list - of the serial issues. - + Batch Operations: + - + - pref: UpdateLastSeenBatch + choices: + yes: Update + no: "Don't update" + - the datalastseen field on items when performing batch modifications. diff --git a/kohaversion.pl b/kohaversion.pl index 63b6d31..ffd2e69 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -11,7 +11,7 @@ use strict; sub kohaversion { - our $VERSION = '3.01.00.145'; + our $VERSION = '3.01.00.146'; # version needs to be set this way # so that it can be picked up by Makefile.PL diff --git a/tools/batchMod.pl b/tools/batchMod.pl index f5138d1..ea21de9 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -132,6 +132,7 @@ if ($op eq "action") { # For each item my $i = 1; + my $update_last_seen = C4::Context->preference('UpdateLastSeenBatch'); foreach my $itemnumber(@itemnumbers){ $job->progress($i) if $runinbackground; @@ -151,7 +152,7 @@ if ($op eq "action") { my $localitem = TransformMarcToKoha( $dbh, $marcitem, "", 'items' ); my $localmarcitem=Item2Marc($itemdata); UpdateMarcWith($marcitem,$localmarcitem); - eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)}; + eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber,$update_last_seen)}; } } $i++; -- 1.7.0.4