@@ -, +, @@ autogeneration of dates in 008 - Administration -> MARC structure -> 952 -> Edit subfields -> d - Expand "Advanced constraints" and add a default value: <> <> <> <
> <> - Save your configuration and go to Cataloging. - Go to the add/edit items page for a record which uses the framework you edited. - In the "Add item" form, in the "Date aquired" field, you should see the correct values. For example: '2019 19 12 03 Leonard' --- C4/Items.pm | 17 +++++++++++++++++ acqui/neworderempty.pl | 4 +++- cataloguing/addbiblio.pl | 4 +++- cataloguing/additem.pl | 4 +++- 4 files changed, 26 insertions(+), 3 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -2398,6 +2398,23 @@ sub PrepareItemrecordDisplay { $defaultvalue = q||; } else { $defaultvalue =~ s/"/"/g; + # get today date & replace <>, <>, <
> if provided in the default value + my $today_dt = dt_from_string; + my $year = $today_dt->strftime('%Y'); + my $shortyear = $today_dt->strftime('%y'); + my $month = $today_dt->strftime('%m'); + my $day = $today_dt->strftime('%d'); + $defaultvalue =~ s/<>/$year/g; + $defaultvalue =~ s/<>/$shortyear/g; + $defaultvalue =~ s/<>/$month/g; + $defaultvalue =~ s/<
>/$day/g; + + # And <> with surname (?) + my $username = + ( C4::Context->userenv + ? C4::Context->userenv->{'surname'} + : "superlibrarian" ); + $defaultvalue =~ s/<>/$username/g; } my $maxlength = $tagslib->{$tag}->{$subfield}->{maxlength}; --- a/acqui/neworderempty.pl +++ a/acqui/neworderempty.pl @@ -227,12 +227,14 @@ if ( not $ordernumber ) { # create order if ( $value eq '' ) { - # get today date & replace <>, <>, <
> if provided in the default value + # get today date & replace <>, <>, <>, <
> if provided in the default value my $today_dt = dt_from_string; my $year = $today_dt->strftime('%Y'); + my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); my $day = $today_dt->strftime('%d'); $value =~ s/<>/$year/g; + $value =~ s/<>/$shortyear/g; $value =~ s/<>/$month/g; $value =~ s/<
>/$day/g; --- a/cataloguing/addbiblio.pl +++ a/cataloguing/addbiblio.pl @@ -279,12 +279,14 @@ sub create_input { if ( $value eq '' ) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{}; - # get today date & replace <>, <>, <
> if provided in the default value + # get today date & replace <>, <>, <>, <
> if provided in the default value my $today_dt = dt_from_string; my $year = $today_dt->strftime('%Y'); + my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); my $day = $today_dt->strftime('%d'); $value =~ s/<>/$year/g; + $value =~ s/<>/$shortyear/g; $value =~ s/<>/$month/g; $value =~ s/<
>/$day/g; # And <> with surname (?) --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -136,12 +136,14 @@ sub generate_subfield_form { if ( ! defined( $value ) || $value eq '') { $value = $subfieldlib->{defaultvalue}; if ( $value ) { - # get today date & replace <>, <>, <
> if provided in the default value + # get today date & replace <>, <>, <>, <
> if provided in the default value my $today_dt = dt_from_string; my $year = $today_dt->strftime('%Y'); + my $shortyear = $today_dt->strftime('%y'); my $month = $today_dt->strftime('%m'); my $day = $today_dt->strftime('%d'); $value =~ s/<>/$year/g; + $value =~ s/<>/$shortyear/g; $value =~ s/<>/$month/g; $value =~ s/<
>/$day/g; # And <> with surname (?) --