From adf7d75ac780ff6fb54b8445f0a78b688e1f072b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Wed, 30 Sep 2015 14:58:40 +0200 Subject: [PATCH] [SIGNED-OFF]Bug 14922 - Remove C4::Dates from cataloguing/additem.pl This patch removes C4::Dates from cataloguing/additem.pl To test: - In MARC bibliographic 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 - Create a new item for a biblio and verify that YYYY, MM and DD are replaced with today's values. - Apply patch and repeat that previous step behaves as before. - Verify that the overall functionality of the form is the same as before applying the patch. Signed-off-by: Hector Castro Works as advertised. With the last script not accept more than YYYYMMDD If you enter something else, the script sends to the end of line. This patch follow up the pattern in constraint default value --- cataloguing/additem.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 696f3cd..c794ca3 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -31,7 +31,7 @@ use C4::Circulation; use C4::Koha; # XXX subfield_is_koha_internal_p use C4::Branch; # XXX subfield_is_koha_internal_p use C4::ClassSource; -use C4::Dates; +use Date::Calc qw(Today); use List::MoreUtils qw/any/; use C4::Search; use Storable qw(thaw freeze); @@ -104,7 +104,7 @@ sub _increment_barcode { sub generate_subfield_form { - my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $restrictededition) = @_; + my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $biblionumber, $temp, $loop_data, $i, $restrictededition) = @_; my $frameworkcode = &GetFrameworkCode($biblionumber); @@ -129,7 +129,9 @@ sub generate_subfield_form { if ( ! defined( $value ) || $value eq '') { $value = $subfieldlib->{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! + my ( $year, $month, $day ) = Today(); + $month = sprintf( "%02d", $month ); + $day = sprintf( "%02d", $day ); $value =~ s/YYYY/$year/g; $value =~ s/MM/$month/g; $value =~ s/DD/$day/g; @@ -402,7 +404,6 @@ $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibra # In case user has fast cataloging permission (and we're in fast cataloging), editing is not restricted $restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'})); -my $today_iso = C4::Dates->today('iso'); my $tagslib = &GetMarcStructure(1,$frameworkcode); my $record = GetMarcBiblio($biblionumber); my $oldrecord = TransformMarcToKoha($dbh,$record); @@ -841,7 +842,7 @@ if($itemrecord){ next if subfield_is_koha_internal_p($subfieldtag); next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); - my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $restrictededition); + my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $biblionumber, $temp, \@loop_data, $i, $restrictededition); push @fields, "$tag$subfieldtag"; push (@loop_data, $subfield_data); $i++; @@ -865,7 +866,7 @@ foreach my $tag ( keys %{$tagslib}){ my @values = (undef); @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag))); for my $value (@values){ - my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $restrictededition); + my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $biblionumber, $temp, \@loop_data, $i, $restrictededition); push (@loop_data, $subfield_data); $i++; } -- 1.7.10.4