From d17cb79309c896a0d9b7fb3babdf6fa3b1cfefd7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Sun, 4 Oct 2015 20:11:26 +0200 Subject: [PATCH] Bug 14950: Assign default value for YYYY, MM and DD MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit [was Remove C4::Dates from tools/batchMod.pl] This patch replace the YYYY, MM and DD if defined in the default values. This patch also 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') - Click 'Save' - Verify that the items are updated as appropriate Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart Amended commit message: This is a bug fix and can be backported. The YYYY, MM and DD were not replaced correctly before this patch. I got Year:2015-10-06 Month: Day: now I correctly get Year: 2015 Month: 10 Day: 06 Signed-off-by: Tomas Cohen Arazi --- tools/batchMod.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 5108419935..a7c8d709f7 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. -- 2.39.5