3 # Converted to new plugin style (Bug 13437)
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use C4::Auth qw( get_template_and_user );
28 use C4::Output qw( output_html_with_http_headers );
29 use Koha::Util::FrameworkPlugin qw|date_entered|;
31 use constant FIXLEN_DATA_ELTS => '|| aca||aabn | a|a d';
32 use constant PREF_008 => 'MARCAuthorityControlField008';
36 my $function_name = $params->{id};
37 my $dateentered = date_entered();
38 my $defaultval = substr( C4::Context->preference(PREF_008) || FIXLEN_DATA_ELTS, 0, 34 );
42 function Focus$function_name(event) {
43 if (!document.getElementById(event.data.id).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(event.data.id).value=fieldval;
54 function Click$function_name(event) {
55 var authtype=document.forms['f'].elements['authtypecode'].value;
56 defaultvalue=document.getElementById(event.data.id).value;
57 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
68 my $input = $params->{cgi};
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",
82 flagsrequired => {editcatalogue => '*'},
84 my $dateentered = date_entered();
85 $result = "$dateentered$defaultval" unless $result;
87 for(0,6..17,28,29,31..33,38,39) {
88 $f[$_]=substr($result,$_,$_==0?6:1);
90 $template->param(index => $index);
92 $f[0]= $dateentered if !$f[0] || $f[0]=~/\s/;
93 $template->param(f1 => $f[0]);
95 for(6..17,28,29,31..33,38,39) {
98 "f$_".($f[$_] eq '|'? 'pipe': $f[$_]) => $f[$_],
101 output_html_with_http_headers $input, $cookie, $template->output;
104 return { builder => $builder, launcher => $launcher };