3 # Copyright 2000-2002 Katipo Communications
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 warnings; FIXME - Bug 2505
28 use Koha::Util::FrameworkPlugin qw|date_entered|;
30 use constant FIXLEN_DATA_ELTS => '|| aca||aabn | a|a d';
31 use constant PREF_008 => 'MARCAuthorityControlField008';
33 sub plugin_javascript {
34 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
35 my $function_name= $field_number;
36 my $dateentered = date_entered();
37 my $defaultval = substr( C4::Context->preference(PREF_008) || FIXLEN_DATA_ELTS, 0, 34 );
39 <script type=\"text/javascript\">
42 function Focus$function_name(subfield_managed) {
43 if (!document.getElementById(\"$field_number\").value) {
44 var authtype=document.forms['f'].elements['authtypecode'].value;
45 var fieldval='$dateentered$defaultval';
46 if(authtype && (authtype == 'TOPIC_TERM' || authtype == 'GENRE/FORM' || authtype == 'CHRON_TERM')) {
47 fieldval= fieldval.substr(0,14)+'b'+fieldval.substr(15);
49 document.getElementById(\"$field_number\").value=fieldval;
54 function Clic$function_name(i) {
55 var authtype=document.forms['f'].elements['authtypecode'].value;
56 defaultvalue=document.getElementById(\"$field_number\").value;
57 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=$field_number&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
64 return ($function_name,$res);
69 my $index= $input->param('index');
70 my $result= $input->param('result');
71 my $authtype= $input->param('authtypecode')||'';
73 my $defaultval = substr( C4::Context->preference(PREF_008) || FIXLEN_DATA_ELTS, 0, 34 );
74 substr($defaultval,14-6,1)='b' if $authtype=~ /TOPIC_TERM|GENRE.FORM|CHRON_TERM/;
76 my $dbh = C4::Context->dbh;
78 my ($template, $loggedinuser, $cookie)
79 = get_template_and_user({template_name => "cataloguing/value_builder/marc21_field_008_authorities.tt",
83 flagsrequired => {editcatalogue => '*'},
86 my $dateentered = date_entered();
87 $result = "$dateentered$defaultval" unless $result;
89 for(0,6..17,28,29,31..33,38,39) {
90 $f[$_]=substr($result,$_,$_==0?6:1);
92 $template->param(index => $index);
94 $f[0]= $dateentered if !$f[0] || $f[0]=~/\s/;
95 $template->param(f1 => $f[0]);
97 for(6..17,28,29,31..33,38,39) {
100 "f$_".($f[$_] eq '|'? 'pipe': $f[$_]) => $f[$_],
103 output_html_with_http_headers $input, $cookie, $template->output;