3 # Copyright 2009 Magnus Enger Libriotech
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use C4::Auth qw( get_template_and_user );
26 use C4::Output qw( output_html_with_http_headers );
29 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
33 my $dateentered = substr($year, 2, 2) . sprintf("%0.2d", $mon) . sprintf("%0.2d", $mday);
35 sub plugin_javascript {
36 my $lang = C4::Context->preference('DefaultLanguageField008' );
37 $lang = "eng" unless $lang;
38 $lang = pack("A3", $lang);
39 my ($dbh, $record, $tagslib, $field_number, $tabloop) = @_;
40 my $function_name = $field_number;
44 function Focus$function_name(subfield_managed) {
46 if ( document.getElementById(\"$field_number\").value ) {
49 document.getElementById(\"$field_number\").value='$dateentered' + 't no ||||| |||| 00| 0 $lang d';
54 function Clic$function_name(i) {
55 defaultvalue=document.getElementById(\"$field_number\").value;
56 defaultvalue=defaultvalue.replace(/ /g, \"+\");
57 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=normarc_field_008.pl&index=$field_number&result=\"+defaultvalue,\"unimarc field 100\",'width=1000,height=600,toolbar=false,scrollbars=yes');
63 return ($function_name, $res);
67 my $lang = C4::Context->preference('DefaultLanguageField008' );
68 $lang = "eng" unless $lang;
69 $lang = pack("A3", $lang);
71 my $index = $input->param('index');
72 my $result = $input->param('result');
74 my $dbh = C4::Context->dbh;
76 my ($template, $loggedinuser, $cookie) = get_template_and_user(
77 { template_name => "cataloguing/value_builder/normarc_field_008.tt",
80 flagsrequired => { editcatalogue => 1 },
84 # $result = " t xxu 00 0 eng d" unless $result;
85 $result = "$dateentered" . "t no ||||| |||| 00| 0 $lang d" unless $result;
86 my $f1 = substr($result, 0, 6);
87 my $f6 = substr($result, 6, 1);
88 my $f710 = substr($result, 7, 4);
89 my $f1114 = substr($result, 11, 4);
90 my $f1517 = substr($result, 15, 3);
91 my $f18 = substr($result, 18, 1);
92 my $f19 = substr($result, 19, 1);
93 my $f20 = substr($result, 20, 1);
94 my $f21 = substr($result, 21, 1);
95 my $f22 = substr($result, 22, 1);
96 my $f23 = substr($result, 23, 1);
97 my $f24 = substr($result, 24, 1);
98 my $f25 = substr($result, 25, 1);
99 my $f26 = substr($result, 26, 1);
100 my $f27 = substr($result, 27, 1);
101 my $f28 = substr($result, 28, 1);
102 my $f29 = substr($result, 29, 1);
103 my $f30 = substr($result, 30, 1);
104 my $f31 = substr($result, 31, 1);
105 my $f32 = substr($result, 32, 1);
106 my $f33 = substr($result, 33, 1);
107 my $f34 = substr($result, 34, 1);
108 my $f3537 = substr($result, 35, 3);
109 my $f38 = substr($result, 38, 1);
110 my $f39 = substr($result, 39, 1);
113 $f710 = "" if ($f710 =~ /^\s*$/);
114 $f1114 = "" if ($f1114 =~ /^\s*$/);
116 if ((!$f1) || ($f1 =~ m/ /)) {
168 output_html_with_http_headers $input, $cookie, $template->output;