[Koha-cvs] koha C4/Biblio.pm cataloguing/addbiblio.pl

paul poulain paul at koha-fr.org
Thu Mar 29 11:42:14 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	paul poulain <tipaul>	07/03/29 09:42:14

Modified files:
	C4             : Biblio.pm 
	cataloguing    : addbiblio.pl 

Log message:
	adding default value new feature into cataloguing. The system (definition) part has already been added by toins

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&r1=1.190&r2=1.191
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&r1=1.20&r2=1.21

Patches:
Index: C4/Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -b -r1.190 -r1.191
--- C4/Biblio.pm	29 Mar 2007 08:45:19 -0000	1.190
+++ C4/Biblio.pm	29 Mar 2007 09:42:13 -0000	1.191
@@ -33,7 +33,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.190 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.191 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
 
 @ISA = qw( Exporter );
 
@@ -1278,7 +1278,7 @@
 
     $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 @@
     my $hidden;
     my $isurl;
     my $link;
+    my $defaultvalue;
 
     while (
         (
@@ -1299,7 +1300,7 @@
             $mandatory,    $repeatable,    $authorised_value,
             $authtypecode, $value_builder, $kohafield,
             $seealso,      $hidden,        $isurl,
-            $link
+            $link,$defaultvalue
         )
         = $sth->fetchrow
       )
@@ -1317,6 +1318,7 @@
         $res->{$tag}->{$subfield}->{hidden}           = $hidden;
         $res->{$tag}->{$subfield}->{isurl}            = $isurl;
         $res->{$tag}->{$subfield}->{link}             = $link;
+        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
     }
     return $res;
 }
@@ -3693,8 +3695,11 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.190 2007/03/29 08:45:19 hdl Exp $
+# $Id: Biblio.pm,v 1.191 2007/03/29 09:42:13 tipaul Exp $
 # $Log: Biblio.pm,v $
+# 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: cataloguing/addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- cataloguing/addbiblio.pl	9 Mar 2007 14:32:55 -0000	1.20
+++ cataloguing/addbiblio.pl	29 Mar 2007 09:42:13 -0000	1.21
@@ -1,6 +1,6 @@
 #!/usr/bin/perl 
 
-# $Id: addbiblio.pl,v 1.20 2007/03/09 14:32:55 tipaul Exp $
+# $Id: addbiblio.pl,v 1.21 2007/03/29 09:42:13 tipaul Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -30,6 +30,7 @@
 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 @@
         #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;





More information about the Koha-cvs mailing list