Bug 11897: Add mising semi-colon to user*.sql
[koha.git] / cataloguing / value_builder / normarc_field_008.pl
bloba156cd268e7583c4120a03fd91f9148c7c034619
1 #!/usr/bin/perl
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>.
20 use Modern::Perl;
21 use C4::Auth;
22 use CGI qw ( -utf8 );
23 use C4::Context;
25 use C4::Search;
26 use C4::Output;
28 # find today's date
29 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
31 $year += 1900;
32 $mon += 1;
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;
41 my $res = "
42 <script type=\"text/javascript\">
43 //<![CDATA[
45 function Focus$function_name(subfield_managed) {
47 if ( document.getElementById(\"$field_number\").value ) {
49 else {
50 document.getElementById(\"$field_number\").value='$dateentered' + 't no ||||| |||| 00| 0 $lang d';
52 return 1;
55 function Clic$function_name(i) {
56 defaultvalue=document.getElementById(\"$field_number\").value;
57 defaultvalue=defaultvalue.replace(/ /g, \"+\");
58 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');
61 //]]>
62 </script>
65 return ($function_name, $res);
68 sub plugin {
69 my $lang = C4::Context->preference('DefaultLanguageField008' );
70 $lang = "eng" unless $lang;
71 $lang = pack("A3", $lang);
72 my ($input) = @_;
73 my $index = $input->param('index');
74 my $result = $input->param('result');
76 my $dbh = C4::Context->dbh;
78 my ($template, $loggedinuser, $cookie) = get_template_and_user(
79 { template_name => "cataloguing/value_builder/normarc_field_008.tt",
80 query => $input,
81 type => "intranet",
82 authnotrequired => 0,
83 flagsrequired => { editcatalogue => 1 },
84 debug => 1,
88 # $result = " t xxu 00 0 eng d" unless $result;
89 $result = "$dateentered" . "t no ||||| |||| 00| 0 $lang d" unless $result;
90 my $f1 = substr($result, 0, 6);
91 my $f6 = substr($result, 6, 1);
92 my $f710 = substr($result, 7, 4);
93 my $f1114 = substr($result, 11, 4);
94 my $f1517 = substr($result, 15, 3);
95 my $f18 = substr($result, 18, 1);
96 my $f19 = substr($result, 19, 1);
97 my $f20 = substr($result, 20, 1);
98 my $f21 = substr($result, 21, 1);
99 my $f22 = substr($result, 22, 1);
100 my $f23 = substr($result, 23, 1);
101 my $f24 = substr($result, 24, 1);
102 my $f25 = substr($result, 25, 1);
103 my $f26 = substr($result, 26, 1);
104 my $f27 = substr($result, 27, 1);
105 my $f28 = substr($result, 28, 1);
106 my $f29 = substr($result, 29, 1);
107 my $f30 = substr($result, 30, 1);
108 my $f31 = substr($result, 31, 1);
109 my $f32 = substr($result, 32, 1);
110 my $f33 = substr($result, 33, 1);
111 my $f34 = substr($result, 34, 1);
112 my $f3537 = substr($result, 35, 3);
113 my $f38 = substr($result, 38, 1);
114 my $f39 = substr($result, 39, 1);
116 # bug 2563
117 $f710 = "" if ($f710 =~ /^\s*$/);
118 $f1114 = "" if ($f1114 =~ /^\s*$/);
120 if ((!$f1) || ($f1 =~ m/ /)) {
121 $f1 = $dateentered;
124 $template->param(
125 index => $index,
126 f1 => $f1,
127 f6 => $f6,
128 "f6$f6" => $f6,
129 f710 => $f710,
130 f1114 => $f1114,
131 f1517 => $f1517,
132 f18 => $f18,
133 "f18$f18" => $f18,
134 f19 => $f19,
135 "f19$f19" => $f19,
136 f20 => $f20,
137 "f20$f20" => $f20,
138 f21 => $f21,
139 "f21$f21" => $f21,
140 f22 => $f22,
141 "f22$f22" => $f22,
142 f23 => $f23,
143 "f23$f23" => $f23,
144 f24 => $f24,
145 "f24$f24" => $f24,
146 f25 => $f25,
147 "f25$f25" => $f25,
148 f26 => $f26,
149 "f26$f26" => $f26,
150 f27 => $f27,
151 "f27$f27" => $f27,
152 f28 => $f28,
153 "f28$f28" => $f28,
154 f29 => $f29,
155 "f29$f29" => $f29,
156 f30 => $f30,
157 "f30$f30" => $f30,
158 f31 => $f31,
159 "f31$f31" => $f31,
160 f32 => $f32,
161 "f32$f32" => $f32,
162 f33 => $f33,
163 "f33$f33" => $f33,
164 f34 => $f34,
165 "f34$f34" => $f34,
166 f3537 => $f3537,
167 f38 => $f38,
168 "f38$f38" => $f38,
169 f39 => $f39,
170 "f39$f39" => $f39,
172 output_html_with_http_headers $input, $cookie, $template->output;