From d6f9ca39ad95a6cd629df9773106b1a5eaeca7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Sun, 4 Oct 2015 20:11:26 +0200 Subject: [PATCH] Bug 14950 - Remove C4::Dates from tools/batchMod.pl This patch removes C4::Dates from tools/batchMod.pl To test: - In MARC bibliographic Default framework, define a default value for one of the in Tag 952 Subfield struture, e.g. for subfield x Non-public note. You can define it under 'Advancde constraints'. Define the value similar to the following: Year:YYYY Month:MM Day:DD - Got to Home > Tools > Batch item modification - Enter one ore more barcodes you want to modify - Check checkbox 'Populate fields with defautl values from defautl framework - Click 'Continue' - Verify on the follwing screen that the field in Edit form is populated as appropriate (in our example 'x - Non public note') - Clcik 'Save' - Verify that the items are updated as appropriate --- tools/batchMod.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 5108419..a7c8d70 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -31,11 +31,11 @@ use C4::Koha; # XXX subfield_is_koha_internal_p use C4::Branch; # XXX subfield_is_koha_internal_p use C4::BackgroundJob; use C4::ClassSource; -use C4::Dates; use C4::Debug; use C4::Members; use MARC::File::XML; use List::MoreUtils qw/uniq/; +use Koha::DateUtils; my $input = new CGI; my $dbh = C4::Context->dbh; @@ -76,7 +76,7 @@ my $restrictededition = $uid ? haspermission($uid, {'tools' => 'items_batchmod_ # In case user is a superlibrarian, edition is not restricted $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian()); -my $today_iso = C4::Dates->today('iso'); +my $today_iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); $template->param(today_iso => $today_iso); $template->param(del => $del); @@ -334,10 +334,13 @@ foreach my $tag (sort keys %{$tagslib}) { if ( !$value && $use_default_values) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; # get today date & replace YYYY, MM, DD if provided in the default value - my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas! - $value =~ s/YYYY/$year/g; - $value =~ s/MM/$month/g; - $value =~ s/DD/$day/g; + my $today = dt_from_string; + my $year = $today->year; + my $month = $today->month; + my $day = $today->day; + $value =~ s/YYYY/$year/g; + $value =~ s/MM/$month/g; + $value =~ s/DD/$day/g; } $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4)); # testing branch value if IndependentBranches. -- 1.7.10.4