adding default value new feature into cataloguing. The system (definition) part has...
authortipaul <tipaul>
Thu, 29 Mar 2007 09:42:13 +0000 (09:42 +0000)
committertipaul <tipaul>
Thu, 29 Mar 2007 09:42:13 +0000 (09:42 +0000)
C4/Biblio.pm
cataloguing/addbiblio.pl

index ebd61c8..202fdcb 100644 (file)
@@ -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
 #
index 95cc348..e8c86b1 100755 (executable)
@@ -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/"/&quot;/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;