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';
35 plugin_parameters : other parameters added when the plugin is called by the dopop function
39 sub plugin_javascript {
40 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
41 my $function_name= $field_number;
42 my $dateentered = date_entered();
43 my $defaultval = substr( C4::Context->preference(PREF_008) || FIXLEN_DATA_ELTS, 0, 34 );
45 <script type=\"text/javascript\">
48 function Focus$function_name(subfield_managed) {
49 if (!document.getElementById(\"$field_number\").value) {
50 var authtype=document.forms['f'].elements['authtypecode'].value;
51 var fieldval='$dateentered$defaultval';
52 if(authtype && (authtype == 'TOPIC_TERM' || authtype == 'GENRE/FORM' || authtype == 'CHRON_TERM')) {
53 fieldval= fieldval.substr(0,14)+'b'+fieldval.substr(15);
55 document.getElementById(\"$field_number\").value=fieldval;
60 function Clic$function_name(i) {
61 var authtype=document.forms['f'].elements['authtypecode'].value;
62 defaultvalue=document.getElementById(\"$field_number\").value;
63 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');
70 return ($function_name,$res);
74 my $index= $input->param('index');
75 my $result= $input->param('result');
76 my $authtype= $input->param('authtypecode')||'';
78 my $defaultval = substr( C4::Context->preference(PREF_008) || FIXLEN_DATA_ELTS, 0, 34 );
79 substr($defaultval,14-6,1)='b' if $authtype=~ /TOPIC_TERM|GENRE.FORM|CHRON_TERM/;
81 my $dbh = C4::Context->dbh;
83 my ($template, $loggedinuser, $cookie)
84 = get_template_and_user({template_name => "cataloguing/value_builder/marc21_field_008_authorities.tt",
88 flagsrequired => {editcatalogue => '*'},
91 my $dateentered = date_entered();
92 $result = "$dateentered$defaultval" unless $result;
94 for(0,6..17,28,29,31..33,38,39) {
95 $f[$_]=substr($result,$_,$_==0?6:1);
97 $template->param(index => $index);
99 $f[0]= $dateentered if !$f[0] || $f[0]=~/\s/;
100 $template->param(f1 => $f[0]);
102 for(6..17,28,29,31..33,38,39) {
105 "f$_".($f[$_] eq '|'? 'pipe': $f[$_]) => $f[$_],
108 output_html_with_http_headers $input, $cookie, $template->output;