From 56c4a32119b57f6f184b39f6b9b16039022f3273 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 29 Mar 2007 09:42:13 +0000 Subject: [PATCH] adding default value new feature into cataloguing. The system (definition) part has already been added by toins --- C4/Biblio.pm | 9 +++++++-- cataloguing/addbiblio.pl | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index ebd61c8d5a..202fdcb3ab 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1278,7 +1278,7 @@ sub MARCgettagslib { $sth = $dbh->prepare( -"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link from marc_subfield_structure where frameworkcode=? order by tagfield,tagsubfield" +"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue from marc_subfield_structure where frameworkcode=? order by tagfield,tagsubfield" ); $sth->execute($frameworkcode); @@ -1291,6 +1291,7 @@ sub MARCgettagslib { my $hidden; my $isurl; my $link; + my $defaultvalue; while ( ( @@ -1299,7 +1300,7 @@ sub MARCgettagslib { $mandatory, $repeatable, $authorised_value, $authtypecode, $value_builder, $kohafield, $seealso, $hidden, $isurl, - $link + $link,$defaultvalue ) = $sth->fetchrow ) @@ -1317,6 +1318,7 @@ sub MARCgettagslib { $res->{$tag}->{$subfield}->{hidden} = $hidden; $res->{$tag}->{$subfield}->{isurl} = $isurl; $res->{$tag}->{$subfield}->{link} = $link; + $res->{$tag}->{$subfield}->{defaultvalue} = $defaultvalue; } return $res; } @@ -3695,6 +3697,9 @@ Joshua Ferraro jmf@liblime.com # $Id$ # $Log$ +# Revision 1.191 2007/03/29 09:42:13 tipaul +# adding default value new feature into cataloguing. The system (definition) part has already been added by toins +# # Revision 1.190 2007/03/29 08:45:19 hdl # Deleting ignore_errors(1) pour MARC::Charset # diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 95cc3483e8..e8c86b196e 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -30,6 +30,7 @@ use C4::Context; use MARC::Record; use C4::Log; use C4::Koha; # XXX subfield_is_koha_internal_p +use Date::Calc qw(Today); use MARC::File::USMARC; use MARC::File::XML; @@ -239,6 +240,18 @@ sub create_input () { #use Encode; #$value = encode('utf-8', $value); $value =~ s/"/"/g; + # if there is no value provided but a default value in parameters, get it + unless ($value) { + $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; + # get today date & replace YYYY, MM, DD if provided in the default value + 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; + + } my $dbh = C4::Context->dbh; my %subfield_data; $subfield_data{tag}=$tag; -- 2.39.5