Bug 14950: Assign default value for YYYY, MM and DD
[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ä <j.kylmala@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> 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 <tomascohen@theke.io>
This commit is contained in:
parent
e954c98199
commit
d17cb79309
1 changed files with 9 additions and 6 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue