3 #use warnings; FIXME - Bug 2505
5 # find Koha's Perl modules
6 # test carefully before changing this
8 eval { require "$FindBin::Bin/../../kohalib.pl" };
11 #use MARC::File::XML(BinaryEncoding=>"utf8");
12 #use MARC::File::USMARC;
14 use C4
::AuthoritiesMarc
;
16 #MARC::File::XML::default_record_format("UNIMARCAUTH");
17 my $dbh = C4
::Context
->dbh;
18 my $rq= $dbh->prepare(qq|
19 SELECT authid
,authtypecode
22 my $filename= shift @ARGV;
24 #ATTENTION : Mettre la base en utf8 auparavant.
25 #BEWARE : Set database into utf8 before.
26 #open FILEOUTPUT,">:utf8", "$filename" or die "unable to open $filename";
27 while (my ($authid,$authtypecode)=$rq->fetchrow){
28 my $record=AUTHgetauthority
($dbh,$authid);
29 if (! utf8
::is_utf8
($record)) {
30 utf8
::decode
($record);
33 if (C4
::Context
->preference('marcflavour') eq "UNIMARC"){
34 $record->leader(' nac 22 1u 4500');
35 my $string=$1 if $time=~m/([0-9\-]+)/;
37 $string = sprintf("%-*s",26, $string);
38 substr($string,9,6,"frey50");
39 unless ($record->subfield('100',"a")){
40 $record->insert_fields_ordered(MARC
::Field
->new('100',"","","a"=>$string));
42 if ($record->field('152')){
43 if ($record->subfield('152','b')){
45 $record->field('152')->add_subfields("b"=>$authtypecode);
48 $record->insert_fields_ordered(MARC
::Field
->new('152',"","","b"=>$authtypecode));
50 unless ($record->field('001')){
51 $record->insert_fields_ordered(MARC
::Field
->new('001',$authid));
54 AUTHmodauthority
($dbh,$authid,$record,1);
56 $record->encoding( 'UTF-8' );
58 # warn $record->as_usmarc;
59 # warn $record->as_formatted;
60 # warn $record->as_usmarc;
62 print $record->as_usmarc();