View | Details | Raw Unified | Return to bug 27461
Collapse All | Expand All

(-)a/Koha/Util/FrameworkPlugin.pm (-1 / +21 lines)
Lines 22-32 package Koha::Util::FrameworkPlugin; Link Here
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
24
25
use constant DEFAULT_008_POS_6_39 => 'b        |||||||| |||| 00| 0 eng d';
26
25
our ( @ISA, @EXPORT_OK );
27
our ( @ISA, @EXPORT_OK );
26
BEGIN {
28
BEGIN {
27
    require Exporter;
29
    require Exporter;
28
    @ISA = qw( Exporter );
30
    @ISA = qw( Exporter );
29
    @EXPORT_OK = qw( wrapper date_entered );
31
    @EXPORT_OK = qw( wrapper date_entered biblio_008 );
30
}
32
}
31
33
32
=head1 NAME
34
=head1 NAME
Lines 65-68 sub date_entered { Link Here
65
    return substr($year,2,2).sprintf ("%0.2d", $mon).sprintf ("%0.2d",$mday);
67
    return substr($year,2,2).sprintf ("%0.2d", $mon).sprintf ("%0.2d",$mday);
66
}
68
}
67
69
70
=head2 biblio_008
71
72
    Returns a default value for MARC21 field 008 for biblio records.
73
    Depends on prefs DefaultCountryField008, DefaultLanguageField008.
74
75
=cut
76
77
sub biblio_008 {
78
    my $result = date_entered() . DEFAULT_008_POS_6_39;
79
    if( C4::Context->preference('DefaultCountryField008') ) {
80
        substr( $result, 15, 3 ) = pack( "A3", C4::Context->preference('DefaultCountryField008') );
81
    }
82
    if( C4::Context->preference('DefaultLanguageField008') ) {
83
        substr( $result, 35, 3 ) = pack( "A3", C4::Context->preference('DefaultLanguageField008' ) );
84
    }
85
    return $result;
86
}
87
68
1;
88
1;
(-)a/cataloguing/value_builder/marc21_field_008.pl (-23 / +6 lines)
Lines 28-56 use C4::Search; Link Here
28
use C4::Output qw( output_html_with_http_headers );
28
use C4::Output qw( output_html_with_http_headers );
29
29
30
use XML::LibXML;
30
use XML::LibXML;
31
use Koha::Util::FrameworkPlugin qw|date_entered|;
31
use Koha::Util::FrameworkPlugin qw( biblio_008 );
32
32
33
my $builder = sub {
33
my $builder = sub {
34
    my ( $params ) = @_;
34
    my ( $params ) = @_;
35
35
36
    my $lang = C4::Context->preference('DefaultLanguageField008' );
37
    $lang = "eng" unless $lang;
38
    $lang = pack("A3", $lang);
39
    my $country = C4::Context->preference('DefaultCountryField008');
40
    $country = "|||" unless $country;
41
    $country = pack("A3", $country);
42
43
    my $function_name = $params->{id};
36
    my $function_name = $params->{id};
44
    my $dateentered = date_entered();
37
    my $default008 = biblio_008();
45
    my $res           = "
38
    my $res           = "
46
<script>
39
<script>
47
40
48
function Focus$function_name(event) {
41
function Focus$function_name(event) {
49
    if ( document.getElementById(event.data.id).value ) {
42
    if( !document.getElementById(event.data.id).value ) {
50
	}
43
        document.getElementById(event.data.id).value='$default008';
51
	else {
44
    }
52
        document.getElementById(event.data.id).value='$dateentered' + 'b        $country||||| |||| 00| 0 $lang d';
53
	}
54
    return 1;
45
    return 1;
55
}
46
}
56
47
Lines 75-88 function Click$function_name(event) { Link Here
75
my $launcher = sub {
66
my $launcher = sub {
76
    my ( $params ) = @_;
67
    my ( $params ) = @_;
77
    my $input = $params->{cgi};
68
    my $input = $params->{cgi};
78
    my $lang = C4::Context->preference('DefaultLanguageField008' );
79
    $lang = "eng" unless $lang;
80
    $lang = pack("A3", $lang);
81
    my $country = C4::Context->preference('DefaultCountryField008') // "xxu";
82
    $country = pack("A3", $country);
83
69
84
    my $index   = $input->param('index');
70
    my $index   = $input->param('index');
85
    my $result  = $input->param('result');
71
    my $result  = $input->param('result') || biblio_008();
86
    my $leader  = $input->param('leader');
72
    my $leader  = $input->param('leader');
87
73
88
    my $material_configuration;
74
    my $material_configuration;
Lines 142-149 my $launcher = sub { Link Here
142
        }
128
        }
143
    );
129
    );
144
130
145
    my $dateentered = date_entered();
146
    $result = "$dateentered" . "b        $country||||| |||| 00| 0 $lang d" unless $result;
147
    my $errorXml = '';
131
    my $errorXml = '';
148
    # Check if the xml, xsd exists and is validated
132
    # Check if the xml, xsd exists and is validated
149
    my $dir = C4::Context->config('intrahtdocs') . '/prog/' . $template->{lang} . '/data/';
133
    my $dir = C4::Context->config('intrahtdocs') . '/prog/' . $template->{lang} . '/data/';
150
- 

Return to bug 27461